├── .vscode └── settings.json ├── src ├── ANTLR4 │ ├── .antlr │ │ ├── Hello.tokens │ │ ├── HelloLexer.tokens │ │ ├── ArrayInit.tokens │ │ ├── ArrayInitLexer.tokens │ │ ├── E.tokens │ │ ├── XMLLexer.tokens │ │ ├── ELexer.tokens │ │ ├── LabeledExpr.tokens │ │ ├── LabeledExprLexer.tokens │ │ ├── Hello.interp │ │ ├── ArrayInit.interp │ │ ├── HelloLexer.interp │ │ ├── ArrayInitLexer.interp │ │ ├── LabeledExpr.interp │ │ ├── Lua.tokens │ │ ├── LuaLexer.tokens │ │ ├── E.interp │ │ ├── LabeledExprLexer.interp │ │ ├── ELexer.interp │ │ ├── Java9.tokens │ │ ├── Java9Lexer.tokens │ │ ├── C.tokens │ │ ├── CLexer.tokens │ │ ├── XMLLexer.interp │ │ ├── HelloLexer.java │ │ ├── HelloParser.java │ │ ├── ArrayInitLexer.java │ │ ├── LabeledExprLexer.java │ │ ├── ELexer.java │ │ ├── XMLLexer.java │ │ ├── ArrayInitParser.java │ │ ├── EParser.java │ │ ├── LabeledExprParser.java │ │ ├── Lua.interp │ │ └── LuaLexer.interp │ ├── Hello.g4 │ ├── ArrayInit.g4 │ ├── E.g4 │ ├── XMLLexer.g4 │ ├── LabeledExpr.g4 │ └── Lua.g4 ├── lark │ ├── comments.lark │ ├── array.lark │ ├── hello.lark │ ├── hello_lark.py │ ├── array_lark.py │ └── transformer.py ├── javacomplier │ └── main │ │ ├── vm │ │ └── VirtualMatchine.java │ │ ├── error │ │ ├── BaseError.java │ │ └── LexError.java │ │ ├── main │ │ ├── test │ │ └── Main.java │ │ ├── inter │ │ ├── Break.java │ │ ├── Id.java │ │ ├── Op.java │ │ ├── Temp.java │ │ ├── Not.java │ │ ├── Stmt.java │ │ ├── If.java │ │ ├── Or.java │ │ ├── Seq.java │ │ ├── And.java │ │ ├── Do.java │ │ ├── Unary.java │ │ ├── While.java │ │ ├── Access.java │ │ ├── Constant.java │ │ ├── Set.java │ │ ├── Else.java │ │ ├── Rel.java │ │ ├── Arith.java │ │ ├── SetElem.java │ │ ├── Node.java │ │ ├── Logical.java │ │ └── Expr.java │ │ ├── lexer │ │ ├── Token.java │ │ ├── Real.java │ │ ├── Num.java │ │ ├── Tag.java │ │ ├── Word.java │ │ └── Lexer.java │ │ ├── symbols │ │ ├── Array.java │ │ ├── Env.java │ │ └── Type.java │ │ └── parser │ │ └── Parser.java └── simplecompiler │ ├── error.c │ ├── init.c │ ├── emtter.c │ ├── symbol.c │ ├── global.h │ ├── lexer.c │ └── parse.c ├── img ├── 9.25.png ├── 9.34.png ├── NFA.png ├── Yacc.png ├── ast.png ├── book.png ├── lr0.png ├── 11.50SOR.png ├── anatree.png ├── comlier.png ├── cpython.webp ├── expr_dag.png ├── flowgraph.png ├── interface.png ├── 10.12global.png ├── Lexcompiler.png ├── analyzetree.png ├── cpython-c.webp ├── operatorpre.png ├── stategraph.png ├── treeDFANFA.png ├── 11.51SORwith.png ├── Syntaxdiagram.png ├── baseblockdag.png ├── basicblock_qs.png ├── codegenerator.png ├── doublebuffer.png ├── dynamicArray.png ├── indirecttriple.png ├── lexerandparser.png ├── pascalnumlexer.png ├── stackgrammer.png ├── tripleandast.png ├── 10.1inspipeline.png ├── 11.6matrix_multi.png ├── activationStack.png ├── expranalystable.png ├── transitiongraph.png ├── 11.54time_par_trait.png ├── annotaionParseTree.png ├── gram_transitiongraph.png ├── 11.2distributed_memory.png ├── 11.1symmetric_multiprocessor.png └── 11.25space_partition_constraint.png ├── .gitattributes ├── scripts ├── ast.json ├── readjson.py ├── lefttree.json └── righttree.json ├── README.md ├── LICENSE ├── makefile ├── doc └── DUGU_POLICY.md └── .gitignore /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Hello.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | ID=2 3 | WS=3 4 | 'hello'=1 5 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/HelloLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | ID=2 3 | WS=3 4 | 'hello'=1 5 | -------------------------------------------------------------------------------- /img/9.25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/9.25.png -------------------------------------------------------------------------------- /img/9.34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/9.34.png -------------------------------------------------------------------------------- /img/NFA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/NFA.png -------------------------------------------------------------------------------- /img/Yacc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/Yacc.png -------------------------------------------------------------------------------- /img/ast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/ast.png -------------------------------------------------------------------------------- /img/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/book.png -------------------------------------------------------------------------------- /img/lr0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/lr0.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /img/11.50SOR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.50SOR.png -------------------------------------------------------------------------------- /img/anatree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/anatree.png -------------------------------------------------------------------------------- /img/comlier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/comlier.png -------------------------------------------------------------------------------- /img/cpython.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/cpython.webp -------------------------------------------------------------------------------- /img/expr_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/expr_dag.png -------------------------------------------------------------------------------- /img/flowgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/flowgraph.png -------------------------------------------------------------------------------- /img/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/interface.png -------------------------------------------------------------------------------- /img/10.12global.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/10.12global.png -------------------------------------------------------------------------------- /img/Lexcompiler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/Lexcompiler.png -------------------------------------------------------------------------------- /img/analyzetree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/analyzetree.png -------------------------------------------------------------------------------- /img/cpython-c.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/cpython-c.webp -------------------------------------------------------------------------------- /img/operatorpre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/operatorpre.png -------------------------------------------------------------------------------- /img/stategraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/stategraph.png -------------------------------------------------------------------------------- /img/treeDFANFA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/treeDFANFA.png -------------------------------------------------------------------------------- /img/11.51SORwith.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.51SORwith.png -------------------------------------------------------------------------------- /img/Syntaxdiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/Syntaxdiagram.png -------------------------------------------------------------------------------- /img/baseblockdag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/baseblockdag.png -------------------------------------------------------------------------------- /img/basicblock_qs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/basicblock_qs.png -------------------------------------------------------------------------------- /img/codegenerator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/codegenerator.png -------------------------------------------------------------------------------- /img/doublebuffer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/doublebuffer.png -------------------------------------------------------------------------------- /img/dynamicArray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/dynamicArray.png -------------------------------------------------------------------------------- /img/indirecttriple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/indirecttriple.png -------------------------------------------------------------------------------- /img/lexerandparser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/lexerandparser.png -------------------------------------------------------------------------------- /img/pascalnumlexer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/pascalnumlexer.png -------------------------------------------------------------------------------- /img/stackgrammer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/stackgrammer.png -------------------------------------------------------------------------------- /img/tripleandast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/tripleandast.png -------------------------------------------------------------------------------- /img/10.1inspipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/10.1inspipeline.png -------------------------------------------------------------------------------- /img/11.6matrix_multi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.6matrix_multi.png -------------------------------------------------------------------------------- /img/activationStack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/activationStack.png -------------------------------------------------------------------------------- /img/expranalystable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/expranalystable.png -------------------------------------------------------------------------------- /img/transitiongraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/transitiongraph.png -------------------------------------------------------------------------------- /img/11.54time_par_trait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.54time_par_trait.png -------------------------------------------------------------------------------- /img/annotaionParseTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/annotaionParseTree.png -------------------------------------------------------------------------------- /img/gram_transitiongraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/gram_transitiongraph.png -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInit.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | INT=4 5 | WS=5 6 | '{'=1 7 | ','=2 8 | '}'=3 9 | -------------------------------------------------------------------------------- /img/11.2distributed_memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.2distributed_memory.png -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInitLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | INT=4 5 | WS=5 6 | '{'=1 7 | ','=2 8 | '}'=3 9 | -------------------------------------------------------------------------------- /src/lark/comments.lark: -------------------------------------------------------------------------------- 1 | start: INT* 2 | 3 | COMMENT: /#.*/ 4 | 5 | %import common (INT, WS) 6 | %ignore COMMENT 7 | %ignore WS -------------------------------------------------------------------------------- /img/11.1symmetric_multiprocessor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.1symmetric_multiprocessor.png -------------------------------------------------------------------------------- /img/11.25space_partition_constraint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peefy/CompileDragonBook/HEAD/img/11.25space_partition_constraint.png -------------------------------------------------------------------------------- /src/lark/array.lark: -------------------------------------------------------------------------------- 1 | 2 | start : "{" value ("," value)* "}" 3 | value : start | INT 4 | INT: /[0-9]+/ 5 | 6 | %ignore " " 7 | -------------------------------------------------------------------------------- /src/javacomplier/main/vm/VirtualMatchine.java: -------------------------------------------------------------------------------- 1 | package vm; 2 | 3 | /** 4 | * VirtualMatchine 5 | */ 6 | public class VirtualMatchine { 7 | 8 | 9 | } -------------------------------------------------------------------------------- /src/lark/hello.lark: -------------------------------------------------------------------------------- 1 | start: WORD "," WORD "!" 2 | %import common.WORD // imports from terminal library 3 | %ignore " " // Disregard spaces in text -------------------------------------------------------------------------------- /src/lark/hello_lark.py: -------------------------------------------------------------------------------- 1 | from lark import Lark 2 | 3 | LARK_NAME = './src/lark/hello.lark' 4 | 5 | with open(LARK_NAME) as fs: 6 | l = Lark(fs) 7 | print( l.parse("Hello, World!") ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/lark/array_lark.py: -------------------------------------------------------------------------------- 1 | from lark import Lark 2 | 3 | LARK_NAME = './src/lark/array.lark' 4 | 5 | with open(LARK_NAME) as fs: 6 | l = Lark(fs) 7 | print( l.parse("{1, 2, {1, 2, 3}}") ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/simplecompiler/error.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 错误处理模块 5 | 6 | // 生成所有的出错信息 7 | void error(const char* m) { 8 | fprintf(stderr, "line: %d : %s\n", lineno, m); 9 | exit(1); /* 非正常终止 */ 10 | } 11 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/E.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | VAR=8 9 | INT=9 10 | STRING=10 11 | WS=11 12 | '='=1 13 | ';'=2 14 | '+'=3 15 | '-'=4 16 | '*'=5 17 | '('=6 18 | ')'=7 19 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/XMLLexer.tokens: -------------------------------------------------------------------------------- 1 | OPEN=1 2 | COMMENT=2 3 | EntityRef=3 4 | TEXT=4 5 | CLOSE=5 6 | SLASH_CLOSE=6 7 | EQUALS=7 8 | STRING=8 9 | SlashName=9 10 | Name=10 11 | S=11 12 | '<'=1 13 | '>'=5 14 | '/>'=6 15 | '='=7 16 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ELexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | VAR=8 9 | INT=9 10 | STRING=10 11 | WS=11 12 | '='=1 13 | ';'=2 14 | '+'=3 15 | '-'=4 16 | '*'=5 17 | '('=6 18 | ')'=7 19 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExpr.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | ID=4 5 | INT=5 6 | NEWLINE=6 7 | WS=7 8 | MUL=8 9 | DIV=9 10 | ADD=10 11 | SUB=11 12 | '='=1 13 | '('=2 14 | ')'=3 15 | '*'=8 16 | '/'=9 17 | '+'=10 18 | '-'=11 19 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExprLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | ID=4 5 | INT=5 6 | NEWLINE=6 7 | WS=7 8 | MUL=8 9 | DIV=9 10 | ADD=10 11 | SUB=11 12 | '='=1 13 | '('=2 14 | ')'=3 15 | '*'=8 16 | '/'=9 17 | '+'=10 18 | '-'=11 19 | -------------------------------------------------------------------------------- /src/javacomplier/main/error/BaseError.java: -------------------------------------------------------------------------------- 1 | package error; 2 | 3 | /** 4 | * BaseError 5 | */ 6 | public class BaseError extends Error { 7 | 8 | /** 9 | * 10 | */ 11 | private static final long serialVersionUID = 1L; 12 | 13 | 14 | } -------------------------------------------------------------------------------- /src/javacomplier/main/error/LexError.java: -------------------------------------------------------------------------------- 1 | package error; 2 | 3 | /** 4 | * LexError 5 | */ 6 | public class LexError extends BaseError { 7 | 8 | /** 9 | * 10 | */ 11 | private static final long serialVersionUID = 2420940070265388325L; 12 | 13 | 14 | } -------------------------------------------------------------------------------- /src/ANTLR4/Hello.g4: -------------------------------------------------------------------------------- 1 | // Define a grammar called Hello 定义一个语法名字:Hello 2 | grammar Hello; 3 | r : 'hello' ID ; // match keyword hello followed by an identifier 匹配关键字hello,后跟标识符 4 | ID : [a-z]+ ; // match lower-case identifiers 匹配全是小写字母的标识符 5 | WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines 跳过空格,制表符,换行符 6 | -------------------------------------------------------------------------------- /src/ANTLR4/ArrayInit.g4: -------------------------------------------------------------------------------- 1 | grammar ArrayInit; 2 | 3 | /* 一条名为init的规则,它匹配一对花括号中的、逗号分隔的value */ 4 | init : '{' value (',' value)* '}'; 5 | /* 一个value可以是嵌套的花括号结构,也可以是一个简单的整数,即INT词法符号 */ 6 | value : init 7 | | INT 8 | ; 9 | INT: [0-9]+; // 定义词法符号INT,它由一个或多个数字组成 10 | WS: [\t\r\n]+ -> skip; // 定义词法规则“空白符号”,丢弃之 -------------------------------------------------------------------------------- /src/javacomplier/main/main/test: -------------------------------------------------------------------------------- 1 | { 2 | int i; int j; float v; float x; 3 | float[100] a; 4 | while (true) { 5 | do i = i + 1 while (a[i] < v); 6 | do j = j - 1 while (a[j] > v); 7 | if (i >= j) 8 | break; 9 | x = a[i]; 10 | a[i] = a[j] 11 | a[j] = x; 12 | } 13 | } -------------------------------------------------------------------------------- /scripts/ast.json: -------------------------------------------------------------------------------- 1 | { 2 | ":=" : { 3 | "left" : "position", 4 | "right" : { 5 | "+" : { 6 | "left" : "initial", 7 | "right" : { 8 | "*" : { 9 | "left" : "rate", 10 | "right" : "60" 11 | } 12 | } 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Hello.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | 'hello' 4 | null 5 | null 6 | 7 | token symbolic names: 8 | null 9 | null 10 | ID 11 | WS 12 | 13 | rule names: 14 | r 15 | 16 | 17 | atn: 18 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 5, 8, 4, 2, 9, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 6, 2, 4, 3, 2, 2, 2, 4, 5, 7, 3, 2, 2, 5, 6, 7, 4, 2, 2, 6, 3, 3, 2, 2, 2, 2] -------------------------------------------------------------------------------- /src/ANTLR4/E.g4: -------------------------------------------------------------------------------- 1 | grammar E; 2 | 3 | program : statement + ; 4 | statement: (expression | VAR '=' expression) ';' ; 5 | expression : (multExpr (('+' |'-' ) multExpr)*) | STRING; 6 | multExpr : atom ('*' atom)*; 7 | atom : INT | '(' expression ')'; 8 | VAR : ('a'..'z' |'A'..'Z' )+ ; 9 | INT : '0'..'9' + ; 10 | STRING : '"' (('A'..'Z' | 'a'..'z' | ' ') +) '"' ; 11 | WS : (' ' |'\t' |'\n' |'\r' )+ {skip();} ; 12 | -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Break.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | 4 | /** 5 | * If 6 | */ 7 | public class Break extends Stmt { 8 | Stmt stmt; 9 | public Break() { 10 | if (Stmt.Enclosing == Stmt.Null) 11 | error("unenclosed break"); 12 | stmt = Stmt.Enclosing; 13 | } 14 | 15 | @Override 16 | public void gen(int b, int a) { 17 | emit("goto L" + stmt.after); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/simplecompiler/init.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 初始化模块 5 | 6 | // 关键字 7 | entry keywords[] = { 8 | {"div", DIV}, 9 | {"mod", MOD}, 10 | {"0", 0}, // 关键字结尾 11 | }; 12 | 13 | // 将关键字填入符号表 14 | void init() { 15 | entry * p; 16 | for (p = keywords;p->token;p++) { 17 | insert(p->lexptr, p->token); 18 | } 19 | } 20 | 21 | void main() { 22 | init(); 23 | parse(); 24 | exit(0); 25 | } 26 | -------------------------------------------------------------------------------- /src/lark/transformer.py: -------------------------------------------------------------------------------- 1 | from lark import Lark, Transformer 2 | 3 | class T(Transformer): 4 | def INT(self, tok): 5 | "Convert the value of `tok` from string to string+int, while maintaining line number & column." 6 | return tok.update(value='lark-int:' + tok) 7 | 8 | parser = Lark(""" 9 | start: INT* 10 | %import common.INT 11 | %ignore " " 12 | """, parser="lalr", transformer=T()) 13 | 14 | print(parser.parse('3 14 159 123')) -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Id.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Id 8 | */ 9 | public class Id extends Expr { 10 | /** 11 | * 相对地址 12 | */ 13 | public int offset; 14 | 15 | /** 16 | * 17 | * @param id 18 | * @param p 19 | * @param b 20 | */ 21 | public Id(Word id, Type p, int b) { 22 | super(id, p); 23 | offset = b; 24 | } 25 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Op.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Op 8 | */ 9 | public class Op extends Expr { 10 | 11 | public Op(Token tok, Type p) { 12 | super(tok, p); 13 | } 14 | 15 | public Expr reduce() { 16 | Expr x = gen(); 17 | Temp t = new Temp(type); 18 | emit(t.toString() + " = " + x.toString()); 19 | return t; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Temp.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Temp 8 | */ 9 | public class Temp extends Expr { 10 | static int count = 0; 11 | int number = 0; 12 | 13 | public Temp(Type p) { 14 | super(Word.temp, p); 15 | number = ++count; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "t" + number; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Token.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | /** 4 | * Token 5 | */ 6 | public class Token { 7 | /** 8 | * 9 | */ 10 | public final int tag; 11 | 12 | /** 13 | * 14 | * @param t 15 | */ 16 | public Token(int t) { 17 | tag = t; 18 | } 19 | 20 | /** 21 | * 22 | */ 23 | @Override 24 | public String toString() { 25 | return String.valueOf((char)tag); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Not.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * Not 7 | */ 8 | public class Not extends Logical { 9 | 10 | public Not(Token tok, Expr x2) { 11 | super(tok, x2, x2); 12 | } 13 | 14 | @Override 15 | public void jumping(int t, int f) { 16 | expr2.jumping(f, t); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return op.toString() + " " + expr2.toString(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Real.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | /** 4 | * Real 5 | */ 6 | public class Real extends Token { 7 | /** 8 | * 9 | */ 10 | public final float value; 11 | 12 | /** 13 | * 14 | * @param v 15 | */ 16 | public Real(float v) { 17 | super(Tag.REAL); 18 | value = v; 19 | } 20 | 21 | /** 22 | * 23 | */ 24 | @Override 25 | public String toString() { 26 | return Float.toString(value); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Num.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | /** 4 | * Num 5 | */ 6 | public class Num extends Token { 7 | /** 8 | * 9 | */ 10 | public final int value; 11 | 12 | /** 13 | * 14 | * @param value 15 | */ 16 | public Num(int value) { 17 | super(Tag.NUM); 18 | this.value = value; 19 | } 20 | 21 | /** 22 | * 23 | */ 24 | @Override 25 | public String toString() { 26 | return String.valueOf(value); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Stmt.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | /** 4 | * Stmt 语句结点 5 | */ 6 | public class Stmt extends Node { 7 | public Stmt() { } 8 | 9 | public static Stmt Null = new Stmt(); 10 | 11 | /** 12 | * 调用时的参数是语句开始处的标号和语句的下一条指令的标号 13 | * @param b 14 | * @param a 15 | */ 16 | public void gen(int b, int a) { } 17 | 18 | /** 19 | * 保存语句的下一条指令的标号 20 | */ 21 | int after = 0; 22 | 23 | /** 24 | * 用于break语句 25 | */ 26 | public static Stmt Enclosing = Stmt.Null; 27 | 28 | } -------------------------------------------------------------------------------- /src/ANTLR4/XMLLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar XMLLexer; 2 | 3 | // 默认的“模式”,所有在标签之外的东西 4 | OPEN : '<' -> pushMode(INSIDE); 5 | COMMENT : '' -> skip; 6 | EntityRef: '&' [a-z]+ ';' ; 7 | TEXT : ~('<'|'&')+ ; // 匹配任意除<和&之外的16位字符 8 | 9 | // ------- 所有在标签之内的东西 ------ 10 | mode INSIDE; 11 | CLOSE : '>' -> popMode; 12 | SLASH_CLOSE : '/>' -> popMode; 13 | EQUALS : '=' ; 14 | STRING : '"' .*? '"' ; 15 | SlashName : '/' Name; 16 | Name : ALPHA (ALPHA|DIGIT)*; 17 | S : [ \t\r\n] -> skip; 18 | 19 | fragment 20 | ALPHA : [a-zA-Z]; 21 | 22 | fragment 23 | DIGIT : [0-9]; -------------------------------------------------------------------------------- /src/javacomplier/main/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import java.io.*; 4 | 5 | import lexer.*; 6 | import parser.*; 7 | 8 | /** 9 | * Main 10 | */ 11 | public class Main { 12 | public static void main(String[] args) { 13 | System.out.println("Hello Java Compiler!"); 14 | Lexer lex = new Lexer(); 15 | try { 16 | Parser parser = new Parser(lex); 17 | parser.program(); 18 | } catch (IOException e) { 19 | System.out.println("error"); 20 | } 21 | System.out.println("finish"); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/simplecompiler/emtter.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 打印输出模块 5 | 6 | // 生成输出 7 | void emit(int t, int tval) { 8 | switch (t) 9 | { 10 | case '+': case '-': case '*': case '/': 11 | printf("%c\n", t); 12 | break; 13 | case DIV: 14 | printf("DIV\n"); break; 15 | case MOD: 16 | printf("MOD\n"); break; 17 | case NUM: 18 | printf("%d\n", tval); break; 19 | case ID: 20 | printf("%s\n", symtabel[tval].lexptr); break; 21 | default: 22 | printf("token %d, tokenval %d\n", t, tval); break; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/javacomplier/main/inter/If.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * If 7 | */ 8 | public class If extends Stmt { 9 | Expr expr; 10 | Stmt stmt; 11 | public If(Expr x, Stmt s) { 12 | expr = x; 13 | stmt = s; 14 | if (expr.type != Type.Bool) 15 | expr.error("boolean required in if"); 16 | } 17 | 18 | @Override 19 | public void gen(int b, int a) { 20 | int label = newlabel(); // stmt代码的标号 21 | expr.jumping(0, a); // 为真时控制流穿越,为假时转向a 22 | emitlabel(label); 23 | stmt.gen(label, a); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Or.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * Or 7 | */ 8 | public class Or extends Logical { 9 | 10 | /** 11 | * 12 | * @param tok 13 | * @param x1 14 | * @param x2 15 | */ 16 | public Or(Token tok, Expr x1, Expr x2) { 17 | super(tok, x1, x2); 18 | } 19 | 20 | /** 21 | * 22 | */ 23 | @Override 24 | public void jumping(int t, int f) { 25 | int label = t != 0 ? t : newlabel(); 26 | expr1.jumping(label, 0); 27 | expr2.jumping(t, f); 28 | if (t == 0) 29 | emitlabel(label); 30 | } 31 | } -------------------------------------------------------------------------------- /src/ANTLR4/LabeledExpr.g4: -------------------------------------------------------------------------------- 1 | grammar LabeledExpr; 2 | /* 起始规则,语法分析的起点 */ 3 | prog: stat+; 4 | stat: expr NEWLINE # printExpr 5 | | ID '=' expr NEWLINE # assign 6 | | NEWLINE # blank 7 | ; 8 | expr: expr op=('*'|'/') expr # MulDiv 9 | | expr op=('+'|'-') expr # AddSub 10 | | INT # int 11 | | ID # id 12 | | '(' expr ')' # parens 13 | ; 14 | ID: [a-zA-Z]+; // 匹配标识符 15 | INT: [0-9]+; // 匹配整数 16 | NEWLINE: 'r'? '\n'; // 告诉语法分析器一个新行的开始(即语句终止标志) 17 | WS: [\t]+ -> skip; // 丢弃空白字符 18 | MUL: '*'; 19 | DIV: '/'; 20 | ADD: '+'; 21 | SUB: '-'; 22 | -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Seq.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | 4 | /** 5 | * Set 6 | */ 7 | public class Seq extends Stmt { 8 | Stmt stmt1; 9 | Stmt stmt2; 10 | 11 | public Seq(Stmt s1, Stmt s2) { 12 | stmt1 = s1; 13 | stmt2 = s2; 14 | } 15 | 16 | @Override 17 | public void gen(int b, int a) { 18 | if (stmt1 == Stmt.Null) 19 | stmt2.gen(b, a); 20 | else if (stmt2 == Stmt.Null) 21 | stmt1.gen(b, a); 22 | else { 23 | int label = newlabel(); 24 | stmt1.gen(b, label); 25 | stmt2.gen(label, a); 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /scripts/readjson.py: -------------------------------------------------------------------------------- 1 | 2 | import json 3 | 4 | # TODO:MyClass 5 | class MyClass: 6 | def __init__(self): 7 | pass 8 | 9 | @staticmethod 10 | def funcname(**arg): 11 | pass 12 | 13 | def __prifunc(self): 14 | pass 15 | 16 | def _prifunc(): 17 | pass 18 | 19 | if __name__ == "__main__": 20 | with open('./scripts/ast.json') as fd: 21 | obj = json.load(fd) 22 | print(obj) 23 | with open('./scripts/lefttree.json') as fd: 24 | obj = json.load(fd) 25 | print(obj) 26 | with open('./scripts/righttree.json') as fd: 27 | obj = json.load(fd) 28 | print(obj) 29 | 30 | -------------------------------------------------------------------------------- /src/javacomplier/main/inter/And.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * And 7 | */ 8 | public class And extends Logical { 9 | /** 10 | * 11 | * @param tok 12 | * @param x1 13 | * @param x2 14 | */ 15 | public And(Token tok, Expr x1, Expr x2) { 16 | super(tok, x1, x2); 17 | } 18 | 19 | /** 20 | * 21 | */ 22 | @Override 23 | public void jumping(int t, int f) { 24 | int label = f != 0 ? f : newlabel(); 25 | expr1.jumping(0, label); 26 | expr2.jumping(t, f); 27 | if (f == 0) 28 | emitlabel(label); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Do.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * Do 7 | */ 8 | public class Do extends Stmt { 9 | Expr expr; 10 | Stmt stmt; 11 | 12 | public Do() { 13 | 14 | } 15 | 16 | public Do(Expr x, Stmt s) { 17 | expr = x; 18 | stmt = s; 19 | if (expr.type != Type.Bool) 20 | expr.error("boolean required in do"); 21 | } 22 | 23 | @Override 24 | public void gen(int b, int a) { 25 | after = a; 26 | int label = newlabel(); 27 | stmt.gen(b, label); 28 | emitlabel(label); 29 | expr.jumping(b, 0); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/javacomplier/main/symbols/Array.java: -------------------------------------------------------------------------------- 1 | package symbols; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * Array 7 | */ 8 | public class Array extends Type { 9 | /** 10 | * 11 | */ 12 | public Type of; 13 | /** 14 | * 15 | */ 16 | public int size = 1; 17 | 18 | /** 19 | * 20 | * @param sz 21 | * @param p 22 | */ 23 | public Array(int sz, Type p) { 24 | super("[]", Tag.INDEX, sz * p.width); 25 | size = sz; 26 | of = p; 27 | } 28 | 29 | /** 30 | * 31 | */ 32 | @Override 33 | public String toString() { 34 | return "[" + size + "]" + of.toString(); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Unary.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Unary 8 | */ 9 | public class Unary extends Op { 10 | public Expr expr; 11 | 12 | /** 13 | * 处理单目减法,对!的处理见Not; 14 | * @param tok 15 | * @param x 16 | */ 17 | public Unary(Token tok, Expr x) { 18 | super(tok, null); 19 | type = Type.max(Type.Int, expr.type); 20 | if (type == null) 21 | error("type error"); 22 | } 23 | 24 | public Expr gen() { 25 | return new Unary(op, expr.reduce()); 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return op.toString() + " " + expr.toString(); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/While.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * While 7 | */ 8 | public class While extends Stmt { 9 | Expr expr; 10 | Stmt stmt; 11 | public While() { 12 | expr = null; 13 | stmt = null; 14 | } 15 | 16 | public void init(Expr x, Stmt s) { 17 | expr = x; 18 | stmt = s; 19 | if (expr.type != Type.Bool) 20 | expr.error("boolean required in while"); 21 | } 22 | 23 | @Override 24 | public void gen(int b, int a) { 25 | after = a; 26 | expr.jumping(0, a); 27 | int label = newlabel(); 28 | emitlabel(label); 29 | stmt.gen(label, b); 30 | emit("goto L" + b); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Access.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Access 8 | */ 9 | public class Access extends Op { 10 | 11 | public Id array; 12 | public Expr index; 13 | 14 | public Access(Id a, Expr i, Type p) { 15 | super(new Word("[]", Tag.INDEX), p); 16 | array = a; 17 | index = i; 18 | } 19 | 20 | @Override 21 | public Expr gen() { 22 | return new Access(array, index.reduce(), type); 23 | } 24 | 25 | @Override 26 | public void jumping(int t, int f) { 27 | emitjumps(reduce().toString(), t, f); 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return array.toString() + " [" + index.toString() + " ]"; 33 | } 34 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Constant.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Constant 8 | */ 9 | public class Constant extends Expr { 10 | 11 | public Constant(Token tok, Type p) { 12 | super(tok, p); 13 | } 14 | 15 | public Constant(int i) { 16 | super(new Num(i), Type.Int); 17 | } 18 | 19 | public static final Constant 20 | True = new Constant(Word.True, Type.Bool), 21 | False = new Constant(Word.Flase, Type.Bool); 22 | 23 | public void jumping(int t, int f) { 24 | if (this == True && t != 0) { 25 | emit("goto L" + t); 26 | } 27 | else if (this == False && f != 0) { 28 | emit("goto L" + f); 29 | } 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Set.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * Set 7 | */ 8 | public class Set extends Stmt { 9 | public Id id; 10 | public Expr expr; 11 | 12 | public Set(Id i, Expr x) { 13 | id = i; 14 | expr = x; 15 | if ( check(id.type, expr.type) == null ) 16 | error("type error"); 17 | } 18 | 19 | public Type check(Type p1, Type p2) { 20 | if (Type.isNumeric(p1) && Type.isNumeric(p2)) 21 | return p2; 22 | else if (p1 == Type.Bool && p2 == Type.Bool ) 23 | return p2; 24 | else 25 | return null; 26 | } 27 | 28 | public void gen(int b, int a) { 29 | emit(id.toString() + " = " + expr.gen().toString()); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Else.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * If 7 | */ 8 | public class Else extends Stmt { 9 | Expr expr; 10 | Stmt stmt1; 11 | Stmt stmt2; 12 | public Else(Expr x, Stmt s1, Stmt s2) { 13 | expr = x; 14 | stmt1 = s1; 15 | stmt2 = s2; 16 | if (expr.type != Type.Bool) 17 | expr.error("boolean required in if"); 18 | } 19 | 20 | @Override 21 | public void gen(int b, int a) { 22 | int label1 = newlabel(); 23 | int label2 = newlabel(); 24 | expr.jumping(0, label2); 25 | emitlabel(label1); 26 | stmt1.gen(label1, a); 27 | emit("goto L" + a); 28 | emitlabel(label2); 29 | stmt2.gen(label2, a); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Rel.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Rel 8 | */ 9 | public class Rel extends Logical { 10 | 11 | public Rel(Token tok, Expr x1, Expr x2) { 12 | super(tok, x1, x2); 13 | } 14 | 15 | @Override 16 | public Type check(Type p1, Type p2) { 17 | if (p1 instanceof Array || p2 instanceof Array) 18 | return null; 19 | else if (p1 == p2) 20 | return Type.Bool; 21 | else 22 | return null; 23 | } 24 | 25 | @Override 26 | public void jumping(int t, int f) { 27 | Expr a = expr1.reduce(); 28 | Expr b = expr2.reduce(); 29 | String test = a.toString() + " " + op.toString() + " " + b.toString(); 30 | emitjumps(test, t, f); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInit.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '{' 4 | ',' 5 | '}' 6 | null 7 | null 8 | 9 | token symbolic names: 10 | null 11 | null 12 | null 13 | null 14 | INT 15 | WS 16 | 17 | rule names: 18 | init 19 | value 20 | 21 | 22 | atn: 23 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 7, 22, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 11, 10, 2, 12, 2, 14, 2, 14, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 5, 3, 20, 10, 3, 3, 3, 2, 2, 4, 2, 4, 2, 2, 2, 21, 2, 6, 3, 2, 2, 2, 4, 19, 3, 2, 2, 2, 6, 7, 7, 3, 2, 2, 7, 12, 5, 4, 3, 2, 8, 9, 7, 4, 2, 2, 9, 11, 5, 4, 3, 2, 10, 8, 3, 2, 2, 2, 11, 14, 3, 2, 2, 2, 12, 10, 3, 2, 2, 2, 12, 13, 3, 2, 2, 2, 13, 15, 3, 2, 2, 2, 14, 12, 3, 2, 2, 2, 15, 16, 7, 5, 2, 2, 16, 3, 3, 2, 2, 2, 17, 20, 5, 2, 2, 2, 18, 20, 7, 6, 2, 2, 19, 17, 3, 2, 2, 2, 19, 18, 3, 2, 2, 2, 20, 5, 3, 2, 2, 2, 4, 12, 19] -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Tag.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | /** 4 | * Tag 5 | * 其中的三个常量INDEX,MINUS,TEMP不是词法单元,将在语法分析中使用 6 | */ 7 | public class Tag { 8 | /** 9 | * 10 | */ 11 | public static final int 12 | AND = 256, // && 13 | BASIC = 257, // 14 | BREAK = 258, // break 15 | DO = 259, // do 16 | ELSE = 260, // else 17 | EQ = 261, // eq 18 | FALSE = 262, // false 19 | GE = 263, // <= 20 | ID = 264, // id 21 | IF = 265, // if 22 | INDEX = 266, 23 | LE = 267, // >= 24 | MINUS = 268, // - 25 | NE = 269, // != 26 | NUM = 270, // num 27 | OR = 271, // || 28 | REAL = 272, // float 29 | TEMP = 273, // temp 30 | TRUE = 274, // true 31 | WHILE = 275; // while 32 | // >> 33 | // << 34 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Arith.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Arith 8 | */ 9 | public class Arith extends Op { 10 | 11 | /** 12 | * 13 | */ 14 | public Expr expr1, expr2; 15 | 16 | /** 17 | * 18 | * @param tok 19 | * @param x1 20 | * @param x2 21 | */ 22 | public Arith(Token tok, Expr x1, Expr x2) { 23 | super(tok, null); 24 | expr1 = x1; 25 | expr2 = x2; 26 | type = Type.max(expr1.type, expr2.type); 27 | if (type == null) 28 | error("type error"); 29 | } 30 | 31 | /** 32 | * 把表达式的子表达式规约为地址 33 | */ 34 | public Expr gen() { 35 | return new Arith(op, expr1.reduce(), expr2.reduce()); 36 | } 37 | 38 | /** 39 | * 40 | */ 41 | @Override 42 | public String toString() { 43 | return expr1.toString() + " " + op.toString() + " " + expr2.toString(); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Word.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | /** 4 | * Word 保留字,标识符,符合词法单元词素 5 | */ 6 | public class Word extends Token { 7 | /** 8 | * 9 | */ 10 | String lexname = ""; 11 | 12 | /** 13 | * 14 | */ 15 | public Word(String s, int tag) { 16 | super(tag); 17 | lexname = s; 18 | } 19 | 20 | /** 21 | * 22 | */ 23 | @Override 24 | public String toString() { 25 | return lexname; 26 | } 27 | 28 | /** 29 | * 30 | */ 31 | public static final Word 32 | and = new Word("&&", Tag.AND), 33 | or = new Word("||", Tag.OR), 34 | eq = new Word("&&", Tag.EQ), 35 | ne = new Word("&&", Tag.NE), 36 | le = new Word("&&", Tag.LE), 37 | ge = new Word("&&", Tag.GE), 38 | minus = new Word("&&", Tag.MINUS), 39 | True = new Word("&&", Tag.TRUE), 40 | Flase = new Word("&&", Tag.FALSE), 41 | temp = new Word("&&", Tag.TEMP); 42 | 43 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/SetElem.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import symbols.*; 4 | 5 | /** 6 | * Set 7 | */ 8 | public class SetElem extends Stmt { 9 | public Id array; 10 | public Expr index; 11 | public Expr expr; 12 | 13 | public SetElem(Access x, Expr y) { 14 | array = x.array; 15 | index = x; 16 | expr = y; 17 | if ( check(x.type, expr.type) == null ) 18 | error("type error"); 19 | } 20 | 21 | public Type check(Type p1, Type p2) { 22 | if (p1 instanceof Array || p2 instanceof Array) 23 | return null; 24 | else if (p1 == p2) 25 | return p2; 26 | else if (Type.isNumeric(p1) && Type.isNumeric(p2)) 27 | return p2; 28 | else 29 | return null; 30 | } 31 | 32 | public void gen(int b, int a) { 33 | String s1 = index.reduce().toString(); 34 | String s2 = expr.reduce().toString(); 35 | emit(array.toString() + " [ " + s1 + " ] " + s2); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Node.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * Node 7 | */ 8 | public class Node { 9 | /** 10 | * 11 | */ 12 | int lexline = 0; 13 | 14 | /** 15 | * 16 | */ 17 | public Node() { 18 | lexline = Lexer.line; 19 | } 20 | 21 | /** 22 | * 23 | * @param s 24 | */ 25 | void error(String s) { 26 | throw new Error("near line" + lexline + ": " + s); 27 | } 28 | 29 | /** 30 | * 31 | */ 32 | static int labels = 0; 33 | 34 | /** 35 | * 36 | * @return 37 | */ 38 | public int newlabel() { 39 | labels += 1; 40 | return labels; 41 | } 42 | 43 | /** 44 | * 45 | * @param i 46 | */ 47 | public void emitlabel(int i) { 48 | System.out.println("L" + i + ":"); 49 | } 50 | 51 | /** 52 | * 53 | * @param s 54 | */ 55 | public void emit(String s) { 56 | System.out.println("\t" + s); 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/javacomplier/main/symbols/Env.java: -------------------------------------------------------------------------------- 1 | package symbols; 2 | 3 | import java.util.*; 4 | 5 | import lexer.*; 6 | import inter.*; 7 | 8 | /** 9 | * Env 把字符串词法映射为类Id的对象 10 | */ 11 | public class Env { 12 | /** 13 | * 14 | */ 15 | private Hashtable table; 16 | 17 | /** 18 | * 19 | */ 20 | protected Env prev; 21 | 22 | /** 23 | * 24 | * @param n 25 | */ 26 | public Env(Env n) { 27 | table = new Hashtable<>(); 28 | prev = n; 29 | } 30 | 31 | /** 32 | * 33 | * @param w 34 | * @param i 35 | */ 36 | public void put(Token w, Id i) { 37 | table.put(w, i); 38 | } 39 | 40 | /** 41 | * 42 | * @param w 43 | * @return 44 | */ 45 | public Id get(Token w) { 46 | for (Env e = this; e != null ; e = e.prev) { 47 | Id found = (Id)(table.get(w)); 48 | if (found != null) 49 | return found; 50 | } 51 | return null; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/javacomplier/main/symbols/Type.java: -------------------------------------------------------------------------------- 1 | package symbols; 2 | 3 | import lexer.*; 4 | 5 | /** 6 | * Type 7 | */ 8 | public class Type extends Word { 9 | /** 10 | * 用于存储分配 11 | */ 12 | public int width = 0; 13 | 14 | public Type(String s, int tag, int w) { 15 | super(s, tag); 16 | width = w; 17 | } 18 | 19 | public static final Type 20 | Int = new Type("int", Tag.BASIC, 4), 21 | Float = new Type("float", Tag.BASIC, 8), 22 | Char = new Type("char", Tag.BASIC, 1), 23 | Bool = new Type("bool", Tag.BASIC, 1); 24 | 25 | public static boolean isNumeric(Type p) { 26 | return p == Type.Char || p == Type.Int || p == Type.Float; 27 | } 28 | 29 | public static Type max(Type p1, Type p2) { 30 | if (!isNumeric(p1) || isNumeric(p2)) 31 | return null; 32 | else if (p1 == Type.Float || p2 == Type.Float) 33 | return Type.Float; 34 | else if (p1 == Type.Int || p2 == Type.Int) 35 | return Type.Int; 36 | return Type.Char; 37 | } 38 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 编译笔记 2 | 3 | * [编译原理龙书笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_COMPILE.md) 4 | 5 | * [领域特定语言DSL笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_DSL.md) 6 | 7 | * [UGuide2CPython 笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_YouGuide2CPython.md) 8 | 9 | * [用Java实现的简单编译器前端](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_JAVA_COMPLIER.md) 10 | 11 | ## 其他笔记 12 | 13 | * [CPython编译器笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_CPYTHON_COMPILER.md) 14 | 15 | * [Lua编译器笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_LUA_COMPILER.md) 16 | 17 | * [ANTLR4解析器生成器笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_ANTLR.md) 18 | 19 | * [lark解析器笔记](https://github.com/Peefy/CompileDragonBook/blob/master/doc/NOTE_LARK.md) 20 | 21 | ## 项目实战 22 | 23 | * [KCL 语言](https://github.com/kcl-lang) 24 | 25 | ## Thanks 26 | 27 | * [antlr/antlr4](https://github.com/antlr/antlr4) 28 | 29 | * [lark-parser/lark](https://github.com/lark-parser/lark) 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/simplecompiler/symbol.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 符号模块 5 | 6 | #define STRMAX 999 // lexemes数组的大小 7 | #define SYMMAX 1000 // symtable的大小 8 | 9 | char lexemes[STRMAX]; 10 | int lastchar = -1; // lexemes中最后引用的位置 11 | entry symtabel[SYMMAX]; 12 | int lastentry = 0; // symtable中最后引用的位置 13 | 14 | // 返回s符号表项的位置 15 | int lookup(char s[]) { 16 | int p = 0; 17 | for (p = lastentry;p > 0; p = p - 1) { 18 | if (strcmp(symtabel[p].lexptr, s) == 0) 19 | return p; 20 | } 21 | return 0; 22 | } 23 | 24 | // 插入符号表,返回s表项的位置 25 | int insert(char s[], int tok) { 26 | int len; 27 | len = strlen(s); 28 | if (lastentry + 1 >= SYMMAX) { 29 | error("symbol table full!"); 30 | } 31 | if (lastchar + len + 1 >= STRMAX) { 32 | error("lexemes array full!"); 33 | } 34 | lastentry = lastentry + 1; 35 | symtabel[lastentry].token = tok; 36 | symtabel[lastentry].lexptr = &lexemes[lastchar + 1]; 37 | lastchar = lastchar + len + 1; 38 | strcpy(symtabel[lastentry].lexptr, s); 39 | return lastentry; 40 | } 41 | -------------------------------------------------------------------------------- /src/simplecompiler/global.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _GLOBAL_H_ 3 | #define _GLOBAL_H_ 4 | 5 | #include // 输入/输出 6 | #include // 加载字符测试程序 7 | #include 8 | 9 | #define BSIZE 128 // 缓冲区大小 10 | #define NONE -1 11 | #define EOS '\0' 12 | 13 | #define NUM 256 14 | #define DIV 257 15 | #define MOD 258 16 | #define ID 259 17 | #define DONE 260 18 | 19 | #ifndef pass 20 | #define pass 21 | #endif 22 | 23 | extern int tokenval; // 记号的属性值 24 | extern int lineno; // 行号 25 | 26 | // 符号表的表项格式 27 | typedef struct entry { 28 | // 指向记号词素内容的指针 29 | char * lexptr; 30 | // 记号 31 | int token; 32 | } entry; 33 | 34 | entry symtabel[]; 35 | 36 | typedef struct token 37 | { 38 | int tokenval; 39 | int lexptr; 40 | } token; 41 | 42 | 43 | /* function declare */ 44 | 45 | void error(const char* m); // 生成所有的出错信息 46 | void emit(int t, int tval); // 生成输出 47 | int lookup(char s[]); // 返回s符号表项的位置 48 | int insert(char s[], int tok); // 插入符号表,返回s表项的位置 49 | int lexan(); // 词法分析器 或者记号 token 50 | void parse(); // 分析并翻译表达式列表 51 | void init(); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Peefy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/HelloLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | 'hello' 4 | null 5 | null 6 | 7 | token symbolic names: 8 | null 9 | null 10 | ID 11 | WS 12 | 13 | rule names: 14 | T__0 15 | ID 16 | WS 17 | 18 | channel names: 19 | DEFAULT_TOKEN_CHANNEL 20 | HIDDEN 21 | 22 | mode names: 23 | DEFAULT_MODE 24 | 25 | atn: 26 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 5, 27, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 6, 3, 17, 10, 3, 13, 3, 14, 3, 18, 3, 4, 6, 4, 22, 10, 4, 13, 4, 14, 4, 23, 3, 4, 3, 4, 2, 2, 5, 3, 3, 5, 4, 7, 5, 3, 2, 4, 3, 2, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 28, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 3, 9, 3, 2, 2, 2, 5, 16, 3, 2, 2, 2, 7, 21, 3, 2, 2, 2, 9, 10, 7, 106, 2, 2, 10, 11, 7, 103, 2, 2, 11, 12, 7, 110, 2, 2, 12, 13, 7, 110, 2, 2, 13, 14, 7, 113, 2, 2, 14, 4, 3, 2, 2, 2, 15, 17, 9, 2, 2, 2, 16, 15, 3, 2, 2, 2, 17, 18, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 18, 19, 3, 2, 2, 2, 19, 6, 3, 2, 2, 2, 20, 22, 9, 3, 2, 2, 21, 20, 3, 2, 2, 2, 22, 23, 3, 2, 2, 2, 23, 21, 3, 2, 2, 2, 23, 24, 3, 2, 2, 2, 24, 25, 3, 2, 2, 2, 25, 26, 8, 4, 2, 2, 26, 8, 3, 2, 2, 2, 5, 2, 18, 23, 3, 8, 2, 2] -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Logical.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Logical 8 | */ 9 | public class Logical extends Expr { 10 | public Expr expr1, expr2; 11 | 12 | public Logical(Token tok, Expr x1, Expr x2) { 13 | super(tok, null); 14 | expr1 = x1; 15 | expr2 = x2; 16 | type = check(expr1.type, expr2.type); 17 | if (type == null) 18 | error("type error"); 19 | } 20 | 21 | public Type check(Type p1, Type p2) { 22 | if (p1 == Type.Bool && p2 == Type.Bool) 23 | return Type.Bool; 24 | return null; 25 | } 26 | 27 | @Override 28 | public Expr gen() { 29 | int f = newlabel(); 30 | int a = newlabel(); 31 | Temp temp = new Temp(type); 32 | this.jumping(0, f); 33 | emit(temp.toString() + " = true"); 34 | emit("goto L" + a); 35 | emitlabel(f); 36 | emit(temp.toString() + " = false"); 37 | emitlabel(a); 38 | return temp; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return expr1.toString() + " " + op.toString() + " " + expr2.toString(); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /scripts/lefttree.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "node" : "list", 4 | "child" : [ 5 | { 6 | "node" : "list", 7 | "child" : [ 8 | { 9 | "node" : "list", 10 | "child" : [ 11 | { 12 | "node" : "digit", 13 | "child" : [ 14 | { 15 | "node" : "9", 16 | "child" : "null" 17 | } 18 | ] 19 | } 20 | ] 21 | }, 22 | { 23 | "node" : "-", 24 | "child" : "null" 25 | }, 26 | { 27 | "node" : "digit", 28 | "child" : "null" 29 | } 30 | ] 31 | }, 32 | { 33 | "node" : "-", 34 | "child" : "null" 35 | }, 36 | { 37 | "node" : "digit", 38 | "child" : [ 39 | { 40 | "node" : "2", 41 | "child" : "null" 42 | } 43 | ] 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | #定义变量,使用变量:$(变量名) 2 | CC=g++ 3 | #定义变量srcs,表示需要编译的源文件,需要表明路径,如果直接写表示这些cpp文件和makefile在同一个目录下,如果有多个源文件,每行以\结尾 4 | SRCS=./src/main.cpp\ 5 | ./src/smartpointer.cpp\ 6 | ./src/stack.cpp\ 7 | ./src/demo.cpp 8 | #定义变量OBJS,表示将原文件中所有以.cpp结尾的文件替换成以.o结尾,即将.cpp源文件编译成.o文件 9 | OBJS=$(SRCS:.cpp=.o) 10 | 11 | ifdef SystemRoot 12 | RM=del 13 | OPEN=start 14 | PYTHON=python 15 | else 16 | RM=rm -rf 17 | OPEN=open 18 | PYTHON=python3 19 | endif 20 | # 21 | 22 | #定义变量,表示最终生成的可执行文件名 23 | EXEC=maincpp 24 | all:start run 25 | #start,表示开始执行,冒号后面的$(OBJS)表示要生成最终可执行文件,需要依赖那些.o文件的 26 | start:$(OBJS) 27 | #相当于执行:g++ -o maincpp .o文件列表,-o表示生成的目标文件 28 | $(CC) -o $(EXEC) $(OBJS) 29 | #表示我的.o文件来自于.cpp文件 30 | .cpp.o: 31 | #如果在依赖关系中,有多个需要编译的.cpp文件,那么这个语句就需要执行多次。-c $<指的是需要编译的.cpp文件,-o $@指这个cpp文件编译后的中间文件名。比如在依赖关系中,有a.cpp和b.cpp,即$(OBJS)的值为a.cpp b.cpp,那么这条语句需要执行2次,第一次的$@为a.o,$<为a.cpp,第二次的$@为b.o,$<为b.cpp。-c表示只编译不链接,-o表示生成的目标文件 32 | #-DMYLINUX:-D为参数,MYLINUX为在cpp源文件中定义的宏名称,如#ifdef MYLINUX。注意-D和宏名称中间没有空格 33 | $(CC) -o $@ -c $< -DMYLINUX 34 | #执行make clean指令 35 | .PHONY:clean 36 | clean: 37 | -@$(RM) $(OBJS) 38 | #执行make clean指令时,需要执行的操作,比如下面的指令时指删除所有.o文件 39 | run: 40 | ./$(EXEC) 41 | cleanimg: 42 | -@$(RM) ./img/._*.* 43 | cleang4: 44 | -@$(RM) ./src/ANTLR4/.antlr/*.* 45 | -@$(RM) ./src/ANTLR4/.antlr/ 46 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInitLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '{' 4 | ',' 5 | '}' 6 | null 7 | null 8 | 9 | token symbolic names: 10 | null 11 | null 12 | null 13 | null 14 | INT 15 | WS 16 | 17 | rule names: 18 | T__0 19 | T__1 20 | T__2 21 | INT 22 | WS 23 | 24 | channel names: 25 | DEFAULT_TOKEN_CHANNEL 26 | HIDDEN 27 | 28 | mode names: 29 | DEFAULT_MODE 30 | 31 | atn: 32 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 7, 31, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 6, 5, 21, 10, 5, 13, 5, 14, 5, 22, 3, 6, 6, 6, 26, 10, 6, 13, 6, 14, 6, 27, 3, 6, 3, 6, 2, 2, 7, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 3, 2, 4, 3, 2, 50, 59, 4, 2, 11, 12, 15, 15, 2, 32, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 3, 13, 3, 2, 2, 2, 5, 15, 3, 2, 2, 2, 7, 17, 3, 2, 2, 2, 9, 20, 3, 2, 2, 2, 11, 25, 3, 2, 2, 2, 13, 14, 7, 125, 2, 2, 14, 4, 3, 2, 2, 2, 15, 16, 7, 46, 2, 2, 16, 6, 3, 2, 2, 2, 17, 18, 7, 127, 2, 2, 18, 8, 3, 2, 2, 2, 19, 21, 9, 2, 2, 2, 20, 19, 3, 2, 2, 2, 21, 22, 3, 2, 2, 2, 22, 20, 3, 2, 2, 2, 22, 23, 3, 2, 2, 2, 23, 10, 3, 2, 2, 2, 24, 26, 9, 3, 2, 2, 25, 24, 3, 2, 2, 2, 26, 27, 3, 2, 2, 2, 27, 25, 3, 2, 2, 2, 27, 28, 3, 2, 2, 2, 28, 29, 3, 2, 2, 2, 29, 30, 8, 6, 2, 2, 30, 12, 3, 2, 2, 2, 5, 2, 22, 27, 3, 8, 2, 2] -------------------------------------------------------------------------------- /src/simplecompiler/lexer.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 词法分析器模块 5 | 6 | char lexbuf[BSIZE]; 7 | int tokenval = NONE; // 记号的属性值 8 | int lineno = 1; // 行号 9 | 10 | // 词法分析器 或者记号 token 11 | int lexan() { 12 | int t; 13 | for (;;) { 14 | t = getchar(); // 从字节流获取一个字符 15 | if (t == ' ' || t == '\t' || t == '\v') // 去除空白符 16 | pass; 17 | else if (t == '\n' || t == '\r') // 检测换行符 18 | lineno = lineno + 1; 19 | else if (isdigit(t)) { 20 | ungetc(t, stdin); 21 | scanf("%d", &tokenval); 22 | return NUM; 23 | } 24 | else if (isalpha(t)) { 25 | int p, b = 0; 26 | while (isalnum(t)) { 27 | lexbuf[b] = t; 28 | t = getchar(); 29 | b = b + 1; 30 | if (b > BSIZE) 31 | error("compiler error"); 32 | } 33 | lexbuf[b] = EOS; 34 | if (t != EOF) 35 | ungetc(t, stdin); 36 | p = lookup(lexbuf); 37 | if (p == 0) 38 | p = insert(lexbuf, ID); 39 | tokenval = p; 40 | return symtabel[p].token; 41 | } 42 | else if (t == EOF) 43 | return DONE; 44 | else { 45 | tokenval = NONE; 46 | return t; 47 | } 48 | } 49 | } 50 | 51 | token nexttoken() { 52 | while (1) { 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/javacomplier/main/inter/Expr.java: -------------------------------------------------------------------------------- 1 | package inter; 2 | 3 | import lexer.*; 4 | import symbols.*; 5 | 6 | /** 7 | * Expr 表达式结点 8 | */ 9 | public class Expr extends Node { 10 | /** 11 | * 12 | */ 13 | public Token op; 14 | 15 | /** 16 | * 17 | */ 18 | public Type type; 19 | 20 | /** 21 | * 22 | * @param tok 23 | * @param p 24 | */ 25 | public Expr(Token tok, Type p) { 26 | op = tok; 27 | type = p; 28 | } 29 | 30 | /** 31 | * 32 | * @return 33 | */ 34 | public Expr gen() { 35 | return this; 36 | } 37 | 38 | /** 39 | * 40 | * @return 41 | */ 42 | public Expr reduce() { 43 | return this; 44 | } 45 | 46 | /** 47 | * 48 | * @param t true 49 | * @param f false 50 | */ 51 | public void jumping(int t, int f) { 52 | emitjumps(toString(), t, f); 53 | } 54 | 55 | /** 56 | * 57 | * @param test 58 | * @param t true 59 | * @param f false 60 | */ 61 | public void emitjumps(String test, int t, int f) { 62 | if (t != 0 && f != 0) { 63 | emit("if " + test + " goto L" + t); 64 | emit("goto L" + f); 65 | } 66 | else if (t != 0) { 67 | emit("if " + test + " goto L" + t); 68 | } 69 | else if (f != 0) { 70 | emit("iffalse " + test + " goto L" + f); 71 | } 72 | } 73 | 74 | /** 75 | * 76 | */ 77 | @Override 78 | public String toString() { 79 | return op.toString(); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExpr.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '=' 4 | '(' 5 | ')' 6 | null 7 | null 8 | null 9 | null 10 | '*' 11 | '/' 12 | '+' 13 | '-' 14 | 15 | token symbolic names: 16 | null 17 | null 18 | null 19 | null 20 | ID 21 | INT 22 | NEWLINE 23 | WS 24 | MUL 25 | DIV 26 | ADD 27 | SUB 28 | 29 | rule names: 30 | prog 31 | stat 32 | expr 33 | 34 | 35 | atn: 36 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 13, 45, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 6, 2, 10, 10, 2, 13, 2, 14, 2, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 23, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 32, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 40, 10, 4, 12, 4, 14, 4, 43, 11, 4, 3, 4, 2, 3, 6, 5, 2, 4, 6, 2, 4, 3, 2, 10, 11, 3, 2, 12, 13, 2, 48, 2, 9, 3, 2, 2, 2, 4, 22, 3, 2, 2, 2, 6, 31, 3, 2, 2, 2, 8, 10, 5, 4, 3, 2, 9, 8, 3, 2, 2, 2, 10, 11, 3, 2, 2, 2, 11, 9, 3, 2, 2, 2, 11, 12, 3, 2, 2, 2, 12, 3, 3, 2, 2, 2, 13, 14, 5, 6, 4, 2, 14, 15, 7, 8, 2, 2, 15, 23, 3, 2, 2, 2, 16, 17, 7, 6, 2, 2, 17, 18, 7, 3, 2, 2, 18, 19, 5, 6, 4, 2, 19, 20, 7, 8, 2, 2, 20, 23, 3, 2, 2, 2, 21, 23, 7, 8, 2, 2, 22, 13, 3, 2, 2, 2, 22, 16, 3, 2, 2, 2, 22, 21, 3, 2, 2, 2, 23, 5, 3, 2, 2, 2, 24, 25, 8, 4, 1, 2, 25, 32, 7, 7, 2, 2, 26, 32, 7, 6, 2, 2, 27, 28, 7, 4, 2, 2, 28, 29, 5, 6, 4, 2, 29, 30, 7, 5, 2, 2, 30, 32, 3, 2, 2, 2, 31, 24, 3, 2, 2, 2, 31, 26, 3, 2, 2, 2, 31, 27, 3, 2, 2, 2, 32, 41, 3, 2, 2, 2, 33, 34, 12, 7, 2, 2, 34, 35, 9, 2, 2, 2, 35, 40, 5, 6, 4, 8, 36, 37, 12, 6, 2, 2, 37, 38, 9, 3, 2, 2, 38, 40, 5, 6, 4, 7, 39, 33, 3, 2, 2, 2, 39, 36, 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 7, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 7, 11, 22, 31, 39, 41] -------------------------------------------------------------------------------- /src/simplecompiler/parse.c: -------------------------------------------------------------------------------- 1 | 2 | #include "global.h" 3 | 4 | // 词法翻译器模块 5 | 6 | int lookahead; 7 | 8 | static void expr(); 9 | static void term(); 10 | static void factor(); 11 | static void match(int t); 12 | 13 | // 分析并翻译表达式列表 14 | void parse() { 15 | lookahead = lexan(); 16 | while (lookahead != DONE) { 17 | // 匹配表达式 18 | expr(); 19 | // 每个表达式结尾要匹配句尾; 20 | match(';'); 21 | } 22 | } 23 | 24 | static void expr() { 25 | int t; 26 | term(); 27 | while (1) { 28 | switch (lookahead) 29 | { 30 | // + - 优先级比* / ( ) 低,最后匹配 31 | case '+': case '-': 32 | t = lookahead; 33 | match(lookahead); term(); emit(t, NONE); 34 | break; 35 | default: 36 | return; 37 | } 38 | } 39 | } 40 | 41 | static void term() { 42 | int t; 43 | factor(); 44 | while (1) { 45 | switch (lookahead) 46 | { 47 | case '*': case '/': case DIV: case MOD: 48 | t = lookahead; 49 | match(lookahead); factor(); emit(t, NONE); 50 | break; 51 | default: 52 | return; 53 | } 54 | } 55 | } 56 | 57 | static void factor() { 58 | switch (lookahead) 59 | { 60 | case '(': 61 | match('('); expr(); match(')'); 62 | break; 63 | case NUM: 64 | emit(NUM, tokenval); match(NUM); 65 | break; 66 | case ID: 67 | emit(ID, tokenval); match(ID); 68 | break; 69 | default: 70 | break; 71 | } 72 | } 73 | 74 | static void match(int t) { 75 | if (lookahead == t) 76 | lookahead = lexan(); 77 | else 78 | error("syntax error!"); 79 | } 80 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Lua.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | T__14=15 16 | T__15=16 17 | T__16=17 18 | T__17=18 19 | T__18=19 20 | T__19=20 21 | T__20=21 22 | T__21=22 23 | T__22=23 24 | T__23=24 25 | T__24=25 26 | T__25=26 27 | T__26=27 28 | T__27=28 29 | T__28=29 30 | T__29=30 31 | T__30=31 32 | T__31=32 33 | T__32=33 34 | T__33=34 35 | T__34=35 36 | T__35=36 37 | T__36=37 38 | T__37=38 39 | T__38=39 40 | T__39=40 41 | T__40=41 42 | T__41=42 43 | T__42=43 44 | T__43=44 45 | T__44=45 46 | T__45=46 47 | T__46=47 48 | T__47=48 49 | T__48=49 50 | T__49=50 51 | T__50=51 52 | T__51=52 53 | T__52=53 54 | T__53=54 55 | T__54=55 56 | NAME=56 57 | NORMALSTRING=57 58 | CHARSTRING=58 59 | LONGSTRING=59 60 | INT=60 61 | HEX=61 62 | FLOAT=62 63 | HEX_FLOAT=63 64 | COMMENT=64 65 | LINE_COMMENT=65 66 | WS=66 67 | SHEBANG=67 68 | ';'=1 69 | '='=2 70 | 'break'=3 71 | 'goto'=4 72 | 'do'=5 73 | 'end'=6 74 | 'while'=7 75 | 'repeat'=8 76 | 'until'=9 77 | 'if'=10 78 | 'then'=11 79 | 'elseif'=12 80 | 'else'=13 81 | 'for'=14 82 | ','=15 83 | 'in'=16 84 | 'function'=17 85 | 'local'=18 86 | 'return'=19 87 | '::'=20 88 | '.'=21 89 | ':'=22 90 | 'nil'=23 91 | 'false'=24 92 | 'true'=25 93 | '...'=26 94 | '('=27 95 | ')'=28 96 | '['=29 97 | ']'=30 98 | '{'=31 99 | '}'=32 100 | 'or'=33 101 | 'and'=34 102 | '<'=35 103 | '>'=36 104 | '<='=37 105 | '>='=38 106 | '~='=39 107 | '=='=40 108 | '..'=41 109 | '+'=42 110 | '-'=43 111 | '*'=44 112 | '/'=45 113 | '%'=46 114 | '//'=47 115 | '&'=48 116 | '|'=49 117 | '~'=50 118 | '<<'=51 119 | '>>'=52 120 | 'not'=53 121 | '#'=54 122 | '^'=55 123 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LuaLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | T__14=15 16 | T__15=16 17 | T__16=17 18 | T__17=18 19 | T__18=19 20 | T__19=20 21 | T__20=21 22 | T__21=22 23 | T__22=23 24 | T__23=24 25 | T__24=25 26 | T__25=26 27 | T__26=27 28 | T__27=28 29 | T__28=29 30 | T__29=30 31 | T__30=31 32 | T__31=32 33 | T__32=33 34 | T__33=34 35 | T__34=35 36 | T__35=36 37 | T__36=37 38 | T__37=38 39 | T__38=39 40 | T__39=40 41 | T__40=41 42 | T__41=42 43 | T__42=43 44 | T__43=44 45 | T__44=45 46 | T__45=46 47 | T__46=47 48 | T__47=48 49 | T__48=49 50 | T__49=50 51 | T__50=51 52 | T__51=52 53 | T__52=53 54 | T__53=54 55 | T__54=55 56 | NAME=56 57 | NORMALSTRING=57 58 | CHARSTRING=58 59 | LONGSTRING=59 60 | INT=60 61 | HEX=61 62 | FLOAT=62 63 | HEX_FLOAT=63 64 | COMMENT=64 65 | LINE_COMMENT=65 66 | WS=66 67 | SHEBANG=67 68 | ';'=1 69 | '='=2 70 | 'break'=3 71 | 'goto'=4 72 | 'do'=5 73 | 'end'=6 74 | 'while'=7 75 | 'repeat'=8 76 | 'until'=9 77 | 'if'=10 78 | 'then'=11 79 | 'elseif'=12 80 | 'else'=13 81 | 'for'=14 82 | ','=15 83 | 'in'=16 84 | 'function'=17 85 | 'local'=18 86 | 'return'=19 87 | '::'=20 88 | '.'=21 89 | ':'=22 90 | 'nil'=23 91 | 'false'=24 92 | 'true'=25 93 | '...'=26 94 | '('=27 95 | ')'=28 96 | '['=29 97 | ']'=30 98 | '{'=31 99 | '}'=32 100 | 'or'=33 101 | 'and'=34 102 | '<'=35 103 | '>'=36 104 | '<='=37 105 | '>='=38 106 | '~='=39 107 | '=='=40 108 | '..'=41 109 | '+'=42 110 | '-'=43 111 | '*'=44 112 | '/'=45 113 | '%'=46 114 | '//'=47 115 | '&'=48 116 | '|'=49 117 | '~'=50 118 | '<<'=51 119 | '>>'=52 120 | 'not'=53 121 | '#'=54 122 | '^'=55 123 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/E.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '=' 4 | ';' 5 | '+' 6 | '-' 7 | '*' 8 | '(' 9 | ')' 10 | null 11 | null 12 | null 13 | null 14 | 15 | token symbolic names: 16 | null 17 | null 18 | null 19 | null 20 | null 21 | null 22 | null 23 | null 24 | VAR 25 | INT 26 | STRING 27 | WS 28 | 29 | rule names: 30 | program 31 | statement 32 | expression 33 | multExpr 34 | atom 35 | 36 | 37 | atn: 38 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 13, 52, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 6, 2, 14, 10, 2, 13, 2, 14, 2, 15, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 22, 10, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 7, 4, 29, 10, 4, 12, 4, 14, 4, 32, 11, 4, 3, 4, 5, 4, 35, 10, 4, 3, 5, 3, 5, 3, 5, 7, 5, 40, 10, 5, 12, 5, 14, 5, 43, 11, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 50, 10, 6, 3, 6, 2, 2, 7, 2, 4, 6, 8, 10, 2, 3, 3, 2, 5, 6, 2, 52, 2, 13, 3, 2, 2, 2, 4, 21, 3, 2, 2, 2, 6, 34, 3, 2, 2, 2, 8, 36, 3, 2, 2, 2, 10, 49, 3, 2, 2, 2, 12, 14, 5, 4, 3, 2, 13, 12, 3, 2, 2, 2, 14, 15, 3, 2, 2, 2, 15, 13, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 3, 3, 2, 2, 2, 17, 22, 5, 6, 4, 2, 18, 19, 7, 10, 2, 2, 19, 20, 7, 3, 2, 2, 20, 22, 5, 6, 4, 2, 21, 17, 3, 2, 2, 2, 21, 18, 3, 2, 2, 2, 22, 23, 3, 2, 2, 2, 23, 24, 7, 4, 2, 2, 24, 5, 3, 2, 2, 2, 25, 30, 5, 8, 5, 2, 26, 27, 9, 2, 2, 2, 27, 29, 5, 8, 5, 2, 28, 26, 3, 2, 2, 2, 29, 32, 3, 2, 2, 2, 30, 28, 3, 2, 2, 2, 30, 31, 3, 2, 2, 2, 31, 35, 3, 2, 2, 2, 32, 30, 3, 2, 2, 2, 33, 35, 7, 12, 2, 2, 34, 25, 3, 2, 2, 2, 34, 33, 3, 2, 2, 2, 35, 7, 3, 2, 2, 2, 36, 41, 5, 10, 6, 2, 37, 38, 7, 7, 2, 2, 38, 40, 5, 10, 6, 2, 39, 37, 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 9, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 44, 50, 7, 11, 2, 2, 45, 46, 7, 8, 2, 2, 46, 47, 5, 6, 4, 2, 47, 48, 7, 9, 2, 2, 48, 50, 3, 2, 2, 2, 49, 44, 3, 2, 2, 2, 49, 45, 3, 2, 2, 2, 50, 11, 3, 2, 2, 2, 8, 15, 21, 30, 34, 41, 49] -------------------------------------------------------------------------------- /scripts/righttree.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "node" : "-", 4 | "child" : [ 5 | { 6 | "node" : "letter", 7 | "child" : [ 8 | { 9 | "node" : "a", 10 | "child" : "null" 11 | } 12 | ] 13 | }, 14 | { 15 | "node" : "=", 16 | "child" : "null" 17 | }, 18 | { 19 | "node" : "right", 20 | "child" : [ 21 | { 22 | "node" : "right", 23 | "child" : [ 24 | { 25 | "node" : "letter", 26 | "child" : [ 27 | { 28 | "node" : "b", 29 | "child" : "null" 30 | } 31 | ] 32 | }, 33 | { 34 | "node" : "=", 35 | "child" : "null" 36 | }, 37 | { 38 | "node" : "right", 39 | "child" : [ 40 | { 41 | "node" : "right", 42 | "child" : [ 43 | { 44 | "node" : "letter", 45 | "child" : [ 46 | { 47 | "node" : "c", 48 | "child" : "null" 49 | } 50 | ] 51 | } 52 | ] 53 | } 54 | ] 55 | } 56 | ] 57 | } 58 | ] 59 | } 60 | ] 61 | } -------------------------------------------------------------------------------- /doc/DUGU_POLICY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## DuGu Policy (策略) 4 | 5 | [-opa,一个统一策略(policy)的方案,自带了json like dsl和controller](https://github.com/open-policy-agent/opa) 6 | 7 | [目前opa会把dsl的执行计划(policies)通过wasm打包编译为WebAssembly,然后让controller调用wasm程序做判断](https://github.com/open-policy-agent/opa/tree/master/wasm) 8 | 9 | [统一controller的部分,一个基于k8s的operator](https://github.com/open-policy-agent/gatekeeper) 10 | 11 | [Python解释器的官方实现](https://github.com/python/cpython) 12 | 13 | [一个社区的go实现的python解释器](https://github.com/go-python/gpython) 14 | 15 | ```py 16 | def resource_assert(deployment, assert_log): 17 | if deployment.spec.relicas < 3: 18 | assert_log("prod deployment should have at least 3 replicas.") 19 | 20 | def replica_validate(): 21 | return ResourceAssertPolicy( 22 | name="minimum-relica-valiadate", 23 | description="Three replicas at least in prod.", 24 | resourceAssertion=[ 25 | ResourceAssertion(Deployment, resource_assert) 26 | ] 27 | ) 28 | 29 | Policies("resource-rules", {[ 30 | replica_validate(), 31 | ]}) 32 | ``` 33 | 34 | ## OPA 35 | 36 | 开放策略代理(Open Policy Agent, OPA)是一个开放源代码的通用策略引擎,可在整个堆栈中实施统一的,基于上下文的策略。 37 | 38 | ### OPA的工作方式 39 | 40 | OPA提供了一种高级声明性语言,以在整个堆栈中编写和实施策略。 41 | 42 | 使用OPA,可以定义规则来控制系统的行为。这些规则可以回答以下问题: 43 | 44 | * 用户X可以调用资源Z上的操作Y吗? 45 | * 应将工作负载W部署到哪些群集? 46 | * 创建资源R之前,必须在资源R上设置哪些标签? 47 | 48 | 将服务与OPA集成在一起,因此不必在服务中对这些类型的策略决策进行硬编码。服务在需要策略决策时通过执行查询与OPA集成。 49 | 50 | 当向OPA查询策略决策时,OPA会评估规则和数据以得出答案。该策略决策作为查询结果发送回。 51 | 52 | 例如,在一个简单的API授权用例中: 53 | 54 | * 编写允许(或拒绝)访问您的服务API的规则。 55 | * 的服务在收到API请求时查询OPA。 56 | * OPA退货允许(或拒绝)您的服务决策。 57 | * 服务通过相应地接受或拒绝请求来执行决策。 58 | 59 | ### OPA与其他容器或者集群集成的案例(docker,k8s等) 60 | 61 | 例子 62 | 63 | 顶层json声明语言`data.json` 64 | 65 | ```json 66 | { 67 | "management_chain": { 68 | "bob": [ 69 | "ken", 70 | "janet" 71 | ], 72 | "alice": [ 73 | "janet" 74 | ] 75 | } 76 | } 77 | ``` 78 | 79 | 使用 80 | 81 | ```cmd 82 | opa run data.json 83 | ``` 84 | 85 | ## CPython的类OPA实现系统架构 86 | 87 | 1. 编写python函数或者python语言子集函数function并调用dugu_py_opa包中的函数完成策略编写和断言(通过给用户编写的包或者如VS Code、Vim、Atom等编辑器插件完成开发,一般主流的编译器都提供插件开发支持)。 88 | 2. 使用python解释器自带的AST抽象语法树包完成**词法**和**语法**翻译等,生成如等json结构的抽象语法树,完成python DSL->中间语言的功能。 89 | 3. 调用生成器将生成的中间语言翻译成如go语言相关的词法语法和包调用,并生成命令行程序供其他程序调用或者直接嵌入到docker或者k8s容器中,由容器的go解释器完成对生成的命令行应用运行 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExprLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '=' 4 | '(' 5 | ')' 6 | null 7 | null 8 | null 9 | null 10 | '*' 11 | '/' 12 | '+' 13 | '-' 14 | 15 | token symbolic names: 16 | null 17 | null 18 | null 19 | null 20 | ID 21 | INT 22 | NEWLINE 23 | WS 24 | MUL 25 | DIV 26 | ADD 27 | SUB 28 | 29 | rule names: 30 | T__0 31 | T__1 32 | T__2 33 | ID 34 | INT 35 | NEWLINE 36 | WS 37 | MUL 38 | DIV 39 | ADD 40 | SUB 41 | 42 | channel names: 43 | DEFAULT_TOKEN_CHANNEL 44 | HIDDEN 45 | 46 | mode names: 47 | DEFAULT_MODE 48 | 49 | atn: 50 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 61, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 6, 5, 33, 10, 5, 13, 5, 14, 5, 34, 3, 6, 6, 6, 38, 10, 6, 13, 6, 14, 6, 39, 3, 7, 5, 7, 43, 10, 7, 3, 7, 3, 7, 3, 8, 6, 8, 48, 10, 8, 13, 8, 14, 8, 49, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 2, 2, 13, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 3, 2, 5, 4, 2, 67, 92, 99, 124, 3, 2, 50, 59, 3, 2, 11, 11, 2, 64, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 3, 25, 3, 2, 2, 2, 5, 27, 3, 2, 2, 2, 7, 29, 3, 2, 2, 2, 9, 32, 3, 2, 2, 2, 11, 37, 3, 2, 2, 2, 13, 42, 3, 2, 2, 2, 15, 47, 3, 2, 2, 2, 17, 53, 3, 2, 2, 2, 19, 55, 3, 2, 2, 2, 21, 57, 3, 2, 2, 2, 23, 59, 3, 2, 2, 2, 25, 26, 7, 63, 2, 2, 26, 4, 3, 2, 2, 2, 27, 28, 7, 42, 2, 2, 28, 6, 3, 2, 2, 2, 29, 30, 7, 43, 2, 2, 30, 8, 3, 2, 2, 2, 31, 33, 9, 2, 2, 2, 32, 31, 3, 2, 2, 2, 33, 34, 3, 2, 2, 2, 34, 32, 3, 2, 2, 2, 34, 35, 3, 2, 2, 2, 35, 10, 3, 2, 2, 2, 36, 38, 9, 3, 2, 2, 37, 36, 3, 2, 2, 2, 38, 39, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 39, 40, 3, 2, 2, 2, 40, 12, 3, 2, 2, 2, 41, 43, 7, 116, 2, 2, 42, 41, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 45, 7, 12, 2, 2, 45, 14, 3, 2, 2, 2, 46, 48, 9, 4, 2, 2, 47, 46, 3, 2, 2, 2, 48, 49, 3, 2, 2, 2, 49, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 52, 8, 8, 2, 2, 52, 16, 3, 2, 2, 2, 53, 54, 7, 44, 2, 2, 54, 18, 3, 2, 2, 2, 55, 56, 7, 49, 2, 2, 56, 20, 3, 2, 2, 2, 57, 58, 7, 45, 2, 2, 58, 22, 3, 2, 2, 2, 59, 60, 7, 47, 2, 2, 60, 24, 3, 2, 2, 2, 7, 2, 34, 39, 42, 49, 3, 8, 2, 2] -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ELexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '=' 4 | ';' 5 | '+' 6 | '-' 7 | '*' 8 | '(' 9 | ')' 10 | null 11 | null 12 | null 13 | null 14 | 15 | token symbolic names: 16 | null 17 | null 18 | null 19 | null 20 | null 21 | null 22 | null 23 | null 24 | VAR 25 | INT 26 | STRING 27 | WS 28 | 29 | rule names: 30 | T__0 31 | T__1 32 | T__2 33 | T__3 34 | T__4 35 | T__5 36 | T__6 37 | VAR 38 | INT 39 | STRING 40 | WS 41 | 42 | channel names: 43 | DEFAULT_TOKEN_CHANNEL 44 | HIDDEN 45 | 46 | mode names: 47 | DEFAULT_MODE 48 | 49 | atn: 50 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 64, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 6, 9, 41, 10, 9, 13, 9, 14, 9, 42, 3, 10, 6, 10, 46, 10, 10, 13, 10, 14, 10, 47, 3, 11, 3, 11, 6, 11, 52, 10, 11, 13, 11, 14, 11, 53, 3, 11, 3, 11, 3, 12, 6, 12, 59, 10, 12, 13, 12, 14, 12, 60, 3, 12, 3, 12, 2, 2, 13, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 3, 2, 5, 4, 2, 67, 92, 99, 124, 5, 2, 34, 34, 67, 92, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 67, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 3, 25, 3, 2, 2, 2, 5, 27, 3, 2, 2, 2, 7, 29, 3, 2, 2, 2, 9, 31, 3, 2, 2, 2, 11, 33, 3, 2, 2, 2, 13, 35, 3, 2, 2, 2, 15, 37, 3, 2, 2, 2, 17, 40, 3, 2, 2, 2, 19, 45, 3, 2, 2, 2, 21, 49, 3, 2, 2, 2, 23, 58, 3, 2, 2, 2, 25, 26, 7, 63, 2, 2, 26, 4, 3, 2, 2, 2, 27, 28, 7, 61, 2, 2, 28, 6, 3, 2, 2, 2, 29, 30, 7, 45, 2, 2, 30, 8, 3, 2, 2, 2, 31, 32, 7, 47, 2, 2, 32, 10, 3, 2, 2, 2, 33, 34, 7, 44, 2, 2, 34, 12, 3, 2, 2, 2, 35, 36, 7, 42, 2, 2, 36, 14, 3, 2, 2, 2, 37, 38, 7, 43, 2, 2, 38, 16, 3, 2, 2, 2, 39, 41, 9, 2, 2, 2, 40, 39, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 40, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 18, 3, 2, 2, 2, 44, 46, 4, 50, 59, 2, 45, 44, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 45, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 20, 3, 2, 2, 2, 49, 51, 7, 36, 2, 2, 50, 52, 9, 3, 2, 2, 51, 50, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 56, 7, 36, 2, 2, 56, 22, 3, 2, 2, 2, 57, 59, 9, 4, 2, 2, 58, 57, 3, 2, 2, 2, 59, 60, 3, 2, 2, 2, 60, 58, 3, 2, 2, 2, 60, 61, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 63, 8, 12, 2, 2, 63, 24, 3, 2, 2, 2, 7, 2, 42, 47, 53, 60, 3, 3, 12, 2] -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Java9.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | ABSTRACT=11 12 | ASSERT=12 13 | BOOLEAN=13 14 | BREAK=14 15 | BYTE=15 16 | CASE=16 17 | CATCH=17 18 | CHAR=18 19 | CLASS=19 20 | CONST=20 21 | CONTINUE=21 22 | DEFAULT=22 23 | DO=23 24 | DOUBLE=24 25 | ELSE=25 26 | ENUM=26 27 | EXTENDS=27 28 | FINAL=28 29 | FINALLY=29 30 | FLOAT=30 31 | FOR=31 32 | IF=32 33 | GOTO=33 34 | IMPLEMENTS=34 35 | IMPORT=35 36 | INSTANCEOF=36 37 | INT=37 38 | INTERFACE=38 39 | LONG=39 40 | NATIVE=40 41 | NEW=41 42 | PACKAGE=42 43 | PRIVATE=43 44 | PROTECTED=44 45 | PUBLIC=45 46 | RETURN=46 47 | SHORT=47 48 | STATIC=48 49 | STRICTFP=49 50 | SUPER=50 51 | SWITCH=51 52 | SYNCHRONIZED=52 53 | THIS=53 54 | THROW=54 55 | THROWS=55 56 | TRANSIENT=56 57 | TRY=57 58 | VOID=58 59 | VOLATILE=59 60 | WHILE=60 61 | UNDER_SCORE=61 62 | IntegerLiteral=62 63 | FloatingPointLiteral=63 64 | BooleanLiteral=64 65 | CharacterLiteral=65 66 | StringLiteral=66 67 | NullLiteral=67 68 | LPAREN=68 69 | RPAREN=69 70 | LBRACE=70 71 | RBRACE=71 72 | LBRACK=72 73 | RBRACK=73 74 | SEMI=74 75 | COMMA=75 76 | DOT=76 77 | ELLIPSIS=77 78 | AT=78 79 | COLONCOLON=79 80 | ASSIGN=80 81 | GT=81 82 | LT=82 83 | BANG=83 84 | TILDE=84 85 | QUESTION=85 86 | COLON=86 87 | ARROW=87 88 | EQUAL=88 89 | LE=89 90 | GE=90 91 | NOTEQUAL=91 92 | AND=92 93 | OR=93 94 | INC=94 95 | DEC=95 96 | ADD=96 97 | SUB=97 98 | MUL=98 99 | DIV=99 100 | BITAND=100 101 | BITOR=101 102 | CARET=102 103 | MOD=103 104 | ADD_ASSIGN=104 105 | SUB_ASSIGN=105 106 | MUL_ASSIGN=106 107 | DIV_ASSIGN=107 108 | AND_ASSIGN=108 109 | OR_ASSIGN=109 110 | XOR_ASSIGN=110 111 | MOD_ASSIGN=111 112 | LSHIFT_ASSIGN=112 113 | RSHIFT_ASSIGN=113 114 | URSHIFT_ASSIGN=114 115 | Identifier=115 116 | WS=116 117 | COMMENT=117 118 | LINE_COMMENT=118 119 | 'open'=1 120 | 'module'=2 121 | 'requires'=3 122 | 'exports'=4 123 | 'to'=5 124 | 'opens'=6 125 | 'uses'=7 126 | 'provides'=8 127 | 'with'=9 128 | 'transitive'=10 129 | 'abstract'=11 130 | 'assert'=12 131 | 'boolean'=13 132 | 'break'=14 133 | 'byte'=15 134 | 'case'=16 135 | 'catch'=17 136 | 'char'=18 137 | 'class'=19 138 | 'const'=20 139 | 'continue'=21 140 | 'default'=22 141 | 'do'=23 142 | 'double'=24 143 | 'else'=25 144 | 'enum'=26 145 | 'extends'=27 146 | 'final'=28 147 | 'finally'=29 148 | 'float'=30 149 | 'for'=31 150 | 'if'=32 151 | 'goto'=33 152 | 'implements'=34 153 | 'import'=35 154 | 'instanceof'=36 155 | 'int'=37 156 | 'interface'=38 157 | 'long'=39 158 | 'native'=40 159 | 'new'=41 160 | 'package'=42 161 | 'private'=43 162 | 'protected'=44 163 | 'public'=45 164 | 'return'=46 165 | 'short'=47 166 | 'static'=48 167 | 'strictfp'=49 168 | 'super'=50 169 | 'switch'=51 170 | 'synchronized'=52 171 | 'this'=53 172 | 'throw'=54 173 | 'throws'=55 174 | 'transient'=56 175 | 'try'=57 176 | 'void'=58 177 | 'volatile'=59 178 | 'while'=60 179 | '_'=61 180 | 'null'=67 181 | '('=68 182 | ')'=69 183 | '{'=70 184 | '}'=71 185 | '['=72 186 | ']'=73 187 | ';'=74 188 | ','=75 189 | '.'=76 190 | '...'=77 191 | '@'=78 192 | '::'=79 193 | '='=80 194 | '>'=81 195 | '<'=82 196 | '!'=83 197 | '~'=84 198 | '?'=85 199 | ':'=86 200 | '->'=87 201 | '=='=88 202 | '<='=89 203 | '>='=90 204 | '!='=91 205 | '&&'=92 206 | '||'=93 207 | '++'=94 208 | '--'=95 209 | '+'=96 210 | '-'=97 211 | '*'=98 212 | '/'=99 213 | '&'=100 214 | '|'=101 215 | '^'=102 216 | '%'=103 217 | '+='=104 218 | '-='=105 219 | '*='=106 220 | '/='=107 221 | '&='=108 222 | '|='=109 223 | '^='=110 224 | '%='=111 225 | '<<='=112 226 | '>>='=113 227 | '>>>='=114 228 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Java9Lexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | ABSTRACT=11 12 | ASSERT=12 13 | BOOLEAN=13 14 | BREAK=14 15 | BYTE=15 16 | CASE=16 17 | CATCH=17 18 | CHAR=18 19 | CLASS=19 20 | CONST=20 21 | CONTINUE=21 22 | DEFAULT=22 23 | DO=23 24 | DOUBLE=24 25 | ELSE=25 26 | ENUM=26 27 | EXTENDS=27 28 | FINAL=28 29 | FINALLY=29 30 | FLOAT=30 31 | FOR=31 32 | IF=32 33 | GOTO=33 34 | IMPLEMENTS=34 35 | IMPORT=35 36 | INSTANCEOF=36 37 | INT=37 38 | INTERFACE=38 39 | LONG=39 40 | NATIVE=40 41 | NEW=41 42 | PACKAGE=42 43 | PRIVATE=43 44 | PROTECTED=44 45 | PUBLIC=45 46 | RETURN=46 47 | SHORT=47 48 | STATIC=48 49 | STRICTFP=49 50 | SUPER=50 51 | SWITCH=51 52 | SYNCHRONIZED=52 53 | THIS=53 54 | THROW=54 55 | THROWS=55 56 | TRANSIENT=56 57 | TRY=57 58 | VOID=58 59 | VOLATILE=59 60 | WHILE=60 61 | UNDER_SCORE=61 62 | IntegerLiteral=62 63 | FloatingPointLiteral=63 64 | BooleanLiteral=64 65 | CharacterLiteral=65 66 | StringLiteral=66 67 | NullLiteral=67 68 | LPAREN=68 69 | RPAREN=69 70 | LBRACE=70 71 | RBRACE=71 72 | LBRACK=72 73 | RBRACK=73 74 | SEMI=74 75 | COMMA=75 76 | DOT=76 77 | ELLIPSIS=77 78 | AT=78 79 | COLONCOLON=79 80 | ASSIGN=80 81 | GT=81 82 | LT=82 83 | BANG=83 84 | TILDE=84 85 | QUESTION=85 86 | COLON=86 87 | ARROW=87 88 | EQUAL=88 89 | LE=89 90 | GE=90 91 | NOTEQUAL=91 92 | AND=92 93 | OR=93 94 | INC=94 95 | DEC=95 96 | ADD=96 97 | SUB=97 98 | MUL=98 99 | DIV=99 100 | BITAND=100 101 | BITOR=101 102 | CARET=102 103 | MOD=103 104 | ADD_ASSIGN=104 105 | SUB_ASSIGN=105 106 | MUL_ASSIGN=106 107 | DIV_ASSIGN=107 108 | AND_ASSIGN=108 109 | OR_ASSIGN=109 110 | XOR_ASSIGN=110 111 | MOD_ASSIGN=111 112 | LSHIFT_ASSIGN=112 113 | RSHIFT_ASSIGN=113 114 | URSHIFT_ASSIGN=114 115 | Identifier=115 116 | WS=116 117 | COMMENT=117 118 | LINE_COMMENT=118 119 | 'open'=1 120 | 'module'=2 121 | 'requires'=3 122 | 'exports'=4 123 | 'to'=5 124 | 'opens'=6 125 | 'uses'=7 126 | 'provides'=8 127 | 'with'=9 128 | 'transitive'=10 129 | 'abstract'=11 130 | 'assert'=12 131 | 'boolean'=13 132 | 'break'=14 133 | 'byte'=15 134 | 'case'=16 135 | 'catch'=17 136 | 'char'=18 137 | 'class'=19 138 | 'const'=20 139 | 'continue'=21 140 | 'default'=22 141 | 'do'=23 142 | 'double'=24 143 | 'else'=25 144 | 'enum'=26 145 | 'extends'=27 146 | 'final'=28 147 | 'finally'=29 148 | 'float'=30 149 | 'for'=31 150 | 'if'=32 151 | 'goto'=33 152 | 'implements'=34 153 | 'import'=35 154 | 'instanceof'=36 155 | 'int'=37 156 | 'interface'=38 157 | 'long'=39 158 | 'native'=40 159 | 'new'=41 160 | 'package'=42 161 | 'private'=43 162 | 'protected'=44 163 | 'public'=45 164 | 'return'=46 165 | 'short'=47 166 | 'static'=48 167 | 'strictfp'=49 168 | 'super'=50 169 | 'switch'=51 170 | 'synchronized'=52 171 | 'this'=53 172 | 'throw'=54 173 | 'throws'=55 174 | 'transient'=56 175 | 'try'=57 176 | 'void'=58 177 | 'volatile'=59 178 | 'while'=60 179 | '_'=61 180 | 'null'=67 181 | '('=68 182 | ')'=69 183 | '{'=70 184 | '}'=71 185 | '['=72 186 | ']'=73 187 | ';'=74 188 | ','=75 189 | '.'=76 190 | '...'=77 191 | '@'=78 192 | '::'=79 193 | '='=80 194 | '>'=81 195 | '<'=82 196 | '!'=83 197 | '~'=84 198 | '?'=85 199 | ':'=86 200 | '->'=87 201 | '=='=88 202 | '<='=89 203 | '>='=90 204 | '!='=91 205 | '&&'=92 206 | '||'=93 207 | '++'=94 208 | '--'=95 209 | '+'=96 210 | '-'=97 211 | '*'=98 212 | '/'=99 213 | '&'=100 214 | '|'=101 215 | '^'=102 216 | '%'=103 217 | '+='=104 218 | '-='=105 219 | '*='=106 220 | '/='=107 221 | '&='=108 222 | '|='=109 223 | '^='=110 224 | '%='=111 225 | '<<='=112 226 | '>>='=113 227 | '>>>='=114 228 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/C.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | Auto=15 16 | Break=16 17 | Case=17 18 | Char=18 19 | Const=19 20 | Continue=20 21 | Default=21 22 | Do=22 23 | Double=23 24 | Else=24 25 | Enum=25 26 | Extern=26 27 | Float=27 28 | For=28 29 | Goto=29 30 | If=30 31 | Inline=31 32 | Int=32 33 | Long=33 34 | Register=34 35 | Restrict=35 36 | Return=36 37 | Short=37 38 | Signed=38 39 | Sizeof=39 40 | Static=40 41 | Struct=41 42 | Switch=42 43 | Typedef=43 44 | Union=44 45 | Unsigned=45 46 | Void=46 47 | Volatile=47 48 | While=48 49 | Alignas=49 50 | Alignof=50 51 | Atomic=51 52 | Bool=52 53 | Complex=53 54 | Generic=54 55 | Imaginary=55 56 | Noreturn=56 57 | StaticAssert=57 58 | ThreadLocal=58 59 | LeftParen=59 60 | RightParen=60 61 | LeftBracket=61 62 | RightBracket=62 63 | LeftBrace=63 64 | RightBrace=64 65 | Less=65 66 | LessEqual=66 67 | Greater=67 68 | GreaterEqual=68 69 | LeftShift=69 70 | RightShift=70 71 | Plus=71 72 | PlusPlus=72 73 | Minus=73 74 | MinusMinus=74 75 | Star=75 76 | Div=76 77 | Mod=77 78 | And=78 79 | Or=79 80 | AndAnd=80 81 | OrOr=81 82 | Caret=82 83 | Not=83 84 | Tilde=84 85 | Question=85 86 | Colon=86 87 | Semi=87 88 | Comma=88 89 | Assign=89 90 | StarAssign=90 91 | DivAssign=91 92 | ModAssign=92 93 | PlusAssign=93 94 | MinusAssign=94 95 | LeftShiftAssign=95 96 | RightShiftAssign=96 97 | AndAssign=97 98 | XorAssign=98 99 | OrAssign=99 100 | Equal=100 101 | NotEqual=101 102 | Arrow=102 103 | Dot=103 104 | Ellipsis=104 105 | Identifier=105 106 | Constant=106 107 | DigitSequence=107 108 | StringLiteral=108 109 | ComplexDefine=109 110 | IncludeDirective=110 111 | AsmBlock=111 112 | LineAfterPreprocessing=112 113 | LineDirective=113 114 | PragmaDirective=114 115 | Whitespace=115 116 | Newline=116 117 | BlockComment=117 118 | LineComment=118 119 | '__extension__'=1 120 | '__builtin_va_arg'=2 121 | '__builtin_offsetof'=3 122 | '__m128'=4 123 | '__m128d'=5 124 | '__m128i'=6 125 | '__typeof__'=7 126 | '__inline__'=8 127 | '__stdcall'=9 128 | '__declspec'=10 129 | '__asm'=11 130 | '__attribute__'=12 131 | '__asm__'=13 132 | '__volatile__'=14 133 | 'auto'=15 134 | 'break'=16 135 | 'case'=17 136 | 'char'=18 137 | 'const'=19 138 | 'continue'=20 139 | 'default'=21 140 | 'do'=22 141 | 'double'=23 142 | 'else'=24 143 | 'enum'=25 144 | 'extern'=26 145 | 'float'=27 146 | 'for'=28 147 | 'goto'=29 148 | 'if'=30 149 | 'inline'=31 150 | 'int'=32 151 | 'long'=33 152 | 'register'=34 153 | 'restrict'=35 154 | 'return'=36 155 | 'short'=37 156 | 'signed'=38 157 | 'sizeof'=39 158 | 'static'=40 159 | 'struct'=41 160 | 'switch'=42 161 | 'typedef'=43 162 | 'union'=44 163 | 'unsigned'=45 164 | 'void'=46 165 | 'volatile'=47 166 | 'while'=48 167 | '_Alignas'=49 168 | '_Alignof'=50 169 | '_Atomic'=51 170 | '_Bool'=52 171 | '_Complex'=53 172 | '_Generic'=54 173 | '_Imaginary'=55 174 | '_Noreturn'=56 175 | '_Static_assert'=57 176 | '_Thread_local'=58 177 | '('=59 178 | ')'=60 179 | '['=61 180 | ']'=62 181 | '{'=63 182 | '}'=64 183 | '<'=65 184 | '<='=66 185 | '>'=67 186 | '>='=68 187 | '<<'=69 188 | '>>'=70 189 | '+'=71 190 | '++'=72 191 | '-'=73 192 | '--'=74 193 | '*'=75 194 | '/'=76 195 | '%'=77 196 | '&'=78 197 | '|'=79 198 | '&&'=80 199 | '||'=81 200 | '^'=82 201 | '!'=83 202 | '~'=84 203 | '?'=85 204 | ':'=86 205 | ';'=87 206 | ','=88 207 | '='=89 208 | '*='=90 209 | '/='=91 210 | '%='=92 211 | '+='=93 212 | '-='=94 213 | '<<='=95 214 | '>>='=96 215 | '&='=97 216 | '^='=98 217 | '|='=99 218 | '=='=100 219 | '!='=101 220 | '->'=102 221 | '.'=103 222 | '...'=104 223 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/CLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | Auto=15 16 | Break=16 17 | Case=17 18 | Char=18 19 | Const=19 20 | Continue=20 21 | Default=21 22 | Do=22 23 | Double=23 24 | Else=24 25 | Enum=25 26 | Extern=26 27 | Float=27 28 | For=28 29 | Goto=29 30 | If=30 31 | Inline=31 32 | Int=32 33 | Long=33 34 | Register=34 35 | Restrict=35 36 | Return=36 37 | Short=37 38 | Signed=38 39 | Sizeof=39 40 | Static=40 41 | Struct=41 42 | Switch=42 43 | Typedef=43 44 | Union=44 45 | Unsigned=45 46 | Void=46 47 | Volatile=47 48 | While=48 49 | Alignas=49 50 | Alignof=50 51 | Atomic=51 52 | Bool=52 53 | Complex=53 54 | Generic=54 55 | Imaginary=55 56 | Noreturn=56 57 | StaticAssert=57 58 | ThreadLocal=58 59 | LeftParen=59 60 | RightParen=60 61 | LeftBracket=61 62 | RightBracket=62 63 | LeftBrace=63 64 | RightBrace=64 65 | Less=65 66 | LessEqual=66 67 | Greater=67 68 | GreaterEqual=68 69 | LeftShift=69 70 | RightShift=70 71 | Plus=71 72 | PlusPlus=72 73 | Minus=73 74 | MinusMinus=74 75 | Star=75 76 | Div=76 77 | Mod=77 78 | And=78 79 | Or=79 80 | AndAnd=80 81 | OrOr=81 82 | Caret=82 83 | Not=83 84 | Tilde=84 85 | Question=85 86 | Colon=86 87 | Semi=87 88 | Comma=88 89 | Assign=89 90 | StarAssign=90 91 | DivAssign=91 92 | ModAssign=92 93 | PlusAssign=93 94 | MinusAssign=94 95 | LeftShiftAssign=95 96 | RightShiftAssign=96 97 | AndAssign=97 98 | XorAssign=98 99 | OrAssign=99 100 | Equal=100 101 | NotEqual=101 102 | Arrow=102 103 | Dot=103 104 | Ellipsis=104 105 | Identifier=105 106 | Constant=106 107 | DigitSequence=107 108 | StringLiteral=108 109 | ComplexDefine=109 110 | IncludeDirective=110 111 | AsmBlock=111 112 | LineAfterPreprocessing=112 113 | LineDirective=113 114 | PragmaDirective=114 115 | Whitespace=115 116 | Newline=116 117 | BlockComment=117 118 | LineComment=118 119 | '__extension__'=1 120 | '__builtin_va_arg'=2 121 | '__builtin_offsetof'=3 122 | '__m128'=4 123 | '__m128d'=5 124 | '__m128i'=6 125 | '__typeof__'=7 126 | '__inline__'=8 127 | '__stdcall'=9 128 | '__declspec'=10 129 | '__asm'=11 130 | '__attribute__'=12 131 | '__asm__'=13 132 | '__volatile__'=14 133 | 'auto'=15 134 | 'break'=16 135 | 'case'=17 136 | 'char'=18 137 | 'const'=19 138 | 'continue'=20 139 | 'default'=21 140 | 'do'=22 141 | 'double'=23 142 | 'else'=24 143 | 'enum'=25 144 | 'extern'=26 145 | 'float'=27 146 | 'for'=28 147 | 'goto'=29 148 | 'if'=30 149 | 'inline'=31 150 | 'int'=32 151 | 'long'=33 152 | 'register'=34 153 | 'restrict'=35 154 | 'return'=36 155 | 'short'=37 156 | 'signed'=38 157 | 'sizeof'=39 158 | 'static'=40 159 | 'struct'=41 160 | 'switch'=42 161 | 'typedef'=43 162 | 'union'=44 163 | 'unsigned'=45 164 | 'void'=46 165 | 'volatile'=47 166 | 'while'=48 167 | '_Alignas'=49 168 | '_Alignof'=50 169 | '_Atomic'=51 170 | '_Bool'=52 171 | '_Complex'=53 172 | '_Generic'=54 173 | '_Imaginary'=55 174 | '_Noreturn'=56 175 | '_Static_assert'=57 176 | '_Thread_local'=58 177 | '('=59 178 | ')'=60 179 | '['=61 180 | ']'=62 181 | '{'=63 182 | '}'=64 183 | '<'=65 184 | '<='=66 185 | '>'=67 186 | '>='=68 187 | '<<'=69 188 | '>>'=70 189 | '+'=71 190 | '++'=72 191 | '-'=73 192 | '--'=74 193 | '*'=75 194 | '/'=76 195 | '%'=77 196 | '&'=78 197 | '|'=79 198 | '&&'=80 199 | '||'=81 200 | '^'=82 201 | '!'=83 202 | '~'=84 203 | '?'=85 204 | ':'=86 205 | ';'=87 206 | ','=88 207 | '='=89 208 | '*='=90 209 | '/='=91 210 | '%='=92 211 | '+='=93 212 | '-='=94 213 | '<<='=95 214 | '>>='=96 215 | '&='=97 216 | '^='=98 217 | '|='=99 218 | '=='=100 219 | '!='=101 220 | '->'=102 221 | '.'=103 222 | '...'=104 223 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/XMLLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '<' 4 | null 5 | null 6 | null 7 | '>' 8 | '/>' 9 | '=' 10 | null 11 | null 12 | null 13 | null 14 | 15 | token symbolic names: 16 | null 17 | OPEN 18 | COMMENT 19 | EntityRef 20 | TEXT 21 | CLOSE 22 | SLASH_CLOSE 23 | EQUALS 24 | STRING 25 | SlashName 26 | Name 27 | S 28 | 29 | rule names: 30 | OPEN 31 | COMMENT 32 | EntityRef 33 | TEXT 34 | CLOSE 35 | SLASH_CLOSE 36 | EQUALS 37 | STRING 38 | SlashName 39 | Name 40 | S 41 | ALPHA 42 | DIGIT 43 | 44 | channel names: 45 | DEFAULT_TOKEN_CHANNEL 46 | HIDDEN 47 | 48 | mode names: 49 | DEFAULT_MODE 50 | INSIDE 51 | 52 | atn: 53 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 103, 8, 1, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 41, 10, 3, 12, 3, 14, 3, 44, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 6, 4, 54, 10, 4, 13, 4, 14, 4, 55, 3, 4, 3, 4, 3, 5, 6, 5, 61, 10, 5, 13, 5, 14, 5, 62, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 7, 9, 78, 10, 9, 12, 9, 14, 9, 81, 11, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 7, 11, 91, 10, 11, 12, 11, 14, 11, 94, 11, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 4, 42, 79, 2, 15, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18, 10, 20, 11, 22, 12, 24, 13, 26, 2, 28, 2, 4, 2, 3, 7, 3, 2, 99, 124, 4, 2, 40, 40, 62, 62, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 67, 92, 99, 124, 3, 2, 50, 59, 2, 105, 2, 4, 3, 2, 2, 2, 2, 6, 3, 2, 2, 2, 2, 8, 3, 2, 2, 2, 2, 10, 3, 2, 2, 2, 3, 12, 3, 2, 2, 2, 3, 14, 3, 2, 2, 2, 3, 16, 3, 2, 2, 2, 3, 18, 3, 2, 2, 2, 3, 20, 3, 2, 2, 2, 3, 22, 3, 2, 2, 2, 3, 24, 3, 2, 2, 2, 4, 30, 3, 2, 2, 2, 6, 34, 3, 2, 2, 2, 8, 51, 3, 2, 2, 2, 10, 60, 3, 2, 2, 2, 12, 64, 3, 2, 2, 2, 14, 68, 3, 2, 2, 2, 16, 73, 3, 2, 2, 2, 18, 75, 3, 2, 2, 2, 20, 84, 3, 2, 2, 2, 22, 87, 3, 2, 2, 2, 24, 95, 3, 2, 2, 2, 26, 99, 3, 2, 2, 2, 28, 101, 3, 2, 2, 2, 30, 31, 7, 62, 2, 2, 31, 32, 3, 2, 2, 2, 32, 33, 8, 2, 2, 2, 33, 5, 3, 2, 2, 2, 34, 35, 7, 62, 2, 2, 35, 36, 7, 35, 2, 2, 36, 37, 7, 47, 2, 2, 37, 38, 7, 47, 2, 2, 38, 42, 3, 2, 2, 2, 39, 41, 11, 2, 2, 2, 40, 39, 3, 2, 2, 2, 41, 44, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 42, 40, 3, 2, 2, 2, 43, 45, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 45, 46, 7, 47, 2, 2, 46, 47, 7, 47, 2, 2, 47, 48, 7, 64, 2, 2, 48, 49, 3, 2, 2, 2, 49, 50, 8, 3, 3, 2, 50, 7, 3, 2, 2, 2, 51, 53, 7, 40, 2, 2, 52, 54, 9, 2, 2, 2, 53, 52, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 55, 56, 3, 2, 2, 2, 56, 57, 3, 2, 2, 2, 57, 58, 7, 61, 2, 2, 58, 9, 3, 2, 2, 2, 59, 61, 10, 3, 2, 2, 60, 59, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 63, 3, 2, 2, 2, 63, 11, 3, 2, 2, 2, 64, 65, 7, 64, 2, 2, 65, 66, 3, 2, 2, 2, 66, 67, 8, 6, 4, 2, 67, 13, 3, 2, 2, 2, 68, 69, 7, 49, 2, 2, 69, 70, 7, 64, 2, 2, 70, 71, 3, 2, 2, 2, 71, 72, 8, 7, 4, 2, 72, 15, 3, 2, 2, 2, 73, 74, 7, 63, 2, 2, 74, 17, 3, 2, 2, 2, 75, 79, 7, 36, 2, 2, 76, 78, 11, 2, 2, 2, 77, 76, 3, 2, 2, 2, 78, 81, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 80, 82, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 82, 83, 7, 36, 2, 2, 83, 19, 3, 2, 2, 2, 84, 85, 7, 49, 2, 2, 85, 86, 5, 22, 11, 2, 86, 21, 3, 2, 2, 2, 87, 92, 5, 26, 13, 2, 88, 91, 5, 26, 13, 2, 89, 91, 5, 28, 14, 2, 90, 88, 3, 2, 2, 2, 90, 89, 3, 2, 2, 2, 91, 94, 3, 2, 2, 2, 92, 90, 3, 2, 2, 2, 92, 93, 3, 2, 2, 2, 93, 23, 3, 2, 2, 2, 94, 92, 3, 2, 2, 2, 95, 96, 9, 4, 2, 2, 96, 97, 3, 2, 2, 2, 97, 98, 8, 12, 3, 2, 98, 25, 3, 2, 2, 2, 99, 100, 9, 5, 2, 2, 100, 27, 3, 2, 2, 2, 101, 102, 9, 6, 2, 2, 102, 29, 3, 2, 2, 2, 10, 2, 3, 42, 55, 62, 79, 90, 92, 5, 7, 3, 2, 8, 2, 2, 6, 2, 2] -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/HelloLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/Hello.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.Lexer; 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.Token; 5 | import org.antlr.v4.runtime.TokenStream; 6 | import org.antlr.v4.runtime.*; 7 | import org.antlr.v4.runtime.atn.*; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | import org.antlr.v4.runtime.misc.*; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class HelloLexer extends Lexer { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, ID=2, WS=3; 20 | public static String[] channelNames = { 21 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 22 | }; 23 | 24 | public static String[] modeNames = { 25 | "DEFAULT_MODE" 26 | }; 27 | 28 | public static final String[] ruleNames = { 29 | "T__0", "ID", "WS" 30 | }; 31 | 32 | private static final String[] _LITERAL_NAMES = { 33 | null, "'hello'" 34 | }; 35 | private static final String[] _SYMBOLIC_NAMES = { 36 | null, null, "ID", "WS" 37 | }; 38 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 39 | 40 | /** 41 | * @deprecated Use {@link #VOCABULARY} instead. 42 | */ 43 | @Deprecated 44 | public static final String[] tokenNames; 45 | static { 46 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 47 | for (int i = 0; i < tokenNames.length; i++) { 48 | tokenNames[i] = VOCABULARY.getLiteralName(i); 49 | if (tokenNames[i] == null) { 50 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 51 | } 52 | 53 | if (tokenNames[i] == null) { 54 | tokenNames[i] = ""; 55 | } 56 | } 57 | } 58 | 59 | @Override 60 | @Deprecated 61 | public String[] getTokenNames() { 62 | return tokenNames; 63 | } 64 | 65 | @Override 66 | 67 | public Vocabulary getVocabulary() { 68 | return VOCABULARY; 69 | } 70 | 71 | 72 | public HelloLexer(CharStream input) { 73 | super(input); 74 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 75 | } 76 | 77 | @Override 78 | public String getGrammarFileName() { return "Hello.g4"; } 79 | 80 | @Override 81 | public String[] getRuleNames() { return ruleNames; } 82 | 83 | @Override 84 | public String getSerializedATN() { return _serializedATN; } 85 | 86 | @Override 87 | public String[] getChannelNames() { return channelNames; } 88 | 89 | @Override 90 | public String[] getModeNames() { return modeNames; } 91 | 92 | @Override 93 | public ATN getATN() { return _ATN; } 94 | 95 | public static final String _serializedATN = 96 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\5\33\b\1\4\2\t\2"+ 97 | "\4\3\t\3\4\4\t\4\3\2\3\2\3\2\3\2\3\2\3\2\3\3\6\3\21\n\3\r\3\16\3\22\3"+ 98 | "\4\6\4\26\n\4\r\4\16\4\27\3\4\3\4\2\2\5\3\3\5\4\7\5\3\2\4\3\2c|\5\2\13"+ 99 | "\f\17\17\"\"\2\34\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\3\t\3\2\2\2\5\20"+ 100 | "\3\2\2\2\7\25\3\2\2\2\t\n\7j\2\2\n\13\7g\2\2\13\f\7n\2\2\f\r\7n\2\2\r"+ 101 | "\16\7q\2\2\16\4\3\2\2\2\17\21\t\2\2\2\20\17\3\2\2\2\21\22\3\2\2\2\22\20"+ 102 | "\3\2\2\2\22\23\3\2\2\2\23\6\3\2\2\2\24\26\t\3\2\2\25\24\3\2\2\2\26\27"+ 103 | "\3\2\2\2\27\25\3\2\2\2\27\30\3\2\2\2\30\31\3\2\2\2\31\32\b\4\2\2\32\b"+ 104 | "\3\2\2\2\5\2\22\27\3\b\2\2"; 105 | public static final ATN _ATN = 106 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 107 | static { 108 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 109 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 110 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/HelloParser.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/Hello.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.atn.*; 3 | import org.antlr.v4.runtime.dfa.DFA; 4 | import org.antlr.v4.runtime.*; 5 | import org.antlr.v4.runtime.misc.*; 6 | import org.antlr.v4.runtime.tree.*; 7 | import java.util.List; 8 | import java.util.Iterator; 9 | import java.util.ArrayList; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class HelloParser extends Parser { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, ID=2, WS=3; 20 | public static final int 21 | RULE_r = 0; 22 | public static final String[] ruleNames = { 23 | "r" 24 | }; 25 | 26 | private static final String[] _LITERAL_NAMES = { 27 | null, "'hello'" 28 | }; 29 | private static final String[] _SYMBOLIC_NAMES = { 30 | null, null, "ID", "WS" 31 | }; 32 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 33 | 34 | /** 35 | * @deprecated Use {@link #VOCABULARY} instead. 36 | */ 37 | @Deprecated 38 | public static final String[] tokenNames; 39 | static { 40 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 41 | for (int i = 0; i < tokenNames.length; i++) { 42 | tokenNames[i] = VOCABULARY.getLiteralName(i); 43 | if (tokenNames[i] == null) { 44 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 45 | } 46 | 47 | if (tokenNames[i] == null) { 48 | tokenNames[i] = ""; 49 | } 50 | } 51 | } 52 | 53 | @Override 54 | @Deprecated 55 | public String[] getTokenNames() { 56 | return tokenNames; 57 | } 58 | 59 | @Override 60 | 61 | public Vocabulary getVocabulary() { 62 | return VOCABULARY; 63 | } 64 | 65 | @Override 66 | public String getGrammarFileName() { return "Hello.g4"; } 67 | 68 | @Override 69 | public String[] getRuleNames() { return ruleNames; } 70 | 71 | @Override 72 | public String getSerializedATN() { return _serializedATN; } 73 | 74 | @Override 75 | public ATN getATN() { return _ATN; } 76 | 77 | public HelloParser(TokenStream input) { 78 | super(input); 79 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 80 | } 81 | public static class RContext extends ParserRuleContext { 82 | public TerminalNode ID() { return getToken(HelloParser.ID, 0); } 83 | public RContext(ParserRuleContext parent, int invokingState) { 84 | super(parent, invokingState); 85 | } 86 | @Override public int getRuleIndex() { return RULE_r; } 87 | } 88 | 89 | public final RContext r() throws RecognitionException { 90 | RContext _localctx = new RContext(_ctx, getState()); 91 | enterRule(_localctx, 0, RULE_r); 92 | try { 93 | enterOuterAlt(_localctx, 1); 94 | { 95 | setState(2); 96 | match(T__0); 97 | setState(3); 98 | match(ID); 99 | } 100 | } 101 | catch (RecognitionException re) { 102 | _localctx.exception = re; 103 | _errHandler.reportError(this, re); 104 | _errHandler.recover(this, re); 105 | } 106 | finally { 107 | exitRule(); 108 | } 109 | return _localctx; 110 | } 111 | 112 | public static final String _serializedATN = 113 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\5\b\4\2\t\2\3\2\3"+ 114 | "\2\3\2\3\2\2\2\3\2\2\2\2\6\2\4\3\2\2\2\4\5\7\3\2\2\5\6\7\4\2\2\6\3\3\2"+ 115 | "\2\2\2"; 116 | public static final ATN _ATN = 117 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 118 | static { 119 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 120 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 121 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 122 | } 123 | } 124 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInitLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/ArrayInit.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.Lexer; 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.Token; 5 | import org.antlr.v4.runtime.TokenStream; 6 | import org.antlr.v4.runtime.*; 7 | import org.antlr.v4.runtime.atn.*; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | import org.antlr.v4.runtime.misc.*; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class ArrayInitLexer extends Lexer { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, INT=4, WS=5; 20 | public static String[] channelNames = { 21 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 22 | }; 23 | 24 | public static String[] modeNames = { 25 | "DEFAULT_MODE" 26 | }; 27 | 28 | public static final String[] ruleNames = { 29 | "T__0", "T__1", "T__2", "INT", "WS" 30 | }; 31 | 32 | private static final String[] _LITERAL_NAMES = { 33 | null, "'{'", "','", "'}'" 34 | }; 35 | private static final String[] _SYMBOLIC_NAMES = { 36 | null, null, null, null, "INT", "WS" 37 | }; 38 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 39 | 40 | /** 41 | * @deprecated Use {@link #VOCABULARY} instead. 42 | */ 43 | @Deprecated 44 | public static final String[] tokenNames; 45 | static { 46 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 47 | for (int i = 0; i < tokenNames.length; i++) { 48 | tokenNames[i] = VOCABULARY.getLiteralName(i); 49 | if (tokenNames[i] == null) { 50 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 51 | } 52 | 53 | if (tokenNames[i] == null) { 54 | tokenNames[i] = ""; 55 | } 56 | } 57 | } 58 | 59 | @Override 60 | @Deprecated 61 | public String[] getTokenNames() { 62 | return tokenNames; 63 | } 64 | 65 | @Override 66 | 67 | public Vocabulary getVocabulary() { 68 | return VOCABULARY; 69 | } 70 | 71 | 72 | public ArrayInitLexer(CharStream input) { 73 | super(input); 74 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 75 | } 76 | 77 | @Override 78 | public String getGrammarFileName() { return "ArrayInit.g4"; } 79 | 80 | @Override 81 | public String[] getRuleNames() { return ruleNames; } 82 | 83 | @Override 84 | public String getSerializedATN() { return _serializedATN; } 85 | 86 | @Override 87 | public String[] getChannelNames() { return channelNames; } 88 | 89 | @Override 90 | public String[] getModeNames() { return modeNames; } 91 | 92 | @Override 93 | public ATN getATN() { return _ATN; } 94 | 95 | public static final String _serializedATN = 96 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\7\37\b\1\4\2\t\2"+ 97 | "\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\3\3\3\3\3\4\3\4\3\5\6\5\25\n"+ 98 | "\5\r\5\16\5\26\3\6\6\6\32\n\6\r\6\16\6\33\3\6\3\6\2\2\7\3\3\5\4\7\5\t"+ 99 | "\6\13\7\3\2\4\3\2\62;\4\2\13\f\17\17\2 \2\3\3\2\2\2\2\5\3\2\2\2\2\7\3"+ 100 | "\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\3\r\3\2\2\2\5\17\3\2\2\2\7\21\3\2\2\2"+ 101 | "\t\24\3\2\2\2\13\31\3\2\2\2\r\16\7}\2\2\16\4\3\2\2\2\17\20\7.\2\2\20\6"+ 102 | "\3\2\2\2\21\22\7\177\2\2\22\b\3\2\2\2\23\25\t\2\2\2\24\23\3\2\2\2\25\26"+ 103 | "\3\2\2\2\26\24\3\2\2\2\26\27\3\2\2\2\27\n\3\2\2\2\30\32\t\3\2\2\31\30"+ 104 | "\3\2\2\2\32\33\3\2\2\2\33\31\3\2\2\2\33\34\3\2\2\2\34\35\3\2\2\2\35\36"+ 105 | "\b\6\2\2\36\f\3\2\2\2\5\2\26\33\3\b\2\2"; 106 | public static final ATN _ATN = 107 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 108 | static { 109 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 110 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 111 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /src/javacomplier/main/lexer/Lexer.java: -------------------------------------------------------------------------------- 1 | package lexer; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | import symbols.*; 7 | 8 | /** 9 | * Lexer 10 | */ 11 | public class Lexer { 12 | /** 13 | * 14 | */ 15 | public static int line = 1; 16 | 17 | /** 18 | * 19 | */ 20 | char peek = ' '; 21 | 22 | /** 23 | * 符号表 24 | */ 25 | Hashtable words = new Hashtable<>(); 26 | 27 | /** 28 | * 29 | * @param w 30 | */ 31 | void reserse(Word w) { 32 | words.put(w.lexname, w); 33 | } 34 | 35 | /** 36 | * 37 | */ 38 | public Lexer() { 39 | reserse(new Word("if", Tag.IF)); 40 | reserse(new Word("else", Tag.ELSE)); 41 | reserse(new Word("while", Tag.WHILE)); 42 | reserse(new Word("do", Tag.DO)); 43 | reserse(new Word("break", Tag.BREAK)); 44 | reserse(Word.True); 45 | reserse(Word.Flase); 46 | reserse(Type.Int); 47 | reserse(Type.Char); 48 | reserse(Type.Bool); 49 | reserse(Type.Float); 50 | } 51 | 52 | /** 53 | * 54 | * @throws IOException 55 | */ 56 | void readch() throws IOException { 57 | peek = (char)System.in.read(); 58 | } 59 | 60 | /** 61 | * 62 | * @param c 63 | * @return 64 | * @throws IOException 65 | */ 66 | boolean readch(char c) throws IOException { 67 | readch(); 68 | if (peek != c) 69 | return false; 70 | peek = ' '; 71 | return true; 72 | } 73 | 74 | /** 75 | * 76 | * @return 77 | * @throws IOException 78 | */ 79 | public Token scan() throws IOException { 80 | for (;;readch()) { 81 | if (peek == ' ' || peek == '\t') 82 | continue; 83 | else if (peek == '\n') 84 | line = line + 1; 85 | else 86 | break; 87 | } 88 | switch (peek) { 89 | case '&': 90 | if (readch('&')) 91 | return Word.and; 92 | else 93 | return new Token('&'); 94 | case '|': 95 | if (readch('|')) 96 | return Word.or; 97 | else 98 | return new Token('|'); 99 | case '=': 100 | if (readch('=')) 101 | return Word.eq; 102 | else 103 | return new Token('='); 104 | case '!': 105 | if (readch('=')) 106 | return Word.ne; 107 | else 108 | return new Token('!'); 109 | case '<': 110 | if (readch('=')) 111 | return Word.le; 112 | else 113 | return new Token('<'); 114 | case '>': 115 | if (readch('=')) 116 | return Word.ge; 117 | else 118 | return new Token('>'); 119 | } 120 | if (Character.isDigit(peek)) { 121 | int v = 0; 122 | do { 123 | v = 10 * v + Character.digit(peek, 10); 124 | readch(); 125 | } while (Character.isDigit(peek)); 126 | if (peek != '.') 127 | return new Num(v); 128 | float x = v; 129 | float d = 10; 130 | for(;;) { 131 | readch(); 132 | if (Character.isDigit(peek) == false) 133 | break; 134 | x = x + Character.digit(peek, 10) / d; 135 | d = d * 10; 136 | } 137 | return new Real(x); 138 | } 139 | if (Character.isLetter(peek)) { 140 | StringBuffer b = new StringBuffer(); 141 | do { 142 | b.append(peek); 143 | readch(); 144 | } while ( Character.isLetterOrDigit(peek) ); 145 | String s = b.toString(); 146 | Word w = words.get(s); 147 | if (w != null) 148 | return w; 149 | w = new Word(s, Tag.ID); 150 | words.put(s, w); 151 | return w; 152 | } 153 | Token tok = new Token(peek); 154 | peek = ' '; 155 | return tok; 156 | } 157 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExprLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/LabeledExpr.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.Lexer; 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.Token; 5 | import org.antlr.v4.runtime.TokenStream; 6 | import org.antlr.v4.runtime.*; 7 | import org.antlr.v4.runtime.atn.*; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | import org.antlr.v4.runtime.misc.*; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class LabeledExprLexer extends Lexer { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, ID=4, INT=5, NEWLINE=6, WS=7, MUL=8, DIV=9, ADD=10, 20 | SUB=11; 21 | public static String[] channelNames = { 22 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 23 | }; 24 | 25 | public static String[] modeNames = { 26 | "DEFAULT_MODE" 27 | }; 28 | 29 | public static final String[] ruleNames = { 30 | "T__0", "T__1", "T__2", "ID", "INT", "NEWLINE", "WS", "MUL", "DIV", "ADD", 31 | "SUB" 32 | }; 33 | 34 | private static final String[] _LITERAL_NAMES = { 35 | null, "'='", "'('", "')'", null, null, null, null, "'*'", "'/'", "'+'", 36 | "'-'" 37 | }; 38 | private static final String[] _SYMBOLIC_NAMES = { 39 | null, null, null, null, "ID", "INT", "NEWLINE", "WS", "MUL", "DIV", "ADD", 40 | "SUB" 41 | }; 42 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 43 | 44 | /** 45 | * @deprecated Use {@link #VOCABULARY} instead. 46 | */ 47 | @Deprecated 48 | public static final String[] tokenNames; 49 | static { 50 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 51 | for (int i = 0; i < tokenNames.length; i++) { 52 | tokenNames[i] = VOCABULARY.getLiteralName(i); 53 | if (tokenNames[i] == null) { 54 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 55 | } 56 | 57 | if (tokenNames[i] == null) { 58 | tokenNames[i] = ""; 59 | } 60 | } 61 | } 62 | 63 | @Override 64 | @Deprecated 65 | public String[] getTokenNames() { 66 | return tokenNames; 67 | } 68 | 69 | @Override 70 | 71 | public Vocabulary getVocabulary() { 72 | return VOCABULARY; 73 | } 74 | 75 | 76 | public LabeledExprLexer(CharStream input) { 77 | super(input); 78 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 79 | } 80 | 81 | @Override 82 | public String getGrammarFileName() { return "LabeledExpr.g4"; } 83 | 84 | @Override 85 | public String[] getRuleNames() { return ruleNames; } 86 | 87 | @Override 88 | public String getSerializedATN() { return _serializedATN; } 89 | 90 | @Override 91 | public String[] getChannelNames() { return channelNames; } 92 | 93 | @Override 94 | public String[] getModeNames() { return modeNames; } 95 | 96 | @Override 97 | public ATN getATN() { return _ATN; } 98 | 99 | public static final String _serializedATN = 100 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\r=\b\1\4\2\t\2\4"+ 101 | "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ 102 | "\13\4\f\t\f\3\2\3\2\3\3\3\3\3\4\3\4\3\5\6\5!\n\5\r\5\16\5\"\3\6\6\6&\n"+ 103 | "\6\r\6\16\6\'\3\7\5\7+\n\7\3\7\3\7\3\b\6\b\60\n\b\r\b\16\b\61\3\b\3\b"+ 104 | "\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\2\2\r\3\3\5\4\7\5\t\6\13\7\r\b\17\t"+ 105 | "\21\n\23\13\25\f\27\r\3\2\5\4\2C\\c|\3\2\62;\3\2\13\13\2@\2\3\3\2\2\2"+ 106 | "\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2"+ 107 | "\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\3\31\3\2\2\2"+ 108 | "\5\33\3\2\2\2\7\35\3\2\2\2\t \3\2\2\2\13%\3\2\2\2\r*\3\2\2\2\17/\3\2\2"+ 109 | "\2\21\65\3\2\2\2\23\67\3\2\2\2\259\3\2\2\2\27;\3\2\2\2\31\32\7?\2\2\32"+ 110 | "\4\3\2\2\2\33\34\7*\2\2\34\6\3\2\2\2\35\36\7+\2\2\36\b\3\2\2\2\37!\t\2"+ 111 | "\2\2 \37\3\2\2\2!\"\3\2\2\2\" \3\2\2\2\"#\3\2\2\2#\n\3\2\2\2$&\t\3\2\2"+ 112 | "%$\3\2\2\2&\'\3\2\2\2\'%\3\2\2\2\'(\3\2\2\2(\f\3\2\2\2)+\7t\2\2*)\3\2"+ 113 | "\2\2*+\3\2\2\2+,\3\2\2\2,-\7\f\2\2-\16\3\2\2\2.\60\t\4\2\2/.\3\2\2\2\60"+ 114 | "\61\3\2\2\2\61/\3\2\2\2\61\62\3\2\2\2\62\63\3\2\2\2\63\64\b\b\2\2\64\20"+ 115 | "\3\2\2\2\65\66\7,\2\2\66\22\3\2\2\2\678\7\61\2\28\24\3\2\2\29:\7-\2\2"+ 116 | ":\26\3\2\2\2;<\7/\2\2<\30\3\2\2\2\7\2\"\'*\61\3\b\2\2"; 117 | public static final ATN _ATN = 118 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 119 | static { 120 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 121 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 122 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ELexer.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/E.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.Lexer; 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.Token; 5 | import org.antlr.v4.runtime.TokenStream; 6 | import org.antlr.v4.runtime.*; 7 | import org.antlr.v4.runtime.atn.*; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | import org.antlr.v4.runtime.misc.*; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class ELexer extends Lexer { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, VAR=8, INT=9, 20 | STRING=10, WS=11; 21 | public static String[] channelNames = { 22 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 23 | }; 24 | 25 | public static String[] modeNames = { 26 | "DEFAULT_MODE" 27 | }; 28 | 29 | public static final String[] ruleNames = { 30 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "VAR", "INT", 31 | "STRING", "WS" 32 | }; 33 | 34 | private static final String[] _LITERAL_NAMES = { 35 | null, "'='", "';'", "'+'", "'-'", "'*'", "'('", "')'" 36 | }; 37 | private static final String[] _SYMBOLIC_NAMES = { 38 | null, null, null, null, null, null, null, null, "VAR", "INT", "STRING", 39 | "WS" 40 | }; 41 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 42 | 43 | /** 44 | * @deprecated Use {@link #VOCABULARY} instead. 45 | */ 46 | @Deprecated 47 | public static final String[] tokenNames; 48 | static { 49 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 50 | for (int i = 0; i < tokenNames.length; i++) { 51 | tokenNames[i] = VOCABULARY.getLiteralName(i); 52 | if (tokenNames[i] == null) { 53 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 54 | } 55 | 56 | if (tokenNames[i] == null) { 57 | tokenNames[i] = ""; 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | @Deprecated 64 | public String[] getTokenNames() { 65 | return tokenNames; 66 | } 67 | 68 | @Override 69 | 70 | public Vocabulary getVocabulary() { 71 | return VOCABULARY; 72 | } 73 | 74 | 75 | public ELexer(CharStream input) { 76 | super(input); 77 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 78 | } 79 | 80 | @Override 81 | public String getGrammarFileName() { return "E.g4"; } 82 | 83 | @Override 84 | public String[] getRuleNames() { return ruleNames; } 85 | 86 | @Override 87 | public String getSerializedATN() { return _serializedATN; } 88 | 89 | @Override 90 | public String[] getChannelNames() { return channelNames; } 91 | 92 | @Override 93 | public String[] getModeNames() { return modeNames; } 94 | 95 | @Override 96 | public ATN getATN() { return _ATN; } 97 | 98 | @Override 99 | public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { 100 | switch (ruleIndex) { 101 | case 10: 102 | WS_action((RuleContext)_localctx, actionIndex); 103 | break; 104 | } 105 | } 106 | private void WS_action(RuleContext _localctx, int actionIndex) { 107 | switch (actionIndex) { 108 | case 0: 109 | skip(); 110 | break; 111 | } 112 | } 113 | 114 | public static final String _serializedATN = 115 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\r@\b\1\4\2\t\2\4"+ 116 | "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ 117 | "\13\4\f\t\f\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3"+ 118 | "\t\6\t)\n\t\r\t\16\t*\3\n\6\n.\n\n\r\n\16\n/\3\13\3\13\6\13\64\n\13\r"+ 119 | "\13\16\13\65\3\13\3\13\3\f\6\f;\n\f\r\f\16\f<\3\f\3\f\2\2\r\3\3\5\4\7"+ 120 | "\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\3\2\5\4\2C\\c|\5\2\"\"C\\c|"+ 121 | "\5\2\13\f\17\17\"\"\2C\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2"+ 122 | "\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25"+ 123 | "\3\2\2\2\2\27\3\2\2\2\3\31\3\2\2\2\5\33\3\2\2\2\7\35\3\2\2\2\t\37\3\2"+ 124 | "\2\2\13!\3\2\2\2\r#\3\2\2\2\17%\3\2\2\2\21(\3\2\2\2\23-\3\2\2\2\25\61"+ 125 | "\3\2\2\2\27:\3\2\2\2\31\32\7?\2\2\32\4\3\2\2\2\33\34\7=\2\2\34\6\3\2\2"+ 126 | "\2\35\36\7-\2\2\36\b\3\2\2\2\37 \7/\2\2 \n\3\2\2\2!\"\7,\2\2\"\f\3\2\2"+ 127 | "\2#$\7*\2\2$\16\3\2\2\2%&\7+\2\2&\20\3\2\2\2\')\t\2\2\2(\'\3\2\2\2)*\3"+ 128 | "\2\2\2*(\3\2\2\2*+\3\2\2\2+\22\3\2\2\2,.\4\62;\2-,\3\2\2\2./\3\2\2\2/"+ 129 | "-\3\2\2\2/\60\3\2\2\2\60\24\3\2\2\2\61\63\7$\2\2\62\64\t\3\2\2\63\62\3"+ 130 | "\2\2\2\64\65\3\2\2\2\65\63\3\2\2\2\65\66\3\2\2\2\66\67\3\2\2\2\678\7$"+ 131 | "\2\28\26\3\2\2\29;\t\4\2\2:9\3\2\2\2;<\3\2\2\2<:\3\2\2\2<=\3\2\2\2=>\3"+ 132 | "\2\2\2>?\b\f\2\2?\30\3\2\2\2\7\2*/\65<\3\3\f\2"; 133 | public static final ATN _ATN = 134 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 135 | static { 136 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 137 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 138 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/XMLLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/XMLLexer.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.Lexer; 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.Token; 5 | import org.antlr.v4.runtime.TokenStream; 6 | import org.antlr.v4.runtime.*; 7 | import org.antlr.v4.runtime.atn.*; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | import org.antlr.v4.runtime.misc.*; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class XMLLexer extends Lexer { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | OPEN=1, COMMENT=2, EntityRef=3, TEXT=4, CLOSE=5, SLASH_CLOSE=6, EQUALS=7, 20 | STRING=8, SlashName=9, Name=10, S=11; 21 | public static final int 22 | INSIDE=1; 23 | public static String[] channelNames = { 24 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 25 | }; 26 | 27 | public static String[] modeNames = { 28 | "DEFAULT_MODE", "INSIDE" 29 | }; 30 | 31 | public static final String[] ruleNames = { 32 | "OPEN", "COMMENT", "EntityRef", "TEXT", "CLOSE", "SLASH_CLOSE", "EQUALS", 33 | "STRING", "SlashName", "Name", "S", "ALPHA", "DIGIT" 34 | }; 35 | 36 | private static final String[] _LITERAL_NAMES = { 37 | null, "'<'", null, null, null, "'>'", "'/>'", "'='" 38 | }; 39 | private static final String[] _SYMBOLIC_NAMES = { 40 | null, "OPEN", "COMMENT", "EntityRef", "TEXT", "CLOSE", "SLASH_CLOSE", 41 | "EQUALS", "STRING", "SlashName", "Name", "S" 42 | }; 43 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 44 | 45 | /** 46 | * @deprecated Use {@link #VOCABULARY} instead. 47 | */ 48 | @Deprecated 49 | public static final String[] tokenNames; 50 | static { 51 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 52 | for (int i = 0; i < tokenNames.length; i++) { 53 | tokenNames[i] = VOCABULARY.getLiteralName(i); 54 | if (tokenNames[i] == null) { 55 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 56 | } 57 | 58 | if (tokenNames[i] == null) { 59 | tokenNames[i] = ""; 60 | } 61 | } 62 | } 63 | 64 | @Override 65 | @Deprecated 66 | public String[] getTokenNames() { 67 | return tokenNames; 68 | } 69 | 70 | @Override 71 | 72 | public Vocabulary getVocabulary() { 73 | return VOCABULARY; 74 | } 75 | 76 | 77 | public XMLLexer(CharStream input) { 78 | super(input); 79 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 80 | } 81 | 82 | @Override 83 | public String getGrammarFileName() { return "XMLLexer.g4"; } 84 | 85 | @Override 86 | public String[] getRuleNames() { return ruleNames; } 87 | 88 | @Override 89 | public String getSerializedATN() { return _serializedATN; } 90 | 91 | @Override 92 | public String[] getChannelNames() { return channelNames; } 93 | 94 | @Override 95 | public String[] getModeNames() { return modeNames; } 96 | 97 | @Override 98 | public ATN getATN() { return _ATN; } 99 | 100 | public static final String _serializedATN = 101 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\rg\b\1\b\1\4\2\t"+ 102 | "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ 103 | "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3"+ 104 | "\3\7\3)\n\3\f\3\16\3,\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\6\4\66\n\4"+ 105 | "\r\4\16\4\67\3\4\3\4\3\5\6\5=\n\5\r\5\16\5>\3\6\3\6\3\6\3\6\3\7\3\7\3"+ 106 | "\7\3\7\3\7\3\b\3\b\3\t\3\t\7\tN\n\t\f\t\16\tQ\13\t\3\t\3\t\3\n\3\n\3\n"+ 107 | "\3\13\3\13\3\13\7\13[\n\13\f\13\16\13^\13\13\3\f\3\f\3\f\3\f\3\r\3\r\3"+ 108 | "\16\3\16\4*O\2\17\4\3\6\4\b\5\n\6\f\7\16\b\20\t\22\n\24\13\26\f\30\r\32"+ 109 | "\2\34\2\4\2\3\7\3\2c|\4\2((>>\5\2\13\f\17\17\"\"\4\2C\\c|\3\2\62;\2i\2"+ 110 | "\4\3\2\2\2\2\6\3\2\2\2\2\b\3\2\2\2\2\n\3\2\2\2\3\f\3\2\2\2\3\16\3\2\2"+ 111 | "\2\3\20\3\2\2\2\3\22\3\2\2\2\3\24\3\2\2\2\3\26\3\2\2\2\3\30\3\2\2\2\4"+ 112 | "\36\3\2\2\2\6\"\3\2\2\2\b\63\3\2\2\2\n<\3\2\2\2\f@\3\2\2\2\16D\3\2\2\2"+ 113 | "\20I\3\2\2\2\22K\3\2\2\2\24T\3\2\2\2\26W\3\2\2\2\30_\3\2\2\2\32c\3\2\2"+ 114 | "\2\34e\3\2\2\2\36\37\7>\2\2\37 \3\2\2\2 !\b\2\2\2!\5\3\2\2\2\"#\7>\2\2"+ 115 | "#$\7#\2\2$%\7/\2\2%&\7/\2\2&*\3\2\2\2\')\13\2\2\2(\'\3\2\2\2),\3\2\2\2"+ 116 | "*+\3\2\2\2*(\3\2\2\2+-\3\2\2\2,*\3\2\2\2-.\7/\2\2./\7/\2\2/\60\7@\2\2"+ 117 | "\60\61\3\2\2\2\61\62\b\3\3\2\62\7\3\2\2\2\63\65\7(\2\2\64\66\t\2\2\2\65"+ 118 | "\64\3\2\2\2\66\67\3\2\2\2\67\65\3\2\2\2\678\3\2\2\289\3\2\2\29:\7=\2\2"+ 119 | ":\t\3\2\2\2;=\n\3\2\2<;\3\2\2\2=>\3\2\2\2><\3\2\2\2>?\3\2\2\2?\13\3\2"+ 120 | "\2\2@A\7@\2\2AB\3\2\2\2BC\b\6\4\2C\r\3\2\2\2DE\7\61\2\2EF\7@\2\2FG\3\2"+ 121 | "\2\2GH\b\7\4\2H\17\3\2\2\2IJ\7?\2\2J\21\3\2\2\2KO\7$\2\2LN\13\2\2\2ML"+ 122 | "\3\2\2\2NQ\3\2\2\2OP\3\2\2\2OM\3\2\2\2PR\3\2\2\2QO\3\2\2\2RS\7$\2\2S\23"+ 123 | "\3\2\2\2TU\7\61\2\2UV\5\26\13\2V\25\3\2\2\2W\\\5\32\r\2X[\5\32\r\2Y[\5"+ 124 | "\34\16\2ZX\3\2\2\2ZY\3\2\2\2[^\3\2\2\2\\Z\3\2\2\2\\]\3\2\2\2]\27\3\2\2"+ 125 | "\2^\\\3\2\2\2_`\t\4\2\2`a\3\2\2\2ab\b\f\3\2b\31\3\2\2\2cd\t\5\2\2d\33"+ 126 | "\3\2\2\2ef\t\6\2\2f\35\3\2\2\2\n\2\3*\67>OZ\\\5\7\3\2\b\2\2\6\2\2"; 127 | public static final ATN _ATN = 128 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 129 | static { 130 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 131 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 132 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /src/ANTLR4/Lua.g4: -------------------------------------------------------------------------------- 1 | grammar Lua; 2 | 3 | chunk 4 | : block EOF 5 | ; 6 | 7 | block 8 | : stat* retstat? 9 | ; 10 | 11 | stat 12 | : ';' 13 | | varlist '=' explist 14 | | functioncall 15 | | label 16 | | 'break' 17 | | 'goto' NAME 18 | | 'do' block 'end' 19 | | 'while' exp 'do' block 'end' 20 | | 'repeat' block 'until' exp 21 | | 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end' 22 | | 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' 23 | | 'for' namelist 'in' explist 'do' block 'end' 24 | | 'function' funcname funcbody 25 | | 'local' 'function' NAME funcbody 26 | | 'local' namelist ('=' explist)? 27 | ; 28 | 29 | retstat 30 | : 'return' explist? ';'? 31 | ; 32 | 33 | label 34 | : '::' NAME '::' 35 | ; 36 | 37 | funcname 38 | : NAME ('.' NAME)* (':' NAME)? 39 | ; 40 | 41 | varlist 42 | : var (',' var)* 43 | ; 44 | 45 | namelist 46 | : NAME (',' NAME)* 47 | ; 48 | 49 | explist 50 | : exp (',' exp)* 51 | ; 52 | 53 | exp 54 | : 'nil' | 'false' | 'true' 55 | | number 56 | | string 57 | | '...' 58 | | functiondef 59 | | prefixexp 60 | | tableconstructor 61 | | exp operatorPower exp 62 | | operatorUnary exp 63 | | exp operatorMulDivMod exp 64 | | exp operatorAddSub exp 65 | | exp operatorStrcat exp 66 | | exp operatorComparison exp 67 | | exp operatorAnd exp 68 | | exp operatorOr exp 69 | | exp operatorBitwise exp 70 | ; 71 | 72 | prefixexp 73 | : varOrExp nameAndArgs* 74 | ; 75 | 76 | functioncall 77 | : varOrExp nameAndArgs+ 78 | ; 79 | 80 | varOrExp 81 | : var | '(' exp ')' 82 | ; 83 | 84 | var 85 | : (NAME | '(' exp ')' varSuffix) varSuffix* 86 | ; 87 | 88 | varSuffix 89 | : nameAndArgs* ('[' exp ']' | '.' NAME) 90 | ; 91 | 92 | nameAndArgs 93 | : (':' NAME)? args 94 | ; 95 | 96 | /* 97 | var 98 | : NAME | prefixexp '[' exp ']' | prefixexp '.' NAME 99 | ; 100 | 101 | prefixexp 102 | : var | functioncall | '(' exp ')' 103 | ; 104 | 105 | functioncall 106 | : prefixexp args | prefixexp ':' NAME args 107 | ; 108 | */ 109 | 110 | args 111 | : '(' explist? ')' | tableconstructor | string 112 | ; 113 | 114 | functiondef 115 | : 'function' funcbody 116 | ; 117 | 118 | funcbody 119 | : '(' parlist? ')' block 'end' 120 | ; 121 | 122 | parlist 123 | : namelist (',' '...')? | '...' 124 | ; 125 | 126 | tableconstructor 127 | : '{' fieldlist? '}' 128 | ; 129 | 130 | fieldlist 131 | : field (fieldsep field)* fieldsep? 132 | ; 133 | 134 | field 135 | : '[' exp ']' '=' exp | NAME '=' exp | exp 136 | ; 137 | 138 | fieldsep 139 | : ',' | ';' 140 | ; 141 | 142 | operatorOr 143 | : 'or'; 144 | 145 | operatorAnd 146 | : 'and'; 147 | 148 | operatorComparison 149 | : '<' | '>' | '<=' | '>=' | '~=' | '=='; 150 | 151 | operatorStrcat 152 | : '..'; 153 | 154 | operatorAddSub 155 | : '+' | '-'; 156 | 157 | operatorMulDivMod 158 | : '*' | '/' | '%' | '//'; 159 | 160 | operatorBitwise 161 | : '&' | '|' | '~' | '<<' | '>>'; 162 | 163 | operatorUnary 164 | : 'not' | '#' | '-' | '~'; 165 | 166 | operatorPower 167 | : '^'; 168 | 169 | number 170 | : INT | HEX | FLOAT | HEX_FLOAT 171 | ; 172 | 173 | string 174 | : NORMALSTRING | CHARSTRING | LONGSTRING 175 | ; 176 | 177 | // LEXER 178 | 179 | NAME 180 | : [a-zA-Z_][a-zA-Z_0-9]* 181 | ; 182 | 183 | NORMALSTRING 184 | : '"' ( EscapeSequence | ~('\\'|'"') )* '"' 185 | ; 186 | 187 | CHARSTRING 188 | : '\'' ( EscapeSequence | ~('\''|'\\') )* '\'' 189 | ; 190 | 191 | LONGSTRING 192 | : '[' NESTED_STR ']' 193 | ; 194 | 195 | fragment 196 | NESTED_STR 197 | : '=' NESTED_STR '=' 198 | | '[' .*? ']' 199 | ; 200 | 201 | INT 202 | : Digit+ 203 | ; 204 | 205 | HEX 206 | : '0' [xX] HexDigit+ 207 | ; 208 | 209 | FLOAT 210 | : Digit+ '.' Digit* ExponentPart? 211 | | '.' Digit+ ExponentPart? 212 | | Digit+ ExponentPart 213 | ; 214 | 215 | HEX_FLOAT 216 | : '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart? 217 | | '0' [xX] '.' HexDigit+ HexExponentPart? 218 | | '0' [xX] HexDigit+ HexExponentPart 219 | ; 220 | 221 | fragment 222 | ExponentPart 223 | : [eE] [+-]? Digit+ 224 | ; 225 | 226 | fragment 227 | HexExponentPart 228 | : [pP] [+-]? Digit+ 229 | ; 230 | 231 | fragment 232 | EscapeSequence 233 | : '\\' [abfnrtvz"'\\] 234 | | '\\' '\r'? '\n' 235 | | DecimalEscape 236 | | HexEscape 237 | | UtfEscape 238 | ; 239 | 240 | fragment 241 | DecimalEscape 242 | : '\\' Digit 243 | | '\\' Digit Digit 244 | | '\\' [0-2] Digit Digit 245 | ; 246 | 247 | fragment 248 | HexEscape 249 | : '\\' 'x' HexDigit HexDigit 250 | ; 251 | 252 | fragment 253 | UtfEscape 254 | : '\\' 'u{' HexDigit+ '}' 255 | ; 256 | 257 | fragment 258 | Digit 259 | : [0-9] 260 | ; 261 | 262 | fragment 263 | HexDigit 264 | : [0-9a-fA-F] 265 | ; 266 | 267 | COMMENT 268 | : '--[' NESTED_STR ']' -> channel(HIDDEN) 269 | ; 270 | 271 | LINE_COMMENT 272 | : '--' 273 | ( // -- 274 | | '[' '='* // --[== 275 | | '[' '='* ~('='|'['|'\r'|'\n') ~('\r'|'\n')* // --[==AA 276 | | ~('['|'\r'|'\n') ~('\r'|'\n')* // --AAA 277 | ) ('\r\n'|'\r'|'\n'|EOF) 278 | -> channel(HIDDEN) 279 | ; 280 | 281 | WS 282 | : [ \t\u000C\r\n]+ -> skip 283 | ; 284 | 285 | SHEBANG 286 | : '#' '!' ~('\n'|'\r')* -> channel(HIDDEN) 287 | ; 288 | -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/ArrayInitParser.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/ArrayInit.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.atn.*; 3 | import org.antlr.v4.runtime.dfa.DFA; 4 | import org.antlr.v4.runtime.*; 5 | import org.antlr.v4.runtime.misc.*; 6 | import org.antlr.v4.runtime.tree.*; 7 | import java.util.List; 8 | import java.util.Iterator; 9 | import java.util.ArrayList; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class ArrayInitParser extends Parser { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, INT=4, WS=5; 20 | public static final int 21 | RULE_init = 0, RULE_value = 1; 22 | public static final String[] ruleNames = { 23 | "init", "value" 24 | }; 25 | 26 | private static final String[] _LITERAL_NAMES = { 27 | null, "'{'", "','", "'}'" 28 | }; 29 | private static final String[] _SYMBOLIC_NAMES = { 30 | null, null, null, null, "INT", "WS" 31 | }; 32 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 33 | 34 | /** 35 | * @deprecated Use {@link #VOCABULARY} instead. 36 | */ 37 | @Deprecated 38 | public static final String[] tokenNames; 39 | static { 40 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 41 | for (int i = 0; i < tokenNames.length; i++) { 42 | tokenNames[i] = VOCABULARY.getLiteralName(i); 43 | if (tokenNames[i] == null) { 44 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 45 | } 46 | 47 | if (tokenNames[i] == null) { 48 | tokenNames[i] = ""; 49 | } 50 | } 51 | } 52 | 53 | @Override 54 | @Deprecated 55 | public String[] getTokenNames() { 56 | return tokenNames; 57 | } 58 | 59 | @Override 60 | 61 | public Vocabulary getVocabulary() { 62 | return VOCABULARY; 63 | } 64 | 65 | @Override 66 | public String getGrammarFileName() { return "ArrayInit.g4"; } 67 | 68 | @Override 69 | public String[] getRuleNames() { return ruleNames; } 70 | 71 | @Override 72 | public String getSerializedATN() { return _serializedATN; } 73 | 74 | @Override 75 | public ATN getATN() { return _ATN; } 76 | 77 | public ArrayInitParser(TokenStream input) { 78 | super(input); 79 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 80 | } 81 | public static class InitContext extends ParserRuleContext { 82 | public List value() { 83 | return getRuleContexts(ValueContext.class); 84 | } 85 | public ValueContext value(int i) { 86 | return getRuleContext(ValueContext.class,i); 87 | } 88 | public InitContext(ParserRuleContext parent, int invokingState) { 89 | super(parent, invokingState); 90 | } 91 | @Override public int getRuleIndex() { return RULE_init; } 92 | } 93 | 94 | public final InitContext init() throws RecognitionException { 95 | InitContext _localctx = new InitContext(_ctx, getState()); 96 | enterRule(_localctx, 0, RULE_init); 97 | int _la; 98 | try { 99 | enterOuterAlt(_localctx, 1); 100 | { 101 | setState(4); 102 | match(T__0); 103 | setState(5); 104 | value(); 105 | setState(10); 106 | _errHandler.sync(this); 107 | _la = _input.LA(1); 108 | while (_la==T__1) { 109 | { 110 | { 111 | setState(6); 112 | match(T__1); 113 | setState(7); 114 | value(); 115 | } 116 | } 117 | setState(12); 118 | _errHandler.sync(this); 119 | _la = _input.LA(1); 120 | } 121 | setState(13); 122 | match(T__2); 123 | } 124 | } 125 | catch (RecognitionException re) { 126 | _localctx.exception = re; 127 | _errHandler.reportError(this, re); 128 | _errHandler.recover(this, re); 129 | } 130 | finally { 131 | exitRule(); 132 | } 133 | return _localctx; 134 | } 135 | 136 | public static class ValueContext extends ParserRuleContext { 137 | public InitContext init() { 138 | return getRuleContext(InitContext.class,0); 139 | } 140 | public TerminalNode INT() { return getToken(ArrayInitParser.INT, 0); } 141 | public ValueContext(ParserRuleContext parent, int invokingState) { 142 | super(parent, invokingState); 143 | } 144 | @Override public int getRuleIndex() { return RULE_value; } 145 | } 146 | 147 | public final ValueContext value() throws RecognitionException { 148 | ValueContext _localctx = new ValueContext(_ctx, getState()); 149 | enterRule(_localctx, 2, RULE_value); 150 | try { 151 | setState(17); 152 | _errHandler.sync(this); 153 | switch (_input.LA(1)) { 154 | case T__0: 155 | enterOuterAlt(_localctx, 1); 156 | { 157 | setState(15); 158 | init(); 159 | } 160 | break; 161 | case INT: 162 | enterOuterAlt(_localctx, 2); 163 | { 164 | setState(16); 165 | match(INT); 166 | } 167 | break; 168 | default: 169 | throw new NoViableAltException(this); 170 | } 171 | } 172 | catch (RecognitionException re) { 173 | _localctx.exception = re; 174 | _errHandler.reportError(this, re); 175 | _errHandler.recover(this, re); 176 | } 177 | finally { 178 | exitRule(); 179 | } 180 | return _localctx; 181 | } 182 | 183 | public static final String _serializedATN = 184 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\7\26\4\2\t\2\4\3"+ 185 | "\t\3\3\2\3\2\3\2\3\2\7\2\13\n\2\f\2\16\2\16\13\2\3\2\3\2\3\3\3\3\5\3\24"+ 186 | "\n\3\3\3\2\2\4\2\4\2\2\2\25\2\6\3\2\2\2\4\23\3\2\2\2\6\7\7\3\2\2\7\f\5"+ 187 | "\4\3\2\b\t\7\4\2\2\t\13\5\4\3\2\n\b\3\2\2\2\13\16\3\2\2\2\f\n\3\2\2\2"+ 188 | "\f\r\3\2\2\2\r\17\3\2\2\2\16\f\3\2\2\2\17\20\7\5\2\2\20\3\3\2\2\2\21\24"+ 189 | "\5\2\2\2\22\24\7\6\2\2\23\21\3\2\2\2\23\22\3\2\2\2\24\5\3\2\2\2\4\f\23"; 190 | public static final ATN _ATN = 191 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 192 | static { 193 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 194 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 195 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 196 | } 197 | } 198 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | ## Ignore Visual Studio temporary files, build results, and 35 | ## files generated by popular Visual Studio add-ons. 36 | ## 37 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 38 | 39 | # User-specific files 40 | *.rsuser 41 | *.suo 42 | *.user 43 | *.userosscache 44 | *.sln.docstates 45 | 46 | # User-specific files (MonoDevelop/Xamarin Studio) 47 | *.userprefs 48 | 49 | # Mono auto generated files 50 | mono_crash.* 51 | 52 | # Build results 53 | [Dd]ebug/ 54 | [Dd]ebugPublic/ 55 | [Rr]elease/ 56 | [Rr]eleases/ 57 | x64/ 58 | x86/ 59 | [Aa][Rr][Mm]/ 60 | [Aa][Rr][Mm]64/ 61 | bld/ 62 | [Bb]in/ 63 | [Oo]bj/ 64 | [Ll]og/ 65 | 66 | # Visual Studio 2015/2017 cache/options directory 67 | .vs/ 68 | # Uncomment if you have tasks that create the project's static files in wwwroot 69 | #wwwroot/ 70 | 71 | # Visual Studio 2017 auto generated files 72 | Generated\ Files/ 73 | 74 | # MSTest test Results 75 | [Tt]est[Rr]esult*/ 76 | [Bb]uild[Ll]og.* 77 | 78 | # NUnit 79 | *.VisualState.xml 80 | TestResult.xml 81 | nunit-*.xml 82 | 83 | # Build Results of an ATL Project 84 | [Dd]ebugPS/ 85 | [Rr]eleasePS/ 86 | dlldata.c 87 | 88 | # Benchmark Results 89 | BenchmarkDotNet.Artifacts/ 90 | 91 | # .NET Core 92 | project.lock.json 93 | project.fragment.lock.json 94 | artifacts/ 95 | 96 | # StyleCop 97 | StyleCopReport.xml 98 | 99 | # Files built by Visual Studio 100 | *_i.c 101 | *_p.c 102 | *_h.h 103 | *.ilk 104 | *.meta 105 | *.obj 106 | *.iobj 107 | *.pch 108 | *.pdb 109 | *.ipdb 110 | *.pgc 111 | *.pgd 112 | *.rsp 113 | *.sbr 114 | *.tlb 115 | *.tli 116 | *.tlh 117 | *.tmp 118 | *.tmp_proj 119 | *_wpftmp.csproj 120 | *.log 121 | *.vspscc 122 | *.vssscc 123 | .builds 124 | *.pidb 125 | *.svclog 126 | *.scc 127 | 128 | # Chutzpah Test files 129 | _Chutzpah* 130 | 131 | # Visual C++ cache files 132 | ipch/ 133 | *.aps 134 | *.ncb 135 | *.opendb 136 | *.opensdf 137 | *.sdf 138 | *.cachefile 139 | *.VC.db 140 | *.VC.VC.opendb 141 | 142 | # Visual Studio profiler 143 | *.psess 144 | *.vsp 145 | *.vspx 146 | *.sap 147 | 148 | # Visual Studio Trace Files 149 | *.e2e 150 | 151 | # TFS 2012 Local Workspace 152 | $tf/ 153 | 154 | # Guidance Automation Toolkit 155 | *.gpState 156 | 157 | # ReSharper is a .NET coding add-in 158 | _ReSharper*/ 159 | *.[Rr]e[Ss]harper 160 | *.DotSettings.user 161 | 162 | # JustCode is a .NET coding add-in 163 | .JustCode 164 | 165 | # TeamCity is a build add-in 166 | _TeamCity* 167 | 168 | # DotCover is a Code Coverage Tool 169 | *.dotCover 170 | 171 | # AxoCover is a Code Coverage Tool 172 | .axoCover/* 173 | !.axoCover/settings.json 174 | 175 | # Visual Studio code coverage results 176 | *.coverage 177 | *.coveragexml 178 | 179 | # NCrunch 180 | _NCrunch_* 181 | .*crunch*.local.xml 182 | nCrunchTemp_* 183 | 184 | # MightyMoose 185 | *.mm.* 186 | AutoTest.Net/ 187 | 188 | # Web workbench (sass) 189 | .sass-cache/ 190 | 191 | # Installshield output folder 192 | [Ee]xpress/ 193 | 194 | # DocProject is a documentation generator add-in 195 | DocProject/buildhelp/ 196 | DocProject/Help/*.HxT 197 | DocProject/Help/*.HxC 198 | DocProject/Help/*.hhc 199 | DocProject/Help/*.hhk 200 | DocProject/Help/*.hhp 201 | DocProject/Help/Html2 202 | DocProject/Help/html 203 | 204 | # Click-Once directory 205 | publish/ 206 | 207 | # Publish Web Output 208 | *.[Pp]ublish.xml 209 | *.azurePubxml 210 | # Note: Comment the next line if you want to checkin your web deploy settings, 211 | # but database connection strings (with potential passwords) will be unencrypted 212 | *.pubxml 213 | *.publishproj 214 | 215 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 216 | # checkin your Azure Web App publish settings, but sensitive information contained 217 | # in these scripts will be unencrypted 218 | PublishScripts/ 219 | 220 | # NuGet Packages 221 | *.nupkg 222 | # NuGet Symbol Packages 223 | *.snupkg 224 | # The packages folder can be ignored because of Package Restore 225 | **/[Pp]ackages/* 226 | # except build/, which is used as an MSBuild target. 227 | !**/[Pp]ackages/build/ 228 | # Uncomment if necessary however generally it will be regenerated when needed 229 | #!**/[Pp]ackages/repositories.config 230 | # NuGet v3's project.json files produces more ignorable files 231 | *.nuget.props 232 | *.nuget.targets 233 | 234 | # Microsoft Azure Build Output 235 | csx/ 236 | *.build.csdef 237 | 238 | # Microsoft Azure Emulator 239 | ecf/ 240 | rcf/ 241 | 242 | # Windows Store app package directories and files 243 | AppPackages/ 244 | BundleArtifacts/ 245 | Package.StoreAssociation.xml 246 | _pkginfo.txt 247 | *.appx 248 | *.appxbundle 249 | *.appxupload 250 | 251 | # Visual Studio cache files 252 | # files ending in .cache can be ignored 253 | *.[Cc]ache 254 | # but keep track of directories ending in .cache 255 | !?*.[Cc]ache/ 256 | 257 | # Others 258 | ClientBin/ 259 | ~$* 260 | *~ 261 | *.dbmdl 262 | *.dbproj.schemaview 263 | *.jfm 264 | *.pfx 265 | *.publishsettings 266 | orleans.codegen.cs 267 | 268 | # Including strong name files can present a security risk 269 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 270 | #*.snk 271 | 272 | # Since there are multiple workflows, uncomment next line to ignore bower_components 273 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 274 | #bower_components/ 275 | 276 | # RIA/Silverlight projects 277 | Generated_Code/ 278 | 279 | # Backup & report files from converting an old project file 280 | # to a newer Visual Studio version. Backup files are not needed, 281 | # because we have git ;-) 282 | _UpgradeReport_Files/ 283 | Backup*/ 284 | UpgradeLog*.XML 285 | UpgradeLog*.htm 286 | ServiceFabricBackup/ 287 | *.rptproj.bak 288 | 289 | # SQL Server files 290 | *.mdf 291 | *.ldf 292 | *.ndf 293 | 294 | # Business Intelligence projects 295 | *.rdl.data 296 | *.bim.layout 297 | *.bim_*.settings 298 | *.rptproj.rsuser 299 | *- [Bb]ackup.rdl 300 | *- [Bb]ackup ([0-9]).rdl 301 | *- [Bb]ackup ([0-9][0-9]).rdl 302 | 303 | # Microsoft Fakes 304 | FakesAssemblies/ 305 | 306 | # GhostDoc plugin setting file 307 | *.GhostDoc.xml 308 | 309 | # Node.js Tools for Visual Studio 310 | .ntvs_analysis.dat 311 | node_modules/ 312 | 313 | # Visual Studio 6 build log 314 | *.plg 315 | 316 | # Visual Studio 6 workspace options file 317 | *.opt 318 | 319 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 320 | *.vbw 321 | 322 | # Visual Studio LightSwitch build output 323 | **/*.HTMLClient/GeneratedArtifacts 324 | **/*.DesktopClient/GeneratedArtifacts 325 | **/*.DesktopClient/ModelManifest.xml 326 | **/*.Server/GeneratedArtifacts 327 | **/*.Server/ModelManifest.xml 328 | _Pvt_Extensions 329 | 330 | # Paket dependency manager 331 | .paket/paket.exe 332 | paket-files/ 333 | 334 | # FAKE - F# Make 335 | .fake/ 336 | 337 | # CodeRush personal settings 338 | .cr/personal 339 | 340 | # Python Tools for Visual Studio (PTVS) 341 | __pycache__/ 342 | *.pyc 343 | 344 | # Cake - Uncomment if you are using it 345 | # tools/** 346 | # !tools/packages.config 347 | 348 | # Tabs Studio 349 | *.tss 350 | 351 | # Telerik's JustMock configuration file 352 | *.jmconfig 353 | 354 | # BizTalk build output 355 | *.btp.cs 356 | *.btm.cs 357 | *.odx.cs 358 | *.xsd.cs 359 | 360 | # OpenCover UI analysis results 361 | OpenCover/ 362 | 363 | # Azure Stream Analytics local run output 364 | ASALocalRun/ 365 | 366 | # MSBuild Binary and Structured Log 367 | *.binlog 368 | 369 | # NVidia Nsight GPU debugger configuration file 370 | *.nvuser 371 | 372 | # MFractors (Xamarin productivity tool) working folder 373 | .mfractor/ 374 | 375 | # Local History for Visual Studio 376 | .localhistory/ 377 | 378 | # BeatPulse healthcheck temp database 379 | healthchecksdb 380 | 381 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 382 | MigrationBackup/ 383 | -------------------------------------------------------------------------------- /src/javacomplier/main/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package parser; 2 | 3 | import java.io.*; 4 | 5 | import lexer.*; 6 | import symbols.*; 7 | import inter.*; 8 | 9 | /** 10 | * Parser 11 | */ 12 | public class Parser { 13 | /** 14 | * 这个语法分析器的词法分析器 15 | */ 16 | Lexer lex; 17 | /** 18 | * 向前看词法单元 19 | */ 20 | Token look; 21 | /** 22 | * 当前或顶层的符号表 23 | */ 24 | Env top = null; 25 | /** 26 | * 用于变量声明的存储位置 27 | */ 28 | int used = 0; 29 | 30 | /** 31 | * 32 | * @param lexer 33 | */ 34 | public Parser(Lexer lexer) throws IOException { 35 | lex = lexer; 36 | move(); 37 | } 38 | 39 | private void move() throws IOException { 40 | look = lex.scan(); 41 | } 42 | 43 | private void error(String s) throws IOException { 44 | throw new Error("near line " + Lexer.line + ": " + s); 45 | } 46 | 47 | void match(int t) throws IOException { 48 | if (look.tag == t) 49 | move(); 50 | else 51 | error("syntax error"); 52 | } 53 | 54 | /** 55 | * 56 | */ 57 | public void program() throws IOException { 58 | Stmt s = block(); 59 | int begin = s.newlabel(); 60 | int after = s.newlabel(); 61 | s.emitlabel(begin); 62 | s.gen(begin, after); 63 | s.emitlabel(after); 64 | } 65 | 66 | private Stmt block() throws IOException { 67 | match('{'); 68 | Env savedEnv = top; 69 | top = new Env(top); 70 | decls(); 71 | Stmt s = stmts(); 72 | match('}'); 73 | top = savedEnv; 74 | return s; 75 | } 76 | 77 | private void decls() throws IOException { 78 | while (look.tag == Tag.BASIC) { 79 | Type p = type(); 80 | Token tok = look; 81 | match(Tag.ID); 82 | match(';'); 83 | Id id = new Id((Word)tok, p, used); 84 | top.put(tok, id); 85 | } 86 | } 87 | 88 | private Type type() throws IOException { 89 | Type p = (Type)look; 90 | match(Tag.BASIC); 91 | if (look.tag != '[') 92 | return p; 93 | else 94 | return dims(p); 95 | } 96 | 97 | private Type dims(Type p) throws IOException { 98 | match('['); 99 | Token tok = look; 100 | match(Tag.NUM); 101 | match(']'); 102 | if (look.tag == '['); 103 | p = dims(p); 104 | return new Array(((Num)tok).value, p); 105 | } 106 | 107 | private Stmt stmts() throws IOException { 108 | if (look.tag == '}') 109 | return Stmt.Null; 110 | else 111 | return new Seq(stmt(), stmts()); 112 | } 113 | 114 | private Stmt stmt() throws IOException { 115 | Expr x; 116 | Stmt s1, s2; 117 | Stmt savedStmt; 118 | switch(look.tag) { 119 | case ';': 120 | move(); 121 | return Stmt.Null; 122 | case Tag.IF: 123 | match(Tag.IF); 124 | match('('); 125 | x = bool(); 126 | match(')'); 127 | s1 = stmt(); 128 | if (look.tag != Tag.ELSE) 129 | return new If(x, s1); 130 | match(Tag.ELSE); 131 | s2 = stmt(); 132 | return new Else(x, s1, s2); 133 | case Tag.WHILE: 134 | While whilenode = new While(); 135 | savedStmt = Stmt.Enclosing; 136 | Stmt.Enclosing = whilenode; 137 | match(Tag.WHILE); 138 | match('('); 139 | x = bool(); 140 | match(')'); 141 | s1 = stmt(); 142 | whilenode.init(x, s1); 143 | Stmt.Enclosing = savedStmt; 144 | return whilenode; 145 | case Tag.DO: 146 | Do donode = new Do(); 147 | savedStmt = Stmt.Enclosing; 148 | Stmt.Enclosing = donode; 149 | match(Tag.DO); 150 | s1 = stmt(); 151 | match(Tag.WHILE); 152 | match('('); 153 | x = bool(); 154 | match(')'); 155 | Stmt.Enclosing = savedStmt; 156 | return donode; 157 | case Tag.BREAK: 158 | match(Tag.BREAK); 159 | match(';'); 160 | return new Break(); 161 | case '{': 162 | return block(); 163 | default: 164 | return assign(); 165 | } 166 | } 167 | 168 | private Expr bool() throws IOException { 169 | Expr x = join(); 170 | while (look.tag == Tag.OR) { 171 | Token tok = look; 172 | move(); 173 | x = new Or(tok, x, join()); 174 | } 175 | return x; 176 | } 177 | 178 | private Expr join() throws IOException { 179 | Expr x = equality(); 180 | while (look.tag == Tag.AND) { 181 | Token tok = look; 182 | move(); 183 | x = new And(tok, x, equality()); 184 | } 185 | return x; 186 | } 187 | 188 | private Expr equality() throws IOException { 189 | Expr x = rel(); 190 | while (look.tag == Tag.EQ || look.tag == Tag.NE) { 191 | Token tok = look; 192 | move(); 193 | x = new Rel(tok, x, rel()); 194 | } 195 | return x; 196 | } 197 | 198 | private Expr rel() throws IOException { 199 | Expr x = expr(); 200 | switch (look.tag) { 201 | case '<': 202 | case Tag.LE: 203 | case Tag.GE: 204 | case '>': 205 | Token tok = look; 206 | move(); 207 | return new Rel(tok, x, expr()); 208 | default: 209 | return x; 210 | } 211 | } 212 | 213 | private Expr expr() throws IOException { 214 | Expr x = term(); 215 | while (look.tag == '+' || look.tag == '-') { 216 | Token tok = look; 217 | move(); 218 | x = new Arith(tok, x, term()); 219 | } 220 | return x; 221 | } 222 | 223 | private Expr term() throws IOException { 224 | Expr x = unary(); 225 | while (look.tag == '+' || look.tag == '/') { 226 | Token tok = look; 227 | move(); 228 | x = new Arith(tok, x, unary()); 229 | } 230 | return x; 231 | } 232 | 233 | private Expr unary() throws IOException { 234 | if (look.tag == '-') { 235 | move(); 236 | return new Unary(Word.minus, unary()); 237 | } 238 | else if (look.tag == '!') { 239 | Token tok = look; 240 | move(); 241 | return new Not(tok, unary()); 242 | } 243 | else 244 | return factor(); 245 | } 246 | 247 | private Expr factor() throws IOException { 248 | Expr x = null; 249 | switch (look.tag) { 250 | case '(': 251 | move(); 252 | x = bool(); 253 | match(')'); 254 | return x; 255 | case Tag.NUM: 256 | x = new Constant(look, Type.Int); 257 | move(); 258 | return x; 259 | case Tag.REAL: 260 | x = new Constant(look, Type.Float); 261 | move(); 262 | return x; 263 | case Tag.TRUE: 264 | x = Constant.True; 265 | move(); 266 | return x; 267 | case Tag.FALSE: 268 | x = Constant.False; 269 | move(); 270 | return x; 271 | default: 272 | error("syntax error"); 273 | return x; 274 | case Tag.ID: 275 | Id id = top.get(look); 276 | if (id == null) 277 | error(look.toString() + " undeclare"); 278 | move(); 279 | if (look.tag != '[') 280 | return id; 281 | else 282 | return offset(id); 283 | } 284 | } 285 | 286 | private Stmt assign() throws IOException { 287 | Stmt stmt; 288 | Token t = look; 289 | match(Tag.ID); 290 | Id id = top.get(t); 291 | if (id == null) 292 | error(t.toString() + " undeclared"); 293 | if (look.tag == '=') { 294 | move(); 295 | stmt = new Set(id, bool()); 296 | } 297 | else { 298 | Access x = offset(id); 299 | match('='); 300 | stmt = new SetElem(x, bool()); 301 | } 302 | match(';'); 303 | return stmt; 304 | } 305 | 306 | private Access offset(Id a) throws IOException { 307 | Expr i; 308 | Expr w; 309 | Expr t1; 310 | Expr t2; 311 | Expr loc; 312 | Type type = a.type; 313 | match('['); 314 | i = bool(); 315 | match(']'); 316 | type = ((Array)type).of; 317 | w = new Constant(type.width); 318 | t1 = new Arith(new Token('*'), i, w); 319 | loc = t1; 320 | while (look.tag == '[') { 321 | match('['); 322 | i = bool(); 323 | match(']'); 324 | type = ((Array)type).of; 325 | w = new Constant(type.width); 326 | t1 = new Arith(new Token('*'), i, w); 327 | t2 = new Arith(new Token('+'), loc, t1); 328 | loc = t2; 329 | } 330 | return new Access(a, loc, type); 331 | } 332 | 333 | 334 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/EParser.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/E.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.atn.*; 3 | import org.antlr.v4.runtime.dfa.DFA; 4 | import org.antlr.v4.runtime.*; 5 | import org.antlr.v4.runtime.misc.*; 6 | import org.antlr.v4.runtime.tree.*; 7 | import java.util.List; 8 | import java.util.Iterator; 9 | import java.util.ArrayList; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class EParser extends Parser { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, VAR=8, INT=9, 20 | STRING=10, WS=11; 21 | public static final int 22 | RULE_program = 0, RULE_statement = 1, RULE_expression = 2, RULE_multExpr = 3, 23 | RULE_atom = 4; 24 | public static final String[] ruleNames = { 25 | "program", "statement", "expression", "multExpr", "atom" 26 | }; 27 | 28 | private static final String[] _LITERAL_NAMES = { 29 | null, "'='", "';'", "'+'", "'-'", "'*'", "'('", "')'" 30 | }; 31 | private static final String[] _SYMBOLIC_NAMES = { 32 | null, null, null, null, null, null, null, null, "VAR", "INT", "STRING", 33 | "WS" 34 | }; 35 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 36 | 37 | /** 38 | * @deprecated Use {@link #VOCABULARY} instead. 39 | */ 40 | @Deprecated 41 | public static final String[] tokenNames; 42 | static { 43 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 44 | for (int i = 0; i < tokenNames.length; i++) { 45 | tokenNames[i] = VOCABULARY.getLiteralName(i); 46 | if (tokenNames[i] == null) { 47 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 48 | } 49 | 50 | if (tokenNames[i] == null) { 51 | tokenNames[i] = ""; 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | @Deprecated 58 | public String[] getTokenNames() { 59 | return tokenNames; 60 | } 61 | 62 | @Override 63 | 64 | public Vocabulary getVocabulary() { 65 | return VOCABULARY; 66 | } 67 | 68 | @Override 69 | public String getGrammarFileName() { return "E.g4"; } 70 | 71 | @Override 72 | public String[] getRuleNames() { return ruleNames; } 73 | 74 | @Override 75 | public String getSerializedATN() { return _serializedATN; } 76 | 77 | @Override 78 | public ATN getATN() { return _ATN; } 79 | 80 | public EParser(TokenStream input) { 81 | super(input); 82 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 83 | } 84 | public static class ProgramContext extends ParserRuleContext { 85 | public List statement() { 86 | return getRuleContexts(StatementContext.class); 87 | } 88 | public StatementContext statement(int i) { 89 | return getRuleContext(StatementContext.class,i); 90 | } 91 | public ProgramContext(ParserRuleContext parent, int invokingState) { 92 | super(parent, invokingState); 93 | } 94 | @Override public int getRuleIndex() { return RULE_program; } 95 | } 96 | 97 | public final ProgramContext program() throws RecognitionException { 98 | ProgramContext _localctx = new ProgramContext(_ctx, getState()); 99 | enterRule(_localctx, 0, RULE_program); 100 | int _la; 101 | try { 102 | enterOuterAlt(_localctx, 1); 103 | { 104 | setState(11); 105 | _errHandler.sync(this); 106 | _la = _input.LA(1); 107 | do { 108 | { 109 | { 110 | setState(10); 111 | statement(); 112 | } 113 | } 114 | setState(13); 115 | _errHandler.sync(this); 116 | _la = _input.LA(1); 117 | } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__5) | (1L << VAR) | (1L << INT) | (1L << STRING))) != 0) ); 118 | } 119 | } 120 | catch (RecognitionException re) { 121 | _localctx.exception = re; 122 | _errHandler.reportError(this, re); 123 | _errHandler.recover(this, re); 124 | } 125 | finally { 126 | exitRule(); 127 | } 128 | return _localctx; 129 | } 130 | 131 | public static class StatementContext extends ParserRuleContext { 132 | public ExpressionContext expression() { 133 | return getRuleContext(ExpressionContext.class,0); 134 | } 135 | public TerminalNode VAR() { return getToken(EParser.VAR, 0); } 136 | public StatementContext(ParserRuleContext parent, int invokingState) { 137 | super(parent, invokingState); 138 | } 139 | @Override public int getRuleIndex() { return RULE_statement; } 140 | } 141 | 142 | public final StatementContext statement() throws RecognitionException { 143 | StatementContext _localctx = new StatementContext(_ctx, getState()); 144 | enterRule(_localctx, 2, RULE_statement); 145 | try { 146 | enterOuterAlt(_localctx, 1); 147 | { 148 | setState(19); 149 | _errHandler.sync(this); 150 | switch (_input.LA(1)) { 151 | case T__5: 152 | case INT: 153 | case STRING: 154 | { 155 | setState(15); 156 | expression(); 157 | } 158 | break; 159 | case VAR: 160 | { 161 | setState(16); 162 | match(VAR); 163 | setState(17); 164 | match(T__0); 165 | setState(18); 166 | expression(); 167 | } 168 | break; 169 | default: 170 | throw new NoViableAltException(this); 171 | } 172 | setState(21); 173 | match(T__1); 174 | } 175 | } 176 | catch (RecognitionException re) { 177 | _localctx.exception = re; 178 | _errHandler.reportError(this, re); 179 | _errHandler.recover(this, re); 180 | } 181 | finally { 182 | exitRule(); 183 | } 184 | return _localctx; 185 | } 186 | 187 | public static class ExpressionContext extends ParserRuleContext { 188 | public List multExpr() { 189 | return getRuleContexts(MultExprContext.class); 190 | } 191 | public MultExprContext multExpr(int i) { 192 | return getRuleContext(MultExprContext.class,i); 193 | } 194 | public TerminalNode STRING() { return getToken(EParser.STRING, 0); } 195 | public ExpressionContext(ParserRuleContext parent, int invokingState) { 196 | super(parent, invokingState); 197 | } 198 | @Override public int getRuleIndex() { return RULE_expression; } 199 | } 200 | 201 | public final ExpressionContext expression() throws RecognitionException { 202 | ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); 203 | enterRule(_localctx, 4, RULE_expression); 204 | int _la; 205 | try { 206 | setState(32); 207 | _errHandler.sync(this); 208 | switch (_input.LA(1)) { 209 | case T__5: 210 | case INT: 211 | enterOuterAlt(_localctx, 1); 212 | { 213 | { 214 | setState(23); 215 | multExpr(); 216 | setState(28); 217 | _errHandler.sync(this); 218 | _la = _input.LA(1); 219 | while (_la==T__2 || _la==T__3) { 220 | { 221 | { 222 | setState(24); 223 | _la = _input.LA(1); 224 | if ( !(_la==T__2 || _la==T__3) ) { 225 | _errHandler.recoverInline(this); 226 | } 227 | else { 228 | if ( _input.LA(1)==Token.EOF ) matchedEOF = true; 229 | _errHandler.reportMatch(this); 230 | consume(); 231 | } 232 | setState(25); 233 | multExpr(); 234 | } 235 | } 236 | setState(30); 237 | _errHandler.sync(this); 238 | _la = _input.LA(1); 239 | } 240 | } 241 | } 242 | break; 243 | case STRING: 244 | enterOuterAlt(_localctx, 2); 245 | { 246 | setState(31); 247 | match(STRING); 248 | } 249 | break; 250 | default: 251 | throw new NoViableAltException(this); 252 | } 253 | } 254 | catch (RecognitionException re) { 255 | _localctx.exception = re; 256 | _errHandler.reportError(this, re); 257 | _errHandler.recover(this, re); 258 | } 259 | finally { 260 | exitRule(); 261 | } 262 | return _localctx; 263 | } 264 | 265 | public static class MultExprContext extends ParserRuleContext { 266 | public List atom() { 267 | return getRuleContexts(AtomContext.class); 268 | } 269 | public AtomContext atom(int i) { 270 | return getRuleContext(AtomContext.class,i); 271 | } 272 | public MultExprContext(ParserRuleContext parent, int invokingState) { 273 | super(parent, invokingState); 274 | } 275 | @Override public int getRuleIndex() { return RULE_multExpr; } 276 | } 277 | 278 | public final MultExprContext multExpr() throws RecognitionException { 279 | MultExprContext _localctx = new MultExprContext(_ctx, getState()); 280 | enterRule(_localctx, 6, RULE_multExpr); 281 | int _la; 282 | try { 283 | enterOuterAlt(_localctx, 1); 284 | { 285 | setState(34); 286 | atom(); 287 | setState(39); 288 | _errHandler.sync(this); 289 | _la = _input.LA(1); 290 | while (_la==T__4) { 291 | { 292 | { 293 | setState(35); 294 | match(T__4); 295 | setState(36); 296 | atom(); 297 | } 298 | } 299 | setState(41); 300 | _errHandler.sync(this); 301 | _la = _input.LA(1); 302 | } 303 | } 304 | } 305 | catch (RecognitionException re) { 306 | _localctx.exception = re; 307 | _errHandler.reportError(this, re); 308 | _errHandler.recover(this, re); 309 | } 310 | finally { 311 | exitRule(); 312 | } 313 | return _localctx; 314 | } 315 | 316 | public static class AtomContext extends ParserRuleContext { 317 | public TerminalNode INT() { return getToken(EParser.INT, 0); } 318 | public ExpressionContext expression() { 319 | return getRuleContext(ExpressionContext.class,0); 320 | } 321 | public AtomContext(ParserRuleContext parent, int invokingState) { 322 | super(parent, invokingState); 323 | } 324 | @Override public int getRuleIndex() { return RULE_atom; } 325 | } 326 | 327 | public final AtomContext atom() throws RecognitionException { 328 | AtomContext _localctx = new AtomContext(_ctx, getState()); 329 | enterRule(_localctx, 8, RULE_atom); 330 | try { 331 | setState(47); 332 | _errHandler.sync(this); 333 | switch (_input.LA(1)) { 334 | case INT: 335 | enterOuterAlt(_localctx, 1); 336 | { 337 | setState(42); 338 | match(INT); 339 | } 340 | break; 341 | case T__5: 342 | enterOuterAlt(_localctx, 2); 343 | { 344 | setState(43); 345 | match(T__5); 346 | setState(44); 347 | expression(); 348 | setState(45); 349 | match(T__6); 350 | } 351 | break; 352 | default: 353 | throw new NoViableAltException(this); 354 | } 355 | } 356 | catch (RecognitionException re) { 357 | _localctx.exception = re; 358 | _errHandler.reportError(this, re); 359 | _errHandler.recover(this, re); 360 | } 361 | finally { 362 | exitRule(); 363 | } 364 | return _localctx; 365 | } 366 | 367 | public static final String _serializedATN = 368 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\r\64\4\2\t\2\4\3"+ 369 | "\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\6\2\16\n\2\r\2\16\2\17\3\3\3\3\3\3\3"+ 370 | "\3\5\3\26\n\3\3\3\3\3\3\4\3\4\3\4\7\4\35\n\4\f\4\16\4 \13\4\3\4\5\4#\n"+ 371 | "\4\3\5\3\5\3\5\7\5(\n\5\f\5\16\5+\13\5\3\6\3\6\3\6\3\6\3\6\5\6\62\n\6"+ 372 | "\3\6\2\2\7\2\4\6\b\n\2\3\3\2\5\6\2\64\2\r\3\2\2\2\4\25\3\2\2\2\6\"\3\2"+ 373 | "\2\2\b$\3\2\2\2\n\61\3\2\2\2\f\16\5\4\3\2\r\f\3\2\2\2\16\17\3\2\2\2\17"+ 374 | "\r\3\2\2\2\17\20\3\2\2\2\20\3\3\2\2\2\21\26\5\6\4\2\22\23\7\n\2\2\23\24"+ 375 | "\7\3\2\2\24\26\5\6\4\2\25\21\3\2\2\2\25\22\3\2\2\2\26\27\3\2\2\2\27\30"+ 376 | "\7\4\2\2\30\5\3\2\2\2\31\36\5\b\5\2\32\33\t\2\2\2\33\35\5\b\5\2\34\32"+ 377 | "\3\2\2\2\35 \3\2\2\2\36\34\3\2\2\2\36\37\3\2\2\2\37#\3\2\2\2 \36\3\2\2"+ 378 | "\2!#\7\f\2\2\"\31\3\2\2\2\"!\3\2\2\2#\7\3\2\2\2$)\5\n\6\2%&\7\7\2\2&("+ 379 | "\5\n\6\2\'%\3\2\2\2(+\3\2\2\2)\'\3\2\2\2)*\3\2\2\2*\t\3\2\2\2+)\3\2\2"+ 380 | "\2,\62\7\13\2\2-.\7\b\2\2./\5\6\4\2/\60\7\t\2\2\60\62\3\2\2\2\61,\3\2"+ 381 | "\2\2\61-\3\2\2\2\62\13\3\2\2\2\b\17\25\36\")\61"; 382 | public static final ATN _ATN = 383 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 384 | static { 385 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 386 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 387 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 388 | } 389 | } 390 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LabeledExprParser.java: -------------------------------------------------------------------------------- 1 | // Generated from /Volumes/MSD64G/Developer/CodeLanuage/C++/CompileDragonBook.Cpp/src/ANTLR4/LabeledExpr.g4 by ANTLR 4.7.1 2 | import org.antlr.v4.runtime.atn.*; 3 | import org.antlr.v4.runtime.dfa.DFA; 4 | import org.antlr.v4.runtime.*; 5 | import org.antlr.v4.runtime.misc.*; 6 | import org.antlr.v4.runtime.tree.*; 7 | import java.util.List; 8 | import java.util.Iterator; 9 | import java.util.ArrayList; 10 | 11 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 12 | public class LabeledExprParser extends Parser { 13 | static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } 14 | 15 | protected static final DFA[] _decisionToDFA; 16 | protected static final PredictionContextCache _sharedContextCache = 17 | new PredictionContextCache(); 18 | public static final int 19 | T__0=1, T__1=2, T__2=3, ID=4, INT=5, NEWLINE=6, WS=7, MUL=8, DIV=9, ADD=10, 20 | SUB=11; 21 | public static final int 22 | RULE_prog = 0, RULE_stat = 1, RULE_expr = 2; 23 | public static final String[] ruleNames = { 24 | "prog", "stat", "expr" 25 | }; 26 | 27 | private static final String[] _LITERAL_NAMES = { 28 | null, "'='", "'('", "')'", null, null, null, null, "'*'", "'/'", "'+'", 29 | "'-'" 30 | }; 31 | private static final String[] _SYMBOLIC_NAMES = { 32 | null, null, null, null, "ID", "INT", "NEWLINE", "WS", "MUL", "DIV", "ADD", 33 | "SUB" 34 | }; 35 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 36 | 37 | /** 38 | * @deprecated Use {@link #VOCABULARY} instead. 39 | */ 40 | @Deprecated 41 | public static final String[] tokenNames; 42 | static { 43 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 44 | for (int i = 0; i < tokenNames.length; i++) { 45 | tokenNames[i] = VOCABULARY.getLiteralName(i); 46 | if (tokenNames[i] == null) { 47 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 48 | } 49 | 50 | if (tokenNames[i] == null) { 51 | tokenNames[i] = ""; 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | @Deprecated 58 | public String[] getTokenNames() { 59 | return tokenNames; 60 | } 61 | 62 | @Override 63 | 64 | public Vocabulary getVocabulary() { 65 | return VOCABULARY; 66 | } 67 | 68 | @Override 69 | public String getGrammarFileName() { return "LabeledExpr.g4"; } 70 | 71 | @Override 72 | public String[] getRuleNames() { return ruleNames; } 73 | 74 | @Override 75 | public String getSerializedATN() { return _serializedATN; } 76 | 77 | @Override 78 | public ATN getATN() { return _ATN; } 79 | 80 | public LabeledExprParser(TokenStream input) { 81 | super(input); 82 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 83 | } 84 | public static class ProgContext extends ParserRuleContext { 85 | public List stat() { 86 | return getRuleContexts(StatContext.class); 87 | } 88 | public StatContext stat(int i) { 89 | return getRuleContext(StatContext.class,i); 90 | } 91 | public ProgContext(ParserRuleContext parent, int invokingState) { 92 | super(parent, invokingState); 93 | } 94 | @Override public int getRuleIndex() { return RULE_prog; } 95 | } 96 | 97 | public final ProgContext prog() throws RecognitionException { 98 | ProgContext _localctx = new ProgContext(_ctx, getState()); 99 | enterRule(_localctx, 0, RULE_prog); 100 | int _la; 101 | try { 102 | enterOuterAlt(_localctx, 1); 103 | { 104 | setState(7); 105 | _errHandler.sync(this); 106 | _la = _input.LA(1); 107 | do { 108 | { 109 | { 110 | setState(6); 111 | stat(); 112 | } 113 | } 114 | setState(9); 115 | _errHandler.sync(this); 116 | _la = _input.LA(1); 117 | } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << ID) | (1L << INT) | (1L << NEWLINE))) != 0) ); 118 | } 119 | } 120 | catch (RecognitionException re) { 121 | _localctx.exception = re; 122 | _errHandler.reportError(this, re); 123 | _errHandler.recover(this, re); 124 | } 125 | finally { 126 | exitRule(); 127 | } 128 | return _localctx; 129 | } 130 | 131 | public static class StatContext extends ParserRuleContext { 132 | public StatContext(ParserRuleContext parent, int invokingState) { 133 | super(parent, invokingState); 134 | } 135 | @Override public int getRuleIndex() { return RULE_stat; } 136 | 137 | public StatContext() { } 138 | public void copyFrom(StatContext ctx) { 139 | super.copyFrom(ctx); 140 | } 141 | } 142 | public static class BlankContext extends StatContext { 143 | public TerminalNode NEWLINE() { return getToken(LabeledExprParser.NEWLINE, 0); } 144 | public BlankContext(StatContext ctx) { copyFrom(ctx); } 145 | } 146 | public static class PrintExprContext extends StatContext { 147 | public ExprContext expr() { 148 | return getRuleContext(ExprContext.class,0); 149 | } 150 | public TerminalNode NEWLINE() { return getToken(LabeledExprParser.NEWLINE, 0); } 151 | public PrintExprContext(StatContext ctx) { copyFrom(ctx); } 152 | } 153 | public static class AssignContext extends StatContext { 154 | public TerminalNode ID() { return getToken(LabeledExprParser.ID, 0); } 155 | public ExprContext expr() { 156 | return getRuleContext(ExprContext.class,0); 157 | } 158 | public TerminalNode NEWLINE() { return getToken(LabeledExprParser.NEWLINE, 0); } 159 | public AssignContext(StatContext ctx) { copyFrom(ctx); } 160 | } 161 | 162 | public final StatContext stat() throws RecognitionException { 163 | StatContext _localctx = new StatContext(_ctx, getState()); 164 | enterRule(_localctx, 2, RULE_stat); 165 | try { 166 | setState(20); 167 | _errHandler.sync(this); 168 | switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) { 169 | case 1: 170 | _localctx = new PrintExprContext(_localctx); 171 | enterOuterAlt(_localctx, 1); 172 | { 173 | setState(11); 174 | expr(0); 175 | setState(12); 176 | match(NEWLINE); 177 | } 178 | break; 179 | case 2: 180 | _localctx = new AssignContext(_localctx); 181 | enterOuterAlt(_localctx, 2); 182 | { 183 | setState(14); 184 | match(ID); 185 | setState(15); 186 | match(T__0); 187 | setState(16); 188 | expr(0); 189 | setState(17); 190 | match(NEWLINE); 191 | } 192 | break; 193 | case 3: 194 | _localctx = new BlankContext(_localctx); 195 | enterOuterAlt(_localctx, 3); 196 | { 197 | setState(19); 198 | match(NEWLINE); 199 | } 200 | break; 201 | } 202 | } 203 | catch (RecognitionException re) { 204 | _localctx.exception = re; 205 | _errHandler.reportError(this, re); 206 | _errHandler.recover(this, re); 207 | } 208 | finally { 209 | exitRule(); 210 | } 211 | return _localctx; 212 | } 213 | 214 | public static class ExprContext extends ParserRuleContext { 215 | public ExprContext(ParserRuleContext parent, int invokingState) { 216 | super(parent, invokingState); 217 | } 218 | @Override public int getRuleIndex() { return RULE_expr; } 219 | 220 | public ExprContext() { } 221 | public void copyFrom(ExprContext ctx) { 222 | super.copyFrom(ctx); 223 | } 224 | } 225 | public static class ParensContext extends ExprContext { 226 | public ExprContext expr() { 227 | return getRuleContext(ExprContext.class,0); 228 | } 229 | public ParensContext(ExprContext ctx) { copyFrom(ctx); } 230 | } 231 | public static class MulDivContext extends ExprContext { 232 | public Token op; 233 | public List expr() { 234 | return getRuleContexts(ExprContext.class); 235 | } 236 | public ExprContext expr(int i) { 237 | return getRuleContext(ExprContext.class,i); 238 | } 239 | public MulDivContext(ExprContext ctx) { copyFrom(ctx); } 240 | } 241 | public static class AddSubContext extends ExprContext { 242 | public Token op; 243 | public List expr() { 244 | return getRuleContexts(ExprContext.class); 245 | } 246 | public ExprContext expr(int i) { 247 | return getRuleContext(ExprContext.class,i); 248 | } 249 | public AddSubContext(ExprContext ctx) { copyFrom(ctx); } 250 | } 251 | public static class IdContext extends ExprContext { 252 | public TerminalNode ID() { return getToken(LabeledExprParser.ID, 0); } 253 | public IdContext(ExprContext ctx) { copyFrom(ctx); } 254 | } 255 | public static class IntContext extends ExprContext { 256 | public TerminalNode INT() { return getToken(LabeledExprParser.INT, 0); } 257 | public IntContext(ExprContext ctx) { copyFrom(ctx); } 258 | } 259 | 260 | public final ExprContext expr() throws RecognitionException { 261 | return expr(0); 262 | } 263 | 264 | private ExprContext expr(int _p) throws RecognitionException { 265 | ParserRuleContext _parentctx = _ctx; 266 | int _parentState = getState(); 267 | ExprContext _localctx = new ExprContext(_ctx, _parentState); 268 | ExprContext _prevctx = _localctx; 269 | int _startState = 4; 270 | enterRecursionRule(_localctx, 4, RULE_expr, _p); 271 | int _la; 272 | try { 273 | int _alt; 274 | enterOuterAlt(_localctx, 1); 275 | { 276 | setState(29); 277 | _errHandler.sync(this); 278 | switch (_input.LA(1)) { 279 | case INT: 280 | { 281 | _localctx = new IntContext(_localctx); 282 | _ctx = _localctx; 283 | _prevctx = _localctx; 284 | 285 | setState(23); 286 | match(INT); 287 | } 288 | break; 289 | case ID: 290 | { 291 | _localctx = new IdContext(_localctx); 292 | _ctx = _localctx; 293 | _prevctx = _localctx; 294 | setState(24); 295 | match(ID); 296 | } 297 | break; 298 | case T__1: 299 | { 300 | _localctx = new ParensContext(_localctx); 301 | _ctx = _localctx; 302 | _prevctx = _localctx; 303 | setState(25); 304 | match(T__1); 305 | setState(26); 306 | expr(0); 307 | setState(27); 308 | match(T__2); 309 | } 310 | break; 311 | default: 312 | throw new NoViableAltException(this); 313 | } 314 | _ctx.stop = _input.LT(-1); 315 | setState(39); 316 | _errHandler.sync(this); 317 | _alt = getInterpreter().adaptivePredict(_input,4,_ctx); 318 | while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { 319 | if ( _alt==1 ) { 320 | if ( _parseListeners!=null ) triggerExitRuleEvent(); 321 | _prevctx = _localctx; 322 | { 323 | setState(37); 324 | _errHandler.sync(this); 325 | switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { 326 | case 1: 327 | { 328 | _localctx = new MulDivContext(new ExprContext(_parentctx, _parentState)); 329 | pushNewRecursionContext(_localctx, _startState, RULE_expr); 330 | setState(31); 331 | if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); 332 | setState(32); 333 | ((MulDivContext)_localctx).op = _input.LT(1); 334 | _la = _input.LA(1); 335 | if ( !(_la==MUL || _la==DIV) ) { 336 | ((MulDivContext)_localctx).op = (Token)_errHandler.recoverInline(this); 337 | } 338 | else { 339 | if ( _input.LA(1)==Token.EOF ) matchedEOF = true; 340 | _errHandler.reportMatch(this); 341 | consume(); 342 | } 343 | setState(33); 344 | expr(6); 345 | } 346 | break; 347 | case 2: 348 | { 349 | _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState)); 350 | pushNewRecursionContext(_localctx, _startState, RULE_expr); 351 | setState(34); 352 | if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); 353 | setState(35); 354 | ((AddSubContext)_localctx).op = _input.LT(1); 355 | _la = _input.LA(1); 356 | if ( !(_la==ADD || _la==SUB) ) { 357 | ((AddSubContext)_localctx).op = (Token)_errHandler.recoverInline(this); 358 | } 359 | else { 360 | if ( _input.LA(1)==Token.EOF ) matchedEOF = true; 361 | _errHandler.reportMatch(this); 362 | consume(); 363 | } 364 | setState(36); 365 | expr(5); 366 | } 367 | break; 368 | } 369 | } 370 | } 371 | setState(41); 372 | _errHandler.sync(this); 373 | _alt = getInterpreter().adaptivePredict(_input,4,_ctx); 374 | } 375 | } 376 | } 377 | catch (RecognitionException re) { 378 | _localctx.exception = re; 379 | _errHandler.reportError(this, re); 380 | _errHandler.recover(this, re); 381 | } 382 | finally { 383 | unrollRecursionContexts(_parentctx); 384 | } 385 | return _localctx; 386 | } 387 | 388 | public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { 389 | switch (ruleIndex) { 390 | case 2: 391 | return expr_sempred((ExprContext)_localctx, predIndex); 392 | } 393 | return true; 394 | } 395 | private boolean expr_sempred(ExprContext _localctx, int predIndex) { 396 | switch (predIndex) { 397 | case 0: 398 | return precpred(_ctx, 5); 399 | case 1: 400 | return precpred(_ctx, 4); 401 | } 402 | return true; 403 | } 404 | 405 | public static final String _serializedATN = 406 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\r-\4\2\t\2\4\3\t"+ 407 | "\3\4\4\t\4\3\2\6\2\n\n\2\r\2\16\2\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ 408 | "\3\5\3\27\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4 \n\4\3\4\3\4\3\4\3\4\3\4"+ 409 | "\3\4\7\4(\n\4\f\4\16\4+\13\4\3\4\2\3\6\5\2\4\6\2\4\3\2\n\13\3\2\f\r\2"+ 410 | "\60\2\t\3\2\2\2\4\26\3\2\2\2\6\37\3\2\2\2\b\n\5\4\3\2\t\b\3\2\2\2\n\13"+ 411 | "\3\2\2\2\13\t\3\2\2\2\13\f\3\2\2\2\f\3\3\2\2\2\r\16\5\6\4\2\16\17\7\b"+ 412 | "\2\2\17\27\3\2\2\2\20\21\7\6\2\2\21\22\7\3\2\2\22\23\5\6\4\2\23\24\7\b"+ 413 | "\2\2\24\27\3\2\2\2\25\27\7\b\2\2\26\r\3\2\2\2\26\20\3\2\2\2\26\25\3\2"+ 414 | "\2\2\27\5\3\2\2\2\30\31\b\4\1\2\31 \7\7\2\2\32 \7\6\2\2\33\34\7\4\2\2"+ 415 | "\34\35\5\6\4\2\35\36\7\5\2\2\36 \3\2\2\2\37\30\3\2\2\2\37\32\3\2\2\2\37"+ 416 | "\33\3\2\2\2 )\3\2\2\2!\"\f\7\2\2\"#\t\2\2\2#(\5\6\4\b$%\f\6\2\2%&\t\3"+ 417 | "\2\2&(\5\6\4\7\'!\3\2\2\2\'$\3\2\2\2(+\3\2\2\2)\'\3\2\2\2)*\3\2\2\2*\7"+ 418 | "\3\2\2\2+)\3\2\2\2\7\13\26\37\')"; 419 | public static final ATN _ATN = 420 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 421 | static { 422 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 423 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 424 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 425 | } 426 | } 427 | } -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/Lua.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | ';' 4 | '=' 5 | 'break' 6 | 'goto' 7 | 'do' 8 | 'end' 9 | 'while' 10 | 'repeat' 11 | 'until' 12 | 'if' 13 | 'then' 14 | 'elseif' 15 | 'else' 16 | 'for' 17 | ',' 18 | 'in' 19 | 'function' 20 | 'local' 21 | 'return' 22 | '::' 23 | '.' 24 | ':' 25 | 'nil' 26 | 'false' 27 | 'true' 28 | '...' 29 | '(' 30 | ')' 31 | '[' 32 | ']' 33 | '{' 34 | '}' 35 | 'or' 36 | 'and' 37 | '<' 38 | '>' 39 | '<=' 40 | '>=' 41 | '~=' 42 | '==' 43 | '..' 44 | '+' 45 | '-' 46 | '*' 47 | '/' 48 | '%' 49 | '//' 50 | '&' 51 | '|' 52 | '~' 53 | '<<' 54 | '>>' 55 | 'not' 56 | '#' 57 | '^' 58 | null 59 | null 60 | null 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | null 68 | null 69 | null 70 | 71 | token symbolic names: 72 | null 73 | null 74 | null 75 | null 76 | null 77 | null 78 | null 79 | null 80 | null 81 | null 82 | null 83 | null 84 | null 85 | null 86 | null 87 | null 88 | null 89 | null 90 | null 91 | null 92 | null 93 | null 94 | null 95 | null 96 | null 97 | null 98 | null 99 | null 100 | null 101 | null 102 | null 103 | null 104 | null 105 | null 106 | null 107 | null 108 | null 109 | null 110 | null 111 | null 112 | null 113 | null 114 | null 115 | null 116 | null 117 | null 118 | null 119 | null 120 | null 121 | null 122 | null 123 | null 124 | null 125 | null 126 | null 127 | null 128 | NAME 129 | NORMALSTRING 130 | CHARSTRING 131 | LONGSTRING 132 | INT 133 | HEX 134 | FLOAT 135 | HEX_FLOAT 136 | COMMENT 137 | LINE_COMMENT 138 | WS 139 | SHEBANG 140 | 141 | rule names: 142 | chunk 143 | block 144 | stat 145 | retstat 146 | label 147 | funcname 148 | varlist 149 | namelist 150 | explist 151 | exp 152 | prefixexp 153 | functioncall 154 | varOrExp 155 | var 156 | varSuffix 157 | nameAndArgs 158 | args 159 | functiondef 160 | funcbody 161 | parlist 162 | tableconstructor 163 | fieldlist 164 | field 165 | fieldsep 166 | operatorOr 167 | operatorAnd 168 | operatorComparison 169 | operatorStrcat 170 | operatorAddSub 171 | operatorMulDivMod 172 | operatorBitwise 173 | operatorUnary 174 | operatorPower 175 | number 176 | string 177 | 178 | 179 | atn: 180 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 69, 403, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 3, 2, 3, 2, 3, 2, 3, 3, 7, 3, 77, 10, 3, 12, 3, 14, 3, 80, 11, 3, 3, 3, 5, 3, 83, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 119, 10, 4, 12, 4, 14, 4, 122, 11, 4, 3, 4, 3, 4, 5, 4, 126, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 138, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 164, 10, 4, 5, 4, 166, 10, 4, 3, 5, 3, 5, 5, 5, 170, 10, 5, 3, 5, 5, 5, 173, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 7, 7, 182, 10, 7, 12, 7, 14, 7, 185, 11, 7, 3, 7, 3, 7, 5, 7, 189, 10, 7, 3, 8, 3, 8, 3, 8, 7, 8, 194, 10, 8, 12, 8, 14, 8, 197, 11, 8, 3, 9, 3, 9, 3, 9, 7, 9, 202, 10, 9, 12, 9, 14, 9, 205, 11, 9, 3, 10, 3, 10, 3, 10, 7, 10, 210, 10, 10, 12, 10, 14, 10, 213, 11, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 228, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 262, 10, 11, 12, 11, 14, 11, 265, 11, 11, 3, 12, 3, 12, 7, 12, 269, 10, 12, 12, 12, 14, 12, 272, 11, 12, 3, 13, 3, 13, 6, 13, 276, 10, 13, 13, 13, 14, 13, 277, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 5, 14, 285, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 293, 10, 15, 3, 15, 7, 15, 296, 10, 15, 12, 15, 14, 15, 299, 11, 15, 3, 16, 7, 16, 302, 10, 16, 12, 16, 14, 16, 305, 11, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 313, 10, 16, 3, 17, 3, 17, 5, 17, 317, 10, 17, 3, 17, 3, 17, 3, 18, 3, 18, 5, 18, 323, 10, 18, 3, 18, 3, 18, 3, 18, 5, 18, 328, 10, 18, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 5, 20, 335, 10, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 5, 21, 344, 10, 21, 3, 21, 5, 21, 347, 10, 21, 3, 22, 3, 22, 5, 22, 351, 10, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 7, 23, 359, 10, 23, 12, 23, 14, 23, 362, 11, 23, 3, 23, 5, 23, 365, 10, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 5, 24, 377, 10, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 2, 3, 20, 37, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 2, 10, 4, 2, 3, 3, 17, 17, 3, 2, 37, 42, 3, 2, 44, 45, 3, 2, 46, 49, 3, 2, 50, 54, 5, 2, 45, 45, 52, 52, 55, 56, 3, 2, 62, 65, 3, 2, 59, 61, 2, 430, 2, 72, 3, 2, 2, 2, 4, 78, 3, 2, 2, 2, 6, 165, 3, 2, 2, 2, 8, 167, 3, 2, 2, 2, 10, 174, 3, 2, 2, 2, 12, 178, 3, 2, 2, 2, 14, 190, 3, 2, 2, 2, 16, 198, 3, 2, 2, 2, 18, 206, 3, 2, 2, 2, 20, 227, 3, 2, 2, 2, 22, 266, 3, 2, 2, 2, 24, 273, 3, 2, 2, 2, 26, 284, 3, 2, 2, 2, 28, 292, 3, 2, 2, 2, 30, 303, 3, 2, 2, 2, 32, 316, 3, 2, 2, 2, 34, 327, 3, 2, 2, 2, 36, 329, 3, 2, 2, 2, 38, 332, 3, 2, 2, 2, 40, 346, 3, 2, 2, 2, 42, 348, 3, 2, 2, 2, 44, 354, 3, 2, 2, 2, 46, 376, 3, 2, 2, 2, 48, 378, 3, 2, 2, 2, 50, 380, 3, 2, 2, 2, 52, 382, 3, 2, 2, 2, 54, 384, 3, 2, 2, 2, 56, 386, 3, 2, 2, 2, 58, 388, 3, 2, 2, 2, 60, 390, 3, 2, 2, 2, 62, 392, 3, 2, 2, 2, 64, 394, 3, 2, 2, 2, 66, 396, 3, 2, 2, 2, 68, 398, 3, 2, 2, 2, 70, 400, 3, 2, 2, 2, 72, 73, 5, 4, 3, 2, 73, 74, 7, 2, 2, 3, 74, 3, 3, 2, 2, 2, 75, 77, 5, 6, 4, 2, 76, 75, 3, 2, 2, 2, 77, 80, 3, 2, 2, 2, 78, 76, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 82, 3, 2, 2, 2, 80, 78, 3, 2, 2, 2, 81, 83, 5, 8, 5, 2, 82, 81, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 5, 3, 2, 2, 2, 84, 166, 7, 3, 2, 2, 85, 86, 5, 14, 8, 2, 86, 87, 7, 4, 2, 2, 87, 88, 5, 18, 10, 2, 88, 166, 3, 2, 2, 2, 89, 166, 5, 24, 13, 2, 90, 166, 5, 10, 6, 2, 91, 166, 7, 5, 2, 2, 92, 93, 7, 6, 2, 2, 93, 166, 7, 58, 2, 2, 94, 95, 7, 7, 2, 2, 95, 96, 5, 4, 3, 2, 96, 97, 7, 8, 2, 2, 97, 166, 3, 2, 2, 2, 98, 99, 7, 9, 2, 2, 99, 100, 5, 20, 11, 2, 100, 101, 7, 7, 2, 2, 101, 102, 5, 4, 3, 2, 102, 103, 7, 8, 2, 2, 103, 166, 3, 2, 2, 2, 104, 105, 7, 10, 2, 2, 105, 106, 5, 4, 3, 2, 106, 107, 7, 11, 2, 2, 107, 108, 5, 20, 11, 2, 108, 166, 3, 2, 2, 2, 109, 110, 7, 12, 2, 2, 110, 111, 5, 20, 11, 2, 111, 112, 7, 13, 2, 2, 112, 120, 5, 4, 3, 2, 113, 114, 7, 14, 2, 2, 114, 115, 5, 20, 11, 2, 115, 116, 7, 13, 2, 2, 116, 117, 5, 4, 3, 2, 117, 119, 3, 2, 2, 2, 118, 113, 3, 2, 2, 2, 119, 122, 3, 2, 2, 2, 120, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 125, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 123, 124, 7, 15, 2, 2, 124, 126, 5, 4, 3, 2, 125, 123, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 127, 3, 2, 2, 2, 127, 128, 7, 8, 2, 2, 128, 166, 3, 2, 2, 2, 129, 130, 7, 16, 2, 2, 130, 131, 7, 58, 2, 2, 131, 132, 7, 4, 2, 2, 132, 133, 5, 20, 11, 2, 133, 134, 7, 17, 2, 2, 134, 137, 5, 20, 11, 2, 135, 136, 7, 17, 2, 2, 136, 138, 5, 20, 11, 2, 137, 135, 3, 2, 2, 2, 137, 138, 3, 2, 2, 2, 138, 139, 3, 2, 2, 2, 139, 140, 7, 7, 2, 2, 140, 141, 5, 4, 3, 2, 141, 142, 7, 8, 2, 2, 142, 166, 3, 2, 2, 2, 143, 144, 7, 16, 2, 2, 144, 145, 5, 16, 9, 2, 145, 146, 7, 18, 2, 2, 146, 147, 5, 18, 10, 2, 147, 148, 7, 7, 2, 2, 148, 149, 5, 4, 3, 2, 149, 150, 7, 8, 2, 2, 150, 166, 3, 2, 2, 2, 151, 152, 7, 19, 2, 2, 152, 153, 5, 12, 7, 2, 153, 154, 5, 38, 20, 2, 154, 166, 3, 2, 2, 2, 155, 156, 7, 20, 2, 2, 156, 157, 7, 19, 2, 2, 157, 158, 7, 58, 2, 2, 158, 166, 5, 38, 20, 2, 159, 160, 7, 20, 2, 2, 160, 163, 5, 16, 9, 2, 161, 162, 7, 4, 2, 2, 162, 164, 5, 18, 10, 2, 163, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 166, 3, 2, 2, 2, 165, 84, 3, 2, 2, 2, 165, 85, 3, 2, 2, 2, 165, 89, 3, 2, 2, 2, 165, 90, 3, 2, 2, 2, 165, 91, 3, 2, 2, 2, 165, 92, 3, 2, 2, 2, 165, 94, 3, 2, 2, 2, 165, 98, 3, 2, 2, 2, 165, 104, 3, 2, 2, 2, 165, 109, 3, 2, 2, 2, 165, 129, 3, 2, 2, 2, 165, 143, 3, 2, 2, 2, 165, 151, 3, 2, 2, 2, 165, 155, 3, 2, 2, 2, 165, 159, 3, 2, 2, 2, 166, 7, 3, 2, 2, 2, 167, 169, 7, 21, 2, 2, 168, 170, 5, 18, 10, 2, 169, 168, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, 170, 172, 3, 2, 2, 2, 171, 173, 7, 3, 2, 2, 172, 171, 3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 9, 3, 2, 2, 2, 174, 175, 7, 22, 2, 2, 175, 176, 7, 58, 2, 2, 176, 177, 7, 22, 2, 2, 177, 11, 3, 2, 2, 2, 178, 183, 7, 58, 2, 2, 179, 180, 7, 23, 2, 2, 180, 182, 7, 58, 2, 2, 181, 179, 3, 2, 2, 2, 182, 185, 3, 2, 2, 2, 183, 181, 3, 2, 2, 2, 183, 184, 3, 2, 2, 2, 184, 188, 3, 2, 2, 2, 185, 183, 3, 2, 2, 2, 186, 187, 7, 24, 2, 2, 187, 189, 7, 58, 2, 2, 188, 186, 3, 2, 2, 2, 188, 189, 3, 2, 2, 2, 189, 13, 3, 2, 2, 2, 190, 195, 5, 28, 15, 2, 191, 192, 7, 17, 2, 2, 192, 194, 5, 28, 15, 2, 193, 191, 3, 2, 2, 2, 194, 197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 15, 3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 203, 7, 58, 2, 2, 199, 200, 7, 17, 2, 2, 200, 202, 7, 58, 2, 2, 201, 199, 3, 2, 2, 2, 202, 205, 3, 2, 2, 2, 203, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 17, 3, 2, 2, 2, 205, 203, 3, 2, 2, 2, 206, 211, 5, 20, 11, 2, 207, 208, 7, 17, 2, 2, 208, 210, 5, 20, 11, 2, 209, 207, 3, 2, 2, 2, 210, 213, 3, 2, 2, 2, 211, 209, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 19, 3, 2, 2, 2, 213, 211, 3, 2, 2, 2, 214, 215, 8, 11, 1, 2, 215, 228, 7, 25, 2, 2, 216, 228, 7, 26, 2, 2, 217, 228, 7, 27, 2, 2, 218, 228, 5, 68, 35, 2, 219, 228, 5, 70, 36, 2, 220, 228, 7, 28, 2, 2, 221, 228, 5, 36, 19, 2, 222, 228, 5, 22, 12, 2, 223, 228, 5, 42, 22, 2, 224, 225, 5, 64, 33, 2, 225, 226, 5, 20, 11, 10, 226, 228, 3, 2, 2, 2, 227, 214, 3, 2, 2, 2, 227, 216, 3, 2, 2, 2, 227, 217, 3, 2, 2, 2, 227, 218, 3, 2, 2, 2, 227, 219, 3, 2, 2, 2, 227, 220, 3, 2, 2, 2, 227, 221, 3, 2, 2, 2, 227, 222, 3, 2, 2, 2, 227, 223, 3, 2, 2, 2, 227, 224, 3, 2, 2, 2, 228, 263, 3, 2, 2, 2, 229, 230, 12, 11, 2, 2, 230, 231, 5, 66, 34, 2, 231, 232, 5, 20, 11, 11, 232, 262, 3, 2, 2, 2, 233, 234, 12, 9, 2, 2, 234, 235, 5, 60, 31, 2, 235, 236, 5, 20, 11, 10, 236, 262, 3, 2, 2, 2, 237, 238, 12, 8, 2, 2, 238, 239, 5, 58, 30, 2, 239, 240, 5, 20, 11, 9, 240, 262, 3, 2, 2, 2, 241, 242, 12, 7, 2, 2, 242, 243, 5, 56, 29, 2, 243, 244, 5, 20, 11, 7, 244, 262, 3, 2, 2, 2, 245, 246, 12, 6, 2, 2, 246, 247, 5, 54, 28, 2, 247, 248, 5, 20, 11, 7, 248, 262, 3, 2, 2, 2, 249, 250, 12, 5, 2, 2, 250, 251, 5, 52, 27, 2, 251, 252, 5, 20, 11, 6, 252, 262, 3, 2, 2, 2, 253, 254, 12, 4, 2, 2, 254, 255, 5, 50, 26, 2, 255, 256, 5, 20, 11, 5, 256, 262, 3, 2, 2, 2, 257, 258, 12, 3, 2, 2, 258, 259, 5, 62, 32, 2, 259, 260, 5, 20, 11, 4, 260, 262, 3, 2, 2, 2, 261, 229, 3, 2, 2, 2, 261, 233, 3, 2, 2, 2, 261, 237, 3, 2, 2, 2, 261, 241, 3, 2, 2, 2, 261, 245, 3, 2, 2, 2, 261, 249, 3, 2, 2, 2, 261, 253, 3, 2, 2, 2, 261, 257, 3, 2, 2, 2, 262, 265, 3, 2, 2, 2, 263, 261, 3, 2, 2, 2, 263, 264, 3, 2, 2, 2, 264, 21, 3, 2, 2, 2, 265, 263, 3, 2, 2, 2, 266, 270, 5, 26, 14, 2, 267, 269, 5, 32, 17, 2, 268, 267, 3, 2, 2, 2, 269, 272, 3, 2, 2, 2, 270, 268, 3, 2, 2, 2, 270, 271, 3, 2, 2, 2, 271, 23, 3, 2, 2, 2, 272, 270, 3, 2, 2, 2, 273, 275, 5, 26, 14, 2, 274, 276, 5, 32, 17, 2, 275, 274, 3, 2, 2, 2, 276, 277, 3, 2, 2, 2, 277, 275, 3, 2, 2, 2, 277, 278, 3, 2, 2, 2, 278, 25, 3, 2, 2, 2, 279, 285, 5, 28, 15, 2, 280, 281, 7, 29, 2, 2, 281, 282, 5, 20, 11, 2, 282, 283, 7, 30, 2, 2, 283, 285, 3, 2, 2, 2, 284, 279, 3, 2, 2, 2, 284, 280, 3, 2, 2, 2, 285, 27, 3, 2, 2, 2, 286, 293, 7, 58, 2, 2, 287, 288, 7, 29, 2, 2, 288, 289, 5, 20, 11, 2, 289, 290, 7, 30, 2, 2, 290, 291, 5, 30, 16, 2, 291, 293, 3, 2, 2, 2, 292, 286, 3, 2, 2, 2, 292, 287, 3, 2, 2, 2, 293, 297, 3, 2, 2, 2, 294, 296, 5, 30, 16, 2, 295, 294, 3, 2, 2, 2, 296, 299, 3, 2, 2, 2, 297, 295, 3, 2, 2, 2, 297, 298, 3, 2, 2, 2, 298, 29, 3, 2, 2, 2, 299, 297, 3, 2, 2, 2, 300, 302, 5, 32, 17, 2, 301, 300, 3, 2, 2, 2, 302, 305, 3, 2, 2, 2, 303, 301, 3, 2, 2, 2, 303, 304, 3, 2, 2, 2, 304, 312, 3, 2, 2, 2, 305, 303, 3, 2, 2, 2, 306, 307, 7, 31, 2, 2, 307, 308, 5, 20, 11, 2, 308, 309, 7, 32, 2, 2, 309, 313, 3, 2, 2, 2, 310, 311, 7, 23, 2, 2, 311, 313, 7, 58, 2, 2, 312, 306, 3, 2, 2, 2, 312, 310, 3, 2, 2, 2, 313, 31, 3, 2, 2, 2, 314, 315, 7, 24, 2, 2, 315, 317, 7, 58, 2, 2, 316, 314, 3, 2, 2, 2, 316, 317, 3, 2, 2, 2, 317, 318, 3, 2, 2, 2, 318, 319, 5, 34, 18, 2, 319, 33, 3, 2, 2, 2, 320, 322, 7, 29, 2, 2, 321, 323, 5, 18, 10, 2, 322, 321, 3, 2, 2, 2, 322, 323, 3, 2, 2, 2, 323, 324, 3, 2, 2, 2, 324, 328, 7, 30, 2, 2, 325, 328, 5, 42, 22, 2, 326, 328, 5, 70, 36, 2, 327, 320, 3, 2, 2, 2, 327, 325, 3, 2, 2, 2, 327, 326, 3, 2, 2, 2, 328, 35, 3, 2, 2, 2, 329, 330, 7, 19, 2, 2, 330, 331, 5, 38, 20, 2, 331, 37, 3, 2, 2, 2, 332, 334, 7, 29, 2, 2, 333, 335, 5, 40, 21, 2, 334, 333, 3, 2, 2, 2, 334, 335, 3, 2, 2, 2, 335, 336, 3, 2, 2, 2, 336, 337, 7, 30, 2, 2, 337, 338, 5, 4, 3, 2, 338, 339, 7, 8, 2, 2, 339, 39, 3, 2, 2, 2, 340, 343, 5, 16, 9, 2, 341, 342, 7, 17, 2, 2, 342, 344, 7, 28, 2, 2, 343, 341, 3, 2, 2, 2, 343, 344, 3, 2, 2, 2, 344, 347, 3, 2, 2, 2, 345, 347, 7, 28, 2, 2, 346, 340, 3, 2, 2, 2, 346, 345, 3, 2, 2, 2, 347, 41, 3, 2, 2, 2, 348, 350, 7, 33, 2, 2, 349, 351, 5, 44, 23, 2, 350, 349, 3, 2, 2, 2, 350, 351, 3, 2, 2, 2, 351, 352, 3, 2, 2, 2, 352, 353, 7, 34, 2, 2, 353, 43, 3, 2, 2, 2, 354, 360, 5, 46, 24, 2, 355, 356, 5, 48, 25, 2, 356, 357, 5, 46, 24, 2, 357, 359, 3, 2, 2, 2, 358, 355, 3, 2, 2, 2, 359, 362, 3, 2, 2, 2, 360, 358, 3, 2, 2, 2, 360, 361, 3, 2, 2, 2, 361, 364, 3, 2, 2, 2, 362, 360, 3, 2, 2, 2, 363, 365, 5, 48, 25, 2, 364, 363, 3, 2, 2, 2, 364, 365, 3, 2, 2, 2, 365, 45, 3, 2, 2, 2, 366, 367, 7, 31, 2, 2, 367, 368, 5, 20, 11, 2, 368, 369, 7, 32, 2, 2, 369, 370, 7, 4, 2, 2, 370, 371, 5, 20, 11, 2, 371, 377, 3, 2, 2, 2, 372, 373, 7, 58, 2, 2, 373, 374, 7, 4, 2, 2, 374, 377, 5, 20, 11, 2, 375, 377, 5, 20, 11, 2, 376, 366, 3, 2, 2, 2, 376, 372, 3, 2, 2, 2, 376, 375, 3, 2, 2, 2, 377, 47, 3, 2, 2, 2, 378, 379, 9, 2, 2, 2, 379, 49, 3, 2, 2, 2, 380, 381, 7, 35, 2, 2, 381, 51, 3, 2, 2, 2, 382, 383, 7, 36, 2, 2, 383, 53, 3, 2, 2, 2, 384, 385, 9, 3, 2, 2, 385, 55, 3, 2, 2, 2, 386, 387, 7, 43, 2, 2, 387, 57, 3, 2, 2, 2, 388, 389, 9, 4, 2, 2, 389, 59, 3, 2, 2, 2, 390, 391, 9, 5, 2, 2, 391, 61, 3, 2, 2, 2, 392, 393, 9, 6, 2, 2, 393, 63, 3, 2, 2, 2, 394, 395, 9, 7, 2, 2, 395, 65, 3, 2, 2, 2, 396, 397, 7, 57, 2, 2, 397, 67, 3, 2, 2, 2, 398, 399, 9, 8, 2, 2, 399, 69, 3, 2, 2, 2, 400, 401, 9, 9, 2, 2, 401, 71, 3, 2, 2, 2, 36, 78, 82, 120, 125, 137, 163, 165, 169, 172, 183, 188, 195, 203, 211, 227, 261, 263, 270, 277, 284, 292, 297, 303, 312, 316, 322, 327, 334, 343, 346, 350, 360, 364, 376] -------------------------------------------------------------------------------- /src/ANTLR4/.antlr/LuaLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | ';' 4 | '=' 5 | 'break' 6 | 'goto' 7 | 'do' 8 | 'end' 9 | 'while' 10 | 'repeat' 11 | 'until' 12 | 'if' 13 | 'then' 14 | 'elseif' 15 | 'else' 16 | 'for' 17 | ',' 18 | 'in' 19 | 'function' 20 | 'local' 21 | 'return' 22 | '::' 23 | '.' 24 | ':' 25 | 'nil' 26 | 'false' 27 | 'true' 28 | '...' 29 | '(' 30 | ')' 31 | '[' 32 | ']' 33 | '{' 34 | '}' 35 | 'or' 36 | 'and' 37 | '<' 38 | '>' 39 | '<=' 40 | '>=' 41 | '~=' 42 | '==' 43 | '..' 44 | '+' 45 | '-' 46 | '*' 47 | '/' 48 | '%' 49 | '//' 50 | '&' 51 | '|' 52 | '~' 53 | '<<' 54 | '>>' 55 | 'not' 56 | '#' 57 | '^' 58 | null 59 | null 60 | null 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | null 68 | null 69 | null 70 | 71 | token symbolic names: 72 | null 73 | null 74 | null 75 | null 76 | null 77 | null 78 | null 79 | null 80 | null 81 | null 82 | null 83 | null 84 | null 85 | null 86 | null 87 | null 88 | null 89 | null 90 | null 91 | null 92 | null 93 | null 94 | null 95 | null 96 | null 97 | null 98 | null 99 | null 100 | null 101 | null 102 | null 103 | null 104 | null 105 | null 106 | null 107 | null 108 | null 109 | null 110 | null 111 | null 112 | null 113 | null 114 | null 115 | null 116 | null 117 | null 118 | null 119 | null 120 | null 121 | null 122 | null 123 | null 124 | null 125 | null 126 | null 127 | null 128 | NAME 129 | NORMALSTRING 130 | CHARSTRING 131 | LONGSTRING 132 | INT 133 | HEX 134 | FLOAT 135 | HEX_FLOAT 136 | COMMENT 137 | LINE_COMMENT 138 | WS 139 | SHEBANG 140 | 141 | rule names: 142 | T__0 143 | T__1 144 | T__2 145 | T__3 146 | T__4 147 | T__5 148 | T__6 149 | T__7 150 | T__8 151 | T__9 152 | T__10 153 | T__11 154 | T__12 155 | T__13 156 | T__14 157 | T__15 158 | T__16 159 | T__17 160 | T__18 161 | T__19 162 | T__20 163 | T__21 164 | T__22 165 | T__23 166 | T__24 167 | T__25 168 | T__26 169 | T__27 170 | T__28 171 | T__29 172 | T__30 173 | T__31 174 | T__32 175 | T__33 176 | T__34 177 | T__35 178 | T__36 179 | T__37 180 | T__38 181 | T__39 182 | T__40 183 | T__41 184 | T__42 185 | T__43 186 | T__44 187 | T__45 188 | T__46 189 | T__47 190 | T__48 191 | T__49 192 | T__50 193 | T__51 194 | T__52 195 | T__53 196 | T__54 197 | NAME 198 | NORMALSTRING 199 | CHARSTRING 200 | LONGSTRING 201 | NESTED_STR 202 | INT 203 | HEX 204 | FLOAT 205 | HEX_FLOAT 206 | ExponentPart 207 | HexExponentPart 208 | EscapeSequence 209 | DecimalEscape 210 | HexEscape 211 | UtfEscape 212 | Digit 213 | HexDigit 214 | COMMENT 215 | LINE_COMMENT 216 | WS 217 | SHEBANG 218 | 219 | channel names: 220 | DEFAULT_TOKEN_CHANNEL 221 | HIDDEN 222 | 223 | mode names: 224 | DEFAULT_MODE 225 | 226 | atn: 227 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 69, 603, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 50, 3, 50, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 56, 3, 56, 3, 57, 3, 57, 7, 57, 347, 10, 57, 12, 57, 14, 57, 350, 11, 57, 3, 58, 3, 58, 3, 58, 7, 58, 355, 10, 58, 12, 58, 14, 58, 358, 11, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 7, 59, 365, 10, 59, 12, 59, 14, 59, 368, 11, 59, 3, 59, 3, 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 7, 61, 382, 10, 61, 12, 61, 14, 61, 385, 11, 61, 3, 61, 5, 61, 388, 10, 61, 3, 62, 6, 62, 391, 10, 62, 13, 62, 14, 62, 392, 3, 63, 3, 63, 3, 63, 6, 63, 398, 10, 63, 13, 63, 14, 63, 399, 3, 64, 6, 64, 403, 10, 64, 13, 64, 14, 64, 404, 3, 64, 3, 64, 7, 64, 409, 10, 64, 12, 64, 14, 64, 412, 11, 64, 3, 64, 5, 64, 415, 10, 64, 3, 64, 3, 64, 6, 64, 419, 10, 64, 13, 64, 14, 64, 420, 3, 64, 5, 64, 424, 10, 64, 3, 64, 6, 64, 427, 10, 64, 13, 64, 14, 64, 428, 3, 64, 3, 64, 5, 64, 433, 10, 64, 3, 65, 3, 65, 3, 65, 6, 65, 438, 10, 65, 13, 65, 14, 65, 439, 3, 65, 3, 65, 7, 65, 444, 10, 65, 12, 65, 14, 65, 447, 11, 65, 3, 65, 5, 65, 450, 10, 65, 3, 65, 3, 65, 3, 65, 3, 65, 6, 65, 456, 10, 65, 13, 65, 14, 65, 457, 3, 65, 5, 65, 461, 10, 65, 3, 65, 3, 65, 3, 65, 6, 65, 466, 10, 65, 13, 65, 14, 65, 467, 3, 65, 3, 65, 5, 65, 472, 10, 65, 3, 66, 3, 66, 5, 66, 476, 10, 66, 3, 66, 6, 66, 479, 10, 66, 13, 66, 14, 66, 480, 3, 67, 3, 67, 5, 67, 485, 10, 67, 3, 67, 6, 67, 488, 10, 67, 13, 67, 14, 67, 489, 3, 68, 3, 68, 3, 68, 3, 68, 5, 68, 496, 10, 68, 3, 68, 3, 68, 3, 68, 3, 68, 5, 68, 502, 10, 68, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 5, 69, 515, 10, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 6, 71, 527, 10, 71, 13, 71, 14, 71, 528, 3, 71, 3, 71, 3, 72, 3, 72, 3, 73, 3, 73, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 7, 75, 552, 10, 75, 12, 75, 14, 75, 555, 11, 75, 3, 75, 3, 75, 7, 75, 559, 10, 75, 12, 75, 14, 75, 562, 11, 75, 3, 75, 3, 75, 7, 75, 566, 10, 75, 12, 75, 14, 75, 569, 11, 75, 3, 75, 3, 75, 7, 75, 573, 10, 75, 12, 75, 14, 75, 576, 11, 75, 5, 75, 578, 10, 75, 3, 75, 3, 75, 3, 75, 5, 75, 583, 10, 75, 3, 75, 3, 75, 3, 76, 6, 76, 588, 10, 76, 13, 76, 14, 76, 589, 3, 76, 3, 76, 3, 77, 3, 77, 3, 77, 7, 77, 597, 10, 77, 12, 77, 14, 77, 600, 11, 77, 3, 77, 3, 77, 3, 383, 2, 78, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 55, 109, 56, 111, 57, 113, 58, 115, 59, 117, 60, 119, 61, 121, 2, 123, 62, 125, 63, 127, 64, 129, 65, 131, 2, 133, 2, 135, 2, 137, 2, 139, 2, 141, 2, 143, 2, 145, 2, 147, 66, 149, 67, 151, 68, 153, 69, 3, 2, 19, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 4, 2, 36, 36, 94, 94, 4, 2, 41, 41, 94, 94, 4, 2, 90, 90, 122, 122, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 82, 82, 114, 114, 12, 2, 36, 36, 41, 41, 94, 94, 99, 100, 104, 104, 112, 112, 116, 116, 118, 118, 120, 120, 124, 124, 3, 2, 50, 52, 3, 2, 50, 59, 5, 2, 50, 59, 67, 72, 99, 104, 6, 2, 12, 12, 15, 15, 63, 63, 93, 93, 4, 2, 12, 12, 15, 15, 5, 2, 12, 12, 15, 15, 93, 93, 4, 3, 12, 12, 15, 15, 5, 2, 11, 12, 14, 15, 34, 34, 2, 640, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 147, 3, 2, 2, 2, 2, 149, 3, 2, 2, 2, 2, 151, 3, 2, 2, 2, 2, 153, 3, 2, 2, 2, 3, 155, 3, 2, 2, 2, 5, 157, 3, 2, 2, 2, 7, 159, 3, 2, 2, 2, 9, 165, 3, 2, 2, 2, 11, 170, 3, 2, 2, 2, 13, 173, 3, 2, 2, 2, 15, 177, 3, 2, 2, 2, 17, 183, 3, 2, 2, 2, 19, 190, 3, 2, 2, 2, 21, 196, 3, 2, 2, 2, 23, 199, 3, 2, 2, 2, 25, 204, 3, 2, 2, 2, 27, 211, 3, 2, 2, 2, 29, 216, 3, 2, 2, 2, 31, 220, 3, 2, 2, 2, 33, 222, 3, 2, 2, 2, 35, 225, 3, 2, 2, 2, 37, 234, 3, 2, 2, 2, 39, 240, 3, 2, 2, 2, 41, 247, 3, 2, 2, 2, 43, 250, 3, 2, 2, 2, 45, 252, 3, 2, 2, 2, 47, 254, 3, 2, 2, 2, 49, 258, 3, 2, 2, 2, 51, 264, 3, 2, 2, 2, 53, 269, 3, 2, 2, 2, 55, 273, 3, 2, 2, 2, 57, 275, 3, 2, 2, 2, 59, 277, 3, 2, 2, 2, 61, 279, 3, 2, 2, 2, 63, 281, 3, 2, 2, 2, 65, 283, 3, 2, 2, 2, 67, 285, 3, 2, 2, 2, 69, 288, 3, 2, 2, 2, 71, 292, 3, 2, 2, 2, 73, 294, 3, 2, 2, 2, 75, 296, 3, 2, 2, 2, 77, 299, 3, 2, 2, 2, 79, 302, 3, 2, 2, 2, 81, 305, 3, 2, 2, 2, 83, 308, 3, 2, 2, 2, 85, 311, 3, 2, 2, 2, 87, 313, 3, 2, 2, 2, 89, 315, 3, 2, 2, 2, 91, 317, 3, 2, 2, 2, 93, 319, 3, 2, 2, 2, 95, 321, 3, 2, 2, 2, 97, 324, 3, 2, 2, 2, 99, 326, 3, 2, 2, 2, 101, 328, 3, 2, 2, 2, 103, 330, 3, 2, 2, 2, 105, 333, 3, 2, 2, 2, 107, 336, 3, 2, 2, 2, 109, 340, 3, 2, 2, 2, 111, 342, 3, 2, 2, 2, 113, 344, 3, 2, 2, 2, 115, 351, 3, 2, 2, 2, 117, 361, 3, 2, 2, 2, 119, 371, 3, 2, 2, 2, 121, 387, 3, 2, 2, 2, 123, 390, 3, 2, 2, 2, 125, 394, 3, 2, 2, 2, 127, 432, 3, 2, 2, 2, 129, 471, 3, 2, 2, 2, 131, 473, 3, 2, 2, 2, 133, 482, 3, 2, 2, 2, 135, 501, 3, 2, 2, 2, 137, 514, 3, 2, 2, 2, 139, 516, 3, 2, 2, 2, 141, 521, 3, 2, 2, 2, 143, 532, 3, 2, 2, 2, 145, 534, 3, 2, 2, 2, 147, 536, 3, 2, 2, 2, 149, 545, 3, 2, 2, 2, 151, 587, 3, 2, 2, 2, 153, 593, 3, 2, 2, 2, 155, 156, 7, 61, 2, 2, 156, 4, 3, 2, 2, 2, 157, 158, 7, 63, 2, 2, 158, 6, 3, 2, 2, 2, 159, 160, 7, 100, 2, 2, 160, 161, 7, 116, 2, 2, 161, 162, 7, 103, 2, 2, 162, 163, 7, 99, 2, 2, 163, 164, 7, 109, 2, 2, 164, 8, 3, 2, 2, 2, 165, 166, 7, 105, 2, 2, 166, 167, 7, 113, 2, 2, 167, 168, 7, 118, 2, 2, 168, 169, 7, 113, 2, 2, 169, 10, 3, 2, 2, 2, 170, 171, 7, 102, 2, 2, 171, 172, 7, 113, 2, 2, 172, 12, 3, 2, 2, 2, 173, 174, 7, 103, 2, 2, 174, 175, 7, 112, 2, 2, 175, 176, 7, 102, 2, 2, 176, 14, 3, 2, 2, 2, 177, 178, 7, 121, 2, 2, 178, 179, 7, 106, 2, 2, 179, 180, 7, 107, 2, 2, 180, 181, 7, 110, 2, 2, 181, 182, 7, 103, 2, 2, 182, 16, 3, 2, 2, 2, 183, 184, 7, 116, 2, 2, 184, 185, 7, 103, 2, 2, 185, 186, 7, 114, 2, 2, 186, 187, 7, 103, 2, 2, 187, 188, 7, 99, 2, 2, 188, 189, 7, 118, 2, 2, 189, 18, 3, 2, 2, 2, 190, 191, 7, 119, 2, 2, 191, 192, 7, 112, 2, 2, 192, 193, 7, 118, 2, 2, 193, 194, 7, 107, 2, 2, 194, 195, 7, 110, 2, 2, 195, 20, 3, 2, 2, 2, 196, 197, 7, 107, 2, 2, 197, 198, 7, 104, 2, 2, 198, 22, 3, 2, 2, 2, 199, 200, 7, 118, 2, 2, 200, 201, 7, 106, 2, 2, 201, 202, 7, 103, 2, 2, 202, 203, 7, 112, 2, 2, 203, 24, 3, 2, 2, 2, 204, 205, 7, 103, 2, 2, 205, 206, 7, 110, 2, 2, 206, 207, 7, 117, 2, 2, 207, 208, 7, 103, 2, 2, 208, 209, 7, 107, 2, 2, 209, 210, 7, 104, 2, 2, 210, 26, 3, 2, 2, 2, 211, 212, 7, 103, 2, 2, 212, 213, 7, 110, 2, 2, 213, 214, 7, 117, 2, 2, 214, 215, 7, 103, 2, 2, 215, 28, 3, 2, 2, 2, 216, 217, 7, 104, 2, 2, 217, 218, 7, 113, 2, 2, 218, 219, 7, 116, 2, 2, 219, 30, 3, 2, 2, 2, 220, 221, 7, 46, 2, 2, 221, 32, 3, 2, 2, 2, 222, 223, 7, 107, 2, 2, 223, 224, 7, 112, 2, 2, 224, 34, 3, 2, 2, 2, 225, 226, 7, 104, 2, 2, 226, 227, 7, 119, 2, 2, 227, 228, 7, 112, 2, 2, 228, 229, 7, 101, 2, 2, 229, 230, 7, 118, 2, 2, 230, 231, 7, 107, 2, 2, 231, 232, 7, 113, 2, 2, 232, 233, 7, 112, 2, 2, 233, 36, 3, 2, 2, 2, 234, 235, 7, 110, 2, 2, 235, 236, 7, 113, 2, 2, 236, 237, 7, 101, 2, 2, 237, 238, 7, 99, 2, 2, 238, 239, 7, 110, 2, 2, 239, 38, 3, 2, 2, 2, 240, 241, 7, 116, 2, 2, 241, 242, 7, 103, 2, 2, 242, 243, 7, 118, 2, 2, 243, 244, 7, 119, 2, 2, 244, 245, 7, 116, 2, 2, 245, 246, 7, 112, 2, 2, 246, 40, 3, 2, 2, 2, 247, 248, 7, 60, 2, 2, 248, 249, 7, 60, 2, 2, 249, 42, 3, 2, 2, 2, 250, 251, 7, 48, 2, 2, 251, 44, 3, 2, 2, 2, 252, 253, 7, 60, 2, 2, 253, 46, 3, 2, 2, 2, 254, 255, 7, 112, 2, 2, 255, 256, 7, 107, 2, 2, 256, 257, 7, 110, 2, 2, 257, 48, 3, 2, 2, 2, 258, 259, 7, 104, 2, 2, 259, 260, 7, 99, 2, 2, 260, 261, 7, 110, 2, 2, 261, 262, 7, 117, 2, 2, 262, 263, 7, 103, 2, 2, 263, 50, 3, 2, 2, 2, 264, 265, 7, 118, 2, 2, 265, 266, 7, 116, 2, 2, 266, 267, 7, 119, 2, 2, 267, 268, 7, 103, 2, 2, 268, 52, 3, 2, 2, 2, 269, 270, 7, 48, 2, 2, 270, 271, 7, 48, 2, 2, 271, 272, 7, 48, 2, 2, 272, 54, 3, 2, 2, 2, 273, 274, 7, 42, 2, 2, 274, 56, 3, 2, 2, 2, 275, 276, 7, 43, 2, 2, 276, 58, 3, 2, 2, 2, 277, 278, 7, 93, 2, 2, 278, 60, 3, 2, 2, 2, 279, 280, 7, 95, 2, 2, 280, 62, 3, 2, 2, 2, 281, 282, 7, 125, 2, 2, 282, 64, 3, 2, 2, 2, 283, 284, 7, 127, 2, 2, 284, 66, 3, 2, 2, 2, 285, 286, 7, 113, 2, 2, 286, 287, 7, 116, 2, 2, 287, 68, 3, 2, 2, 2, 288, 289, 7, 99, 2, 2, 289, 290, 7, 112, 2, 2, 290, 291, 7, 102, 2, 2, 291, 70, 3, 2, 2, 2, 292, 293, 7, 62, 2, 2, 293, 72, 3, 2, 2, 2, 294, 295, 7, 64, 2, 2, 295, 74, 3, 2, 2, 2, 296, 297, 7, 62, 2, 2, 297, 298, 7, 63, 2, 2, 298, 76, 3, 2, 2, 2, 299, 300, 7, 64, 2, 2, 300, 301, 7, 63, 2, 2, 301, 78, 3, 2, 2, 2, 302, 303, 7, 128, 2, 2, 303, 304, 7, 63, 2, 2, 304, 80, 3, 2, 2, 2, 305, 306, 7, 63, 2, 2, 306, 307, 7, 63, 2, 2, 307, 82, 3, 2, 2, 2, 308, 309, 7, 48, 2, 2, 309, 310, 7, 48, 2, 2, 310, 84, 3, 2, 2, 2, 311, 312, 7, 45, 2, 2, 312, 86, 3, 2, 2, 2, 313, 314, 7, 47, 2, 2, 314, 88, 3, 2, 2, 2, 315, 316, 7, 44, 2, 2, 316, 90, 3, 2, 2, 2, 317, 318, 7, 49, 2, 2, 318, 92, 3, 2, 2, 2, 319, 320, 7, 39, 2, 2, 320, 94, 3, 2, 2, 2, 321, 322, 7, 49, 2, 2, 322, 323, 7, 49, 2, 2, 323, 96, 3, 2, 2, 2, 324, 325, 7, 40, 2, 2, 325, 98, 3, 2, 2, 2, 326, 327, 7, 126, 2, 2, 327, 100, 3, 2, 2, 2, 328, 329, 7, 128, 2, 2, 329, 102, 3, 2, 2, 2, 330, 331, 7, 62, 2, 2, 331, 332, 7, 62, 2, 2, 332, 104, 3, 2, 2, 2, 333, 334, 7, 64, 2, 2, 334, 335, 7, 64, 2, 2, 335, 106, 3, 2, 2, 2, 336, 337, 7, 112, 2, 2, 337, 338, 7, 113, 2, 2, 338, 339, 7, 118, 2, 2, 339, 108, 3, 2, 2, 2, 340, 341, 7, 37, 2, 2, 341, 110, 3, 2, 2, 2, 342, 343, 7, 96, 2, 2, 343, 112, 3, 2, 2, 2, 344, 348, 9, 2, 2, 2, 345, 347, 9, 3, 2, 2, 346, 345, 3, 2, 2, 2, 347, 350, 3, 2, 2, 2, 348, 346, 3, 2, 2, 2, 348, 349, 3, 2, 2, 2, 349, 114, 3, 2, 2, 2, 350, 348, 3, 2, 2, 2, 351, 356, 7, 36, 2, 2, 352, 355, 5, 135, 68, 2, 353, 355, 10, 4, 2, 2, 354, 352, 3, 2, 2, 2, 354, 353, 3, 2, 2, 2, 355, 358, 3, 2, 2, 2, 356, 354, 3, 2, 2, 2, 356, 357, 3, 2, 2, 2, 357, 359, 3, 2, 2, 2, 358, 356, 3, 2, 2, 2, 359, 360, 7, 36, 2, 2, 360, 116, 3, 2, 2, 2, 361, 366, 7, 41, 2, 2, 362, 365, 5, 135, 68, 2, 363, 365, 10, 5, 2, 2, 364, 362, 3, 2, 2, 2, 364, 363, 3, 2, 2, 2, 365, 368, 3, 2, 2, 2, 366, 364, 3, 2, 2, 2, 366, 367, 3, 2, 2, 2, 367, 369, 3, 2, 2, 2, 368, 366, 3, 2, 2, 2, 369, 370, 7, 41, 2, 2, 370, 118, 3, 2, 2, 2, 371, 372, 7, 93, 2, 2, 372, 373, 5, 121, 61, 2, 373, 374, 7, 95, 2, 2, 374, 120, 3, 2, 2, 2, 375, 376, 7, 63, 2, 2, 376, 377, 5, 121, 61, 2, 377, 378, 7, 63, 2, 2, 378, 388, 3, 2, 2, 2, 379, 383, 7, 93, 2, 2, 380, 382, 11, 2, 2, 2, 381, 380, 3, 2, 2, 2, 382, 385, 3, 2, 2, 2, 383, 384, 3, 2, 2, 2, 383, 381, 3, 2, 2, 2, 384, 386, 3, 2, 2, 2, 385, 383, 3, 2, 2, 2, 386, 388, 7, 95, 2, 2, 387, 375, 3, 2, 2, 2, 387, 379, 3, 2, 2, 2, 388, 122, 3, 2, 2, 2, 389, 391, 5, 143, 72, 2, 390, 389, 3, 2, 2, 2, 391, 392, 3, 2, 2, 2, 392, 390, 3, 2, 2, 2, 392, 393, 3, 2, 2, 2, 393, 124, 3, 2, 2, 2, 394, 395, 7, 50, 2, 2, 395, 397, 9, 6, 2, 2, 396, 398, 5, 145, 73, 2, 397, 396, 3, 2, 2, 2, 398, 399, 3, 2, 2, 2, 399, 397, 3, 2, 2, 2, 399, 400, 3, 2, 2, 2, 400, 126, 3, 2, 2, 2, 401, 403, 5, 143, 72, 2, 402, 401, 3, 2, 2, 2, 403, 404, 3, 2, 2, 2, 404, 402, 3, 2, 2, 2, 404, 405, 3, 2, 2, 2, 405, 406, 3, 2, 2, 2, 406, 410, 7, 48, 2, 2, 407, 409, 5, 143, 72, 2, 408, 407, 3, 2, 2, 2, 409, 412, 3, 2, 2, 2, 410, 408, 3, 2, 2, 2, 410, 411, 3, 2, 2, 2, 411, 414, 3, 2, 2, 2, 412, 410, 3, 2, 2, 2, 413, 415, 5, 131, 66, 2, 414, 413, 3, 2, 2, 2, 414, 415, 3, 2, 2, 2, 415, 433, 3, 2, 2, 2, 416, 418, 7, 48, 2, 2, 417, 419, 5, 143, 72, 2, 418, 417, 3, 2, 2, 2, 419, 420, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 420, 421, 3, 2, 2, 2, 421, 423, 3, 2, 2, 2, 422, 424, 5, 131, 66, 2, 423, 422, 3, 2, 2, 2, 423, 424, 3, 2, 2, 2, 424, 433, 3, 2, 2, 2, 425, 427, 5, 143, 72, 2, 426, 425, 3, 2, 2, 2, 427, 428, 3, 2, 2, 2, 428, 426, 3, 2, 2, 2, 428, 429, 3, 2, 2, 2, 429, 430, 3, 2, 2, 2, 430, 431, 5, 131, 66, 2, 431, 433, 3, 2, 2, 2, 432, 402, 3, 2, 2, 2, 432, 416, 3, 2, 2, 2, 432, 426, 3, 2, 2, 2, 433, 128, 3, 2, 2, 2, 434, 435, 7, 50, 2, 2, 435, 437, 9, 6, 2, 2, 436, 438, 5, 145, 73, 2, 437, 436, 3, 2, 2, 2, 438, 439, 3, 2, 2, 2, 439, 437, 3, 2, 2, 2, 439, 440, 3, 2, 2, 2, 440, 441, 3, 2, 2, 2, 441, 445, 7, 48, 2, 2, 442, 444, 5, 145, 73, 2, 443, 442, 3, 2, 2, 2, 444, 447, 3, 2, 2, 2, 445, 443, 3, 2, 2, 2, 445, 446, 3, 2, 2, 2, 446, 449, 3, 2, 2, 2, 447, 445, 3, 2, 2, 2, 448, 450, 5, 133, 67, 2, 449, 448, 3, 2, 2, 2, 449, 450, 3, 2, 2, 2, 450, 472, 3, 2, 2, 2, 451, 452, 7, 50, 2, 2, 452, 453, 9, 6, 2, 2, 453, 455, 7, 48, 2, 2, 454, 456, 5, 145, 73, 2, 455, 454, 3, 2, 2, 2, 456, 457, 3, 2, 2, 2, 457, 455, 3, 2, 2, 2, 457, 458, 3, 2, 2, 2, 458, 460, 3, 2, 2, 2, 459, 461, 5, 133, 67, 2, 460, 459, 3, 2, 2, 2, 460, 461, 3, 2, 2, 2, 461, 472, 3, 2, 2, 2, 462, 463, 7, 50, 2, 2, 463, 465, 9, 6, 2, 2, 464, 466, 5, 145, 73, 2, 465, 464, 3, 2, 2, 2, 466, 467, 3, 2, 2, 2, 467, 465, 3, 2, 2, 2, 467, 468, 3, 2, 2, 2, 468, 469, 3, 2, 2, 2, 469, 470, 5, 133, 67, 2, 470, 472, 3, 2, 2, 2, 471, 434, 3, 2, 2, 2, 471, 451, 3, 2, 2, 2, 471, 462, 3, 2, 2, 2, 472, 130, 3, 2, 2, 2, 473, 475, 9, 7, 2, 2, 474, 476, 9, 8, 2, 2, 475, 474, 3, 2, 2, 2, 475, 476, 3, 2, 2, 2, 476, 478, 3, 2, 2, 2, 477, 479, 5, 143, 72, 2, 478, 477, 3, 2, 2, 2, 479, 480, 3, 2, 2, 2, 480, 478, 3, 2, 2, 2, 480, 481, 3, 2, 2, 2, 481, 132, 3, 2, 2, 2, 482, 484, 9, 9, 2, 2, 483, 485, 9, 8, 2, 2, 484, 483, 3, 2, 2, 2, 484, 485, 3, 2, 2, 2, 485, 487, 3, 2, 2, 2, 486, 488, 5, 143, 72, 2, 487, 486, 3, 2, 2, 2, 488, 489, 3, 2, 2, 2, 489, 487, 3, 2, 2, 2, 489, 490, 3, 2, 2, 2, 490, 134, 3, 2, 2, 2, 491, 492, 7, 94, 2, 2, 492, 502, 9, 10, 2, 2, 493, 495, 7, 94, 2, 2, 494, 496, 7, 15, 2, 2, 495, 494, 3, 2, 2, 2, 495, 496, 3, 2, 2, 2, 496, 497, 3, 2, 2, 2, 497, 502, 7, 12, 2, 2, 498, 502, 5, 137, 69, 2, 499, 502, 5, 139, 70, 2, 500, 502, 5, 141, 71, 2, 501, 491, 3, 2, 2, 2, 501, 493, 3, 2, 2, 2, 501, 498, 3, 2, 2, 2, 501, 499, 3, 2, 2, 2, 501, 500, 3, 2, 2, 2, 502, 136, 3, 2, 2, 2, 503, 504, 7, 94, 2, 2, 504, 515, 5, 143, 72, 2, 505, 506, 7, 94, 2, 2, 506, 507, 5, 143, 72, 2, 507, 508, 5, 143, 72, 2, 508, 515, 3, 2, 2, 2, 509, 510, 7, 94, 2, 2, 510, 511, 9, 11, 2, 2, 511, 512, 5, 143, 72, 2, 512, 513, 5, 143, 72, 2, 513, 515, 3, 2, 2, 2, 514, 503, 3, 2, 2, 2, 514, 505, 3, 2, 2, 2, 514, 509, 3, 2, 2, 2, 515, 138, 3, 2, 2, 2, 516, 517, 7, 94, 2, 2, 517, 518, 7, 122, 2, 2, 518, 519, 5, 145, 73, 2, 519, 520, 5, 145, 73, 2, 520, 140, 3, 2, 2, 2, 521, 522, 7, 94, 2, 2, 522, 523, 7, 119, 2, 2, 523, 524, 7, 125, 2, 2, 524, 526, 3, 2, 2, 2, 525, 527, 5, 145, 73, 2, 526, 525, 3, 2, 2, 2, 527, 528, 3, 2, 2, 2, 528, 526, 3, 2, 2, 2, 528, 529, 3, 2, 2, 2, 529, 530, 3, 2, 2, 2, 530, 531, 7, 127, 2, 2, 531, 142, 3, 2, 2, 2, 532, 533, 9, 12, 2, 2, 533, 144, 3, 2, 2, 2, 534, 535, 9, 13, 2, 2, 535, 146, 3, 2, 2, 2, 536, 537, 7, 47, 2, 2, 537, 538, 7, 47, 2, 2, 538, 539, 7, 93, 2, 2, 539, 540, 3, 2, 2, 2, 540, 541, 5, 121, 61, 2, 541, 542, 7, 95, 2, 2, 542, 543, 3, 2, 2, 2, 543, 544, 8, 74, 2, 2, 544, 148, 3, 2, 2, 2, 545, 546, 7, 47, 2, 2, 546, 547, 7, 47, 2, 2, 547, 577, 3, 2, 2, 2, 548, 578, 3, 2, 2, 2, 549, 553, 7, 93, 2, 2, 550, 552, 7, 63, 2, 2, 551, 550, 3, 2, 2, 2, 552, 555, 3, 2, 2, 2, 553, 551, 3, 2, 2, 2, 553, 554, 3, 2, 2, 2, 554, 578, 3, 2, 2, 2, 555, 553, 3, 2, 2, 2, 556, 560, 7, 93, 2, 2, 557, 559, 7, 63, 2, 2, 558, 557, 3, 2, 2, 2, 559, 562, 3, 2, 2, 2, 560, 558, 3, 2, 2, 2, 560, 561, 3, 2, 2, 2, 561, 563, 3, 2, 2, 2, 562, 560, 3, 2, 2, 2, 563, 567, 10, 14, 2, 2, 564, 566, 10, 15, 2, 2, 565, 564, 3, 2, 2, 2, 566, 569, 3, 2, 2, 2, 567, 565, 3, 2, 2, 2, 567, 568, 3, 2, 2, 2, 568, 578, 3, 2, 2, 2, 569, 567, 3, 2, 2, 2, 570, 574, 10, 16, 2, 2, 571, 573, 10, 15, 2, 2, 572, 571, 3, 2, 2, 2, 573, 576, 3, 2, 2, 2, 574, 572, 3, 2, 2, 2, 574, 575, 3, 2, 2, 2, 575, 578, 3, 2, 2, 2, 576, 574, 3, 2, 2, 2, 577, 548, 3, 2, 2, 2, 577, 549, 3, 2, 2, 2, 577, 556, 3, 2, 2, 2, 577, 570, 3, 2, 2, 2, 578, 582, 3, 2, 2, 2, 579, 580, 7, 15, 2, 2, 580, 583, 7, 12, 2, 2, 581, 583, 9, 17, 2, 2, 582, 579, 3, 2, 2, 2, 582, 581, 3, 2, 2, 2, 583, 584, 3, 2, 2, 2, 584, 585, 8, 75, 2, 2, 585, 150, 3, 2, 2, 2, 586, 588, 9, 18, 2, 2, 587, 586, 3, 2, 2, 2, 588, 589, 3, 2, 2, 2, 589, 587, 3, 2, 2, 2, 589, 590, 3, 2, 2, 2, 590, 591, 3, 2, 2, 2, 591, 592, 8, 76, 3, 2, 592, 152, 3, 2, 2, 2, 593, 594, 7, 37, 2, 2, 594, 598, 7, 35, 2, 2, 595, 597, 10, 15, 2, 2, 596, 595, 3, 2, 2, 2, 597, 600, 3, 2, 2, 2, 598, 596, 3, 2, 2, 2, 598, 599, 3, 2, 2, 2, 599, 601, 3, 2, 2, 2, 600, 598, 3, 2, 2, 2, 601, 602, 8, 77, 2, 2, 602, 154, 3, 2, 2, 2, 42, 2, 348, 354, 356, 364, 366, 383, 387, 392, 399, 404, 410, 414, 420, 423, 428, 432, 439, 445, 449, 457, 460, 467, 471, 475, 480, 484, 489, 495, 501, 514, 528, 553, 560, 567, 574, 577, 582, 589, 598, 4, 2, 3, 2, 8, 2, 2] --------------------------------------------------------------------------------