├── scripts └── compile-antlr.sh ├── languages ├── README.md ├── define │ ├── Define.tokens │ ├── DefineLexer.tokens │ ├── define_base_visitor.go │ ├── define_visitor.go │ ├── Define.interp │ ├── define_listener.go │ ├── define_base_listener.go │ ├── DefineLexer.interp │ ├── define_lexer.go │ └── define_parser.go ├── code │ ├── Code.tokens │ ├── CodeLexer.tokens │ ├── code_base_visitor.go │ ├── code_visitor.go │ ├── code_listener.go │ ├── Code.interp │ ├── code_base_listener.go │ ├── CodeLexer.interp │ └── code_lexer.go ├── Define.g4 └── Code.g4 ├── .gitignore ├── examples ├── helloworld.code └── mu.define ├── parser ├── template │ ├── unsafe.go │ ├── LICENSE │ └── template.go ├── code │ ├── code_app.go │ └── code_app_listener.go └── define │ ├── define_app.go │ └── define_app_listener.go ├── README.md ├── model ├── define_model.go └── model.go ├── docs └── model.md ├── LICENSE ├── main.go └── transform └── transform.go /scripts/compile-antlr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd languages 4 | 5 | antlr -Dlanguage=Go -visitor -listener Code.g4 -o code 6 | antlr -Dlanguage=Go -visitor -listener Define.g4 -o define 7 | -------------------------------------------------------------------------------- /languages/README.md: -------------------------------------------------------------------------------- 1 | # Architecture Design 2 | 3 | Steps: 4 | 5 | 1. "Code" DSL Code to AST Code (or Code Model) 6 | 2. "Define" DSL to Define Model 7 | 3. Transform "Code" DSL to "Define" Code 8 | 4. Run Language 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | .idea 14 | test/ 15 | code.json -------------------------------------------------------------------------------- /examples/helloworld.code: -------------------------------------------------------------------------------- 1 | print("aa") 2 | print(222) 3 | 4 | func show() { 5 | print("bbb") 6 | var b = 1 7 | print(b) 8 | } 9 | 10 | show() 11 | 12 | var a = "5" 13 | print(a) 14 | 15 | show() 16 | 17 | func hello() { 18 | print("world") 19 | } 20 | hello() 21 | 22 | func loopDemo() { 23 | var n = 1 24 | for (n < 5) { 25 | n = n * 2 26 | print(n) 27 | } 28 | } -------------------------------------------------------------------------------- /parser/template/unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | package template 3 | 4 | import ( 5 | "reflect" 6 | "unsafe" 7 | ) 8 | 9 | func unsafeBytes2String(b []byte) string { 10 | return *(*string)(unsafe.Pointer(&b)) 11 | } 12 | 13 | func unsafeString2Bytes(s string) []byte { 14 | sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) 15 | bh := reflect.SliceHeader{ 16 | Data: sh.Data, 17 | Len: sh.Len, 18 | Cap: sh.Len, 19 | } 20 | return *(*[]byte)(unsafe.Pointer(&bh)) 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | > Code as Code 4 | 5 | ## Setup 6 | 7 | 8 | 1. compiler antlr grammar to .go files 9 | 10 | ``` 11 | ./scripts/compile-antlr.sh 12 | ``` 13 | 14 | 2. run code demo 15 | 16 | ``` 17 | go run main.go 18 | ``` 19 | 20 | License 21 | --- 22 | 23 | [![Phodal's Idea](http://brand.phodal.com/shields/idea-small.svg)](http://ideas.phodal.com/) 24 | 25 | @ 2019 A [Phodal Huang](https://www.phodal.com)'s [Idea](http://github.com/phodal/ideas). This code is distributed under the MIT license. See `LICENSE` in this directory. 26 | -------------------------------------------------------------------------------- /model/define_model.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type DefineInformation struct { 4 | DefineTemplates map[string]string 5 | SymbolsMap map[string]string 6 | DefineModules []DefineModule 7 | } 8 | 9 | type DefineModule struct { 10 | ModuleName string 11 | ModuleFunctions []ModuleFunction 12 | } 13 | 14 | type ModuleFunction struct { 15 | FunctionName string 16 | EqualName string 17 | ImportName string 18 | } 19 | 20 | type CodeModel struct { 21 | FunctionCalls []CodeFunctionCall 22 | Functions []CodeFunction 23 | Variables map[string]string 24 | } 25 | -------------------------------------------------------------------------------- /languages/define/Define.tokens: -------------------------------------------------------------------------------- 1 | SYMBOL_TEXT=1 2 | DEFINE=2 3 | DEFAULT_SYMBOL=3 4 | DEFAULT_TEMPLATE=4 5 | MODULE=5 6 | IMPORT=6 7 | EQUAL=7 8 | IDENTIFIER=8 9 | LPAREN=9 10 | RPAREN=10 11 | LBRACE=11 12 | RBRACE=12 13 | LBRACK=13 14 | RBRACK=14 15 | SEMI=15 16 | COMMA=16 17 | DOT=17 18 | COLON=18 19 | WS=19 20 | COMMENT=20 21 | LINE_COMMENT=21 22 | STRING_LITERAL=22 23 | 'symbol'=1 24 | 'define'=2 25 | 'defaultSymbol'=3 26 | 'defaultTemplate'=4 27 | 'module'=5 28 | 'import'=6 29 | 'equal'=7 30 | '('=9 31 | ')'=10 32 | '{'=11 33 | '}'=12 34 | '['=13 35 | ']'=14 36 | ';'=15 37 | ','=16 38 | '.'=17 39 | ':'=18 40 | -------------------------------------------------------------------------------- /languages/define/DefineLexer.tokens: -------------------------------------------------------------------------------- 1 | SYMBOL_TEXT=1 2 | DEFINE=2 3 | DEFAULT_SYMBOL=3 4 | DEFAULT_TEMPLATE=4 5 | MODULE=5 6 | IMPORT=6 7 | EQUAL=7 8 | IDENTIFIER=8 9 | LPAREN=9 10 | RPAREN=10 11 | LBRACE=11 12 | RBRACE=12 13 | LBRACK=13 14 | RBRACK=14 15 | SEMI=15 16 | COMMA=16 17 | DOT=17 18 | COLON=18 19 | WS=19 20 | COMMENT=20 21 | LINE_COMMENT=21 22 | STRING_LITERAL=22 23 | 'symbol'=1 24 | 'define'=2 25 | 'defaultSymbol'=3 26 | 'defaultTemplate'=4 27 | 'module'=5 28 | 'import'=6 29 | 'equal'=7 30 | '('=9 31 | ')'=10 32 | '{'=11 33 | '}'=12 34 | '['=13 35 | ']'=14 36 | ';'=15 37 | ','=16 38 | '.'=17 39 | ':'=18 40 | -------------------------------------------------------------------------------- /examples/mu.define: -------------------------------------------------------------------------------- 1 | symbol FUNCTION "func" 2 | symbol METHOD_START "{" 3 | symbol METHOD_END "}" 4 | symbol PARAMETER_START "(" 5 | symbol PARAMETER_END ")" 6 | symbol PARAMETER_SPLIT "," 7 | symbol MAIN "main" 8 | symbol FOR "for" 9 | symbol SPACE "" 10 | 11 | define entry_point { 12 | defaultTemplate(code) { 13 | FUNCTION "main" PARAMETER_START PARAMETER_END SPACE METHOD_START code METHOD_END 14 | } 15 | } 16 | 17 | /* 18 | define loop { 19 | defaultTemplate(condition) { 20 | FOR "loop" 21 | } 22 | } 23 | */ 24 | 25 | module sys { 26 | print { 27 | import "fmt" 28 | equal "fmt.Println" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /docs/model.md: -------------------------------------------------------------------------------- 1 | # Code Model 2 | 3 | Core: Function, Parameter List, Return Type, Refs 4 | 5 | Function (Ref) -> File -> Dir 6 | 7 | Function (mapping) <-> Data Struct 8 | 9 | Function (mapping) <-> Member 10 | 11 | ## Model 12 | 13 | Entity: File 14 | VO: Full Name 15 | 16 | Entity: Member 17 | VO: Name 18 | VO: Line Number 19 | VO: Data Struct ID 20 | VO: File ID 21 | VO: NameSpace / Package 22 | VOs: Position 23 | VO: Start 24 | VO: End 25 | 26 | Entity: Data Struct 27 | VO: Member ID 28 | 29 | Entity: Commit 30 | VO: File ID 31 | 32 | Entity: Function 33 | VO: MemberId 34 | VOs: Parameter 35 | VO: Type 36 | VOs: Return Type 37 | VO: Type 38 | VOS: Refs 39 | VO: member ID 40 | -------------------------------------------------------------------------------- /parser/code/code_app.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import ( 4 | . "../../languages/code" 5 | . "../../model" 6 | "github.com/antlr/antlr4/runtime/Go/antlr" 7 | ) 8 | 9 | func NewCodeApp() *CodeApp { 10 | return &CodeApp{} 11 | } 12 | 13 | type CodeApp struct { 14 | } 15 | 16 | func (j *CodeApp) Start(path string) CodeModel { 17 | context := (*CodeApp)(nil).ProcessFile(path).CompilationUnit() 18 | listener := NewCodeAppListener() 19 | 20 | antlr.NewParseTreeWalker().Walk(listener, context) 21 | 22 | codeModel := listener.getCode() 23 | return codeModel 24 | } 25 | 26 | func (j *CodeApp) ProcessFile(path string) *CodeParser { 27 | is, _ := antlr.NewFileStream(path) 28 | lexer := NewCodeLexer(is) 29 | stream := antlr.NewCommonTokenStream(lexer, 0); 30 | parser := NewCodeParser(stream) 31 | return parser 32 | } 33 | -------------------------------------------------------------------------------- /languages/code/Code.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 | FOR=25 26 | VAR=26 27 | PACKAGE=27 28 | IMPORT=28 29 | DATA_STRUCT=29 30 | MEMBER=30 31 | FUNCTION=31 32 | IDENTIFIER=32 33 | WS=33 34 | COMMENT=34 35 | LINE_COMMENT=35 36 | STRING_LITERAL=36 37 | DECIMAL_LITERAL=37 38 | '('=1 39 | ')'=2 40 | '{'=3 41 | '}'=4 42 | '<='=5 43 | '>='=6 44 | '>'=7 45 | '<'=8 46 | '*'=9 47 | '/'=10 48 | '%'=11 49 | '='=12 50 | '+='=13 51 | '-='=14 52 | '*='=15 53 | '/='=16 54 | '&='=17 55 | '|='=18 56 | '^='=19 57 | '>>='=20 58 | '>>>='=21 59 | '<<='=22 60 | '%='=23 61 | ','=24 62 | 'for'=25 63 | 'var'=26 64 | 'package'=27 65 | 'import'=28 66 | 'struct'=29 67 | 'member'=30 68 | 'func'=31 69 | -------------------------------------------------------------------------------- /languages/code/CodeLexer.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 | FOR=25 26 | VAR=26 27 | PACKAGE=27 28 | IMPORT=28 29 | DATA_STRUCT=29 30 | MEMBER=30 31 | FUNCTION=31 32 | IDENTIFIER=32 33 | WS=33 34 | COMMENT=34 35 | LINE_COMMENT=35 36 | STRING_LITERAL=36 37 | DECIMAL_LITERAL=37 38 | '('=1 39 | ')'=2 40 | '{'=3 41 | '}'=4 42 | '<='=5 43 | '>='=6 44 | '>'=7 45 | '<'=8 46 | '*'=9 47 | '/'=10 48 | '%'=11 49 | '='=12 50 | '+='=13 51 | '-='=14 52 | '*='=15 53 | '/='=16 54 | '&='=17 55 | '|='=18 56 | '^='=19 57 | '>>='=20 58 | '>>>='=21 59 | '<<='=22 60 | '%='=23 61 | ','=24 62 | 'for'=25 63 | 'var'=26 64 | 'package'=27 65 | 'import'=28 66 | 'struct'=29 67 | 'member'=30 68 | 'func'=31 69 | -------------------------------------------------------------------------------- /parser/define/define_app.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import ( 4 | . "../../languages/define" 5 | . "../../model" 6 | "github.com/antlr/antlr4/runtime/Go/antlr" 7 | ) 8 | 9 | var startTemplateSymbol string 10 | var endTemplateSymbol string 11 | 12 | func NewDefineApp(startSymbol string, endSymbol string) *DefineApp { 13 | startTemplateSymbol = startSymbol 14 | endTemplateSymbol = endSymbol 15 | return &DefineApp{} 16 | } 17 | 18 | type DefineApp struct { 19 | } 20 | 21 | func (j *DefineApp) Start(path string) DefineInformation { 22 | context := (*DefineApp)(nil).ProcessFile(path).CompilationUnit() 23 | listener := NewDefineAppListener(startTemplateSymbol, endTemplateSymbol) 24 | 25 | antlr.NewParseTreeWalker().Walk(listener, context) 26 | 27 | information := listener.getDefineInformation() 28 | return information 29 | } 30 | 31 | func (j *DefineApp) ProcessFile(path string) *DefineParser { 32 | is, _ := antlr.NewFileStream(path) 33 | lexer := NewDefineLexer(is) 34 | stream := antlr.NewCommonTokenStream(lexer, 0); 35 | parser := NewDefineParser(stream) 36 | return parser 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Phodal Huang 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 | -------------------------------------------------------------------------------- /parser/template/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Aliaksandr Valialkin 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 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | . "./parser/code" 5 | . "./parser/define" 6 | . "./transform" 7 | "encoding/json" 8 | "fmt" 9 | "io/ioutil" 10 | "os/exec" 11 | ) 12 | 13 | var transform Transform 14 | 15 | func main() { 16 | transform = *&Transform{} 17 | 18 | app := NewCodeApp() 19 | codeModel := app.Start("examples/helloworld.code") 20 | 21 | bytes, _ := json.MarshalIndent(codeModel, "", "\t") 22 | _ = ioutil.WriteFile("code.json", bytes, 0644) 23 | 24 | startTemplateSymbol := "{{" 25 | endTemplateSymbol := "}}" 26 | defineApp := NewDefineApp(startTemplateSymbol, endTemplateSymbol) 27 | info := defineApp.Start("examples/mu.define") 28 | 29 | code := "" 30 | 31 | code = code + transform.TransformMainCode(codeModel, info, startTemplateSymbol, endTemplateSymbol) 32 | code = code + transform.TransformNormalCode(codeModel, info) 33 | 34 | runCode(code) 35 | } 36 | 37 | func runCode(codeWithImport string) { 38 | fileName := "test/main/main.go" 39 | _ = ioutil.WriteFile(fileName, []byte(codeWithImport), 0644) 40 | cmd := exec.Command("go", "run", fileName) 41 | stdout, err := cmd.StdoutPipe() 42 | _ = cmd.Start() 43 | content, err := ioutil.ReadAll(stdout) 44 | if err != nil { 45 | fmt.Println(err) 46 | } 47 | fmt.Println(string(content)) 48 | } 49 | 50 | -------------------------------------------------------------------------------- /model/model.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type CodeFile struct { 4 | FileId string 5 | FullName string 6 | } 7 | 8 | type CodePosition struct { 9 | StartLine int 10 | StartLineColumn int 11 | StopLine int 12 | StopLineColumn int 13 | } 14 | 15 | type CodeMember struct { 16 | MemberId string 17 | Name string 18 | DataStructId string 19 | FileId string 20 | PackageName string // namespace 21 | } 22 | 23 | type CodeDataStruct struct { 24 | DataStructId string 25 | Name string 26 | MemberIds []string 27 | } 28 | 29 | type CodeCommit struct { 30 | FileId string 31 | } 32 | 33 | type CodeType struct { 34 | Type string 35 | } 36 | 37 | type MemberId struct { 38 | Id string 39 | } 40 | 41 | // define function 42 | type CodeFunction struct { 43 | MemberId string 44 | Parameters []CodeType 45 | ReturnTypes []CodeType 46 | References []MemberId 47 | CodeFunctionCalls []CodeFunctionCall 48 | Variables map[string]string 49 | Expression []Expression 50 | Position CodePosition 51 | } 52 | 53 | type Expression struct { 54 | Expressions []Expression 55 | BlockStatement []string 56 | BlockCondition string 57 | Position CodePosition 58 | } 59 | 60 | type CodeFunctionCall struct { 61 | MemberId string 62 | ReturnVars []CodeType 63 | Parameters []CodeParameter 64 | } 65 | 66 | type CodeParameter struct { 67 | Key CodeType 68 | Value CodeParameterValue 69 | } 70 | 71 | type CodeParameterValue struct { 72 | Value string 73 | } 74 | 75 | func CreateFunctionCall(functionName string, parameters []CodeParameter) CodeFunctionCall { 76 | var call CodeFunctionCall 77 | switch functionName { 78 | case "print": 79 | call = *&CodeFunctionCall{ 80 | MemberId: functionName, 81 | ReturnVars: nil, 82 | Parameters: parameters, 83 | } 84 | default: 85 | call = *&CodeFunctionCall{ 86 | MemberId: functionName, 87 | ReturnVars: nil, 88 | Parameters: parameters, 89 | } 90 | } 91 | 92 | return call 93 | } 94 | 95 | func CreateFunction(name string) CodeFunction { 96 | function := *&CodeFunction{ 97 | MemberId: name, 98 | Parameters: nil, 99 | ReturnTypes: nil, 100 | References: nil, 101 | CodeFunctionCalls: nil, 102 | Variables: make(map[string]string), 103 | } 104 | 105 | return function 106 | } 107 | -------------------------------------------------------------------------------- /languages/define/define_base_visitor.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Define 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | type BaseDefineVisitor struct { 8 | *antlr.BaseParseTreeVisitor 9 | } 10 | 11 | func (v *BaseDefineVisitor) VisitCompilationUnit(ctx *CompilationUnitContext) interface{} { 12 | return v.VisitChildren(ctx) 13 | } 14 | 15 | func (v *BaseDefineVisitor) VisitSymbolDeclaration(ctx *SymbolDeclarationContext) interface{} { 16 | return v.VisitChildren(ctx) 17 | } 18 | 19 | func (v *BaseDefineVisitor) VisitNormalDeclarations(ctx *NormalDeclarationsContext) interface{} { 20 | return v.VisitChildren(ctx) 21 | } 22 | 23 | func (v *BaseDefineVisitor) VisitDefineDeclaration(ctx *DefineDeclarationContext) interface{} { 24 | return v.VisitChildren(ctx) 25 | } 26 | 27 | func (v *BaseDefineVisitor) VisitDefineExpress(ctx *DefineExpressContext) interface{} { 28 | return v.VisitChildren(ctx) 29 | } 30 | 31 | func (v *BaseDefineVisitor) VisitDefineAttribute(ctx *DefineAttributeContext) interface{} { 32 | return v.VisitChildren(ctx) 33 | } 34 | 35 | func (v *BaseDefineVisitor) VisitDefineTemplate(ctx *DefineTemplateContext) interface{} { 36 | return v.VisitChildren(ctx) 37 | } 38 | 39 | func (v *BaseDefineVisitor) VisitSymbolKey(ctx *SymbolKeyContext) interface{} { 40 | return v.VisitChildren(ctx) 41 | } 42 | 43 | func (v *BaseDefineVisitor) VisitSymbolValue(ctx *SymbolValueContext) interface{} { 44 | return v.VisitChildren(ctx) 45 | } 46 | 47 | func (v *BaseDefineVisitor) VisitDefineBody(ctx *DefineBodyContext) interface{} { 48 | return v.VisitChildren(ctx) 49 | } 50 | 51 | func (v *BaseDefineVisitor) VisitTemplateData(ctx *TemplateDataContext) interface{} { 52 | return v.VisitChildren(ctx) 53 | } 54 | 55 | func (v *BaseDefineVisitor) VisitSystemDeclaration(ctx *SystemDeclarationContext) interface{} { 56 | return v.VisitChildren(ctx) 57 | } 58 | 59 | func (v *BaseDefineVisitor) VisitDefineKey(ctx *DefineKeyContext) interface{} { 60 | return v.VisitChildren(ctx) 61 | } 62 | 63 | func (v *BaseDefineVisitor) VisitDefineValue(ctx *DefineValueContext) interface{} { 64 | return v.VisitChildren(ctx) 65 | } 66 | 67 | func (v *BaseDefineVisitor) VisitModuleDeclaration(ctx *ModuleDeclarationContext) interface{} { 68 | return v.VisitChildren(ctx) 69 | } 70 | 71 | func (v *BaseDefineVisitor) VisitModuleDefines(ctx *ModuleDefinesContext) interface{} { 72 | return v.VisitChildren(ctx) 73 | } 74 | 75 | func (v *BaseDefineVisitor) VisitModuleAttribute(ctx *ModuleAttributeContext) interface{} { 76 | return v.VisitChildren(ctx) 77 | } 78 | -------------------------------------------------------------------------------- /languages/define/define_visitor.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Define 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // A complete Visitor for a parse tree produced by DefineParser. 8 | type DefineVisitor interface { 9 | antlr.ParseTreeVisitor 10 | 11 | // Visit a parse tree produced by DefineParser#compilationUnit. 12 | VisitCompilationUnit(ctx *CompilationUnitContext) interface{} 13 | 14 | // Visit a parse tree produced by DefineParser#symbolDeclaration. 15 | VisitSymbolDeclaration(ctx *SymbolDeclarationContext) interface{} 16 | 17 | // Visit a parse tree produced by DefineParser#normalDeclarations. 18 | VisitNormalDeclarations(ctx *NormalDeclarationsContext) interface{} 19 | 20 | // Visit a parse tree produced by DefineParser#defineDeclaration. 21 | VisitDefineDeclaration(ctx *DefineDeclarationContext) interface{} 22 | 23 | // Visit a parse tree produced by DefineParser#defineExpress. 24 | VisitDefineExpress(ctx *DefineExpressContext) interface{} 25 | 26 | // Visit a parse tree produced by DefineParser#defineAttribute. 27 | VisitDefineAttribute(ctx *DefineAttributeContext) interface{} 28 | 29 | // Visit a parse tree produced by DefineParser#defineTemplate. 30 | VisitDefineTemplate(ctx *DefineTemplateContext) interface{} 31 | 32 | // Visit a parse tree produced by DefineParser#symbolKey. 33 | VisitSymbolKey(ctx *SymbolKeyContext) interface{} 34 | 35 | // Visit a parse tree produced by DefineParser#symbolValue. 36 | VisitSymbolValue(ctx *SymbolValueContext) interface{} 37 | 38 | // Visit a parse tree produced by DefineParser#defineBody. 39 | VisitDefineBody(ctx *DefineBodyContext) interface{} 40 | 41 | // Visit a parse tree produced by DefineParser#templateData. 42 | VisitTemplateData(ctx *TemplateDataContext) interface{} 43 | 44 | // Visit a parse tree produced by DefineParser#systemDeclaration. 45 | VisitSystemDeclaration(ctx *SystemDeclarationContext) interface{} 46 | 47 | // Visit a parse tree produced by DefineParser#defineKey. 48 | VisitDefineKey(ctx *DefineKeyContext) interface{} 49 | 50 | // Visit a parse tree produced by DefineParser#defineValue. 51 | VisitDefineValue(ctx *DefineValueContext) interface{} 52 | 53 | // Visit a parse tree produced by DefineParser#moduleDeclaration. 54 | VisitModuleDeclaration(ctx *ModuleDeclarationContext) interface{} 55 | 56 | // Visit a parse tree produced by DefineParser#moduleDefines. 57 | VisitModuleDefines(ctx *ModuleDefinesContext) interface{} 58 | 59 | // Visit a parse tree produced by DefineParser#moduleAttribute. 60 | VisitModuleAttribute(ctx *ModuleAttributeContext) interface{} 61 | } 62 | -------------------------------------------------------------------------------- /languages/Define.g4: -------------------------------------------------------------------------------- 1 | grammar Define; 2 | 3 | compilationUnit 4 | : symbolDeclaration* defineDeclaration? normalDeclarations* EOF 5 | ; 6 | 7 | symbolDeclaration 8 | : SYMBOL_TEXT IDENTIFIER STRING_LITERAL 9 | ; 10 | 11 | normalDeclarations 12 | : systemDeclaration 13 | | moduleDeclaration 14 | ; 15 | 16 | SYMBOL_TEXT: 'symbol'; 17 | //SPECIAL_SYMBOL: SYMBOLS; 18 | 19 | //Define 20 | 21 | defineDeclaration 22 | : DEFINE defineKey LBRACE defineExpress* RBRACE 23 | ; 24 | 25 | 26 | defineExpress 27 | : defineAttribute 28 | | defineTemplate 29 | ; 30 | 31 | defineAttribute: DEFAULT_SYMBOL COLON symbolKey symbolValue; 32 | 33 | defineTemplate: DEFAULT_TEMPLATE LPAREN IDENTIFIER RPAREN LBRACE defineBody RBRACE; 34 | 35 | symbolKey: IDENTIFIER; 36 | symbolValue: IDENTIFIER; 37 | defineBody 38 | : symbolKey STRING_LITERAL symbolKey* templateData symbolKey 39 | ; 40 | 41 | DEFINE: 'define'; 42 | DEFAULT_SYMBOL: 'defaultSymbol'; 43 | DEFAULT_TEMPLATE: 'defaultTemplate'; 44 | 45 | templateData: IDENTIFIER; 46 | 47 | 48 | // 49 | 50 | systemDeclaration 51 | : defineKey ':' defineValue 52 | ; 53 | 54 | defineKey: IDENTIFIER; 55 | defineValue: IDENTIFIER; 56 | 57 | // 58 | 59 | moduleDeclaration 60 | : MODULE IDENTIFIER LBRACE moduleDefines* RBRACE 61 | ; 62 | 63 | moduleDefines 64 | : IDENTIFIER LBRACE moduleAttribute* RBRACE 65 | ; 66 | 67 | moduleAttribute 68 | : IMPORT STRING_LITERAL 69 | | EQUAL STRING_LITERAL 70 | ; 71 | 72 | MODULE: 'module'; 73 | IMPORT: 'import'; 74 | EQUAL: 'equal'; 75 | 76 | 77 | IDENTIFIER: Letter LetterOrDigit*; 78 | 79 | // Separators 80 | 81 | LPAREN: '('; 82 | RPAREN: ')'; 83 | LBRACE: '{'; 84 | RBRACE: '}'; 85 | LBRACK: '['; 86 | RBRACK: ']'; 87 | SEMI: ';'; 88 | COMMA: ','; 89 | DOT: '.'; 90 | COLON: ':'; 91 | 92 | // Whitespace and comments 93 | 94 | WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); 95 | COMMENT: '/*' .*? '*/' -> channel(HIDDEN); 96 | LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); 97 | 98 | STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; 99 | 100 | 101 | fragment HexDigit 102 | : [0-9a-fA-F] 103 | ; 104 | 105 | fragment EscapeSequence 106 | : '\\' [btnfr"'\\] 107 | | '\\' ([0-3]? [0-7])? [0-7] 108 | | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit 109 | ; 110 | 111 | fragment LetterOrDigit 112 | : Letter 113 | | [0-9] 114 | ; 115 | 116 | //SYMBOLS 117 | // : '{' | '}' | '$' | ')' | '(' | '[' | ']' 118 | // ; 119 | 120 | fragment Letter 121 | : [a-zA-Z$_] // these are the "java letters" below 0x7F 122 | | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate 123 | | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF 124 | ; 125 | -------------------------------------------------------------------------------- /languages/code/code_base_visitor.go: -------------------------------------------------------------------------------- 1 | // Code generated from Code.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Code 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | type BaseCodeVisitor struct { 8 | *antlr.BaseParseTreeVisitor 9 | } 10 | 11 | func (v *BaseCodeVisitor) VisitCompilationUnit(ctx *CompilationUnitContext) interface{} { 12 | return v.VisitChildren(ctx) 13 | } 14 | 15 | func (v *BaseCodeVisitor) VisitPackageDeclaration(ctx *PackageDeclarationContext) interface{} { 16 | return v.VisitChildren(ctx) 17 | } 18 | 19 | func (v *BaseCodeVisitor) VisitImportDeclaration(ctx *ImportDeclarationContext) interface{} { 20 | return v.VisitChildren(ctx) 21 | } 22 | 23 | func (v *BaseCodeVisitor) VisitTypeDeclaration(ctx *TypeDeclarationContext) interface{} { 24 | return v.VisitChildren(ctx) 25 | } 26 | 27 | func (v *BaseCodeVisitor) VisitFunctionDeclaration(ctx *FunctionDeclarationContext) interface{} { 28 | return v.VisitChildren(ctx) 29 | } 30 | 31 | func (v *BaseCodeVisitor) VisitFunctionBody(ctx *FunctionBodyContext) interface{} { 32 | return v.VisitChildren(ctx) 33 | } 34 | 35 | func (v *BaseCodeVisitor) VisitPrimary(ctx *PrimaryContext) interface{} { 36 | return v.VisitChildren(ctx) 37 | } 38 | 39 | func (v *BaseCodeVisitor) VisitExpression(ctx *ExpressionContext) interface{} { 40 | return v.VisitChildren(ctx) 41 | } 42 | 43 | func (v *BaseCodeVisitor) VisitBlock(ctx *BlockContext) interface{} { 44 | return v.VisitChildren(ctx) 45 | } 46 | 47 | func (v *BaseCodeVisitor) VisitBlockStatement(ctx *BlockStatementContext) interface{} { 48 | return v.VisitChildren(ctx) 49 | } 50 | 51 | func (v *BaseCodeVisitor) VisitStatement(ctx *StatementContext) interface{} { 52 | return v.VisitChildren(ctx) 53 | } 54 | 55 | func (v *BaseCodeVisitor) VisitForControl(ctx *ForControlContext) interface{} { 56 | return v.VisitChildren(ctx) 57 | } 58 | 59 | func (v *BaseCodeVisitor) VisitLocalVariableDeclaration(ctx *LocalVariableDeclarationContext) interface{} { 60 | return v.VisitChildren(ctx) 61 | } 62 | 63 | func (v *BaseCodeVisitor) VisitVariableDeclarators(ctx *VariableDeclaratorsContext) interface{} { 64 | return v.VisitChildren(ctx) 65 | } 66 | 67 | func (v *BaseCodeVisitor) VisitVariableDeclarator(ctx *VariableDeclaratorContext) interface{} { 68 | return v.VisitChildren(ctx) 69 | } 70 | 71 | func (v *BaseCodeVisitor) VisitVariableDeclaratorId(ctx *VariableDeclaratorIdContext) interface{} { 72 | return v.VisitChildren(ctx) 73 | } 74 | 75 | func (v *BaseCodeVisitor) VisitVariableInitializer(ctx *VariableInitializerContext) interface{} { 76 | return v.VisitChildren(ctx) 77 | } 78 | 79 | func (v *BaseCodeVisitor) VisitMethodCallDeclaration(ctx *MethodCallDeclarationContext) interface{} { 80 | return v.VisitChildren(ctx) 81 | } 82 | 83 | func (v *BaseCodeVisitor) VisitParameter(ctx *ParameterContext) interface{} { 84 | return v.VisitChildren(ctx) 85 | } 86 | 87 | func (v *BaseCodeVisitor) VisitLiteral(ctx *LiteralContext) interface{} { 88 | return v.VisitChildren(ctx) 89 | } 90 | 91 | func (v *BaseCodeVisitor) VisitDataStructDeclaration(ctx *DataStructDeclarationContext) interface{} { 92 | return v.VisitChildren(ctx) 93 | } 94 | 95 | func (v *BaseCodeVisitor) VisitMemberDeclaration(ctx *MemberDeclarationContext) interface{} { 96 | return v.VisitChildren(ctx) 97 | } 98 | -------------------------------------------------------------------------------- /languages/code/code_visitor.go: -------------------------------------------------------------------------------- 1 | // Code generated from Code.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Code 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // A complete Visitor for a parse tree produced by CodeParser. 8 | type CodeVisitor interface { 9 | antlr.ParseTreeVisitor 10 | 11 | // Visit a parse tree produced by CodeParser#compilationUnit. 12 | VisitCompilationUnit(ctx *CompilationUnitContext) interface{} 13 | 14 | // Visit a parse tree produced by CodeParser#packageDeclaration. 15 | VisitPackageDeclaration(ctx *PackageDeclarationContext) interface{} 16 | 17 | // Visit a parse tree produced by CodeParser#importDeclaration. 18 | VisitImportDeclaration(ctx *ImportDeclarationContext) interface{} 19 | 20 | // Visit a parse tree produced by CodeParser#typeDeclaration. 21 | VisitTypeDeclaration(ctx *TypeDeclarationContext) interface{} 22 | 23 | // Visit a parse tree produced by CodeParser#functionDeclaration. 24 | VisitFunctionDeclaration(ctx *FunctionDeclarationContext) interface{} 25 | 26 | // Visit a parse tree produced by CodeParser#functionBody. 27 | VisitFunctionBody(ctx *FunctionBodyContext) interface{} 28 | 29 | // Visit a parse tree produced by CodeParser#primary. 30 | VisitPrimary(ctx *PrimaryContext) interface{} 31 | 32 | // Visit a parse tree produced by CodeParser#expression. 33 | VisitExpression(ctx *ExpressionContext) interface{} 34 | 35 | // Visit a parse tree produced by CodeParser#block. 36 | VisitBlock(ctx *BlockContext) interface{} 37 | 38 | // Visit a parse tree produced by CodeParser#blockStatement. 39 | VisitBlockStatement(ctx *BlockStatementContext) interface{} 40 | 41 | // Visit a parse tree produced by CodeParser#statement. 42 | VisitStatement(ctx *StatementContext) interface{} 43 | 44 | // Visit a parse tree produced by CodeParser#forControl. 45 | VisitForControl(ctx *ForControlContext) interface{} 46 | 47 | // Visit a parse tree produced by CodeParser#localVariableDeclaration. 48 | VisitLocalVariableDeclaration(ctx *LocalVariableDeclarationContext) interface{} 49 | 50 | // Visit a parse tree produced by CodeParser#variableDeclarators. 51 | VisitVariableDeclarators(ctx *VariableDeclaratorsContext) interface{} 52 | 53 | // Visit a parse tree produced by CodeParser#variableDeclarator. 54 | VisitVariableDeclarator(ctx *VariableDeclaratorContext) interface{} 55 | 56 | // Visit a parse tree produced by CodeParser#variableDeclaratorId. 57 | VisitVariableDeclaratorId(ctx *VariableDeclaratorIdContext) interface{} 58 | 59 | // Visit a parse tree produced by CodeParser#variableInitializer. 60 | VisitVariableInitializer(ctx *VariableInitializerContext) interface{} 61 | 62 | // Visit a parse tree produced by CodeParser#methodCallDeclaration. 63 | VisitMethodCallDeclaration(ctx *MethodCallDeclarationContext) interface{} 64 | 65 | // Visit a parse tree produced by CodeParser#parameter. 66 | VisitParameter(ctx *ParameterContext) interface{} 67 | 68 | // Visit a parse tree produced by CodeParser#literal. 69 | VisitLiteral(ctx *LiteralContext) interface{} 70 | 71 | // Visit a parse tree produced by CodeParser#dataStructDeclaration. 72 | VisitDataStructDeclaration(ctx *DataStructDeclarationContext) interface{} 73 | 74 | // Visit a parse tree produced by CodeParser#memberDeclaration. 75 | VisitMemberDeclaration(ctx *MemberDeclarationContext) interface{} 76 | } 77 | -------------------------------------------------------------------------------- /languages/Code.g4: -------------------------------------------------------------------------------- 1 | grammar Code; 2 | 3 | compilationUnit 4 | : packageDeclaration? importDeclaration* typeDeclaration* EOF 5 | ; 6 | 7 | packageDeclaration 8 | : PACKAGE IDENTIFIER 9 | ; 10 | 11 | importDeclaration 12 | : IMPORT IDENTIFIER 13 | ; 14 | 15 | typeDeclaration 16 | : dataStructDeclaration 17 | | memberDeclaration 18 | | functionDeclaration 19 | | expression 20 | ; 21 | 22 | functionDeclaration: FUNCTION IDENTIFIER '(' parameter? ')' '{' functionBody '}'; 23 | 24 | functionBody: expression (expression)*; 25 | 26 | primary: IDENTIFIER | DECIMAL_LITERAL | STRING_LITERAL; 27 | 28 | expression 29 | : primary 30 | | methodCallDeclaration 31 | | expression bop=('<=' | '>=' | '>' | '<') expression 32 | | expression bop=('*'|'/'|'%') expression 33 | | expression 34 | bop=('=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '>>=' | '>>>=' | '<<=' | '%=') 35 | expression 36 | | blockStatement 37 | ; 38 | 39 | 40 | block 41 | : '{' blockStatement* '}' 42 | ; 43 | 44 | blockStatement 45 | : localVariableDeclaration 46 | | statement 47 | ; 48 | 49 | statement 50 | : blockLabel=block 51 | | FOR '(' forControl ')' statement 52 | | methodCallDeclaration 53 | ; 54 | 55 | forControl: expression; 56 | 57 | FOR: 'for'; 58 | 59 | localVariableDeclaration 60 | : variableDeclarators 61 | ; 62 | 63 | variableDeclarators 64 | : VAR? variableDeclarator (',' variableDeclarator)* 65 | ; 66 | 67 | VAR: 'var'; 68 | 69 | variableDeclarator 70 | : variableDeclaratorId ('=' variableInitializer)? 71 | ; 72 | 73 | variableDeclaratorId 74 | : IDENTIFIER 75 | ; 76 | 77 | variableInitializer 78 | : expression 79 | ; 80 | 81 | methodCallDeclaration: IDENTIFIER '(' parameter* ')'; 82 | 83 | parameter 84 | : literal 85 | | IDENTIFIER 86 | ; 87 | 88 | literal 89 | : DECIMAL_LITERAL 90 | | STRING_LITERAL 91 | ; 92 | 93 | dataStructDeclaration: DATA_STRUCT IDENTIFIER; 94 | memberDeclaration: MEMBER IDENTIFIER; 95 | 96 | PACKAGE: 'package'; 97 | IMPORT: 'import'; 98 | DATA_STRUCT: 'struct'; 99 | MEMBER: 'member'; 100 | FUNCTION: 'func'; 101 | 102 | 103 | IDENTIFIER: Letter LetterOrDigit*; 104 | 105 | // Whitespace and comments 106 | 107 | WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); 108 | COMMENT: '/*' .*? '*/' -> channel(HIDDEN); 109 | LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); 110 | 111 | STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; 112 | 113 | 114 | DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; 115 | 116 | fragment Digits 117 | : [0-9] ([0-9_]* [0-9])? 118 | ; 119 | 120 | fragment HexDigit 121 | : [0-9a-fA-F] 122 | ; 123 | 124 | fragment EscapeSequence 125 | : '\\' [btnfr"'\\] 126 | | '\\' ([0-3]? [0-7])? [0-7] 127 | | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit 128 | ; 129 | 130 | fragment LetterOrDigit 131 | : Letter 132 | | [0-9] 133 | ; 134 | 135 | fragment Letter 136 | : [a-zA-Z$_] // these are the "java letters" below 0x7F 137 | | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate 138 | | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF 139 | ; 140 | -------------------------------------------------------------------------------- /transform/transform.go: -------------------------------------------------------------------------------- 1 | package transform 2 | 3 | import ( 4 | . "../model" 5 | codetemplate "../parser/template" 6 | "fmt" 7 | "strings" 8 | ) 9 | 10 | var imports = make(map[string]string) 11 | 12 | type Transform struct { 13 | } 14 | 15 | func (transform Transform) BuildFunctionCall(call CodeFunctionCall, info DefineInformation, model CodeModel) string { 16 | var parameters []string 17 | for _, parameter := range call.Parameters { 18 | switch parameter.Key.Type { 19 | case "string": 20 | parameters = append(parameters, parameter.Value.Value) 21 | case "type": 22 | value := model.Variables[parameter.Value.Value] 23 | parameters = append(parameters, value) 24 | } 25 | } 26 | 27 | modules := info.DefineModules 28 | 29 | callName := call.MemberId 30 | for _, module := range modules { 31 | for _, function := range module.ModuleFunctions { 32 | if function.FunctionName == call.MemberId { 33 | callName = function.EqualName[1 : len(function.EqualName)-1] 34 | } 35 | } 36 | } 37 | 38 | paramList := strings.Join(parameters, ",") 39 | 40 | return addSpace(callName + "(" + paramList + ")") 41 | } 42 | 43 | func (transform Transform) BuildImport(call CodeFunctionCall, modules []DefineModule) { 44 | for _, module := range modules { 45 | for _, function := range module.ModuleFunctions { 46 | if function.FunctionName == call.MemberId { 47 | imports[function.ImportName] = function.ImportName 48 | } 49 | } 50 | } 51 | } 52 | 53 | func (transform Transform) GetImports() string { 54 | var str = "" 55 | for _, imp := range imports { 56 | str += "import " + imp + "\n" 57 | } 58 | 59 | return str + "\n" 60 | } 61 | 62 | func (transform Transform) BuildPackage(s string) string { 63 | return "package " + s + "\n" 64 | } 65 | 66 | func (transform Transform) BuildFunction(function CodeFunction, information DefineInformation, model CodeModel) string { 67 | symbolMap := information.SymbolsMap 68 | funcBody := "" 69 | funcName := function.MemberId 70 | params := "" 71 | callCode := "" 72 | 73 | for _, param := range function.Parameters { 74 | fmt.Println(param.Type) 75 | } 76 | 77 | for _, call := range function.CodeFunctionCalls { 78 | callCode = callCode + "\n" + transform.BuildFunctionCall(call, information, model) 79 | } 80 | 81 | funcBody = callCode 82 | 83 | return symbolMap["FUNCTION"] + " " + funcName + symbolMap["PARAMETER_START"] + params + symbolMap["PARAMETER_END"] + symbolMap["METHOD_START"] + funcBody + "\n" + symbolMap["METHOD_END"] 84 | } 85 | 86 | func (transform Transform) TransformMainCode(codeModel CodeModel, info DefineInformation, startTemplateSymbol string, endTemplateSymbol string) string { 87 | var packageInfo string 88 | var importStr string 89 | var code = "" 90 | var result = "" 91 | for _, call := range codeModel.FunctionCalls { 92 | code = code + "\n" + transform.BuildFunctionCall(call, info, codeModel) 93 | transform.BuildImport(call, info.DefineModules) 94 | } 95 | code = code + "\n" 96 | 97 | importStr = transform.GetImports() 98 | 99 | templates := info.DefineTemplates 100 | template := codetemplate.New(templates["code"], startTemplateSymbol, endTemplateSymbol) 101 | result = template.ExecuteString(map[string]interface{}{ 102 | "code": code, 103 | }) 104 | packageInfo = transform.BuildPackage("main") 105 | codeWithImport := packageInfo + importStr + result 106 | 107 | return codeWithImport 108 | } 109 | 110 | func (transform Transform) TransformNormalCode(model CodeModel, information DefineInformation) string { 111 | funcStr := "" 112 | for _, function := range model.Functions { 113 | funcStr = funcStr + "\n\n" + transform.BuildFunction(function, information, model) 114 | } 115 | 116 | return funcStr 117 | } 118 | 119 | func addSpace(str string) string { 120 | return " " + str 121 | } -------------------------------------------------------------------------------- /parser/define/define_app_listener.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import ( 4 | . "../../languages/define" 5 | . "../../model" 6 | "reflect" 7 | "strings" 8 | ) 9 | 10 | type Symbol struct { 11 | Key string 12 | Value string 13 | } 14 | 15 | var symbols []Symbol 16 | 17 | var startSymbol string 18 | var endSymbol string 19 | 20 | var defineInformation DefineInformation 21 | 22 | func NewDefineAppListener(start string, end string) *DefineAppListener { 23 | startSymbol = start 24 | endSymbol = end 25 | defineInformation = *&DefineInformation{ 26 | DefineTemplates: make(map[string]string), 27 | } 28 | defineInformation.SymbolsMap = make(map[string]string) 29 | return &DefineAppListener{} 30 | } 31 | 32 | type DefineAppListener struct { 33 | BaseDefineListener 34 | } 35 | 36 | func (s *DefineAppListener) EnterSymbolDeclaration(ctx *SymbolDeclarationContext) { 37 | key := ctx.IDENTIFIER().GetText() 38 | value := ctx.STRING_LITERAL().GetText() 39 | symbol := &Symbol{key, value} 40 | symbols = append(symbols, *symbol) 41 | 42 | defineInformation.SymbolsMap[key] = value[1: len(value)-1] 43 | 44 | } 45 | 46 | func (s *DefineAppListener) EnterModuleDeclaration(ctx *ModuleDeclarationContext) { 47 | defineModule := &DefineModule{ 48 | ModuleName: ctx.IDENTIFIER().GetText(), 49 | ModuleFunctions: nil, 50 | } 51 | 52 | for _, moduleDefine := range ctx.AllModuleDefines() { 53 | moduleFunction := &ModuleFunction{} 54 | moduleDefineCtx := moduleDefine.(*ModuleDefinesContext) 55 | for _, attribute := range moduleDefineCtx.AllModuleAttribute() { 56 | moduleFunction.FunctionName = moduleDefineCtx.IDENTIFIER().GetText() 57 | attr := attribute.(*ModuleAttributeContext) 58 | if attr.IMPORT() != nil { 59 | moduleFunction.ImportName = attr.STRING_LITERAL().GetText() 60 | } 61 | if attr.EQUAL() != nil { 62 | moduleFunction.EqualName = attr.STRING_LITERAL().GetText() 63 | } 64 | } 65 | 66 | defineModule.ModuleFunctions = append(defineModule.ModuleFunctions, *moduleFunction) 67 | 68 | } 69 | 70 | defineInformation.DefineModules = append(defineInformation.DefineModules, *defineModule) 71 | } 72 | 73 | func (s *DefineAppListener) EnterDefineDeclaration(ctx *DefineDeclarationContext) { 74 | switch ctx.DefineKey().GetText() { 75 | case "entry_point": 76 | buildEntryPoint(ctx) 77 | } 78 | } 79 | 80 | func buildEntryPoint(ctx *DefineDeclarationContext) { 81 | for _, express := range ctx.AllDefineExpress() { 82 | firstChild := express.(*DefineExpressContext).GetChild(0) 83 | typeOfExpress := reflect.TypeOf(firstChild).String() 84 | switch typeOfExpress { 85 | case "*parser.DefineAttributeContext": 86 | attributeCtx := firstChild.(*DefineAttributeContext) 87 | attributeCtx.GetText() 88 | case "*parser.DefineTemplateContext": 89 | defineCtx := firstChild.(*DefineTemplateContext) 90 | templateKey := defineCtx.IDENTIFIER().GetText() 91 | defineBody := defineCtx.DefineBody().(*DefineBodyContext) 92 | funcName := defineBody.STRING_LITERAL().GetText() 93 | templateData := defineBody.TemplateData().GetText() 94 | 95 | allSymbol := defineBody.AllSymbolKey() 96 | 97 | var codeText []string 98 | for index, symbolKey := range allSymbol { 99 | symbolCtx := symbolKey.(*SymbolKeyContext) 100 | symbolText := symbolCtx.GetText() 101 | 102 | codeText = append(codeText, defineInformation.SymbolsMap[symbolText]) 103 | if index == 0 { 104 | codeText = append(codeText, funcName[1:len(funcName)-1]) 105 | } 106 | if index == len(allSymbol)-2 { 107 | codeText = append(codeText, buildTemplate(templateData)) 108 | } 109 | } 110 | 111 | defineInformation.DefineTemplates[templateKey] = strings.Join(codeText, " ") 112 | } 113 | } 114 | } 115 | 116 | func buildTemplate(templateData string) string { 117 | return startSymbol + templateData + endSymbol 118 | } 119 | 120 | func (s *DefineAppListener) getDefineInformation() DefineInformation { 121 | return defineInformation 122 | } 123 | -------------------------------------------------------------------------------- /languages/define/Define.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | 'symbol' 4 | 'define' 5 | 'defaultSymbol' 6 | 'defaultTemplate' 7 | 'module' 8 | 'import' 9 | 'equal' 10 | null 11 | '(' 12 | ')' 13 | '{' 14 | '}' 15 | '[' 16 | ']' 17 | ';' 18 | ',' 19 | '.' 20 | ':' 21 | null 22 | null 23 | null 24 | null 25 | 26 | token symbolic names: 27 | null 28 | SYMBOL_TEXT 29 | DEFINE 30 | DEFAULT_SYMBOL 31 | DEFAULT_TEMPLATE 32 | MODULE 33 | IMPORT 34 | EQUAL 35 | IDENTIFIER 36 | LPAREN 37 | RPAREN 38 | LBRACE 39 | RBRACE 40 | LBRACK 41 | RBRACK 42 | SEMI 43 | COMMA 44 | DOT 45 | COLON 46 | WS 47 | COMMENT 48 | LINE_COMMENT 49 | STRING_LITERAL 50 | 51 | rule names: 52 | compilationUnit 53 | symbolDeclaration 54 | normalDeclarations 55 | defineDeclaration 56 | defineExpress 57 | defineAttribute 58 | defineTemplate 59 | symbolKey 60 | symbolValue 61 | defineBody 62 | templateData 63 | systemDeclaration 64 | defineKey 65 | defineValue 66 | moduleDeclaration 67 | moduleDefines 68 | moduleAttribute 69 | 70 | 71 | atn: 72 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 24, 142, 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, 3, 2, 7, 2, 38, 10, 2, 12, 2, 14, 2, 41, 11, 2, 3, 2, 5, 2, 44, 10, 2, 3, 2, 7, 2, 47, 10, 2, 12, 2, 14, 2, 50, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 5, 4, 60, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 66, 10, 5, 12, 5, 14, 5, 69, 11, 5, 3, 5, 3, 5, 3, 6, 3, 6, 5, 6, 75, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 7, 11, 97, 10, 11, 12, 11, 14, 11, 100, 11, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 7, 16, 119, 10, 16, 12, 16, 14, 16, 122, 11, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 7, 17, 129, 10, 17, 12, 17, 14, 17, 132, 11, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 5, 18, 140, 10, 18, 3, 18, 2, 2, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 2, 2, 2, 134, 2, 39, 3, 2, 2, 2, 4, 53, 3, 2, 2, 2, 6, 59, 3, 2, 2, 2, 8, 61, 3, 2, 2, 2, 10, 74, 3, 2, 2, 2, 12, 76, 3, 2, 2, 2, 14, 81, 3, 2, 2, 2, 16, 89, 3, 2, 2, 2, 18, 91, 3, 2, 2, 2, 20, 93, 3, 2, 2, 2, 22, 104, 3, 2, 2, 2, 24, 106, 3, 2, 2, 2, 26, 110, 3, 2, 2, 2, 28, 112, 3, 2, 2, 2, 30, 114, 3, 2, 2, 2, 32, 125, 3, 2, 2, 2, 34, 139, 3, 2, 2, 2, 36, 38, 5, 4, 3, 2, 37, 36, 3, 2, 2, 2, 38, 41, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 39, 40, 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 42, 44, 5, 8, 5, 2, 43, 42, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 48, 3, 2, 2, 2, 45, 47, 5, 6, 4, 2, 46, 45, 3, 2, 2, 2, 47, 50, 3, 2, 2, 2, 48, 46, 3, 2, 2, 2, 48, 49, 3, 2, 2, 2, 49, 51, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 51, 52, 7, 2, 2, 3, 52, 3, 3, 2, 2, 2, 53, 54, 7, 3, 2, 2, 54, 55, 7, 10, 2, 2, 55, 56, 7, 24, 2, 2, 56, 5, 3, 2, 2, 2, 57, 60, 5, 24, 13, 2, 58, 60, 5, 30, 16, 2, 59, 57, 3, 2, 2, 2, 59, 58, 3, 2, 2, 2, 60, 7, 3, 2, 2, 2, 61, 62, 7, 4, 2, 2, 62, 63, 5, 26, 14, 2, 63, 67, 7, 13, 2, 2, 64, 66, 5, 10, 6, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 71, 7, 14, 2, 2, 71, 9, 3, 2, 2, 2, 72, 75, 5, 12, 7, 2, 73, 75, 5, 14, 8, 2, 74, 72, 3, 2, 2, 2, 74, 73, 3, 2, 2, 2, 75, 11, 3, 2, 2, 2, 76, 77, 7, 5, 2, 2, 77, 78, 7, 20, 2, 2, 78, 79, 5, 16, 9, 2, 79, 80, 5, 18, 10, 2, 80, 13, 3, 2, 2, 2, 81, 82, 7, 6, 2, 2, 82, 83, 7, 11, 2, 2, 83, 84, 7, 10, 2, 2, 84, 85, 7, 12, 2, 2, 85, 86, 7, 13, 2, 2, 86, 87, 5, 20, 11, 2, 87, 88, 7, 14, 2, 2, 88, 15, 3, 2, 2, 2, 89, 90, 7, 10, 2, 2, 90, 17, 3, 2, 2, 2, 91, 92, 7, 10, 2, 2, 92, 19, 3, 2, 2, 2, 93, 94, 5, 16, 9, 2, 94, 98, 7, 24, 2, 2, 95, 97, 5, 16, 9, 2, 96, 95, 3, 2, 2, 2, 97, 100, 3, 2, 2, 2, 98, 96, 3, 2, 2, 2, 98, 99, 3, 2, 2, 2, 99, 101, 3, 2, 2, 2, 100, 98, 3, 2, 2, 2, 101, 102, 5, 22, 12, 2, 102, 103, 5, 16, 9, 2, 103, 21, 3, 2, 2, 2, 104, 105, 7, 10, 2, 2, 105, 23, 3, 2, 2, 2, 106, 107, 5, 26, 14, 2, 107, 108, 7, 20, 2, 2, 108, 109, 5, 28, 15, 2, 109, 25, 3, 2, 2, 2, 110, 111, 7, 10, 2, 2, 111, 27, 3, 2, 2, 2, 112, 113, 7, 10, 2, 2, 113, 29, 3, 2, 2, 2, 114, 115, 7, 7, 2, 2, 115, 116, 7, 10, 2, 2, 116, 120, 7, 13, 2, 2, 117, 119, 5, 32, 17, 2, 118, 117, 3, 2, 2, 2, 119, 122, 3, 2, 2, 2, 120, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 123, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 123, 124, 7, 14, 2, 2, 124, 31, 3, 2, 2, 2, 125, 126, 7, 10, 2, 2, 126, 130, 7, 13, 2, 2, 127, 129, 5, 34, 18, 2, 128, 127, 3, 2, 2, 2, 129, 132, 3, 2, 2, 2, 130, 128, 3, 2, 2, 2, 130, 131, 3, 2, 2, 2, 131, 133, 3, 2, 2, 2, 132, 130, 3, 2, 2, 2, 133, 134, 7, 14, 2, 2, 134, 33, 3, 2, 2, 2, 135, 136, 7, 8, 2, 2, 136, 140, 7, 24, 2, 2, 137, 138, 7, 9, 2, 2, 138, 140, 7, 24, 2, 2, 139, 135, 3, 2, 2, 2, 139, 137, 3, 2, 2, 2, 140, 35, 3, 2, 2, 2, 12, 39, 43, 48, 59, 67, 74, 98, 120, 130, 139] -------------------------------------------------------------------------------- /languages/define/define_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Define 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // DefineListener is a complete listener for a parse tree produced by DefineParser. 8 | type DefineListener interface { 9 | antlr.ParseTreeListener 10 | 11 | // EnterCompilationUnit is called when entering the compilationUnit production. 12 | EnterCompilationUnit(c *CompilationUnitContext) 13 | 14 | // EnterSymbolDeclaration is called when entering the symbolDeclaration production. 15 | EnterSymbolDeclaration(c *SymbolDeclarationContext) 16 | 17 | // EnterNormalDeclarations is called when entering the normalDeclarations production. 18 | EnterNormalDeclarations(c *NormalDeclarationsContext) 19 | 20 | // EnterDefineDeclaration is called when entering the defineDeclaration production. 21 | EnterDefineDeclaration(c *DefineDeclarationContext) 22 | 23 | // EnterDefineExpress is called when entering the defineExpress production. 24 | EnterDefineExpress(c *DefineExpressContext) 25 | 26 | // EnterDefineAttribute is called when entering the defineAttribute production. 27 | EnterDefineAttribute(c *DefineAttributeContext) 28 | 29 | // EnterDefineTemplate is called when entering the defineTemplate production. 30 | EnterDefineTemplate(c *DefineTemplateContext) 31 | 32 | // EnterSymbolKey is called when entering the symbolKey production. 33 | EnterSymbolKey(c *SymbolKeyContext) 34 | 35 | // EnterSymbolValue is called when entering the symbolValue production. 36 | EnterSymbolValue(c *SymbolValueContext) 37 | 38 | // EnterDefineBody is called when entering the defineBody production. 39 | EnterDefineBody(c *DefineBodyContext) 40 | 41 | // EnterTemplateData is called when entering the templateData production. 42 | EnterTemplateData(c *TemplateDataContext) 43 | 44 | // EnterSystemDeclaration is called when entering the systemDeclaration production. 45 | EnterSystemDeclaration(c *SystemDeclarationContext) 46 | 47 | // EnterDefineKey is called when entering the defineKey production. 48 | EnterDefineKey(c *DefineKeyContext) 49 | 50 | // EnterDefineValue is called when entering the defineValue production. 51 | EnterDefineValue(c *DefineValueContext) 52 | 53 | // EnterModuleDeclaration is called when entering the moduleDeclaration production. 54 | EnterModuleDeclaration(c *ModuleDeclarationContext) 55 | 56 | // EnterModuleDefines is called when entering the moduleDefines production. 57 | EnterModuleDefines(c *ModuleDefinesContext) 58 | 59 | // EnterModuleAttribute is called when entering the moduleAttribute production. 60 | EnterModuleAttribute(c *ModuleAttributeContext) 61 | 62 | // ExitCompilationUnit is called when exiting the compilationUnit production. 63 | ExitCompilationUnit(c *CompilationUnitContext) 64 | 65 | // ExitSymbolDeclaration is called when exiting the symbolDeclaration production. 66 | ExitSymbolDeclaration(c *SymbolDeclarationContext) 67 | 68 | // ExitNormalDeclarations is called when exiting the normalDeclarations production. 69 | ExitNormalDeclarations(c *NormalDeclarationsContext) 70 | 71 | // ExitDefineDeclaration is called when exiting the defineDeclaration production. 72 | ExitDefineDeclaration(c *DefineDeclarationContext) 73 | 74 | // ExitDefineExpress is called when exiting the defineExpress production. 75 | ExitDefineExpress(c *DefineExpressContext) 76 | 77 | // ExitDefineAttribute is called when exiting the defineAttribute production. 78 | ExitDefineAttribute(c *DefineAttributeContext) 79 | 80 | // ExitDefineTemplate is called when exiting the defineTemplate production. 81 | ExitDefineTemplate(c *DefineTemplateContext) 82 | 83 | // ExitSymbolKey is called when exiting the symbolKey production. 84 | ExitSymbolKey(c *SymbolKeyContext) 85 | 86 | // ExitSymbolValue is called when exiting the symbolValue production. 87 | ExitSymbolValue(c *SymbolValueContext) 88 | 89 | // ExitDefineBody is called when exiting the defineBody production. 90 | ExitDefineBody(c *DefineBodyContext) 91 | 92 | // ExitTemplateData is called when exiting the templateData production. 93 | ExitTemplateData(c *TemplateDataContext) 94 | 95 | // ExitSystemDeclaration is called when exiting the systemDeclaration production. 96 | ExitSystemDeclaration(c *SystemDeclarationContext) 97 | 98 | // ExitDefineKey is called when exiting the defineKey production. 99 | ExitDefineKey(c *DefineKeyContext) 100 | 101 | // ExitDefineValue is called when exiting the defineValue production. 102 | ExitDefineValue(c *DefineValueContext) 103 | 104 | // ExitModuleDeclaration is called when exiting the moduleDeclaration production. 105 | ExitModuleDeclaration(c *ModuleDeclarationContext) 106 | 107 | // ExitModuleDefines is called when exiting the moduleDefines production. 108 | ExitModuleDefines(c *ModuleDefinesContext) 109 | 110 | // ExitModuleAttribute is called when exiting the moduleAttribute production. 111 | ExitModuleAttribute(c *ModuleAttributeContext) 112 | } 113 | -------------------------------------------------------------------------------- /parser/code/code_app_listener.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import ( 4 | . "../../languages/code" 5 | . "../../model" 6 | "fmt" 7 | "github.com/antlr/antlr4/runtime/Go/antlr" 8 | "reflect" 9 | ) 10 | 11 | var currentCodeModel CodeModel 12 | var currentFunction = CreateFunction("") 13 | var varMaps = make(map[string]string) 14 | 15 | func NewCodeAppListener() *CodeAppListener { 16 | currentCodeModel = *&CodeModel{nil, nil, nil} 17 | return &CodeAppListener{} 18 | } 19 | 20 | type CodeAppListener struct { 21 | BaseCodeListener 22 | } 23 | 24 | func (s *CodeAppListener) EnterMethodCallDeclaration(ctx *MethodCallDeclarationContext) { 25 | allParameters := ctx.AllParameter() 26 | functionName := ctx.IDENTIFIER().GetText() 27 | 28 | parentParentType := reflect.TypeOf(ctx.GetParent().GetParent()).String() 29 | switch parentParentType { 30 | case "*parser.TypeDeclarationContext": 31 | functionCall := BuildFunctionCall(allParameters, functionName) 32 | currentCodeModel.FunctionCalls = append(currentCodeModel.FunctionCalls, functionCall) 33 | case "*parser.FunctionBodyContext": 34 | functionCall := BuildFunctionCall(allParameters, functionName) 35 | currentFunction.CodeFunctionCalls = append(currentFunction.CodeFunctionCalls, functionCall) 36 | } 37 | } 38 | 39 | func BuildFunctionCall(allParameters []IParameterContext, functionName string) CodeFunctionCall { 40 | var parameters []CodeParameter 41 | for _, parameter := range allParameters { 42 | childType := reflect.TypeOf(parameter.GetChild(0)).String() 43 | paraCodeType := &CodeType{ 44 | Type: "string", 45 | } 46 | 47 | switch childType { 48 | case "*antlr.TerminalNodeImpl": 49 | paraCodeType.Type = "type" 50 | default: 51 | } 52 | 53 | var paramValue = &CodeParameterValue{Value: parameter.GetText()} 54 | parameter := &CodeParameter{*paraCodeType, *paramValue} 55 | parameters = append(parameters, *parameter) 56 | } 57 | functionCall := CreateFunctionCall(functionName, parameters) 58 | return functionCall 59 | } 60 | 61 | func (s *CodeAppListener) EnterFunctionDeclaration(ctx *FunctionDeclarationContext) { 62 | function := CreateFunction(ctx.IDENTIFIER().GetText()) 63 | currentFunction = function 64 | 65 | function.Position.StartLine = ctx.GetStart().GetLine() 66 | function.Position.StartLineColumn = ctx.IDENTIFIER().GetSymbol().GetColumn() 67 | function.Position.StopLine = ctx.GetStop().GetLine() 68 | function.Position.StopLineColumn = ctx.IDENTIFIER().GetSymbol().GetColumn() 69 | 70 | allExpressDeclaration := ctx.FunctionBody().(*FunctionBodyContext).AllExpression() 71 | for _, express := range allExpressDeclaration { 72 | expressCtx := express.(*ExpressionContext) 73 | 74 | firstChildCtx := expressCtx.GetChild(0) 75 | 76 | switch reflect.TypeOf(firstChildCtx).String() { 77 | case "*parser.MethodCallDeclarationContext": 78 | context := firstChildCtx.(*MethodCallDeclarationContext) 79 | functionCall := BuildFunctionCall(context.AllParameter(), context.IDENTIFIER().GetText()) 80 | function.CodeFunctionCalls = append(function.CodeFunctionCalls, functionCall) 81 | 82 | case "*parser.BlockStatementContext": 83 | child := firstChildCtx.GetChild(0) 84 | childType := reflect.TypeOf(child).String() 85 | switch childType { 86 | case "*parser.LocalVariableDeclarationContext": 87 | context := child.(*LocalVariableDeclarationContext).GetChild(0).(*VariableDeclaratorsContext) 88 | 89 | s.handleLocalVariable(context) 90 | case "*parser.StatementContext": 91 | statement := s.handleStatement(child.(*StatementContext)) 92 | fmt.Println(statement) 93 | } 94 | } 95 | } 96 | 97 | currentCodeModel.Functions = append(currentCodeModel.Functions, function) 98 | } 99 | 100 | type BlockStatement struct { 101 | Condition string 102 | BlockStatement []string 103 | } 104 | 105 | func (s *CodeAppListener) handleStatement(statementCtx *StatementContext) BlockStatement { 106 | blockStatement := &BlockStatement{ 107 | Condition: "", 108 | BlockStatement: nil, 109 | } 110 | 111 | child := statementCtx.GetChild(0) 112 | childType := reflect.TypeOf(child).String() 113 | switch childType { 114 | case "*antlr.TerminalNodeImpl": 115 | nodeType := child.(*antlr.TerminalNodeImpl) 116 | switch nodeType.GetText() { 117 | case "for": 118 | FOR_STATEMENT_INDEX := 4 119 | FOR_CONTROL_INDEX := 2 120 | 121 | forControlText := statementCtx.GetChild(FOR_CONTROL_INDEX).(*ForControlContext).GetText() 122 | blockStatement.Condition = forControlText 123 | blockCtx := statementCtx.GetChild(FOR_STATEMENT_INDEX).GetChild(0).(*BlockContext) 124 | for _, statement := range blockCtx.AllBlockStatement() { 125 | blockStatement.BlockStatement = append(blockStatement.BlockStatement, statement.GetText()) 126 | } 127 | } 128 | } 129 | 130 | return *blockStatement 131 | } 132 | 133 | func (s *CodeAppListener) handleLocalVariable(context *VariableDeclaratorsContext) { 134 | for _, varDeclarator := range context.AllVariableDeclarator() { 135 | varCtx := varDeclarator.(*VariableDeclaratorContext) 136 | ident := varCtx.VariableDeclaratorId().GetText() 137 | value := "" 138 | 139 | if varCtx.VariableInitializer() != nil { 140 | value = varCtx.VariableInitializer().GetText() 141 | } 142 | 143 | currentFunction.Variables[ident] = value 144 | } 145 | } 146 | 147 | func (s *CodeAppListener) EnterVariableDeclarators(ctx *VariableDeclaratorsContext) { 148 | for _, varDeclarator := range ctx.AllVariableDeclarator() { 149 | varCtx := varDeclarator.(*VariableDeclaratorContext) 150 | ident := varCtx.VariableDeclaratorId().GetText() 151 | value := "" 152 | 153 | if varCtx.VariableInitializer() != nil { 154 | value = varCtx.VariableInitializer().GetText() 155 | } 156 | 157 | varMaps[ident] = value 158 | } 159 | } 160 | 161 | func (s *CodeAppListener) getCode() CodeModel { 162 | currentCodeModel.Variables = varMaps 163 | return currentCodeModel 164 | } 165 | -------------------------------------------------------------------------------- /languages/code/code_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Code.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Code 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // CodeListener is a complete listener for a parse tree produced by CodeParser. 8 | type CodeListener interface { 9 | antlr.ParseTreeListener 10 | 11 | // EnterCompilationUnit is called when entering the compilationUnit production. 12 | EnterCompilationUnit(c *CompilationUnitContext) 13 | 14 | // EnterPackageDeclaration is called when entering the packageDeclaration production. 15 | EnterPackageDeclaration(c *PackageDeclarationContext) 16 | 17 | // EnterImportDeclaration is called when entering the importDeclaration production. 18 | EnterImportDeclaration(c *ImportDeclarationContext) 19 | 20 | // EnterTypeDeclaration is called when entering the typeDeclaration production. 21 | EnterTypeDeclaration(c *TypeDeclarationContext) 22 | 23 | // EnterFunctionDeclaration is called when entering the functionDeclaration production. 24 | EnterFunctionDeclaration(c *FunctionDeclarationContext) 25 | 26 | // EnterFunctionBody is called when entering the functionBody production. 27 | EnterFunctionBody(c *FunctionBodyContext) 28 | 29 | // EnterPrimary is called when entering the primary production. 30 | EnterPrimary(c *PrimaryContext) 31 | 32 | // EnterExpression is called when entering the expression production. 33 | EnterExpression(c *ExpressionContext) 34 | 35 | // EnterBlock is called when entering the block production. 36 | EnterBlock(c *BlockContext) 37 | 38 | // EnterBlockStatement is called when entering the blockStatement production. 39 | EnterBlockStatement(c *BlockStatementContext) 40 | 41 | // EnterStatement is called when entering the statement production. 42 | EnterStatement(c *StatementContext) 43 | 44 | // EnterForControl is called when entering the forControl production. 45 | EnterForControl(c *ForControlContext) 46 | 47 | // EnterLocalVariableDeclaration is called when entering the localVariableDeclaration production. 48 | EnterLocalVariableDeclaration(c *LocalVariableDeclarationContext) 49 | 50 | // EnterVariableDeclarators is called when entering the variableDeclarators production. 51 | EnterVariableDeclarators(c *VariableDeclaratorsContext) 52 | 53 | // EnterVariableDeclarator is called when entering the variableDeclarator production. 54 | EnterVariableDeclarator(c *VariableDeclaratorContext) 55 | 56 | // EnterVariableDeclaratorId is called when entering the variableDeclaratorId production. 57 | EnterVariableDeclaratorId(c *VariableDeclaratorIdContext) 58 | 59 | // EnterVariableInitializer is called when entering the variableInitializer production. 60 | EnterVariableInitializer(c *VariableInitializerContext) 61 | 62 | // EnterMethodCallDeclaration is called when entering the methodCallDeclaration production. 63 | EnterMethodCallDeclaration(c *MethodCallDeclarationContext) 64 | 65 | // EnterParameter is called when entering the parameter production. 66 | EnterParameter(c *ParameterContext) 67 | 68 | // EnterLiteral is called when entering the literal production. 69 | EnterLiteral(c *LiteralContext) 70 | 71 | // EnterDataStructDeclaration is called when entering the dataStructDeclaration production. 72 | EnterDataStructDeclaration(c *DataStructDeclarationContext) 73 | 74 | // EnterMemberDeclaration is called when entering the memberDeclaration production. 75 | EnterMemberDeclaration(c *MemberDeclarationContext) 76 | 77 | // ExitCompilationUnit is called when exiting the compilationUnit production. 78 | ExitCompilationUnit(c *CompilationUnitContext) 79 | 80 | // ExitPackageDeclaration is called when exiting the packageDeclaration production. 81 | ExitPackageDeclaration(c *PackageDeclarationContext) 82 | 83 | // ExitImportDeclaration is called when exiting the importDeclaration production. 84 | ExitImportDeclaration(c *ImportDeclarationContext) 85 | 86 | // ExitTypeDeclaration is called when exiting the typeDeclaration production. 87 | ExitTypeDeclaration(c *TypeDeclarationContext) 88 | 89 | // ExitFunctionDeclaration is called when exiting the functionDeclaration production. 90 | ExitFunctionDeclaration(c *FunctionDeclarationContext) 91 | 92 | // ExitFunctionBody is called when exiting the functionBody production. 93 | ExitFunctionBody(c *FunctionBodyContext) 94 | 95 | // ExitPrimary is called when exiting the primary production. 96 | ExitPrimary(c *PrimaryContext) 97 | 98 | // ExitExpression is called when exiting the expression production. 99 | ExitExpression(c *ExpressionContext) 100 | 101 | // ExitBlock is called when exiting the block production. 102 | ExitBlock(c *BlockContext) 103 | 104 | // ExitBlockStatement is called when exiting the blockStatement production. 105 | ExitBlockStatement(c *BlockStatementContext) 106 | 107 | // ExitStatement is called when exiting the statement production. 108 | ExitStatement(c *StatementContext) 109 | 110 | // ExitForControl is called when exiting the forControl production. 111 | ExitForControl(c *ForControlContext) 112 | 113 | // ExitLocalVariableDeclaration is called when exiting the localVariableDeclaration production. 114 | ExitLocalVariableDeclaration(c *LocalVariableDeclarationContext) 115 | 116 | // ExitVariableDeclarators is called when exiting the variableDeclarators production. 117 | ExitVariableDeclarators(c *VariableDeclaratorsContext) 118 | 119 | // ExitVariableDeclarator is called when exiting the variableDeclarator production. 120 | ExitVariableDeclarator(c *VariableDeclaratorContext) 121 | 122 | // ExitVariableDeclaratorId is called when exiting the variableDeclaratorId production. 123 | ExitVariableDeclaratorId(c *VariableDeclaratorIdContext) 124 | 125 | // ExitVariableInitializer is called when exiting the variableInitializer production. 126 | ExitVariableInitializer(c *VariableInitializerContext) 127 | 128 | // ExitMethodCallDeclaration is called when exiting the methodCallDeclaration production. 129 | ExitMethodCallDeclaration(c *MethodCallDeclarationContext) 130 | 131 | // ExitParameter is called when exiting the parameter production. 132 | ExitParameter(c *ParameterContext) 133 | 134 | // ExitLiteral is called when exiting the literal production. 135 | ExitLiteral(c *LiteralContext) 136 | 137 | // ExitDataStructDeclaration is called when exiting the dataStructDeclaration production. 138 | ExitDataStructDeclaration(c *DataStructDeclarationContext) 139 | 140 | // ExitMemberDeclaration is called when exiting the memberDeclaration production. 141 | ExitMemberDeclaration(c *MemberDeclarationContext) 142 | } 143 | -------------------------------------------------------------------------------- /languages/define/define_base_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Define 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // BaseDefineListener is a complete listener for a parse tree produced by DefineParser. 8 | type BaseDefineListener struct{} 9 | 10 | var _ DefineListener = &BaseDefineListener{} 11 | 12 | // VisitTerminal is called when a terminal node is visited. 13 | func (s *BaseDefineListener) VisitTerminal(node antlr.TerminalNode) {} 14 | 15 | // VisitErrorNode is called when an error node is visited. 16 | func (s *BaseDefineListener) VisitErrorNode(node antlr.ErrorNode) {} 17 | 18 | // EnterEveryRule is called when any rule is entered. 19 | func (s *BaseDefineListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} 20 | 21 | // ExitEveryRule is called when any rule is exited. 22 | func (s *BaseDefineListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} 23 | 24 | // EnterCompilationUnit is called when production compilationUnit is entered. 25 | func (s *BaseDefineListener) EnterCompilationUnit(ctx *CompilationUnitContext) {} 26 | 27 | // ExitCompilationUnit is called when production compilationUnit is exited. 28 | func (s *BaseDefineListener) ExitCompilationUnit(ctx *CompilationUnitContext) {} 29 | 30 | // EnterSymbolDeclaration is called when production symbolDeclaration is entered. 31 | func (s *BaseDefineListener) EnterSymbolDeclaration(ctx *SymbolDeclarationContext) {} 32 | 33 | // ExitSymbolDeclaration is called when production symbolDeclaration is exited. 34 | func (s *BaseDefineListener) ExitSymbolDeclaration(ctx *SymbolDeclarationContext) {} 35 | 36 | // EnterNormalDeclarations is called when production normalDeclarations is entered. 37 | func (s *BaseDefineListener) EnterNormalDeclarations(ctx *NormalDeclarationsContext) {} 38 | 39 | // ExitNormalDeclarations is called when production normalDeclarations is exited. 40 | func (s *BaseDefineListener) ExitNormalDeclarations(ctx *NormalDeclarationsContext) {} 41 | 42 | // EnterDefineDeclaration is called when production defineDeclaration is entered. 43 | func (s *BaseDefineListener) EnterDefineDeclaration(ctx *DefineDeclarationContext) {} 44 | 45 | // ExitDefineDeclaration is called when production defineDeclaration is exited. 46 | func (s *BaseDefineListener) ExitDefineDeclaration(ctx *DefineDeclarationContext) {} 47 | 48 | // EnterDefineExpress is called when production defineExpress is entered. 49 | func (s *BaseDefineListener) EnterDefineExpress(ctx *DefineExpressContext) {} 50 | 51 | // ExitDefineExpress is called when production defineExpress is exited. 52 | func (s *BaseDefineListener) ExitDefineExpress(ctx *DefineExpressContext) {} 53 | 54 | // EnterDefineAttribute is called when production defineAttribute is entered. 55 | func (s *BaseDefineListener) EnterDefineAttribute(ctx *DefineAttributeContext) {} 56 | 57 | // ExitDefineAttribute is called when production defineAttribute is exited. 58 | func (s *BaseDefineListener) ExitDefineAttribute(ctx *DefineAttributeContext) {} 59 | 60 | // EnterDefineTemplate is called when production defineTemplate is entered. 61 | func (s *BaseDefineListener) EnterDefineTemplate(ctx *DefineTemplateContext) {} 62 | 63 | // ExitDefineTemplate is called when production defineTemplate is exited. 64 | func (s *BaseDefineListener) ExitDefineTemplate(ctx *DefineTemplateContext) {} 65 | 66 | // EnterSymbolKey is called when production symbolKey is entered. 67 | func (s *BaseDefineListener) EnterSymbolKey(ctx *SymbolKeyContext) {} 68 | 69 | // ExitSymbolKey is called when production symbolKey is exited. 70 | func (s *BaseDefineListener) ExitSymbolKey(ctx *SymbolKeyContext) {} 71 | 72 | // EnterSymbolValue is called when production symbolValue is entered. 73 | func (s *BaseDefineListener) EnterSymbolValue(ctx *SymbolValueContext) {} 74 | 75 | // ExitSymbolValue is called when production symbolValue is exited. 76 | func (s *BaseDefineListener) ExitSymbolValue(ctx *SymbolValueContext) {} 77 | 78 | // EnterDefineBody is called when production defineBody is entered. 79 | func (s *BaseDefineListener) EnterDefineBody(ctx *DefineBodyContext) {} 80 | 81 | // ExitDefineBody is called when production defineBody is exited. 82 | func (s *BaseDefineListener) ExitDefineBody(ctx *DefineBodyContext) {} 83 | 84 | // EnterTemplateData is called when production templateData is entered. 85 | func (s *BaseDefineListener) EnterTemplateData(ctx *TemplateDataContext) {} 86 | 87 | // ExitTemplateData is called when production templateData is exited. 88 | func (s *BaseDefineListener) ExitTemplateData(ctx *TemplateDataContext) {} 89 | 90 | // EnterSystemDeclaration is called when production systemDeclaration is entered. 91 | func (s *BaseDefineListener) EnterSystemDeclaration(ctx *SystemDeclarationContext) {} 92 | 93 | // ExitSystemDeclaration is called when production systemDeclaration is exited. 94 | func (s *BaseDefineListener) ExitSystemDeclaration(ctx *SystemDeclarationContext) {} 95 | 96 | // EnterDefineKey is called when production defineKey is entered. 97 | func (s *BaseDefineListener) EnterDefineKey(ctx *DefineKeyContext) {} 98 | 99 | // ExitDefineKey is called when production defineKey is exited. 100 | func (s *BaseDefineListener) ExitDefineKey(ctx *DefineKeyContext) {} 101 | 102 | // EnterDefineValue is called when production defineValue is entered. 103 | func (s *BaseDefineListener) EnterDefineValue(ctx *DefineValueContext) {} 104 | 105 | // ExitDefineValue is called when production defineValue is exited. 106 | func (s *BaseDefineListener) ExitDefineValue(ctx *DefineValueContext) {} 107 | 108 | // EnterModuleDeclaration is called when production moduleDeclaration is entered. 109 | func (s *BaseDefineListener) EnterModuleDeclaration(ctx *ModuleDeclarationContext) {} 110 | 111 | // ExitModuleDeclaration is called when production moduleDeclaration is exited. 112 | func (s *BaseDefineListener) ExitModuleDeclaration(ctx *ModuleDeclarationContext) {} 113 | 114 | // EnterModuleDefines is called when production moduleDefines is entered. 115 | func (s *BaseDefineListener) EnterModuleDefines(ctx *ModuleDefinesContext) {} 116 | 117 | // ExitModuleDefines is called when production moduleDefines is exited. 118 | func (s *BaseDefineListener) ExitModuleDefines(ctx *ModuleDefinesContext) {} 119 | 120 | // EnterModuleAttribute is called when production moduleAttribute is entered. 121 | func (s *BaseDefineListener) EnterModuleAttribute(ctx *ModuleAttributeContext) {} 122 | 123 | // ExitModuleAttribute is called when production moduleAttribute is exited. 124 | func (s *BaseDefineListener) ExitModuleAttribute(ctx *ModuleAttributeContext) {} 125 | -------------------------------------------------------------------------------- /languages/code/Code.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '(' 4 | ')' 5 | '{' 6 | '}' 7 | '<=' 8 | '>=' 9 | '>' 10 | '<' 11 | '*' 12 | '/' 13 | '%' 14 | '=' 15 | '+=' 16 | '-=' 17 | '*=' 18 | '/=' 19 | '&=' 20 | '|=' 21 | '^=' 22 | '>>=' 23 | '>>>=' 24 | '<<=' 25 | '%=' 26 | ',' 27 | 'for' 28 | 'var' 29 | 'package' 30 | 'import' 31 | 'struct' 32 | 'member' 33 | 'func' 34 | null 35 | null 36 | null 37 | null 38 | null 39 | null 40 | 41 | token symbolic names: 42 | null 43 | null 44 | null 45 | null 46 | null 47 | null 48 | null 49 | null 50 | null 51 | null 52 | null 53 | null 54 | null 55 | null 56 | null 57 | null 58 | null 59 | null 60 | null 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | FOR 68 | VAR 69 | PACKAGE 70 | IMPORT 71 | DATA_STRUCT 72 | MEMBER 73 | FUNCTION 74 | IDENTIFIER 75 | WS 76 | COMMENT 77 | LINE_COMMENT 78 | STRING_LITERAL 79 | DECIMAL_LITERAL 80 | 81 | rule names: 82 | compilationUnit 83 | packageDeclaration 84 | importDeclaration 85 | typeDeclaration 86 | functionDeclaration 87 | functionBody 88 | primary 89 | expression 90 | block 91 | blockStatement 92 | statement 93 | forControl 94 | localVariableDeclaration 95 | variableDeclarators 96 | variableDeclarator 97 | variableDeclaratorId 98 | variableInitializer 99 | methodCallDeclaration 100 | parameter 101 | literal 102 | dataStructDeclaration 103 | memberDeclaration 104 | 105 | 106 | atn: 107 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 39, 185, 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, 3, 2, 5, 2, 48, 10, 2, 3, 2, 7, 2, 51, 10, 2, 12, 2, 14, 2, 54, 11, 2, 3, 2, 7, 2, 57, 10, 2, 12, 2, 14, 2, 60, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 74, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 80, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 7, 7, 89, 10, 7, 12, 7, 14, 7, 92, 11, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 5, 9, 100, 10, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 111, 10, 9, 12, 9, 14, 9, 114, 11, 9, 3, 10, 3, 10, 7, 10, 118, 10, 10, 12, 10, 14, 10, 121, 11, 10, 3, 10, 3, 10, 3, 11, 3, 11, 5, 11, 127, 10, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 137, 10, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 5, 15, 144, 10, 15, 3, 15, 3, 15, 3, 15, 7, 15, 149, 10, 15, 12, 15, 14, 15, 152, 11, 15, 3, 16, 3, 16, 3, 16, 5, 16, 157, 10, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 7, 19, 166, 10, 19, 12, 19, 14, 19, 169, 11, 19, 3, 19, 3, 19, 3, 20, 3, 20, 5, 20, 175, 10, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 2, 3, 16, 24, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 2, 7, 4, 2, 34, 34, 38, 39, 3, 2, 7, 10, 3, 2, 11, 13, 3, 2, 14, 25, 3, 2, 38, 39, 2, 184, 2, 47, 3, 2, 2, 2, 4, 63, 3, 2, 2, 2, 6, 66, 3, 2, 2, 2, 8, 73, 3, 2, 2, 2, 10, 75, 3, 2, 2, 2, 12, 86, 3, 2, 2, 2, 14, 93, 3, 2, 2, 2, 16, 99, 3, 2, 2, 2, 18, 115, 3, 2, 2, 2, 20, 126, 3, 2, 2, 2, 22, 136, 3, 2, 2, 2, 24, 138, 3, 2, 2, 2, 26, 140, 3, 2, 2, 2, 28, 143, 3, 2, 2, 2, 30, 153, 3, 2, 2, 2, 32, 158, 3, 2, 2, 2, 34, 160, 3, 2, 2, 2, 36, 162, 3, 2, 2, 2, 38, 174, 3, 2, 2, 2, 40, 176, 3, 2, 2, 2, 42, 178, 3, 2, 2, 2, 44, 181, 3, 2, 2, 2, 46, 48, 5, 4, 3, 2, 47, 46, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 52, 3, 2, 2, 2, 49, 51, 5, 6, 4, 2, 50, 49, 3, 2, 2, 2, 51, 54, 3, 2, 2, 2, 52, 50, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 58, 3, 2, 2, 2, 54, 52, 3, 2, 2, 2, 55, 57, 5, 8, 5, 2, 56, 55, 3, 2, 2, 2, 57, 60, 3, 2, 2, 2, 58, 56, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 61, 3, 2, 2, 2, 60, 58, 3, 2, 2, 2, 61, 62, 7, 2, 2, 3, 62, 3, 3, 2, 2, 2, 63, 64, 7, 29, 2, 2, 64, 65, 7, 34, 2, 2, 65, 5, 3, 2, 2, 2, 66, 67, 7, 30, 2, 2, 67, 68, 7, 34, 2, 2, 68, 7, 3, 2, 2, 2, 69, 74, 5, 42, 22, 2, 70, 74, 5, 44, 23, 2, 71, 74, 5, 10, 6, 2, 72, 74, 5, 16, 9, 2, 73, 69, 3, 2, 2, 2, 73, 70, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 72, 3, 2, 2, 2, 74, 9, 3, 2, 2, 2, 75, 76, 7, 33, 2, 2, 76, 77, 7, 34, 2, 2, 77, 79, 7, 3, 2, 2, 78, 80, 5, 38, 20, 2, 79, 78, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 80, 81, 3, 2, 2, 2, 81, 82, 7, 4, 2, 2, 82, 83, 7, 5, 2, 2, 83, 84, 5, 12, 7, 2, 84, 85, 7, 6, 2, 2, 85, 11, 3, 2, 2, 2, 86, 90, 5, 16, 9, 2, 87, 89, 5, 16, 9, 2, 88, 87, 3, 2, 2, 2, 89, 92, 3, 2, 2, 2, 90, 88, 3, 2, 2, 2, 90, 91, 3, 2, 2, 2, 91, 13, 3, 2, 2, 2, 92, 90, 3, 2, 2, 2, 93, 94, 9, 2, 2, 2, 94, 15, 3, 2, 2, 2, 95, 96, 8, 9, 1, 2, 96, 100, 5, 14, 8, 2, 97, 100, 5, 36, 19, 2, 98, 100, 5, 20, 11, 2, 99, 95, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 99, 98, 3, 2, 2, 2, 100, 112, 3, 2, 2, 2, 101, 102, 12, 6, 2, 2, 102, 103, 9, 3, 2, 2, 103, 111, 5, 16, 9, 7, 104, 105, 12, 5, 2, 2, 105, 106, 9, 4, 2, 2, 106, 111, 5, 16, 9, 6, 107, 108, 12, 4, 2, 2, 108, 109, 9, 5, 2, 2, 109, 111, 5, 16, 9, 4, 110, 101, 3, 2, 2, 2, 110, 104, 3, 2, 2, 2, 110, 107, 3, 2, 2, 2, 111, 114, 3, 2, 2, 2, 112, 110, 3, 2, 2, 2, 112, 113, 3, 2, 2, 2, 113, 17, 3, 2, 2, 2, 114, 112, 3, 2, 2, 2, 115, 119, 7, 5, 2, 2, 116, 118, 5, 20, 11, 2, 117, 116, 3, 2, 2, 2, 118, 121, 3, 2, 2, 2, 119, 117, 3, 2, 2, 2, 119, 120, 3, 2, 2, 2, 120, 122, 3, 2, 2, 2, 121, 119, 3, 2, 2, 2, 122, 123, 7, 6, 2, 2, 123, 19, 3, 2, 2, 2, 124, 127, 5, 26, 14, 2, 125, 127, 5, 22, 12, 2, 126, 124, 3, 2, 2, 2, 126, 125, 3, 2, 2, 2, 127, 21, 3, 2, 2, 2, 128, 137, 5, 18, 10, 2, 129, 130, 7, 27, 2, 2, 130, 131, 7, 3, 2, 2, 131, 132, 5, 24, 13, 2, 132, 133, 7, 4, 2, 2, 133, 134, 5, 22, 12, 2, 134, 137, 3, 2, 2, 2, 135, 137, 5, 36, 19, 2, 136, 128, 3, 2, 2, 2, 136, 129, 3, 2, 2, 2, 136, 135, 3, 2, 2, 2, 137, 23, 3, 2, 2, 2, 138, 139, 5, 16, 9, 2, 139, 25, 3, 2, 2, 2, 140, 141, 5, 28, 15, 2, 141, 27, 3, 2, 2, 2, 142, 144, 7, 28, 2, 2, 143, 142, 3, 2, 2, 2, 143, 144, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 150, 5, 30, 16, 2, 146, 147, 7, 26, 2, 2, 147, 149, 5, 30, 16, 2, 148, 146, 3, 2, 2, 2, 149, 152, 3, 2, 2, 2, 150, 148, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 29, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 153, 156, 5, 32, 17, 2, 154, 155, 7, 14, 2, 2, 155, 157, 5, 34, 18, 2, 156, 154, 3, 2, 2, 2, 156, 157, 3, 2, 2, 2, 157, 31, 3, 2, 2, 2, 158, 159, 7, 34, 2, 2, 159, 33, 3, 2, 2, 2, 160, 161, 5, 16, 9, 2, 161, 35, 3, 2, 2, 2, 162, 163, 7, 34, 2, 2, 163, 167, 7, 3, 2, 2, 164, 166, 5, 38, 20, 2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2, 2, 2, 167, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 170, 171, 7, 4, 2, 2, 171, 37, 3, 2, 2, 2, 172, 175, 5, 40, 21, 2, 173, 175, 7, 34, 2, 2, 174, 172, 3, 2, 2, 2, 174, 173, 3, 2, 2, 2, 175, 39, 3, 2, 2, 2, 176, 177, 9, 6, 2, 2, 177, 41, 3, 2, 2, 2, 178, 179, 7, 31, 2, 2, 179, 180, 7, 34, 2, 2, 180, 43, 3, 2, 2, 2, 181, 182, 7, 32, 2, 2, 182, 183, 7, 34, 2, 2, 183, 45, 3, 2, 2, 2, 19, 47, 52, 58, 73, 79, 90, 99, 110, 112, 119, 126, 136, 143, 150, 156, 167, 174] -------------------------------------------------------------------------------- /languages/define/DefineLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | 'symbol' 4 | 'define' 5 | 'defaultSymbol' 6 | 'defaultTemplate' 7 | 'module' 8 | 'import' 9 | 'equal' 10 | null 11 | '(' 12 | ')' 13 | '{' 14 | '}' 15 | '[' 16 | ']' 17 | ';' 18 | ',' 19 | '.' 20 | ':' 21 | null 22 | null 23 | null 24 | null 25 | 26 | token symbolic names: 27 | null 28 | SYMBOL_TEXT 29 | DEFINE 30 | DEFAULT_SYMBOL 31 | DEFAULT_TEMPLATE 32 | MODULE 33 | IMPORT 34 | EQUAL 35 | IDENTIFIER 36 | LPAREN 37 | RPAREN 38 | LBRACE 39 | RBRACE 40 | LBRACK 41 | RBRACK 42 | SEMI 43 | COMMA 44 | DOT 45 | COLON 46 | WS 47 | COMMENT 48 | LINE_COMMENT 49 | STRING_LITERAL 50 | 51 | rule names: 52 | SYMBOL_TEXT 53 | DEFINE 54 | DEFAULT_SYMBOL 55 | DEFAULT_TEMPLATE 56 | MODULE 57 | IMPORT 58 | EQUAL 59 | IDENTIFIER 60 | LPAREN 61 | RPAREN 62 | LBRACE 63 | RBRACE 64 | LBRACK 65 | RBRACK 66 | SEMI 67 | COMMA 68 | DOT 69 | COLON 70 | WS 71 | COMMENT 72 | LINE_COMMENT 73 | STRING_LITERAL 74 | HexDigit 75 | EscapeSequence 76 | LetterOrDigit 77 | Letter 78 | 79 | channel names: 80 | DEFAULT_TOKEN_CHANNEL 81 | HIDDEN 82 | 83 | mode names: 84 | DEFAULT_MODE 85 | 86 | atn: 87 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 24, 223, 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, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 7, 9, 122, 10, 9, 12, 9, 14, 9, 125, 11, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 6, 20, 148, 10, 20, 13, 20, 14, 20, 149, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 7, 21, 158, 10, 21, 12, 21, 14, 21, 161, 11, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 172, 10, 22, 12, 22, 14, 22, 175, 11, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 7, 23, 182, 10, 23, 12, 23, 14, 23, 185, 11, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 195, 10, 25, 3, 25, 5, 25, 198, 10, 25, 3, 25, 3, 25, 3, 25, 6, 25, 203, 10, 25, 13, 25, 14, 25, 204, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 212, 10, 25, 3, 26, 3, 26, 5, 26, 216, 10, 26, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 222, 10, 27, 3, 159, 2, 28, 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, 2, 49, 2, 51, 2, 53, 2, 3, 2, 14, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 6, 2, 12, 12, 15, 15, 36, 36, 94, 94, 5, 2, 50, 59, 67, 72, 99, 104, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 3, 2, 50, 59, 6, 2, 38, 38, 67, 92, 97, 97, 99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345, 2, 232, 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, 3, 55, 3, 2, 2, 2, 5, 62, 3, 2, 2, 2, 7, 69, 3, 2, 2, 2, 9, 83, 3, 2, 2, 2, 11, 99, 3, 2, 2, 2, 13, 106, 3, 2, 2, 2, 15, 113, 3, 2, 2, 2, 17, 119, 3, 2, 2, 2, 19, 126, 3, 2, 2, 2, 21, 128, 3, 2, 2, 2, 23, 130, 3, 2, 2, 2, 25, 132, 3, 2, 2, 2, 27, 134, 3, 2, 2, 2, 29, 136, 3, 2, 2, 2, 31, 138, 3, 2, 2, 2, 33, 140, 3, 2, 2, 2, 35, 142, 3, 2, 2, 2, 37, 144, 3, 2, 2, 2, 39, 147, 3, 2, 2, 2, 41, 153, 3, 2, 2, 2, 43, 167, 3, 2, 2, 2, 45, 178, 3, 2, 2, 2, 47, 188, 3, 2, 2, 2, 49, 211, 3, 2, 2, 2, 51, 215, 3, 2, 2, 2, 53, 221, 3, 2, 2, 2, 55, 56, 7, 117, 2, 2, 56, 57, 7, 123, 2, 2, 57, 58, 7, 111, 2, 2, 58, 59, 7, 100, 2, 2, 59, 60, 7, 113, 2, 2, 60, 61, 7, 110, 2, 2, 61, 4, 3, 2, 2, 2, 62, 63, 7, 102, 2, 2, 63, 64, 7, 103, 2, 2, 64, 65, 7, 104, 2, 2, 65, 66, 7, 107, 2, 2, 66, 67, 7, 112, 2, 2, 67, 68, 7, 103, 2, 2, 68, 6, 3, 2, 2, 2, 69, 70, 7, 102, 2, 2, 70, 71, 7, 103, 2, 2, 71, 72, 7, 104, 2, 2, 72, 73, 7, 99, 2, 2, 73, 74, 7, 119, 2, 2, 74, 75, 7, 110, 2, 2, 75, 76, 7, 118, 2, 2, 76, 77, 7, 85, 2, 2, 77, 78, 7, 123, 2, 2, 78, 79, 7, 111, 2, 2, 79, 80, 7, 100, 2, 2, 80, 81, 7, 113, 2, 2, 81, 82, 7, 110, 2, 2, 82, 8, 3, 2, 2, 2, 83, 84, 7, 102, 2, 2, 84, 85, 7, 103, 2, 2, 85, 86, 7, 104, 2, 2, 86, 87, 7, 99, 2, 2, 87, 88, 7, 119, 2, 2, 88, 89, 7, 110, 2, 2, 89, 90, 7, 118, 2, 2, 90, 91, 7, 86, 2, 2, 91, 92, 7, 103, 2, 2, 92, 93, 7, 111, 2, 2, 93, 94, 7, 114, 2, 2, 94, 95, 7, 110, 2, 2, 95, 96, 7, 99, 2, 2, 96, 97, 7, 118, 2, 2, 97, 98, 7, 103, 2, 2, 98, 10, 3, 2, 2, 2, 99, 100, 7, 111, 2, 2, 100, 101, 7, 113, 2, 2, 101, 102, 7, 102, 2, 2, 102, 103, 7, 119, 2, 2, 103, 104, 7, 110, 2, 2, 104, 105, 7, 103, 2, 2, 105, 12, 3, 2, 2, 2, 106, 107, 7, 107, 2, 2, 107, 108, 7, 111, 2, 2, 108, 109, 7, 114, 2, 2, 109, 110, 7, 113, 2, 2, 110, 111, 7, 116, 2, 2, 111, 112, 7, 118, 2, 2, 112, 14, 3, 2, 2, 2, 113, 114, 7, 103, 2, 2, 114, 115, 7, 115, 2, 2, 115, 116, 7, 119, 2, 2, 116, 117, 7, 99, 2, 2, 117, 118, 7, 110, 2, 2, 118, 16, 3, 2, 2, 2, 119, 123, 5, 53, 27, 2, 120, 122, 5, 51, 26, 2, 121, 120, 3, 2, 2, 2, 122, 125, 3, 2, 2, 2, 123, 121, 3, 2, 2, 2, 123, 124, 3, 2, 2, 2, 124, 18, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 126, 127, 7, 42, 2, 2, 127, 20, 3, 2, 2, 2, 128, 129, 7, 43, 2, 2, 129, 22, 3, 2, 2, 2, 130, 131, 7, 125, 2, 2, 131, 24, 3, 2, 2, 2, 132, 133, 7, 127, 2, 2, 133, 26, 3, 2, 2, 2, 134, 135, 7, 93, 2, 2, 135, 28, 3, 2, 2, 2, 136, 137, 7, 95, 2, 2, 137, 30, 3, 2, 2, 2, 138, 139, 7, 61, 2, 2, 139, 32, 3, 2, 2, 2, 140, 141, 7, 46, 2, 2, 141, 34, 3, 2, 2, 2, 142, 143, 7, 48, 2, 2, 143, 36, 3, 2, 2, 2, 144, 145, 7, 60, 2, 2, 145, 38, 3, 2, 2, 2, 146, 148, 9, 2, 2, 2, 147, 146, 3, 2, 2, 2, 148, 149, 3, 2, 2, 2, 149, 147, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 152, 8, 20, 2, 2, 152, 40, 3, 2, 2, 2, 153, 154, 7, 49, 2, 2, 154, 155, 7, 44, 2, 2, 155, 159, 3, 2, 2, 2, 156, 158, 11, 2, 2, 2, 157, 156, 3, 2, 2, 2, 158, 161, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 159, 157, 3, 2, 2, 2, 160, 162, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 162, 163, 7, 44, 2, 2, 163, 164, 7, 49, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 8, 21, 2, 2, 166, 42, 3, 2, 2, 2, 167, 168, 7, 49, 2, 2, 168, 169, 7, 49, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 10, 3, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 176, 177, 8, 22, 2, 2, 177, 44, 3, 2, 2, 2, 178, 183, 7, 36, 2, 2, 179, 182, 10, 4, 2, 2, 180, 182, 5, 49, 25, 2, 181, 179, 3, 2, 2, 2, 181, 180, 3, 2, 2, 2, 182, 185, 3, 2, 2, 2, 183, 181, 3, 2, 2, 2, 183, 184, 3, 2, 2, 2, 184, 186, 3, 2, 2, 2, 185, 183, 3, 2, 2, 2, 186, 187, 7, 36, 2, 2, 187, 46, 3, 2, 2, 2, 188, 189, 9, 5, 2, 2, 189, 48, 3, 2, 2, 2, 190, 191, 7, 94, 2, 2, 191, 212, 9, 6, 2, 2, 192, 197, 7, 94, 2, 2, 193, 195, 9, 7, 2, 2, 194, 193, 3, 2, 2, 2, 194, 195, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 198, 9, 8, 2, 2, 197, 194, 3, 2, 2, 2, 197, 198, 3, 2, 2, 2, 198, 199, 3, 2, 2, 2, 199, 212, 9, 8, 2, 2, 200, 202, 7, 94, 2, 2, 201, 203, 7, 119, 2, 2, 202, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 207, 5, 47, 24, 2, 207, 208, 5, 47, 24, 2, 208, 209, 5, 47, 24, 2, 209, 210, 5, 47, 24, 2, 210, 212, 3, 2, 2, 2, 211, 190, 3, 2, 2, 2, 211, 192, 3, 2, 2, 2, 211, 200, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2, 213, 216, 5, 53, 27, 2, 214, 216, 9, 9, 2, 2, 215, 213, 3, 2, 2, 2, 215, 214, 3, 2, 2, 2, 216, 52, 3, 2, 2, 2, 217, 222, 9, 10, 2, 2, 218, 222, 10, 11, 2, 2, 219, 220, 9, 12, 2, 2, 220, 222, 9, 13, 2, 2, 221, 217, 3, 2, 2, 2, 221, 218, 3, 2, 2, 2, 221, 219, 3, 2, 2, 2, 222, 54, 3, 2, 2, 2, 15, 2, 123, 149, 159, 173, 181, 183, 194, 197, 204, 211, 215, 221, 3, 2, 3, 2] -------------------------------------------------------------------------------- /languages/code/code_base_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Code.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Code 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // BaseCodeListener is a complete listener for a parse tree produced by CodeParser. 8 | type BaseCodeListener struct{} 9 | 10 | var _ CodeListener = &BaseCodeListener{} 11 | 12 | // VisitTerminal is called when a terminal node is visited. 13 | func (s *BaseCodeListener) VisitTerminal(node antlr.TerminalNode) {} 14 | 15 | // VisitErrorNode is called when an error node is visited. 16 | func (s *BaseCodeListener) VisitErrorNode(node antlr.ErrorNode) {} 17 | 18 | // EnterEveryRule is called when any rule is entered. 19 | func (s *BaseCodeListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} 20 | 21 | // ExitEveryRule is called when any rule is exited. 22 | func (s *BaseCodeListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} 23 | 24 | // EnterCompilationUnit is called when production compilationUnit is entered. 25 | func (s *BaseCodeListener) EnterCompilationUnit(ctx *CompilationUnitContext) {} 26 | 27 | // ExitCompilationUnit is called when production compilationUnit is exited. 28 | func (s *BaseCodeListener) ExitCompilationUnit(ctx *CompilationUnitContext) {} 29 | 30 | // EnterPackageDeclaration is called when production packageDeclaration is entered. 31 | func (s *BaseCodeListener) EnterPackageDeclaration(ctx *PackageDeclarationContext) {} 32 | 33 | // ExitPackageDeclaration is called when production packageDeclaration is exited. 34 | func (s *BaseCodeListener) ExitPackageDeclaration(ctx *PackageDeclarationContext) {} 35 | 36 | // EnterImportDeclaration is called when production importDeclaration is entered. 37 | func (s *BaseCodeListener) EnterImportDeclaration(ctx *ImportDeclarationContext) {} 38 | 39 | // ExitImportDeclaration is called when production importDeclaration is exited. 40 | func (s *BaseCodeListener) ExitImportDeclaration(ctx *ImportDeclarationContext) {} 41 | 42 | // EnterTypeDeclaration is called when production typeDeclaration is entered. 43 | func (s *BaseCodeListener) EnterTypeDeclaration(ctx *TypeDeclarationContext) {} 44 | 45 | // ExitTypeDeclaration is called when production typeDeclaration is exited. 46 | func (s *BaseCodeListener) ExitTypeDeclaration(ctx *TypeDeclarationContext) {} 47 | 48 | // EnterFunctionDeclaration is called when production functionDeclaration is entered. 49 | func (s *BaseCodeListener) EnterFunctionDeclaration(ctx *FunctionDeclarationContext) {} 50 | 51 | // ExitFunctionDeclaration is called when production functionDeclaration is exited. 52 | func (s *BaseCodeListener) ExitFunctionDeclaration(ctx *FunctionDeclarationContext) {} 53 | 54 | // EnterFunctionBody is called when production functionBody is entered. 55 | func (s *BaseCodeListener) EnterFunctionBody(ctx *FunctionBodyContext) {} 56 | 57 | // ExitFunctionBody is called when production functionBody is exited. 58 | func (s *BaseCodeListener) ExitFunctionBody(ctx *FunctionBodyContext) {} 59 | 60 | // EnterPrimary is called when production primary is entered. 61 | func (s *BaseCodeListener) EnterPrimary(ctx *PrimaryContext) {} 62 | 63 | // ExitPrimary is called when production primary is exited. 64 | func (s *BaseCodeListener) ExitPrimary(ctx *PrimaryContext) {} 65 | 66 | // EnterExpression is called when production expression is entered. 67 | func (s *BaseCodeListener) EnterExpression(ctx *ExpressionContext) {} 68 | 69 | // ExitExpression is called when production expression is exited. 70 | func (s *BaseCodeListener) ExitExpression(ctx *ExpressionContext) {} 71 | 72 | // EnterBlock is called when production block is entered. 73 | func (s *BaseCodeListener) EnterBlock(ctx *BlockContext) {} 74 | 75 | // ExitBlock is called when production block is exited. 76 | func (s *BaseCodeListener) ExitBlock(ctx *BlockContext) {} 77 | 78 | // EnterBlockStatement is called when production blockStatement is entered. 79 | func (s *BaseCodeListener) EnterBlockStatement(ctx *BlockStatementContext) {} 80 | 81 | // ExitBlockStatement is called when production blockStatement is exited. 82 | func (s *BaseCodeListener) ExitBlockStatement(ctx *BlockStatementContext) {} 83 | 84 | // EnterStatement is called when production statement is entered. 85 | func (s *BaseCodeListener) EnterStatement(ctx *StatementContext) {} 86 | 87 | // ExitStatement is called when production statement is exited. 88 | func (s *BaseCodeListener) ExitStatement(ctx *StatementContext) {} 89 | 90 | // EnterForControl is called when production forControl is entered. 91 | func (s *BaseCodeListener) EnterForControl(ctx *ForControlContext) {} 92 | 93 | // ExitForControl is called when production forControl is exited. 94 | func (s *BaseCodeListener) ExitForControl(ctx *ForControlContext) {} 95 | 96 | // EnterLocalVariableDeclaration is called when production localVariableDeclaration is entered. 97 | func (s *BaseCodeListener) EnterLocalVariableDeclaration(ctx *LocalVariableDeclarationContext) {} 98 | 99 | // ExitLocalVariableDeclaration is called when production localVariableDeclaration is exited. 100 | func (s *BaseCodeListener) ExitLocalVariableDeclaration(ctx *LocalVariableDeclarationContext) {} 101 | 102 | // EnterVariableDeclarators is called when production variableDeclarators is entered. 103 | func (s *BaseCodeListener) EnterVariableDeclarators(ctx *VariableDeclaratorsContext) {} 104 | 105 | // ExitVariableDeclarators is called when production variableDeclarators is exited. 106 | func (s *BaseCodeListener) ExitVariableDeclarators(ctx *VariableDeclaratorsContext) {} 107 | 108 | // EnterVariableDeclarator is called when production variableDeclarator is entered. 109 | func (s *BaseCodeListener) EnterVariableDeclarator(ctx *VariableDeclaratorContext) {} 110 | 111 | // ExitVariableDeclarator is called when production variableDeclarator is exited. 112 | func (s *BaseCodeListener) ExitVariableDeclarator(ctx *VariableDeclaratorContext) {} 113 | 114 | // EnterVariableDeclaratorId is called when production variableDeclaratorId is entered. 115 | func (s *BaseCodeListener) EnterVariableDeclaratorId(ctx *VariableDeclaratorIdContext) {} 116 | 117 | // ExitVariableDeclaratorId is called when production variableDeclaratorId is exited. 118 | func (s *BaseCodeListener) ExitVariableDeclaratorId(ctx *VariableDeclaratorIdContext) {} 119 | 120 | // EnterVariableInitializer is called when production variableInitializer is entered. 121 | func (s *BaseCodeListener) EnterVariableInitializer(ctx *VariableInitializerContext) {} 122 | 123 | // ExitVariableInitializer is called when production variableInitializer is exited. 124 | func (s *BaseCodeListener) ExitVariableInitializer(ctx *VariableInitializerContext) {} 125 | 126 | // EnterMethodCallDeclaration is called when production methodCallDeclaration is entered. 127 | func (s *BaseCodeListener) EnterMethodCallDeclaration(ctx *MethodCallDeclarationContext) {} 128 | 129 | // ExitMethodCallDeclaration is called when production methodCallDeclaration is exited. 130 | func (s *BaseCodeListener) ExitMethodCallDeclaration(ctx *MethodCallDeclarationContext) {} 131 | 132 | // EnterParameter is called when production parameter is entered. 133 | func (s *BaseCodeListener) EnterParameter(ctx *ParameterContext) {} 134 | 135 | // ExitParameter is called when production parameter is exited. 136 | func (s *BaseCodeListener) ExitParameter(ctx *ParameterContext) {} 137 | 138 | // EnterLiteral is called when production literal is entered. 139 | func (s *BaseCodeListener) EnterLiteral(ctx *LiteralContext) {} 140 | 141 | // ExitLiteral is called when production literal is exited. 142 | func (s *BaseCodeListener) ExitLiteral(ctx *LiteralContext) {} 143 | 144 | // EnterDataStructDeclaration is called when production dataStructDeclaration is entered. 145 | func (s *BaseCodeListener) EnterDataStructDeclaration(ctx *DataStructDeclarationContext) {} 146 | 147 | // ExitDataStructDeclaration is called when production dataStructDeclaration is exited. 148 | func (s *BaseCodeListener) ExitDataStructDeclaration(ctx *DataStructDeclarationContext) {} 149 | 150 | // EnterMemberDeclaration is called when production memberDeclaration is entered. 151 | func (s *BaseCodeListener) EnterMemberDeclaration(ctx *MemberDeclarationContext) {} 152 | 153 | // ExitMemberDeclaration is called when production memberDeclaration is exited. 154 | func (s *BaseCodeListener) ExitMemberDeclaration(ctx *MemberDeclarationContext) {} 155 | -------------------------------------------------------------------------------- /parser/template/template.go: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "github.com/valyala/bytebufferpool" 7 | "io" 8 | ) 9 | 10 | // ExecuteFunc calls f on each template tag (placeholder) occurrence. 11 | // 12 | // Returns the number of bytes written to w. 13 | // 14 | // This function is optimized for constantly changing templates. 15 | // Use Template.ExecuteFunc for frozen templates. 16 | func ExecuteFunc(template, startTag, endTag string, w io.Writer, f TagFunc) (int64, error) { 17 | s := unsafeString2Bytes(template) 18 | a := unsafeString2Bytes(startTag) 19 | b := unsafeString2Bytes(endTag) 20 | 21 | var nn int64 22 | var ni int 23 | var err error 24 | for { 25 | n := bytes.Index(s, a) 26 | if n < 0 { 27 | break 28 | } 29 | ni, err = w.Write(s[:n]) 30 | nn += int64(ni) 31 | if err != nil { 32 | return nn, err 33 | } 34 | 35 | s = s[n+len(a):] 36 | n = bytes.Index(s, b) 37 | if n < 0 { 38 | // cannot find end tag - just write it to the output. 39 | ni, _ = w.Write(a) 40 | nn += int64(ni) 41 | break 42 | } 43 | 44 | ni, err = f(w, unsafeBytes2String(s[:n])) 45 | nn += int64(ni) 46 | s = s[n+len(b):] 47 | } 48 | ni, err = w.Write(s) 49 | nn += int64(ni) 50 | 51 | return nn, err 52 | } 53 | 54 | // Execute substitutes template tags (placeholders) with the corresponding 55 | // values from the map m and writes the result to the given writer w. 56 | // 57 | // Substitution map m may contain values with the following types: 58 | // * []byte - the fastest value type 59 | // * string - convenient value type 60 | // * TagFunc - flexible value type 61 | // 62 | // Returns the number of bytes written to w. 63 | // 64 | // This function is optimized for constantly changing templates. 65 | // Use Template.Execute for frozen templates. 66 | func Execute(template, startTag, endTag string, w io.Writer, m map[string]interface{}) (int64, error) { 67 | return ExecuteFunc(template, startTag, endTag, w, func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) }) 68 | } 69 | 70 | // ExecuteFuncString calls f on each template tag (placeholder) occurrence 71 | // and substitutes it with the data written to TagFunc's w. 72 | // 73 | // Returns the resulting string. 74 | // 75 | // This function is optimized for constantly changing templates. 76 | // Use Template.ExecuteFuncString for frozen templates. 77 | func ExecuteFuncString(template, startTag, endTag string, f TagFunc) string { 78 | tagsCount := bytes.Count(unsafeString2Bytes(template), unsafeString2Bytes(startTag)) 79 | if tagsCount == 0 { 80 | return template 81 | } 82 | 83 | bb := byteBufferPool.Get() 84 | if _, err := ExecuteFunc(template, startTag, endTag, bb, f); err != nil { 85 | panic(fmt.Sprintf("unexpected error: %s", err)) 86 | } 87 | s := string(bb.B) 88 | bb.Reset() 89 | byteBufferPool.Put(bb) 90 | return s 91 | } 92 | 93 | var byteBufferPool bytebufferpool.Pool 94 | 95 | // ExecuteString substitutes template tags (placeholders) with the corresponding 96 | // values from the map m and returns the result. 97 | // 98 | // Substitution map m may contain values with the following types: 99 | // * []byte - the fastest value type 100 | // * string - convenient value type 101 | // * TagFunc - flexible value type 102 | // 103 | // This function is optimized for constantly changing templates. 104 | // Use Template.ExecuteString for frozen templates. 105 | func ExecuteString(template, startTag, endTag string, m map[string]interface{}) string { 106 | return ExecuteFuncString(template, startTag, endTag, func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) }) 107 | } 108 | 109 | // Template implements simple template engine, which can be used for fast 110 | // tags' (aka placeholders) substitution. 111 | type Template struct { 112 | template string 113 | startTag string 114 | endTag string 115 | 116 | texts [][]byte 117 | tags []string 118 | byteBufferPool bytebufferpool.Pool 119 | } 120 | 121 | // New parses the given template using the given startTag and endTag 122 | // as tag start and tag end. 123 | // 124 | // The returned template can be executed by concurrently running goroutines 125 | // using Execute* methods. 126 | // 127 | // New panics if the given template cannot be parsed. Use NewTemplate instead 128 | // if template may contain errors. 129 | func New(template, startTag, endTag string) *Template { 130 | t, err := NewTemplate(template, startTag, endTag) 131 | if err != nil { 132 | panic(err) 133 | } 134 | return t 135 | } 136 | 137 | // NewTemplate parses the given template using the given startTag and endTag 138 | // as tag start and tag end. 139 | // 140 | // The returned template can be executed by concurrently running goroutines 141 | // using Execute* methods. 142 | func NewTemplate(template, startTag, endTag string) (*Template, error) { 143 | var t Template 144 | err := t.Reset(template, startTag, endTag) 145 | if err != nil { 146 | return nil, err 147 | } 148 | return &t, nil 149 | } 150 | 151 | // TagFunc can be used as a substitution value in the map passed to Execute*. 152 | // Execute* functions pass tag (placeholder) name in 'tag' argument. 153 | // 154 | // TagFunc must be safe to call from concurrently running goroutines. 155 | // 156 | // TagFunc must write contents to w and return the number of bytes written. 157 | type TagFunc func(w io.Writer, tag string) (int, error) 158 | 159 | // Reset resets the template t to new one defined by 160 | // template, startTag and endTag. 161 | // 162 | // Reset allows Template object re-use. 163 | // 164 | // Reset may be called only if no other goroutines call t methods at the moment. 165 | func (t *Template) Reset(template, startTag, endTag string) error { 166 | // Keep these vars in t, so GC won't collect them and won't break 167 | // vars derived via unsafe* 168 | t.template = template 169 | t.startTag = startTag 170 | t.endTag = endTag 171 | t.texts = t.texts[:0] 172 | t.tags = t.tags[:0] 173 | 174 | if len(startTag) == 0 { 175 | panic("startTag cannot be empty") 176 | } 177 | if len(endTag) == 0 { 178 | panic("endTag cannot be empty") 179 | } 180 | 181 | s := unsafeString2Bytes(template) 182 | a := unsafeString2Bytes(startTag) 183 | b := unsafeString2Bytes(endTag) 184 | 185 | tagsCount := bytes.Count(s, a) 186 | if tagsCount == 0 { 187 | return nil 188 | } 189 | 190 | if tagsCount+1 > cap(t.texts) { 191 | t.texts = make([][]byte, 0, tagsCount+1) 192 | } 193 | if tagsCount > cap(t.tags) { 194 | t.tags = make([]string, 0, tagsCount) 195 | } 196 | 197 | for { 198 | n := bytes.Index(s, a) 199 | if n < 0 { 200 | t.texts = append(t.texts, s) 201 | break 202 | } 203 | t.texts = append(t.texts, s[:n]) 204 | 205 | s = s[n+len(a):] 206 | n = bytes.Index(s, b) 207 | if n < 0 { 208 | return fmt.Errorf("Cannot find end tag=%q in the template=%q starting from %q", endTag, template, s) 209 | } 210 | 211 | t.tags = append(t.tags, unsafeBytes2String(s[:n])) 212 | s = s[n+len(b):] 213 | } 214 | 215 | return nil 216 | } 217 | 218 | // ExecuteFunc calls f on each template tag (placeholder) occurrence. 219 | // 220 | // Returns the number of bytes written to w. 221 | // 222 | // This function is optimized for frozen templates. 223 | // Use ExecuteFunc for constantly changing templates. 224 | func (t *Template) ExecuteFunc(w io.Writer, f TagFunc) (int64, error) { 225 | var nn int64 226 | 227 | n := len(t.texts) - 1 228 | if n == -1 { 229 | ni, err := w.Write(unsafeString2Bytes(t.template)) 230 | return int64(ni), err 231 | } 232 | 233 | for i := 0; i < n; i++ { 234 | ni, err := w.Write(t.texts[i]) 235 | nn += int64(ni) 236 | if err != nil { 237 | return nn, err 238 | } 239 | 240 | ni, err = f(w, t.tags[i]) 241 | nn += int64(ni) 242 | if err != nil { 243 | return nn, err 244 | } 245 | } 246 | ni, err := w.Write(t.texts[n]) 247 | nn += int64(ni) 248 | return nn, err 249 | } 250 | 251 | // Execute substitutes template tags (placeholders) with the corresponding 252 | // values from the map m and writes the result to the given writer w. 253 | // 254 | // Substitution map m may contain values with the following types: 255 | // * []byte - the fastest value type 256 | // * string - convenient value type 257 | // * TagFunc - flexible value type 258 | // 259 | // Returns the number of bytes written to w. 260 | func (t *Template) Execute(w io.Writer, m map[string]interface{}) (int64, error) { 261 | return t.ExecuteFunc(w, func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) }) 262 | } 263 | 264 | // ExecuteFuncString calls f on each template tag (placeholder) occurrence 265 | // and substitutes it with the data written to TagFunc's w. 266 | // 267 | // Returns the resulting string. 268 | // 269 | // This function is optimized for frozen templates. 270 | // Use ExecuteFuncString for constantly changing templates. 271 | func (t *Template) ExecuteFuncString(f TagFunc) string { 272 | bb := t.byteBufferPool.Get() 273 | if _, err := t.ExecuteFunc(bb, f); err != nil { 274 | panic(fmt.Sprintf("unexpected error: %s", err)) 275 | } 276 | s := string(bb.Bytes()) 277 | bb.Reset() 278 | t.byteBufferPool.Put(bb) 279 | return s 280 | } 281 | 282 | // ExecuteString substitutes template tags (placeholders) with the corresponding 283 | // values from the map m and returns the result. 284 | // 285 | // Substitution map m may contain values with the following types: 286 | // * []byte - the fastest value type 287 | // * string - convenient value type 288 | // * TagFunc - flexible value type 289 | // 290 | // This function is optimized for frozen templates. 291 | // Use ExecuteString for constantly changing templates. 292 | func (t *Template) ExecuteString(m map[string]interface{}) string { 293 | return t.ExecuteFuncString(func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) }) 294 | } 295 | 296 | func stdTagFunc(w io.Writer, tag string, m map[string]interface{}) (int, error) { 297 | v := m[tag] 298 | if v == nil { 299 | return 0, nil 300 | } 301 | switch value := v.(type) { 302 | case []byte: 303 | return w.Write(value) 304 | case string: 305 | return w.Write([]byte(value)) 306 | case TagFunc: 307 | return value(w, tag) 308 | default: 309 | panic(fmt.Sprintf("tag=%q contains unexpected value type=%#v. Expected []byte, string or TagFunc", tag, v)) 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /languages/define/define_lexer.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser 4 | 5 | import ( 6 | "fmt" 7 | "unicode" 8 | 9 | "github.com/antlr/antlr4/runtime/Go/antlr" 10 | ) 11 | 12 | // Suppress unused import error 13 | var _ = fmt.Printf 14 | var _ = unicode.IsLetter 15 | 16 | var serializedLexerAtn = []uint16{ 17 | 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 24, 223, 18 | 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 19 | 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 20 | 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 21 | 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 22 | 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 3, 2, 3, 23 | 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 24 | 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 25 | 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 26 | 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 27 | 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 28 | 8, 3, 8, 3, 8, 3, 9, 3, 9, 7, 9, 122, 10, 9, 12, 9, 14, 9, 125, 11, 9, 29 | 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 30 | 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 31 | 6, 20, 148, 10, 20, 13, 20, 14, 20, 149, 3, 20, 3, 20, 3, 21, 3, 21, 3, 32 | 21, 3, 21, 7, 21, 158, 10, 21, 12, 21, 14, 21, 161, 11, 21, 3, 21, 3, 21, 33 | 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 172, 10, 22, 12, 34 | 22, 14, 22, 175, 11, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 7, 23, 182, 35 | 10, 23, 12, 23, 14, 23, 185, 11, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 36 | 3, 25, 3, 25, 3, 25, 5, 25, 195, 10, 25, 3, 25, 5, 25, 198, 10, 25, 3, 37 | 25, 3, 25, 3, 25, 6, 25, 203, 10, 25, 13, 25, 14, 25, 204, 3, 25, 3, 25, 38 | 3, 25, 3, 25, 3, 25, 5, 25, 212, 10, 25, 3, 26, 3, 26, 5, 26, 216, 10, 39 | 26, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 222, 10, 27, 3, 159, 2, 28, 3, 3, 40 | 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 41 | 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 42 | 43, 23, 45, 24, 47, 2, 49, 2, 51, 2, 53, 2, 3, 2, 14, 5, 2, 11, 12, 14, 43 | 15, 34, 34, 4, 2, 12, 12, 15, 15, 6, 2, 12, 12, 15, 15, 36, 36, 94, 94, 44 | 5, 2, 50, 59, 67, 72, 99, 104, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 45 | 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 3, 46 | 2, 50, 59, 6, 2, 38, 38, 67, 92, 97, 97, 99, 124, 4, 2, 2, 129, 55298, 47 | 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345, 2, 232, 2, 3, 3, 2, 2, 2, 48 | 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 49 | 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 50 | 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 51 | 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 52 | 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 53 | 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 3, 55, 3, 2, 2, 2, 5, 62, 3, 2, 2, 2, 7, 54 | 69, 3, 2, 2, 2, 9, 83, 3, 2, 2, 2, 11, 99, 3, 2, 2, 2, 13, 106, 3, 2, 2, 55 | 2, 15, 113, 3, 2, 2, 2, 17, 119, 3, 2, 2, 2, 19, 126, 3, 2, 2, 2, 21, 128, 56 | 3, 2, 2, 2, 23, 130, 3, 2, 2, 2, 25, 132, 3, 2, 2, 2, 27, 134, 3, 2, 2, 57 | 2, 29, 136, 3, 2, 2, 2, 31, 138, 3, 2, 2, 2, 33, 140, 3, 2, 2, 2, 35, 142, 58 | 3, 2, 2, 2, 37, 144, 3, 2, 2, 2, 39, 147, 3, 2, 2, 2, 41, 153, 3, 2, 2, 59 | 2, 43, 167, 3, 2, 2, 2, 45, 178, 3, 2, 2, 2, 47, 188, 3, 2, 2, 2, 49, 211, 60 | 3, 2, 2, 2, 51, 215, 3, 2, 2, 2, 53, 221, 3, 2, 2, 2, 55, 56, 7, 117, 2, 61 | 2, 56, 57, 7, 123, 2, 2, 57, 58, 7, 111, 2, 2, 58, 59, 7, 100, 2, 2, 59, 62 | 60, 7, 113, 2, 2, 60, 61, 7, 110, 2, 2, 61, 4, 3, 2, 2, 2, 62, 63, 7, 102, 63 | 2, 2, 63, 64, 7, 103, 2, 2, 64, 65, 7, 104, 2, 2, 65, 66, 7, 107, 2, 2, 64 | 66, 67, 7, 112, 2, 2, 67, 68, 7, 103, 2, 2, 68, 6, 3, 2, 2, 2, 69, 70, 65 | 7, 102, 2, 2, 70, 71, 7, 103, 2, 2, 71, 72, 7, 104, 2, 2, 72, 73, 7, 99, 66 | 2, 2, 73, 74, 7, 119, 2, 2, 74, 75, 7, 110, 2, 2, 75, 76, 7, 118, 2, 2, 67 | 76, 77, 7, 85, 2, 2, 77, 78, 7, 123, 2, 2, 78, 79, 7, 111, 2, 2, 79, 80, 68 | 7, 100, 2, 2, 80, 81, 7, 113, 2, 2, 81, 82, 7, 110, 2, 2, 82, 8, 3, 2, 69 | 2, 2, 83, 84, 7, 102, 2, 2, 84, 85, 7, 103, 2, 2, 85, 86, 7, 104, 2, 2, 70 | 86, 87, 7, 99, 2, 2, 87, 88, 7, 119, 2, 2, 88, 89, 7, 110, 2, 2, 89, 90, 71 | 7, 118, 2, 2, 90, 91, 7, 86, 2, 2, 91, 92, 7, 103, 2, 2, 92, 93, 7, 111, 72 | 2, 2, 93, 94, 7, 114, 2, 2, 94, 95, 7, 110, 2, 2, 95, 96, 7, 99, 2, 2, 73 | 96, 97, 7, 118, 2, 2, 97, 98, 7, 103, 2, 2, 98, 10, 3, 2, 2, 2, 99, 100, 74 | 7, 111, 2, 2, 100, 101, 7, 113, 2, 2, 101, 102, 7, 102, 2, 2, 102, 103, 75 | 7, 119, 2, 2, 103, 104, 7, 110, 2, 2, 104, 105, 7, 103, 2, 2, 105, 12, 76 | 3, 2, 2, 2, 106, 107, 7, 107, 2, 2, 107, 108, 7, 111, 2, 2, 108, 109, 7, 77 | 114, 2, 2, 109, 110, 7, 113, 2, 2, 110, 111, 7, 116, 2, 2, 111, 112, 7, 78 | 118, 2, 2, 112, 14, 3, 2, 2, 2, 113, 114, 7, 103, 2, 2, 114, 115, 7, 115, 79 | 2, 2, 115, 116, 7, 119, 2, 2, 116, 117, 7, 99, 2, 2, 117, 118, 7, 110, 80 | 2, 2, 118, 16, 3, 2, 2, 2, 119, 123, 5, 53, 27, 2, 120, 122, 5, 51, 26, 81 | 2, 121, 120, 3, 2, 2, 2, 122, 125, 3, 2, 2, 2, 123, 121, 3, 2, 2, 2, 123, 82 | 124, 3, 2, 2, 2, 124, 18, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 126, 127, 7, 83 | 42, 2, 2, 127, 20, 3, 2, 2, 2, 128, 129, 7, 43, 2, 2, 129, 22, 3, 2, 2, 84 | 2, 130, 131, 7, 125, 2, 2, 131, 24, 3, 2, 2, 2, 132, 133, 7, 127, 2, 2, 85 | 133, 26, 3, 2, 2, 2, 134, 135, 7, 93, 2, 2, 135, 28, 3, 2, 2, 2, 136, 137, 86 | 7, 95, 2, 2, 137, 30, 3, 2, 2, 2, 138, 139, 7, 61, 2, 2, 139, 32, 3, 2, 87 | 2, 2, 140, 141, 7, 46, 2, 2, 141, 34, 3, 2, 2, 2, 142, 143, 7, 48, 2, 2, 88 | 143, 36, 3, 2, 2, 2, 144, 145, 7, 60, 2, 2, 145, 38, 3, 2, 2, 2, 146, 148, 89 | 9, 2, 2, 2, 147, 146, 3, 2, 2, 2, 148, 149, 3, 2, 2, 2, 149, 147, 3, 2, 90 | 2, 2, 149, 150, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 152, 8, 20, 2, 2, 91 | 152, 40, 3, 2, 2, 2, 153, 154, 7, 49, 2, 2, 154, 155, 7, 44, 2, 2, 155, 92 | 159, 3, 2, 2, 2, 156, 158, 11, 2, 2, 2, 157, 156, 3, 2, 2, 2, 158, 161, 93 | 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 159, 157, 3, 2, 2, 2, 160, 162, 3, 2, 94 | 2, 2, 161, 159, 3, 2, 2, 2, 162, 163, 7, 44, 2, 2, 163, 164, 7, 49, 2, 95 | 2, 164, 165, 3, 2, 2, 2, 165, 166, 8, 21, 2, 2, 166, 42, 3, 2, 2, 2, 167, 96 | 168, 7, 49, 2, 2, 168, 169, 7, 49, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 97 | 10, 3, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 171, 3, 2, 98 | 2, 2, 173, 174, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 99 | 176, 177, 8, 22, 2, 2, 177, 44, 3, 2, 2, 2, 178, 183, 7, 36, 2, 2, 179, 100 | 182, 10, 4, 2, 2, 180, 182, 5, 49, 25, 2, 181, 179, 3, 2, 2, 2, 181, 180, 101 | 3, 2, 2, 2, 182, 185, 3, 2, 2, 2, 183, 181, 3, 2, 2, 2, 183, 184, 3, 2, 102 | 2, 2, 184, 186, 3, 2, 2, 2, 185, 183, 3, 2, 2, 2, 186, 187, 7, 36, 2, 2, 103 | 187, 46, 3, 2, 2, 2, 188, 189, 9, 5, 2, 2, 189, 48, 3, 2, 2, 2, 190, 191, 104 | 7, 94, 2, 2, 191, 212, 9, 6, 2, 2, 192, 197, 7, 94, 2, 2, 193, 195, 9, 105 | 7, 2, 2, 194, 193, 3, 2, 2, 2, 194, 195, 3, 2, 2, 2, 195, 196, 3, 2, 2, 106 | 2, 196, 198, 9, 8, 2, 2, 197, 194, 3, 2, 2, 2, 197, 198, 3, 2, 2, 2, 198, 107 | 199, 3, 2, 2, 2, 199, 212, 9, 8, 2, 2, 200, 202, 7, 94, 2, 2, 201, 203, 108 | 7, 119, 2, 2, 202, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 202, 3, 109 | 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 207, 5, 47, 24, 110 | 2, 207, 208, 5, 47, 24, 2, 208, 209, 5, 47, 24, 2, 209, 210, 5, 47, 24, 111 | 2, 210, 212, 3, 2, 2, 2, 211, 190, 3, 2, 2, 2, 211, 192, 3, 2, 2, 2, 211, 112 | 200, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2, 213, 216, 5, 53, 27, 2, 214, 216, 113 | 9, 9, 2, 2, 215, 213, 3, 2, 2, 2, 215, 214, 3, 2, 2, 2, 216, 52, 3, 2, 114 | 2, 2, 217, 222, 9, 10, 2, 2, 218, 222, 10, 11, 2, 2, 219, 220, 9, 12, 2, 115 | 2, 220, 222, 9, 13, 2, 2, 221, 217, 3, 2, 2, 2, 221, 218, 3, 2, 2, 2, 221, 116 | 219, 3, 2, 2, 2, 222, 54, 3, 2, 2, 2, 15, 2, 123, 149, 159, 173, 181, 183, 117 | 194, 197, 204, 211, 215, 221, 3, 2, 3, 2, 118 | } 119 | 120 | var lexerDeserializer = antlr.NewATNDeserializer(nil) 121 | var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) 122 | 123 | var lexerChannelNames = []string{ 124 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN", 125 | } 126 | 127 | var lexerModeNames = []string{ 128 | "DEFAULT_MODE", 129 | } 130 | 131 | var lexerLiteralNames = []string{ 132 | "", "'symbol'", "'define'", "'defaultSymbol'", "'defaultTemplate'", "'module'", 133 | "'import'", "'equal'", "", "'('", "')'", "'{'", "'}'", "'['", "']'", "';'", 134 | "','", "'.'", "':'", 135 | } 136 | 137 | var lexerSymbolicNames = []string{ 138 | "", "SYMBOL_TEXT", "DEFINE", "DEFAULT_SYMBOL", "DEFAULT_TEMPLATE", "MODULE", 139 | "IMPORT", "EQUAL", "IDENTIFIER", "LPAREN", "RPAREN", "LBRACE", "RBRACE", 140 | "LBRACK", "RBRACK", "SEMI", "COMMA", "DOT", "COLON", "WS", "COMMENT", "LINE_COMMENT", 141 | "STRING_LITERAL", 142 | } 143 | 144 | var lexerRuleNames = []string{ 145 | "SYMBOL_TEXT", "DEFINE", "DEFAULT_SYMBOL", "DEFAULT_TEMPLATE", "MODULE", 146 | "IMPORT", "EQUAL", "IDENTIFIER", "LPAREN", "RPAREN", "LBRACE", "RBRACE", 147 | "LBRACK", "RBRACK", "SEMI", "COMMA", "DOT", "COLON", "WS", "COMMENT", "LINE_COMMENT", 148 | "STRING_LITERAL", "HexDigit", "EscapeSequence", "LetterOrDigit", "Letter", 149 | } 150 | 151 | type DefineLexer struct { 152 | *antlr.BaseLexer 153 | channelNames []string 154 | modeNames []string 155 | // TODO: EOF string 156 | } 157 | 158 | var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState)) 159 | 160 | func init() { 161 | for index, ds := range lexerAtn.DecisionToState { 162 | lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) 163 | } 164 | } 165 | 166 | func NewDefineLexer(input antlr.CharStream) *DefineLexer { 167 | 168 | l := new(DefineLexer) 169 | 170 | l.BaseLexer = antlr.NewBaseLexer(input) 171 | l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) 172 | 173 | l.channelNames = lexerChannelNames 174 | l.modeNames = lexerModeNames 175 | l.RuleNames = lexerRuleNames 176 | l.LiteralNames = lexerLiteralNames 177 | l.SymbolicNames = lexerSymbolicNames 178 | l.GrammarFileName = "Define.g4" 179 | // TODO: l.EOF = antlr.TokenEOF 180 | 181 | return l 182 | } 183 | 184 | // DefineLexer tokens. 185 | const ( 186 | DefineLexerSYMBOL_TEXT = 1 187 | DefineLexerDEFINE = 2 188 | DefineLexerDEFAULT_SYMBOL = 3 189 | DefineLexerDEFAULT_TEMPLATE = 4 190 | DefineLexerMODULE = 5 191 | DefineLexerIMPORT = 6 192 | DefineLexerEQUAL = 7 193 | DefineLexerIDENTIFIER = 8 194 | DefineLexerLPAREN = 9 195 | DefineLexerRPAREN = 10 196 | DefineLexerLBRACE = 11 197 | DefineLexerRBRACE = 12 198 | DefineLexerLBRACK = 13 199 | DefineLexerRBRACK = 14 200 | DefineLexerSEMI = 15 201 | DefineLexerCOMMA = 16 202 | DefineLexerDOT = 17 203 | DefineLexerCOLON = 18 204 | DefineLexerWS = 19 205 | DefineLexerCOMMENT = 20 206 | DefineLexerLINE_COMMENT = 21 207 | DefineLexerSTRING_LITERAL = 22 208 | ) 209 | -------------------------------------------------------------------------------- /languages/code/CodeLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '(' 4 | ')' 5 | '{' 6 | '}' 7 | '<=' 8 | '>=' 9 | '>' 10 | '<' 11 | '*' 12 | '/' 13 | '%' 14 | '=' 15 | '+=' 16 | '-=' 17 | '*=' 18 | '/=' 19 | '&=' 20 | '|=' 21 | '^=' 22 | '>>=' 23 | '>>>=' 24 | '<<=' 25 | '%=' 26 | ',' 27 | 'for' 28 | 'var' 29 | 'package' 30 | 'import' 31 | 'struct' 32 | 'member' 33 | 'func' 34 | null 35 | null 36 | null 37 | null 38 | null 39 | null 40 | 41 | token symbolic names: 42 | null 43 | null 44 | null 45 | null 46 | null 47 | null 48 | null 49 | null 50 | null 51 | null 52 | null 53 | null 54 | null 55 | null 56 | null 57 | null 58 | null 59 | null 60 | null 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | FOR 68 | VAR 69 | PACKAGE 70 | IMPORT 71 | DATA_STRUCT 72 | MEMBER 73 | FUNCTION 74 | IDENTIFIER 75 | WS 76 | COMMENT 77 | LINE_COMMENT 78 | STRING_LITERAL 79 | DECIMAL_LITERAL 80 | 81 | rule names: 82 | T__0 83 | T__1 84 | T__2 85 | T__3 86 | T__4 87 | T__5 88 | T__6 89 | T__7 90 | T__8 91 | T__9 92 | T__10 93 | T__11 94 | T__12 95 | T__13 96 | T__14 97 | T__15 98 | T__16 99 | T__17 100 | T__18 101 | T__19 102 | T__20 103 | T__21 104 | T__22 105 | T__23 106 | FOR 107 | VAR 108 | PACKAGE 109 | IMPORT 110 | DATA_STRUCT 111 | MEMBER 112 | FUNCTION 113 | IDENTIFIER 114 | WS 115 | COMMENT 116 | LINE_COMMENT 117 | STRING_LITERAL 118 | DECIMAL_LITERAL 119 | Digits 120 | HexDigit 121 | EscapeSequence 122 | LetterOrDigit 123 | Letter 124 | 125 | channel names: 126 | DEFAULT_TOKEN_CHANNEL 127 | HIDDEN 128 | 129 | mode names: 130 | DEFAULT_MODE 131 | 132 | atn: 133 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 39, 306, 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, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 7, 33, 197, 10, 33, 12, 33, 14, 33, 200, 11, 33, 3, 34, 6, 34, 203, 10, 34, 13, 34, 14, 34, 204, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 7, 35, 213, 10, 35, 12, 35, 14, 35, 216, 11, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 7, 36, 227, 10, 36, 12, 36, 14, 36, 230, 11, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 7, 37, 237, 10, 37, 12, 37, 14, 37, 240, 11, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 5, 38, 247, 10, 38, 3, 38, 6, 38, 250, 10, 38, 13, 38, 14, 38, 251, 3, 38, 5, 38, 255, 10, 38, 5, 38, 257, 10, 38, 3, 38, 5, 38, 260, 10, 38, 3, 39, 3, 39, 7, 39, 264, 10, 39, 12, 39, 14, 39, 267, 11, 39, 3, 39, 5, 39, 270, 10, 39, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 278, 10, 41, 3, 41, 5, 41, 281, 10, 41, 3, 41, 3, 41, 3, 41, 6, 41, 286, 10, 41, 13, 41, 14, 41, 287, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 295, 10, 41, 3, 42, 3, 42, 5, 42, 299, 10, 42, 3, 43, 3, 43, 3, 43, 3, 43, 5, 43, 305, 10, 43, 3, 214, 2, 44, 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, 2, 79, 2, 81, 2, 83, 2, 85, 2, 3, 2, 17, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 6, 2, 12, 12, 15, 15, 36, 36, 94, 94, 3, 2, 51, 59, 4, 2, 78, 78, 110, 110, 3, 2, 50, 59, 4, 2, 50, 59, 97, 97, 5, 2, 50, 59, 67, 72, 99, 104, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 6, 2, 38, 38, 67, 92, 97, 97, 99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345, 2, 321, 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, 3, 87, 3, 2, 2, 2, 5, 89, 3, 2, 2, 2, 7, 91, 3, 2, 2, 2, 9, 93, 3, 2, 2, 2, 11, 95, 3, 2, 2, 2, 13, 98, 3, 2, 2, 2, 15, 101, 3, 2, 2, 2, 17, 103, 3, 2, 2, 2, 19, 105, 3, 2, 2, 2, 21, 107, 3, 2, 2, 2, 23, 109, 3, 2, 2, 2, 25, 111, 3, 2, 2, 2, 27, 113, 3, 2, 2, 2, 29, 116, 3, 2, 2, 2, 31, 119, 3, 2, 2, 2, 33, 122, 3, 2, 2, 2, 35, 125, 3, 2, 2, 2, 37, 128, 3, 2, 2, 2, 39, 131, 3, 2, 2, 2, 41, 134, 3, 2, 2, 2, 43, 138, 3, 2, 2, 2, 45, 143, 3, 2, 2, 2, 47, 147, 3, 2, 2, 2, 49, 150, 3, 2, 2, 2, 51, 152, 3, 2, 2, 2, 53, 156, 3, 2, 2, 2, 55, 160, 3, 2, 2, 2, 57, 168, 3, 2, 2, 2, 59, 175, 3, 2, 2, 2, 61, 182, 3, 2, 2, 2, 63, 189, 3, 2, 2, 2, 65, 194, 3, 2, 2, 2, 67, 202, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 222, 3, 2, 2, 2, 73, 233, 3, 2, 2, 2, 75, 256, 3, 2, 2, 2, 77, 261, 3, 2, 2, 2, 79, 271, 3, 2, 2, 2, 81, 294, 3, 2, 2, 2, 83, 298, 3, 2, 2, 2, 85, 304, 3, 2, 2, 2, 87, 88, 7, 42, 2, 2, 88, 4, 3, 2, 2, 2, 89, 90, 7, 43, 2, 2, 90, 6, 3, 2, 2, 2, 91, 92, 7, 125, 2, 2, 92, 8, 3, 2, 2, 2, 93, 94, 7, 127, 2, 2, 94, 10, 3, 2, 2, 2, 95, 96, 7, 62, 2, 2, 96, 97, 7, 63, 2, 2, 97, 12, 3, 2, 2, 2, 98, 99, 7, 64, 2, 2, 99, 100, 7, 63, 2, 2, 100, 14, 3, 2, 2, 2, 101, 102, 7, 64, 2, 2, 102, 16, 3, 2, 2, 2, 103, 104, 7, 62, 2, 2, 104, 18, 3, 2, 2, 2, 105, 106, 7, 44, 2, 2, 106, 20, 3, 2, 2, 2, 107, 108, 7, 49, 2, 2, 108, 22, 3, 2, 2, 2, 109, 110, 7, 39, 2, 2, 110, 24, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 26, 3, 2, 2, 2, 113, 114, 7, 45, 2, 2, 114, 115, 7, 63, 2, 2, 115, 28, 3, 2, 2, 2, 116, 117, 7, 47, 2, 2, 117, 118, 7, 63, 2, 2, 118, 30, 3, 2, 2, 2, 119, 120, 7, 44, 2, 2, 120, 121, 7, 63, 2, 2, 121, 32, 3, 2, 2, 2, 122, 123, 7, 49, 2, 2, 123, 124, 7, 63, 2, 2, 124, 34, 3, 2, 2, 2, 125, 126, 7, 40, 2, 2, 126, 127, 7, 63, 2, 2, 127, 36, 3, 2, 2, 2, 128, 129, 7, 126, 2, 2, 129, 130, 7, 63, 2, 2, 130, 38, 3, 2, 2, 2, 131, 132, 7, 96, 2, 2, 132, 133, 7, 63, 2, 2, 133, 40, 3, 2, 2, 2, 134, 135, 7, 64, 2, 2, 135, 136, 7, 64, 2, 2, 136, 137, 7, 63, 2, 2, 137, 42, 3, 2, 2, 2, 138, 139, 7, 64, 2, 2, 139, 140, 7, 64, 2, 2, 140, 141, 7, 64, 2, 2, 141, 142, 7, 63, 2, 2, 142, 44, 3, 2, 2, 2, 143, 144, 7, 62, 2, 2, 144, 145, 7, 62, 2, 2, 145, 146, 7, 63, 2, 2, 146, 46, 3, 2, 2, 2, 147, 148, 7, 39, 2, 2, 148, 149, 7, 63, 2, 2, 149, 48, 3, 2, 2, 2, 150, 151, 7, 46, 2, 2, 151, 50, 3, 2, 2, 2, 152, 153, 7, 104, 2, 2, 153, 154, 7, 113, 2, 2, 154, 155, 7, 116, 2, 2, 155, 52, 3, 2, 2, 2, 156, 157, 7, 120, 2, 2, 157, 158, 7, 99, 2, 2, 158, 159, 7, 116, 2, 2, 159, 54, 3, 2, 2, 2, 160, 161, 7, 114, 2, 2, 161, 162, 7, 99, 2, 2, 162, 163, 7, 101, 2, 2, 163, 164, 7, 109, 2, 2, 164, 165, 7, 99, 2, 2, 165, 166, 7, 105, 2, 2, 166, 167, 7, 103, 2, 2, 167, 56, 3, 2, 2, 2, 168, 169, 7, 107, 2, 2, 169, 170, 7, 111, 2, 2, 170, 171, 7, 114, 2, 2, 171, 172, 7, 113, 2, 2, 172, 173, 7, 116, 2, 2, 173, 174, 7, 118, 2, 2, 174, 58, 3, 2, 2, 2, 175, 176, 7, 117, 2, 2, 176, 177, 7, 118, 2, 2, 177, 178, 7, 116, 2, 2, 178, 179, 7, 119, 2, 2, 179, 180, 7, 101, 2, 2, 180, 181, 7, 118, 2, 2, 181, 60, 3, 2, 2, 2, 182, 183, 7, 111, 2, 2, 183, 184, 7, 103, 2, 2, 184, 185, 7, 111, 2, 2, 185, 186, 7, 100, 2, 2, 186, 187, 7, 103, 2, 2, 187, 188, 7, 116, 2, 2, 188, 62, 3, 2, 2, 2, 189, 190, 7, 104, 2, 2, 190, 191, 7, 119, 2, 2, 191, 192, 7, 112, 2, 2, 192, 193, 7, 101, 2, 2, 193, 64, 3, 2, 2, 2, 194, 198, 5, 85, 43, 2, 195, 197, 5, 83, 42, 2, 196, 195, 3, 2, 2, 2, 197, 200, 3, 2, 2, 2, 198, 196, 3, 2, 2, 2, 198, 199, 3, 2, 2, 2, 199, 66, 3, 2, 2, 2, 200, 198, 3, 2, 2, 2, 201, 203, 9, 2, 2, 2, 202, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 207, 8, 34, 2, 2, 207, 68, 3, 2, 2, 2, 208, 209, 7, 49, 2, 2, 209, 210, 7, 44, 2, 2, 210, 214, 3, 2, 2, 2, 211, 213, 11, 2, 2, 2, 212, 211, 3, 2, 2, 2, 213, 216, 3, 2, 2, 2, 214, 215, 3, 2, 2, 2, 214, 212, 3, 2, 2, 2, 215, 217, 3, 2, 2, 2, 216, 214, 3, 2, 2, 2, 217, 218, 7, 44, 2, 2, 218, 219, 7, 49, 2, 2, 219, 220, 3, 2, 2, 2, 220, 221, 8, 35, 2, 2, 221, 70, 3, 2, 2, 2, 222, 223, 7, 49, 2, 2, 223, 224, 7, 49, 2, 2, 224, 228, 3, 2, 2, 2, 225, 227, 10, 3, 2, 2, 226, 225, 3, 2, 2, 2, 227, 230, 3, 2, 2, 2, 228, 226, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 231, 3, 2, 2, 2, 230, 228, 3, 2, 2, 2, 231, 232, 8, 36, 2, 2, 232, 72, 3, 2, 2, 2, 233, 238, 7, 36, 2, 2, 234, 237, 10, 4, 2, 2, 235, 237, 5, 81, 41, 2, 236, 234, 3, 2, 2, 2, 236, 235, 3, 2, 2, 2, 237, 240, 3, 2, 2, 2, 238, 236, 3, 2, 2, 2, 238, 239, 3, 2, 2, 2, 239, 241, 3, 2, 2, 2, 240, 238, 3, 2, 2, 2, 241, 242, 7, 36, 2, 2, 242, 74, 3, 2, 2, 2, 243, 257, 7, 50, 2, 2, 244, 254, 9, 5, 2, 2, 245, 247, 5, 77, 39, 2, 246, 245, 3, 2, 2, 2, 246, 247, 3, 2, 2, 2, 247, 255, 3, 2, 2, 2, 248, 250, 7, 97, 2, 2, 249, 248, 3, 2, 2, 2, 250, 251, 3, 2, 2, 2, 251, 249, 3, 2, 2, 2, 251, 252, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 255, 5, 77, 39, 2, 254, 246, 3, 2, 2, 2, 254, 249, 3, 2, 2, 2, 255, 257, 3, 2, 2, 2, 256, 243, 3, 2, 2, 2, 256, 244, 3, 2, 2, 2, 257, 259, 3, 2, 2, 2, 258, 260, 9, 6, 2, 2, 259, 258, 3, 2, 2, 2, 259, 260, 3, 2, 2, 2, 260, 76, 3, 2, 2, 2, 261, 269, 9, 7, 2, 2, 262, 264, 9, 8, 2, 2, 263, 262, 3, 2, 2, 2, 264, 267, 3, 2, 2, 2, 265, 263, 3, 2, 2, 2, 265, 266, 3, 2, 2, 2, 266, 268, 3, 2, 2, 2, 267, 265, 3, 2, 2, 2, 268, 270, 9, 7, 2, 2, 269, 265, 3, 2, 2, 2, 269, 270, 3, 2, 2, 2, 270, 78, 3, 2, 2, 2, 271, 272, 9, 9, 2, 2, 272, 80, 3, 2, 2, 2, 273, 274, 7, 94, 2, 2, 274, 295, 9, 10, 2, 2, 275, 280, 7, 94, 2, 2, 276, 278, 9, 11, 2, 2, 277, 276, 3, 2, 2, 2, 277, 278, 3, 2, 2, 2, 278, 279, 3, 2, 2, 2, 279, 281, 9, 12, 2, 2, 280, 277, 3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 282, 3, 2, 2, 2, 282, 295, 9, 12, 2, 2, 283, 285, 7, 94, 2, 2, 284, 286, 7, 119, 2, 2, 285, 284, 3, 2, 2, 2, 286, 287, 3, 2, 2, 2, 287, 285, 3, 2, 2, 2, 287, 288, 3, 2, 2, 2, 288, 289, 3, 2, 2, 2, 289, 290, 5, 79, 40, 2, 290, 291, 5, 79, 40, 2, 291, 292, 5, 79, 40, 2, 292, 293, 5, 79, 40, 2, 293, 295, 3, 2, 2, 2, 294, 273, 3, 2, 2, 2, 294, 275, 3, 2, 2, 2, 294, 283, 3, 2, 2, 2, 295, 82, 3, 2, 2, 2, 296, 299, 5, 85, 43, 2, 297, 299, 9, 7, 2, 2, 298, 296, 3, 2, 2, 2, 298, 297, 3, 2, 2, 2, 299, 84, 3, 2, 2, 2, 300, 305, 9, 13, 2, 2, 301, 305, 10, 14, 2, 2, 302, 303, 9, 15, 2, 2, 303, 305, 9, 16, 2, 2, 304, 300, 3, 2, 2, 2, 304, 301, 3, 2, 2, 2, 304, 302, 3, 2, 2, 2, 305, 86, 3, 2, 2, 2, 22, 2, 198, 204, 214, 228, 236, 238, 246, 251, 254, 256, 259, 265, 269, 277, 280, 287, 294, 298, 304, 3, 2, 3, 2] -------------------------------------------------------------------------------- /languages/code/code_lexer.go: -------------------------------------------------------------------------------- 1 | // Code generated from Code.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser 4 | 5 | import ( 6 | "fmt" 7 | "unicode" 8 | 9 | "github.com/antlr/antlr4/runtime/Go/antlr" 10 | ) 11 | 12 | // Suppress unused import error 13 | var _ = fmt.Printf 14 | var _ = unicode.IsLetter 15 | 16 | var serializedLexerAtn = []uint16{ 17 | 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 39, 306, 18 | 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 19 | 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 20 | 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 21 | 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 22 | 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 23 | 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 24 | 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 25 | 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 3, 2, 26 | 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 27 | 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 28 | 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 29 | 16, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 20, 30 | 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 31 | 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 32 | 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 33 | 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 34 | 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 35 | 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 36 | 3, 33, 7, 33, 197, 10, 33, 12, 33, 14, 33, 200, 11, 33, 3, 34, 6, 34, 203, 37 | 10, 34, 13, 34, 14, 34, 204, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 38 | 7, 35, 213, 10, 35, 12, 35, 14, 35, 216, 11, 35, 3, 35, 3, 35, 3, 35, 3, 39 | 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 7, 36, 227, 10, 36, 12, 36, 14, 40 | 36, 230, 11, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 7, 37, 237, 10, 37, 41 | 12, 37, 14, 37, 240, 11, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 5, 38, 42 | 247, 10, 38, 3, 38, 6, 38, 250, 10, 38, 13, 38, 14, 38, 251, 3, 38, 5, 43 | 38, 255, 10, 38, 5, 38, 257, 10, 38, 3, 38, 5, 38, 260, 10, 38, 3, 39, 44 | 3, 39, 7, 39, 264, 10, 39, 12, 39, 14, 39, 267, 11, 39, 3, 39, 5, 39, 270, 45 | 10, 39, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 278, 10, 41, 3, 46 | 41, 5, 41, 281, 10, 41, 3, 41, 3, 41, 3, 41, 6, 41, 286, 10, 41, 13, 41, 47 | 14, 41, 287, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 295, 10, 41, 3, 48 | 42, 3, 42, 5, 42, 299, 10, 42, 3, 43, 3, 43, 3, 43, 3, 43, 5, 43, 305, 49 | 10, 43, 3, 214, 2, 44, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 50 | 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 51 | 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 52 | 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 53 | 37, 73, 38, 75, 39, 77, 2, 79, 2, 81, 2, 83, 2, 85, 2, 3, 2, 17, 5, 2, 54 | 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 6, 2, 12, 12, 15, 15, 36, 55 | 36, 94, 94, 3, 2, 51, 59, 4, 2, 78, 78, 110, 110, 3, 2, 50, 59, 4, 2, 50, 56 | 59, 97, 97, 5, 2, 50, 59, 67, 72, 99, 104, 10, 2, 36, 36, 41, 41, 94, 94, 57 | 100, 100, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 58 | 57, 6, 2, 38, 38, 67, 92, 97, 97, 99, 124, 4, 2, 2, 129, 55298, 56321, 59 | 3, 2, 55298, 56321, 3, 2, 56322, 57345, 2, 321, 2, 3, 3, 2, 2, 2, 2, 5, 60 | 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 61 | 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 62 | 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 63 | 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 64 | 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 65 | 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 66 | 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 67 | 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 68 | 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 69 | 2, 75, 3, 2, 2, 2, 3, 87, 3, 2, 2, 2, 5, 89, 3, 2, 2, 2, 7, 91, 3, 2, 2, 70 | 2, 9, 93, 3, 2, 2, 2, 11, 95, 3, 2, 2, 2, 13, 98, 3, 2, 2, 2, 15, 101, 71 | 3, 2, 2, 2, 17, 103, 3, 2, 2, 2, 19, 105, 3, 2, 2, 2, 21, 107, 3, 2, 2, 72 | 2, 23, 109, 3, 2, 2, 2, 25, 111, 3, 2, 2, 2, 27, 113, 3, 2, 2, 2, 29, 116, 73 | 3, 2, 2, 2, 31, 119, 3, 2, 2, 2, 33, 122, 3, 2, 2, 2, 35, 125, 3, 2, 2, 74 | 2, 37, 128, 3, 2, 2, 2, 39, 131, 3, 2, 2, 2, 41, 134, 3, 2, 2, 2, 43, 138, 75 | 3, 2, 2, 2, 45, 143, 3, 2, 2, 2, 47, 147, 3, 2, 2, 2, 49, 150, 3, 2, 2, 76 | 2, 51, 152, 3, 2, 2, 2, 53, 156, 3, 2, 2, 2, 55, 160, 3, 2, 2, 2, 57, 168, 77 | 3, 2, 2, 2, 59, 175, 3, 2, 2, 2, 61, 182, 3, 2, 2, 2, 63, 189, 3, 2, 2, 78 | 2, 65, 194, 3, 2, 2, 2, 67, 202, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 222, 79 | 3, 2, 2, 2, 73, 233, 3, 2, 2, 2, 75, 256, 3, 2, 2, 2, 77, 261, 3, 2, 2, 80 | 2, 79, 271, 3, 2, 2, 2, 81, 294, 3, 2, 2, 2, 83, 298, 3, 2, 2, 2, 85, 304, 81 | 3, 2, 2, 2, 87, 88, 7, 42, 2, 2, 88, 4, 3, 2, 2, 2, 89, 90, 7, 43, 2, 2, 82 | 90, 6, 3, 2, 2, 2, 91, 92, 7, 125, 2, 2, 92, 8, 3, 2, 2, 2, 93, 94, 7, 83 | 127, 2, 2, 94, 10, 3, 2, 2, 2, 95, 96, 7, 62, 2, 2, 96, 97, 7, 63, 2, 2, 84 | 97, 12, 3, 2, 2, 2, 98, 99, 7, 64, 2, 2, 99, 100, 7, 63, 2, 2, 100, 14, 85 | 3, 2, 2, 2, 101, 102, 7, 64, 2, 2, 102, 16, 3, 2, 2, 2, 103, 104, 7, 62, 86 | 2, 2, 104, 18, 3, 2, 2, 2, 105, 106, 7, 44, 2, 2, 106, 20, 3, 2, 2, 2, 87 | 107, 108, 7, 49, 2, 2, 108, 22, 3, 2, 2, 2, 109, 110, 7, 39, 2, 2, 110, 88 | 24, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 26, 3, 2, 2, 2, 113, 114, 7, 89 | 45, 2, 2, 114, 115, 7, 63, 2, 2, 115, 28, 3, 2, 2, 2, 116, 117, 7, 47, 90 | 2, 2, 117, 118, 7, 63, 2, 2, 118, 30, 3, 2, 2, 2, 119, 120, 7, 44, 2, 2, 91 | 120, 121, 7, 63, 2, 2, 121, 32, 3, 2, 2, 2, 122, 123, 7, 49, 2, 2, 123, 92 | 124, 7, 63, 2, 2, 124, 34, 3, 2, 2, 2, 125, 126, 7, 40, 2, 2, 126, 127, 93 | 7, 63, 2, 2, 127, 36, 3, 2, 2, 2, 128, 129, 7, 126, 2, 2, 129, 130, 7, 94 | 63, 2, 2, 130, 38, 3, 2, 2, 2, 131, 132, 7, 96, 2, 2, 132, 133, 7, 63, 95 | 2, 2, 133, 40, 3, 2, 2, 2, 134, 135, 7, 64, 2, 2, 135, 136, 7, 64, 2, 2, 96 | 136, 137, 7, 63, 2, 2, 137, 42, 3, 2, 2, 2, 138, 139, 7, 64, 2, 2, 139, 97 | 140, 7, 64, 2, 2, 140, 141, 7, 64, 2, 2, 141, 142, 7, 63, 2, 2, 142, 44, 98 | 3, 2, 2, 2, 143, 144, 7, 62, 2, 2, 144, 145, 7, 62, 2, 2, 145, 146, 7, 99 | 63, 2, 2, 146, 46, 3, 2, 2, 2, 147, 148, 7, 39, 2, 2, 148, 149, 7, 63, 100 | 2, 2, 149, 48, 3, 2, 2, 2, 150, 151, 7, 46, 2, 2, 151, 50, 3, 2, 2, 2, 101 | 152, 153, 7, 104, 2, 2, 153, 154, 7, 113, 2, 2, 154, 155, 7, 116, 2, 2, 102 | 155, 52, 3, 2, 2, 2, 156, 157, 7, 120, 2, 2, 157, 158, 7, 99, 2, 2, 158, 103 | 159, 7, 116, 2, 2, 159, 54, 3, 2, 2, 2, 160, 161, 7, 114, 2, 2, 161, 162, 104 | 7, 99, 2, 2, 162, 163, 7, 101, 2, 2, 163, 164, 7, 109, 2, 2, 164, 165, 105 | 7, 99, 2, 2, 165, 166, 7, 105, 2, 2, 166, 167, 7, 103, 2, 2, 167, 56, 3, 106 | 2, 2, 2, 168, 169, 7, 107, 2, 2, 169, 170, 7, 111, 2, 2, 170, 171, 7, 114, 107 | 2, 2, 171, 172, 7, 113, 2, 2, 172, 173, 7, 116, 2, 2, 173, 174, 7, 118, 108 | 2, 2, 174, 58, 3, 2, 2, 2, 175, 176, 7, 117, 2, 2, 176, 177, 7, 118, 2, 109 | 2, 177, 178, 7, 116, 2, 2, 178, 179, 7, 119, 2, 2, 179, 180, 7, 101, 2, 110 | 2, 180, 181, 7, 118, 2, 2, 181, 60, 3, 2, 2, 2, 182, 183, 7, 111, 2, 2, 111 | 183, 184, 7, 103, 2, 2, 184, 185, 7, 111, 2, 2, 185, 186, 7, 100, 2, 2, 112 | 186, 187, 7, 103, 2, 2, 187, 188, 7, 116, 2, 2, 188, 62, 3, 2, 2, 2, 189, 113 | 190, 7, 104, 2, 2, 190, 191, 7, 119, 2, 2, 191, 192, 7, 112, 2, 2, 192, 114 | 193, 7, 101, 2, 2, 193, 64, 3, 2, 2, 2, 194, 198, 5, 85, 43, 2, 195, 197, 115 | 5, 83, 42, 2, 196, 195, 3, 2, 2, 2, 197, 200, 3, 2, 2, 2, 198, 196, 3, 116 | 2, 2, 2, 198, 199, 3, 2, 2, 2, 199, 66, 3, 2, 2, 2, 200, 198, 3, 2, 2, 117 | 2, 201, 203, 9, 2, 2, 2, 202, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 118 | 202, 3, 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 207, 119 | 8, 34, 2, 2, 207, 68, 3, 2, 2, 2, 208, 209, 7, 49, 2, 2, 209, 210, 7, 44, 120 | 2, 2, 210, 214, 3, 2, 2, 2, 211, 213, 11, 2, 2, 2, 212, 211, 3, 2, 2, 2, 121 | 213, 216, 3, 2, 2, 2, 214, 215, 3, 2, 2, 2, 214, 212, 3, 2, 2, 2, 215, 122 | 217, 3, 2, 2, 2, 216, 214, 3, 2, 2, 2, 217, 218, 7, 44, 2, 2, 218, 219, 123 | 7, 49, 2, 2, 219, 220, 3, 2, 2, 2, 220, 221, 8, 35, 2, 2, 221, 70, 3, 2, 124 | 2, 2, 222, 223, 7, 49, 2, 2, 223, 224, 7, 49, 2, 2, 224, 228, 3, 2, 2, 125 | 2, 225, 227, 10, 3, 2, 2, 226, 225, 3, 2, 2, 2, 227, 230, 3, 2, 2, 2, 228, 126 | 226, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 231, 3, 2, 2, 2, 230, 228, 127 | 3, 2, 2, 2, 231, 232, 8, 36, 2, 2, 232, 72, 3, 2, 2, 2, 233, 238, 7, 36, 128 | 2, 2, 234, 237, 10, 4, 2, 2, 235, 237, 5, 81, 41, 2, 236, 234, 3, 2, 2, 129 | 2, 236, 235, 3, 2, 2, 2, 237, 240, 3, 2, 2, 2, 238, 236, 3, 2, 2, 2, 238, 130 | 239, 3, 2, 2, 2, 239, 241, 3, 2, 2, 2, 240, 238, 3, 2, 2, 2, 241, 242, 131 | 7, 36, 2, 2, 242, 74, 3, 2, 2, 2, 243, 257, 7, 50, 2, 2, 244, 254, 9, 5, 132 | 2, 2, 245, 247, 5, 77, 39, 2, 246, 245, 3, 2, 2, 2, 246, 247, 3, 2, 2, 133 | 2, 247, 255, 3, 2, 2, 2, 248, 250, 7, 97, 2, 2, 249, 248, 3, 2, 2, 2, 250, 134 | 251, 3, 2, 2, 2, 251, 249, 3, 2, 2, 2, 251, 252, 3, 2, 2, 2, 252, 253, 135 | 3, 2, 2, 2, 253, 255, 5, 77, 39, 2, 254, 246, 3, 2, 2, 2, 254, 249, 3, 136 | 2, 2, 2, 255, 257, 3, 2, 2, 2, 256, 243, 3, 2, 2, 2, 256, 244, 3, 2, 2, 137 | 2, 257, 259, 3, 2, 2, 2, 258, 260, 9, 6, 2, 2, 259, 258, 3, 2, 2, 2, 259, 138 | 260, 3, 2, 2, 2, 260, 76, 3, 2, 2, 2, 261, 269, 9, 7, 2, 2, 262, 264, 9, 139 | 8, 2, 2, 263, 262, 3, 2, 2, 2, 264, 267, 3, 2, 2, 2, 265, 263, 3, 2, 2, 140 | 2, 265, 266, 3, 2, 2, 2, 266, 268, 3, 2, 2, 2, 267, 265, 3, 2, 2, 2, 268, 141 | 270, 9, 7, 2, 2, 269, 265, 3, 2, 2, 2, 269, 270, 3, 2, 2, 2, 270, 78, 3, 142 | 2, 2, 2, 271, 272, 9, 9, 2, 2, 272, 80, 3, 2, 2, 2, 273, 274, 7, 94, 2, 143 | 2, 274, 295, 9, 10, 2, 2, 275, 280, 7, 94, 2, 2, 276, 278, 9, 11, 2, 2, 144 | 277, 276, 3, 2, 2, 2, 277, 278, 3, 2, 2, 2, 278, 279, 3, 2, 2, 2, 279, 145 | 281, 9, 12, 2, 2, 280, 277, 3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 282, 146 | 3, 2, 2, 2, 282, 295, 9, 12, 2, 2, 283, 285, 7, 94, 2, 2, 284, 286, 7, 147 | 119, 2, 2, 285, 284, 3, 2, 2, 2, 286, 287, 3, 2, 2, 2, 287, 285, 3, 2, 148 | 2, 2, 287, 288, 3, 2, 2, 2, 288, 289, 3, 2, 2, 2, 289, 290, 5, 79, 40, 149 | 2, 290, 291, 5, 79, 40, 2, 291, 292, 5, 79, 40, 2, 292, 293, 5, 79, 40, 150 | 2, 293, 295, 3, 2, 2, 2, 294, 273, 3, 2, 2, 2, 294, 275, 3, 2, 2, 2, 294, 151 | 283, 3, 2, 2, 2, 295, 82, 3, 2, 2, 2, 296, 299, 5, 85, 43, 2, 297, 299, 152 | 9, 7, 2, 2, 298, 296, 3, 2, 2, 2, 298, 297, 3, 2, 2, 2, 299, 84, 3, 2, 153 | 2, 2, 300, 305, 9, 13, 2, 2, 301, 305, 10, 14, 2, 2, 302, 303, 9, 15, 2, 154 | 2, 303, 305, 9, 16, 2, 2, 304, 300, 3, 2, 2, 2, 304, 301, 3, 2, 2, 2, 304, 155 | 302, 3, 2, 2, 2, 305, 86, 3, 2, 2, 2, 22, 2, 198, 204, 214, 228, 236, 238, 156 | 246, 251, 254, 256, 259, 265, 269, 277, 280, 287, 294, 298, 304, 3, 2, 157 | 3, 2, 158 | } 159 | 160 | var lexerDeserializer = antlr.NewATNDeserializer(nil) 161 | var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) 162 | 163 | var lexerChannelNames = []string{ 164 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN", 165 | } 166 | 167 | var lexerModeNames = []string{ 168 | "DEFAULT_MODE", 169 | } 170 | 171 | var lexerLiteralNames = []string{ 172 | "", "'('", "')'", "'{'", "'}'", "'<='", "'>='", "'>'", "'<'", "'*'", "'/'", 173 | "'%'", "'='", "'+='", "'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'>>='", 174 | "'>>>='", "'<<='", "'%='", "','", "'for'", "'var'", "'package'", "'import'", 175 | "'struct'", "'member'", "'func'", 176 | } 177 | 178 | var lexerSymbolicNames = []string{ 179 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 180 | "", "", "", "", "", "", "", "FOR", "VAR", "PACKAGE", "IMPORT", "DATA_STRUCT", 181 | "MEMBER", "FUNCTION", "IDENTIFIER", "WS", "COMMENT", "LINE_COMMENT", "STRING_LITERAL", 182 | "DECIMAL_LITERAL", 183 | } 184 | 185 | var lexerRuleNames = []string{ 186 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", 187 | "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", 188 | "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "FOR", "VAR", 189 | "PACKAGE", "IMPORT", "DATA_STRUCT", "MEMBER", "FUNCTION", "IDENTIFIER", 190 | "WS", "COMMENT", "LINE_COMMENT", "STRING_LITERAL", "DECIMAL_LITERAL", "Digits", 191 | "HexDigit", "EscapeSequence", "LetterOrDigit", "Letter", 192 | } 193 | 194 | type CodeLexer struct { 195 | *antlr.BaseLexer 196 | channelNames []string 197 | modeNames []string 198 | // TODO: EOF string 199 | } 200 | 201 | var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState)) 202 | 203 | func init() { 204 | for index, ds := range lexerAtn.DecisionToState { 205 | lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) 206 | } 207 | } 208 | 209 | func NewCodeLexer(input antlr.CharStream) *CodeLexer { 210 | 211 | l := new(CodeLexer) 212 | 213 | l.BaseLexer = antlr.NewBaseLexer(input) 214 | l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) 215 | 216 | l.channelNames = lexerChannelNames 217 | l.modeNames = lexerModeNames 218 | l.RuleNames = lexerRuleNames 219 | l.LiteralNames = lexerLiteralNames 220 | l.SymbolicNames = lexerSymbolicNames 221 | l.GrammarFileName = "Code.g4" 222 | // TODO: l.EOF = antlr.TokenEOF 223 | 224 | return l 225 | } 226 | 227 | // CodeLexer tokens. 228 | const ( 229 | CodeLexerT__0 = 1 230 | CodeLexerT__1 = 2 231 | CodeLexerT__2 = 3 232 | CodeLexerT__3 = 4 233 | CodeLexerT__4 = 5 234 | CodeLexerT__5 = 6 235 | CodeLexerT__6 = 7 236 | CodeLexerT__7 = 8 237 | CodeLexerT__8 = 9 238 | CodeLexerT__9 = 10 239 | CodeLexerT__10 = 11 240 | CodeLexerT__11 = 12 241 | CodeLexerT__12 = 13 242 | CodeLexerT__13 = 14 243 | CodeLexerT__14 = 15 244 | CodeLexerT__15 = 16 245 | CodeLexerT__16 = 17 246 | CodeLexerT__17 = 18 247 | CodeLexerT__18 = 19 248 | CodeLexerT__19 = 20 249 | CodeLexerT__20 = 21 250 | CodeLexerT__21 = 22 251 | CodeLexerT__22 = 23 252 | CodeLexerT__23 = 24 253 | CodeLexerFOR = 25 254 | CodeLexerVAR = 26 255 | CodeLexerPACKAGE = 27 256 | CodeLexerIMPORT = 28 257 | CodeLexerDATA_STRUCT = 29 258 | CodeLexerMEMBER = 30 259 | CodeLexerFUNCTION = 31 260 | CodeLexerIDENTIFIER = 32 261 | CodeLexerWS = 33 262 | CodeLexerCOMMENT = 34 263 | CodeLexerLINE_COMMENT = 35 264 | CodeLexerSTRING_LITERAL = 36 265 | CodeLexerDECIMAL_LITERAL = 37 266 | ) 267 | -------------------------------------------------------------------------------- /languages/define/define_parser.go: -------------------------------------------------------------------------------- 1 | // Code generated from Define.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Define 4 | 5 | import ( 6 | "fmt" 7 | "reflect" 8 | "strconv" 9 | 10 | "github.com/antlr/antlr4/runtime/Go/antlr" 11 | ) 12 | 13 | // Suppress unused import errors 14 | var _ = fmt.Printf 15 | var _ = reflect.Copy 16 | var _ = strconv.Itoa 17 | 18 | var parserATN = []uint16{ 19 | 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 24, 142, 20 | 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 21 | 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 22 | 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 23 | 18, 3, 2, 7, 2, 38, 10, 2, 12, 2, 14, 2, 41, 11, 2, 3, 2, 5, 2, 44, 10, 24 | 2, 3, 2, 7, 2, 47, 10, 2, 12, 2, 14, 2, 50, 11, 2, 3, 2, 3, 2, 3, 3, 3, 25 | 3, 3, 3, 3, 3, 3, 4, 3, 4, 5, 4, 60, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 7, 26 | 5, 66, 10, 5, 12, 5, 14, 5, 69, 11, 5, 3, 5, 3, 5, 3, 6, 3, 6, 5, 6, 75, 27 | 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 28 | 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 7, 11, 97, 10, 29 | 11, 12, 11, 14, 11, 100, 11, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 30 | 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 31 | 3, 16, 7, 16, 119, 10, 16, 12, 16, 14, 16, 122, 11, 16, 3, 16, 3, 16, 3, 32 | 17, 3, 17, 3, 17, 7, 17, 129, 10, 17, 12, 17, 14, 17, 132, 11, 17, 3, 17, 33 | 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 5, 18, 140, 10, 18, 3, 18, 2, 2, 19, 34 | 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 2, 2, 2, 35 | 134, 2, 39, 3, 2, 2, 2, 4, 53, 3, 2, 2, 2, 6, 59, 3, 2, 2, 2, 8, 61, 3, 36 | 2, 2, 2, 10, 74, 3, 2, 2, 2, 12, 76, 3, 2, 2, 2, 14, 81, 3, 2, 2, 2, 16, 37 | 89, 3, 2, 2, 2, 18, 91, 3, 2, 2, 2, 20, 93, 3, 2, 2, 2, 22, 104, 3, 2, 38 | 2, 2, 24, 106, 3, 2, 2, 2, 26, 110, 3, 2, 2, 2, 28, 112, 3, 2, 2, 2, 30, 39 | 114, 3, 2, 2, 2, 32, 125, 3, 2, 2, 2, 34, 139, 3, 2, 2, 2, 36, 38, 5, 4, 40 | 3, 2, 37, 36, 3, 2, 2, 2, 38, 41, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 39, 40, 41 | 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 42, 44, 5, 8, 5, 2, 42 | 43, 42, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 48, 3, 2, 2, 2, 45, 47, 5, 43 | 6, 4, 2, 46, 45, 3, 2, 2, 2, 47, 50, 3, 2, 2, 2, 48, 46, 3, 2, 2, 2, 48, 44 | 49, 3, 2, 2, 2, 49, 51, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 51, 52, 7, 2, 2, 45 | 3, 52, 3, 3, 2, 2, 2, 53, 54, 7, 3, 2, 2, 54, 55, 7, 10, 2, 2, 55, 56, 46 | 7, 24, 2, 2, 56, 5, 3, 2, 2, 2, 57, 60, 5, 24, 13, 2, 58, 60, 5, 30, 16, 47 | 2, 59, 57, 3, 2, 2, 2, 59, 58, 3, 2, 2, 2, 60, 7, 3, 2, 2, 2, 61, 62, 7, 48 | 4, 2, 2, 62, 63, 5, 26, 14, 2, 63, 67, 7, 13, 2, 2, 64, 66, 5, 10, 6, 2, 49 | 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 50 | 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 71, 7, 14, 2, 2, 71, 51 | 9, 3, 2, 2, 2, 72, 75, 5, 12, 7, 2, 73, 75, 5, 14, 8, 2, 74, 72, 3, 2, 52 | 2, 2, 74, 73, 3, 2, 2, 2, 75, 11, 3, 2, 2, 2, 76, 77, 7, 5, 2, 2, 77, 78, 53 | 7, 20, 2, 2, 78, 79, 5, 16, 9, 2, 79, 80, 5, 18, 10, 2, 80, 13, 3, 2, 2, 54 | 2, 81, 82, 7, 6, 2, 2, 82, 83, 7, 11, 2, 2, 83, 84, 7, 10, 2, 2, 84, 85, 55 | 7, 12, 2, 2, 85, 86, 7, 13, 2, 2, 86, 87, 5, 20, 11, 2, 87, 88, 7, 14, 56 | 2, 2, 88, 15, 3, 2, 2, 2, 89, 90, 7, 10, 2, 2, 90, 17, 3, 2, 2, 2, 91, 57 | 92, 7, 10, 2, 2, 92, 19, 3, 2, 2, 2, 93, 94, 5, 16, 9, 2, 94, 98, 7, 24, 58 | 2, 2, 95, 97, 5, 16, 9, 2, 96, 95, 3, 2, 2, 2, 97, 100, 3, 2, 2, 2, 98, 59 | 96, 3, 2, 2, 2, 98, 99, 3, 2, 2, 2, 99, 101, 3, 2, 2, 2, 100, 98, 3, 2, 60 | 2, 2, 101, 102, 5, 22, 12, 2, 102, 103, 5, 16, 9, 2, 103, 21, 3, 2, 2, 61 | 2, 104, 105, 7, 10, 2, 2, 105, 23, 3, 2, 2, 2, 106, 107, 5, 26, 14, 2, 62 | 107, 108, 7, 20, 2, 2, 108, 109, 5, 28, 15, 2, 109, 25, 3, 2, 2, 2, 110, 63 | 111, 7, 10, 2, 2, 111, 27, 3, 2, 2, 2, 112, 113, 7, 10, 2, 2, 113, 29, 64 | 3, 2, 2, 2, 114, 115, 7, 7, 2, 2, 115, 116, 7, 10, 2, 2, 116, 120, 7, 13, 65 | 2, 2, 117, 119, 5, 32, 17, 2, 118, 117, 3, 2, 2, 2, 119, 122, 3, 2, 2, 66 | 2, 120, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 123, 3, 2, 2, 2, 122, 67 | 120, 3, 2, 2, 2, 123, 124, 7, 14, 2, 2, 124, 31, 3, 2, 2, 2, 125, 126, 68 | 7, 10, 2, 2, 126, 130, 7, 13, 2, 2, 127, 129, 5, 34, 18, 2, 128, 127, 3, 69 | 2, 2, 2, 129, 132, 3, 2, 2, 2, 130, 128, 3, 2, 2, 2, 130, 131, 3, 2, 2, 70 | 2, 131, 133, 3, 2, 2, 2, 132, 130, 3, 2, 2, 2, 133, 134, 7, 14, 2, 2, 134, 71 | 33, 3, 2, 2, 2, 135, 136, 7, 8, 2, 2, 136, 140, 7, 24, 2, 2, 137, 138, 72 | 7, 9, 2, 2, 138, 140, 7, 24, 2, 2, 139, 135, 3, 2, 2, 2, 139, 137, 3, 2, 73 | 2, 2, 140, 35, 3, 2, 2, 2, 12, 39, 43, 48, 59, 67, 74, 98, 120, 130, 139, 74 | } 75 | var deserializer = antlr.NewATNDeserializer(nil) 76 | var deserializedATN = deserializer.DeserializeFromUInt16(parserATN) 77 | 78 | var literalNames = []string{ 79 | "", "'symbol'", "'define'", "'defaultSymbol'", "'defaultTemplate'", "'module'", 80 | "'import'", "'equal'", "", "'('", "')'", "'{'", "'}'", "'['", "']'", "';'", 81 | "','", "'.'", "':'", 82 | } 83 | var symbolicNames = []string{ 84 | "", "SYMBOL_TEXT", "DEFINE", "DEFAULT_SYMBOL", "DEFAULT_TEMPLATE", "MODULE", 85 | "IMPORT", "EQUAL", "IDENTIFIER", "LPAREN", "RPAREN", "LBRACE", "RBRACE", 86 | "LBRACK", "RBRACK", "SEMI", "COMMA", "DOT", "COLON", "WS", "COMMENT", "LINE_COMMENT", 87 | "STRING_LITERAL", 88 | } 89 | 90 | var ruleNames = []string{ 91 | "compilationUnit", "symbolDeclaration", "normalDeclarations", "defineDeclaration", 92 | "defineExpress", "defineAttribute", "defineTemplate", "symbolKey", "symbolValue", 93 | "defineBody", "templateData", "systemDeclaration", "defineKey", "defineValue", 94 | "moduleDeclaration", "moduleDefines", "moduleAttribute", 95 | } 96 | var decisionToDFA = make([]*antlr.DFA, len(deserializedATN.DecisionToState)) 97 | 98 | func init() { 99 | for index, ds := range deserializedATN.DecisionToState { 100 | decisionToDFA[index] = antlr.NewDFA(ds, index) 101 | } 102 | } 103 | 104 | type DefineParser struct { 105 | *antlr.BaseParser 106 | } 107 | 108 | func NewDefineParser(input antlr.TokenStream) *DefineParser { 109 | this := new(DefineParser) 110 | 111 | this.BaseParser = antlr.NewBaseParser(input) 112 | 113 | this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) 114 | this.RuleNames = ruleNames 115 | this.LiteralNames = literalNames 116 | this.SymbolicNames = symbolicNames 117 | this.GrammarFileName = "Define.g4" 118 | 119 | return this 120 | } 121 | 122 | // DefineParser tokens. 123 | const ( 124 | DefineParserEOF = antlr.TokenEOF 125 | DefineParserSYMBOL_TEXT = 1 126 | DefineParserDEFINE = 2 127 | DefineParserDEFAULT_SYMBOL = 3 128 | DefineParserDEFAULT_TEMPLATE = 4 129 | DefineParserMODULE = 5 130 | DefineParserIMPORT = 6 131 | DefineParserEQUAL = 7 132 | DefineParserIDENTIFIER = 8 133 | DefineParserLPAREN = 9 134 | DefineParserRPAREN = 10 135 | DefineParserLBRACE = 11 136 | DefineParserRBRACE = 12 137 | DefineParserLBRACK = 13 138 | DefineParserRBRACK = 14 139 | DefineParserSEMI = 15 140 | DefineParserCOMMA = 16 141 | DefineParserDOT = 17 142 | DefineParserCOLON = 18 143 | DefineParserWS = 19 144 | DefineParserCOMMENT = 20 145 | DefineParserLINE_COMMENT = 21 146 | DefineParserSTRING_LITERAL = 22 147 | ) 148 | 149 | // DefineParser rules. 150 | const ( 151 | DefineParserRULE_compilationUnit = 0 152 | DefineParserRULE_symbolDeclaration = 1 153 | DefineParserRULE_normalDeclarations = 2 154 | DefineParserRULE_defineDeclaration = 3 155 | DefineParserRULE_defineExpress = 4 156 | DefineParserRULE_defineAttribute = 5 157 | DefineParserRULE_defineTemplate = 6 158 | DefineParserRULE_symbolKey = 7 159 | DefineParserRULE_symbolValue = 8 160 | DefineParserRULE_defineBody = 9 161 | DefineParserRULE_templateData = 10 162 | DefineParserRULE_systemDeclaration = 11 163 | DefineParserRULE_defineKey = 12 164 | DefineParserRULE_defineValue = 13 165 | DefineParserRULE_moduleDeclaration = 14 166 | DefineParserRULE_moduleDefines = 15 167 | DefineParserRULE_moduleAttribute = 16 168 | ) 169 | 170 | // ICompilationUnitContext is an interface to support dynamic dispatch. 171 | type ICompilationUnitContext interface { 172 | antlr.ParserRuleContext 173 | 174 | // GetParser returns the parser. 175 | GetParser() antlr.Parser 176 | 177 | // IsCompilationUnitContext differentiates from other interfaces. 178 | IsCompilationUnitContext() 179 | } 180 | 181 | type CompilationUnitContext struct { 182 | *antlr.BaseParserRuleContext 183 | parser antlr.Parser 184 | } 185 | 186 | func NewEmptyCompilationUnitContext() *CompilationUnitContext { 187 | var p = new(CompilationUnitContext) 188 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 189 | p.RuleIndex = DefineParserRULE_compilationUnit 190 | return p 191 | } 192 | 193 | func (*CompilationUnitContext) IsCompilationUnitContext() {} 194 | 195 | func NewCompilationUnitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CompilationUnitContext { 196 | var p = new(CompilationUnitContext) 197 | 198 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 199 | 200 | p.parser = parser 201 | p.RuleIndex = DefineParserRULE_compilationUnit 202 | 203 | return p 204 | } 205 | 206 | func (s *CompilationUnitContext) GetParser() antlr.Parser { return s.parser } 207 | 208 | func (s *CompilationUnitContext) EOF() antlr.TerminalNode { 209 | return s.GetToken(DefineParserEOF, 0) 210 | } 211 | 212 | func (s *CompilationUnitContext) AllSymbolDeclaration() []ISymbolDeclarationContext { 213 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISymbolDeclarationContext)(nil)).Elem()) 214 | var tst = make([]ISymbolDeclarationContext, len(ts)) 215 | 216 | for i, t := range ts { 217 | if t != nil { 218 | tst[i] = t.(ISymbolDeclarationContext) 219 | } 220 | } 221 | 222 | return tst 223 | } 224 | 225 | func (s *CompilationUnitContext) SymbolDeclaration(i int) ISymbolDeclarationContext { 226 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ISymbolDeclarationContext)(nil)).Elem(), i) 227 | 228 | if t == nil { 229 | return nil 230 | } 231 | 232 | return t.(ISymbolDeclarationContext) 233 | } 234 | 235 | func (s *CompilationUnitContext) DefineDeclaration() IDefineDeclarationContext { 236 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineDeclarationContext)(nil)).Elem(), 0) 237 | 238 | if t == nil { 239 | return nil 240 | } 241 | 242 | return t.(IDefineDeclarationContext) 243 | } 244 | 245 | func (s *CompilationUnitContext) AllNormalDeclarations() []INormalDeclarationsContext { 246 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*INormalDeclarationsContext)(nil)).Elem()) 247 | var tst = make([]INormalDeclarationsContext, len(ts)) 248 | 249 | for i, t := range ts { 250 | if t != nil { 251 | tst[i] = t.(INormalDeclarationsContext) 252 | } 253 | } 254 | 255 | return tst 256 | } 257 | 258 | func (s *CompilationUnitContext) NormalDeclarations(i int) INormalDeclarationsContext { 259 | var t = s.GetTypedRuleContext(reflect.TypeOf((*INormalDeclarationsContext)(nil)).Elem(), i) 260 | 261 | if t == nil { 262 | return nil 263 | } 264 | 265 | return t.(INormalDeclarationsContext) 266 | } 267 | 268 | func (s *CompilationUnitContext) GetRuleContext() antlr.RuleContext { 269 | return s 270 | } 271 | 272 | func (s *CompilationUnitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 273 | return antlr.TreesStringTree(s, ruleNames, recog) 274 | } 275 | 276 | func (s *CompilationUnitContext) EnterRule(listener antlr.ParseTreeListener) { 277 | if listenerT, ok := listener.(DefineListener); ok { 278 | listenerT.EnterCompilationUnit(s) 279 | } 280 | } 281 | 282 | func (s *CompilationUnitContext) ExitRule(listener antlr.ParseTreeListener) { 283 | if listenerT, ok := listener.(DefineListener); ok { 284 | listenerT.ExitCompilationUnit(s) 285 | } 286 | } 287 | 288 | func (s *CompilationUnitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 289 | switch t := visitor.(type) { 290 | case DefineVisitor: 291 | return t.VisitCompilationUnit(s) 292 | 293 | default: 294 | return t.VisitChildren(s) 295 | } 296 | } 297 | 298 | func (p *DefineParser) CompilationUnit() (localctx ICompilationUnitContext) { 299 | localctx = NewCompilationUnitContext(p, p.GetParserRuleContext(), p.GetState()) 300 | p.EnterRule(localctx, 0, DefineParserRULE_compilationUnit) 301 | var _la int 302 | 303 | defer func() { 304 | p.ExitRule() 305 | }() 306 | 307 | defer func() { 308 | if err := recover(); err != nil { 309 | if v, ok := err.(antlr.RecognitionException); ok { 310 | localctx.SetException(v) 311 | p.GetErrorHandler().ReportError(p, v) 312 | p.GetErrorHandler().Recover(p, v) 313 | } else { 314 | panic(err) 315 | } 316 | } 317 | }() 318 | 319 | p.EnterOuterAlt(localctx, 1) 320 | p.SetState(37) 321 | p.GetErrorHandler().Sync(p) 322 | _la = p.GetTokenStream().LA(1) 323 | 324 | for _la == DefineParserSYMBOL_TEXT { 325 | { 326 | p.SetState(34) 327 | p.SymbolDeclaration() 328 | } 329 | 330 | p.SetState(39) 331 | p.GetErrorHandler().Sync(p) 332 | _la = p.GetTokenStream().LA(1) 333 | } 334 | p.SetState(41) 335 | p.GetErrorHandler().Sync(p) 336 | _la = p.GetTokenStream().LA(1) 337 | 338 | if _la == DefineParserDEFINE { 339 | { 340 | p.SetState(40) 341 | p.DefineDeclaration() 342 | } 343 | 344 | } 345 | p.SetState(46) 346 | p.GetErrorHandler().Sync(p) 347 | _la = p.GetTokenStream().LA(1) 348 | 349 | for _la == DefineParserMODULE || _la == DefineParserIDENTIFIER { 350 | { 351 | p.SetState(43) 352 | p.NormalDeclarations() 353 | } 354 | 355 | p.SetState(48) 356 | p.GetErrorHandler().Sync(p) 357 | _la = p.GetTokenStream().LA(1) 358 | } 359 | { 360 | p.SetState(49) 361 | p.Match(DefineParserEOF) 362 | } 363 | 364 | return localctx 365 | } 366 | 367 | // ISymbolDeclarationContext is an interface to support dynamic dispatch. 368 | type ISymbolDeclarationContext interface { 369 | antlr.ParserRuleContext 370 | 371 | // GetParser returns the parser. 372 | GetParser() antlr.Parser 373 | 374 | // IsSymbolDeclarationContext differentiates from other interfaces. 375 | IsSymbolDeclarationContext() 376 | } 377 | 378 | type SymbolDeclarationContext struct { 379 | *antlr.BaseParserRuleContext 380 | parser antlr.Parser 381 | } 382 | 383 | func NewEmptySymbolDeclarationContext() *SymbolDeclarationContext { 384 | var p = new(SymbolDeclarationContext) 385 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 386 | p.RuleIndex = DefineParserRULE_symbolDeclaration 387 | return p 388 | } 389 | 390 | func (*SymbolDeclarationContext) IsSymbolDeclarationContext() {} 391 | 392 | func NewSymbolDeclarationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SymbolDeclarationContext { 393 | var p = new(SymbolDeclarationContext) 394 | 395 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 396 | 397 | p.parser = parser 398 | p.RuleIndex = DefineParserRULE_symbolDeclaration 399 | 400 | return p 401 | } 402 | 403 | func (s *SymbolDeclarationContext) GetParser() antlr.Parser { return s.parser } 404 | 405 | func (s *SymbolDeclarationContext) SYMBOL_TEXT() antlr.TerminalNode { 406 | return s.GetToken(DefineParserSYMBOL_TEXT, 0) 407 | } 408 | 409 | func (s *SymbolDeclarationContext) IDENTIFIER() antlr.TerminalNode { 410 | return s.GetToken(DefineParserIDENTIFIER, 0) 411 | } 412 | 413 | func (s *SymbolDeclarationContext) STRING_LITERAL() antlr.TerminalNode { 414 | return s.GetToken(DefineParserSTRING_LITERAL, 0) 415 | } 416 | 417 | func (s *SymbolDeclarationContext) GetRuleContext() antlr.RuleContext { 418 | return s 419 | } 420 | 421 | func (s *SymbolDeclarationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 422 | return antlr.TreesStringTree(s, ruleNames, recog) 423 | } 424 | 425 | func (s *SymbolDeclarationContext) EnterRule(listener antlr.ParseTreeListener) { 426 | if listenerT, ok := listener.(DefineListener); ok { 427 | listenerT.EnterSymbolDeclaration(s) 428 | } 429 | } 430 | 431 | func (s *SymbolDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { 432 | if listenerT, ok := listener.(DefineListener); ok { 433 | listenerT.ExitSymbolDeclaration(s) 434 | } 435 | } 436 | 437 | func (s *SymbolDeclarationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 438 | switch t := visitor.(type) { 439 | case DefineVisitor: 440 | return t.VisitSymbolDeclaration(s) 441 | 442 | default: 443 | return t.VisitChildren(s) 444 | } 445 | } 446 | 447 | func (p *DefineParser) SymbolDeclaration() (localctx ISymbolDeclarationContext) { 448 | localctx = NewSymbolDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) 449 | p.EnterRule(localctx, 2, DefineParserRULE_symbolDeclaration) 450 | 451 | defer func() { 452 | p.ExitRule() 453 | }() 454 | 455 | defer func() { 456 | if err := recover(); err != nil { 457 | if v, ok := err.(antlr.RecognitionException); ok { 458 | localctx.SetException(v) 459 | p.GetErrorHandler().ReportError(p, v) 460 | p.GetErrorHandler().Recover(p, v) 461 | } else { 462 | panic(err) 463 | } 464 | } 465 | }() 466 | 467 | p.EnterOuterAlt(localctx, 1) 468 | { 469 | p.SetState(51) 470 | p.Match(DefineParserSYMBOL_TEXT) 471 | } 472 | { 473 | p.SetState(52) 474 | p.Match(DefineParserIDENTIFIER) 475 | } 476 | { 477 | p.SetState(53) 478 | p.Match(DefineParserSTRING_LITERAL) 479 | } 480 | 481 | return localctx 482 | } 483 | 484 | // INormalDeclarationsContext is an interface to support dynamic dispatch. 485 | type INormalDeclarationsContext interface { 486 | antlr.ParserRuleContext 487 | 488 | // GetParser returns the parser. 489 | GetParser() antlr.Parser 490 | 491 | // IsNormalDeclarationsContext differentiates from other interfaces. 492 | IsNormalDeclarationsContext() 493 | } 494 | 495 | type NormalDeclarationsContext struct { 496 | *antlr.BaseParserRuleContext 497 | parser antlr.Parser 498 | } 499 | 500 | func NewEmptyNormalDeclarationsContext() *NormalDeclarationsContext { 501 | var p = new(NormalDeclarationsContext) 502 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 503 | p.RuleIndex = DefineParserRULE_normalDeclarations 504 | return p 505 | } 506 | 507 | func (*NormalDeclarationsContext) IsNormalDeclarationsContext() {} 508 | 509 | func NewNormalDeclarationsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalDeclarationsContext { 510 | var p = new(NormalDeclarationsContext) 511 | 512 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 513 | 514 | p.parser = parser 515 | p.RuleIndex = DefineParserRULE_normalDeclarations 516 | 517 | return p 518 | } 519 | 520 | func (s *NormalDeclarationsContext) GetParser() antlr.Parser { return s.parser } 521 | 522 | func (s *NormalDeclarationsContext) SystemDeclaration() ISystemDeclarationContext { 523 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ISystemDeclarationContext)(nil)).Elem(), 0) 524 | 525 | if t == nil { 526 | return nil 527 | } 528 | 529 | return t.(ISystemDeclarationContext) 530 | } 531 | 532 | func (s *NormalDeclarationsContext) ModuleDeclaration() IModuleDeclarationContext { 533 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IModuleDeclarationContext)(nil)).Elem(), 0) 534 | 535 | if t == nil { 536 | return nil 537 | } 538 | 539 | return t.(IModuleDeclarationContext) 540 | } 541 | 542 | func (s *NormalDeclarationsContext) GetRuleContext() antlr.RuleContext { 543 | return s 544 | } 545 | 546 | func (s *NormalDeclarationsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 547 | return antlr.TreesStringTree(s, ruleNames, recog) 548 | } 549 | 550 | func (s *NormalDeclarationsContext) EnterRule(listener antlr.ParseTreeListener) { 551 | if listenerT, ok := listener.(DefineListener); ok { 552 | listenerT.EnterNormalDeclarations(s) 553 | } 554 | } 555 | 556 | func (s *NormalDeclarationsContext) ExitRule(listener antlr.ParseTreeListener) { 557 | if listenerT, ok := listener.(DefineListener); ok { 558 | listenerT.ExitNormalDeclarations(s) 559 | } 560 | } 561 | 562 | func (s *NormalDeclarationsContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 563 | switch t := visitor.(type) { 564 | case DefineVisitor: 565 | return t.VisitNormalDeclarations(s) 566 | 567 | default: 568 | return t.VisitChildren(s) 569 | } 570 | } 571 | 572 | func (p *DefineParser) NormalDeclarations() (localctx INormalDeclarationsContext) { 573 | localctx = NewNormalDeclarationsContext(p, p.GetParserRuleContext(), p.GetState()) 574 | p.EnterRule(localctx, 4, DefineParserRULE_normalDeclarations) 575 | 576 | defer func() { 577 | p.ExitRule() 578 | }() 579 | 580 | defer func() { 581 | if err := recover(); err != nil { 582 | if v, ok := err.(antlr.RecognitionException); ok { 583 | localctx.SetException(v) 584 | p.GetErrorHandler().ReportError(p, v) 585 | p.GetErrorHandler().Recover(p, v) 586 | } else { 587 | panic(err) 588 | } 589 | } 590 | }() 591 | 592 | p.SetState(57) 593 | p.GetErrorHandler().Sync(p) 594 | 595 | switch p.GetTokenStream().LA(1) { 596 | case DefineParserIDENTIFIER: 597 | p.EnterOuterAlt(localctx, 1) 598 | { 599 | p.SetState(55) 600 | p.SystemDeclaration() 601 | } 602 | 603 | case DefineParserMODULE: 604 | p.EnterOuterAlt(localctx, 2) 605 | { 606 | p.SetState(56) 607 | p.ModuleDeclaration() 608 | } 609 | 610 | default: 611 | panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) 612 | } 613 | 614 | return localctx 615 | } 616 | 617 | // IDefineDeclarationContext is an interface to support dynamic dispatch. 618 | type IDefineDeclarationContext interface { 619 | antlr.ParserRuleContext 620 | 621 | // GetParser returns the parser. 622 | GetParser() antlr.Parser 623 | 624 | // IsDefineDeclarationContext differentiates from other interfaces. 625 | IsDefineDeclarationContext() 626 | } 627 | 628 | type DefineDeclarationContext struct { 629 | *antlr.BaseParserRuleContext 630 | parser antlr.Parser 631 | } 632 | 633 | func NewEmptyDefineDeclarationContext() *DefineDeclarationContext { 634 | var p = new(DefineDeclarationContext) 635 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 636 | p.RuleIndex = DefineParserRULE_defineDeclaration 637 | return p 638 | } 639 | 640 | func (*DefineDeclarationContext) IsDefineDeclarationContext() {} 641 | 642 | func NewDefineDeclarationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineDeclarationContext { 643 | var p = new(DefineDeclarationContext) 644 | 645 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 646 | 647 | p.parser = parser 648 | p.RuleIndex = DefineParserRULE_defineDeclaration 649 | 650 | return p 651 | } 652 | 653 | func (s *DefineDeclarationContext) GetParser() antlr.Parser { return s.parser } 654 | 655 | func (s *DefineDeclarationContext) DEFINE() antlr.TerminalNode { 656 | return s.GetToken(DefineParserDEFINE, 0) 657 | } 658 | 659 | func (s *DefineDeclarationContext) DefineKey() IDefineKeyContext { 660 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineKeyContext)(nil)).Elem(), 0) 661 | 662 | if t == nil { 663 | return nil 664 | } 665 | 666 | return t.(IDefineKeyContext) 667 | } 668 | 669 | func (s *DefineDeclarationContext) LBRACE() antlr.TerminalNode { 670 | return s.GetToken(DefineParserLBRACE, 0) 671 | } 672 | 673 | func (s *DefineDeclarationContext) RBRACE() antlr.TerminalNode { 674 | return s.GetToken(DefineParserRBRACE, 0) 675 | } 676 | 677 | func (s *DefineDeclarationContext) AllDefineExpress() []IDefineExpressContext { 678 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IDefineExpressContext)(nil)).Elem()) 679 | var tst = make([]IDefineExpressContext, len(ts)) 680 | 681 | for i, t := range ts { 682 | if t != nil { 683 | tst[i] = t.(IDefineExpressContext) 684 | } 685 | } 686 | 687 | return tst 688 | } 689 | 690 | func (s *DefineDeclarationContext) DefineExpress(i int) IDefineExpressContext { 691 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineExpressContext)(nil)).Elem(), i) 692 | 693 | if t == nil { 694 | return nil 695 | } 696 | 697 | return t.(IDefineExpressContext) 698 | } 699 | 700 | func (s *DefineDeclarationContext) GetRuleContext() antlr.RuleContext { 701 | return s 702 | } 703 | 704 | func (s *DefineDeclarationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 705 | return antlr.TreesStringTree(s, ruleNames, recog) 706 | } 707 | 708 | func (s *DefineDeclarationContext) EnterRule(listener antlr.ParseTreeListener) { 709 | if listenerT, ok := listener.(DefineListener); ok { 710 | listenerT.EnterDefineDeclaration(s) 711 | } 712 | } 713 | 714 | func (s *DefineDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { 715 | if listenerT, ok := listener.(DefineListener); ok { 716 | listenerT.ExitDefineDeclaration(s) 717 | } 718 | } 719 | 720 | func (s *DefineDeclarationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 721 | switch t := visitor.(type) { 722 | case DefineVisitor: 723 | return t.VisitDefineDeclaration(s) 724 | 725 | default: 726 | return t.VisitChildren(s) 727 | } 728 | } 729 | 730 | func (p *DefineParser) DefineDeclaration() (localctx IDefineDeclarationContext) { 731 | localctx = NewDefineDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) 732 | p.EnterRule(localctx, 6, DefineParserRULE_defineDeclaration) 733 | var _la int 734 | 735 | defer func() { 736 | p.ExitRule() 737 | }() 738 | 739 | defer func() { 740 | if err := recover(); err != nil { 741 | if v, ok := err.(antlr.RecognitionException); ok { 742 | localctx.SetException(v) 743 | p.GetErrorHandler().ReportError(p, v) 744 | p.GetErrorHandler().Recover(p, v) 745 | } else { 746 | panic(err) 747 | } 748 | } 749 | }() 750 | 751 | p.EnterOuterAlt(localctx, 1) 752 | { 753 | p.SetState(59) 754 | p.Match(DefineParserDEFINE) 755 | } 756 | { 757 | p.SetState(60) 758 | p.DefineKey() 759 | } 760 | { 761 | p.SetState(61) 762 | p.Match(DefineParserLBRACE) 763 | } 764 | p.SetState(65) 765 | p.GetErrorHandler().Sync(p) 766 | _la = p.GetTokenStream().LA(1) 767 | 768 | for _la == DefineParserDEFAULT_SYMBOL || _la == DefineParserDEFAULT_TEMPLATE { 769 | { 770 | p.SetState(62) 771 | p.DefineExpress() 772 | } 773 | 774 | p.SetState(67) 775 | p.GetErrorHandler().Sync(p) 776 | _la = p.GetTokenStream().LA(1) 777 | } 778 | { 779 | p.SetState(68) 780 | p.Match(DefineParserRBRACE) 781 | } 782 | 783 | return localctx 784 | } 785 | 786 | // IDefineExpressContext is an interface to support dynamic dispatch. 787 | type IDefineExpressContext interface { 788 | antlr.ParserRuleContext 789 | 790 | // GetParser returns the parser. 791 | GetParser() antlr.Parser 792 | 793 | // IsDefineExpressContext differentiates from other interfaces. 794 | IsDefineExpressContext() 795 | } 796 | 797 | type DefineExpressContext struct { 798 | *antlr.BaseParserRuleContext 799 | parser antlr.Parser 800 | } 801 | 802 | func NewEmptyDefineExpressContext() *DefineExpressContext { 803 | var p = new(DefineExpressContext) 804 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 805 | p.RuleIndex = DefineParserRULE_defineExpress 806 | return p 807 | } 808 | 809 | func (*DefineExpressContext) IsDefineExpressContext() {} 810 | 811 | func NewDefineExpressContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineExpressContext { 812 | var p = new(DefineExpressContext) 813 | 814 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 815 | 816 | p.parser = parser 817 | p.RuleIndex = DefineParserRULE_defineExpress 818 | 819 | return p 820 | } 821 | 822 | func (s *DefineExpressContext) GetParser() antlr.Parser { return s.parser } 823 | 824 | func (s *DefineExpressContext) DefineAttribute() IDefineAttributeContext { 825 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineAttributeContext)(nil)).Elem(), 0) 826 | 827 | if t == nil { 828 | return nil 829 | } 830 | 831 | return t.(IDefineAttributeContext) 832 | } 833 | 834 | func (s *DefineExpressContext) DefineTemplate() IDefineTemplateContext { 835 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineTemplateContext)(nil)).Elem(), 0) 836 | 837 | if t == nil { 838 | return nil 839 | } 840 | 841 | return t.(IDefineTemplateContext) 842 | } 843 | 844 | func (s *DefineExpressContext) GetRuleContext() antlr.RuleContext { 845 | return s 846 | } 847 | 848 | func (s *DefineExpressContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 849 | return antlr.TreesStringTree(s, ruleNames, recog) 850 | } 851 | 852 | func (s *DefineExpressContext) EnterRule(listener antlr.ParseTreeListener) { 853 | if listenerT, ok := listener.(DefineListener); ok { 854 | listenerT.EnterDefineExpress(s) 855 | } 856 | } 857 | 858 | func (s *DefineExpressContext) ExitRule(listener antlr.ParseTreeListener) { 859 | if listenerT, ok := listener.(DefineListener); ok { 860 | listenerT.ExitDefineExpress(s) 861 | } 862 | } 863 | 864 | func (s *DefineExpressContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 865 | switch t := visitor.(type) { 866 | case DefineVisitor: 867 | return t.VisitDefineExpress(s) 868 | 869 | default: 870 | return t.VisitChildren(s) 871 | } 872 | } 873 | 874 | func (p *DefineParser) DefineExpress() (localctx IDefineExpressContext) { 875 | localctx = NewDefineExpressContext(p, p.GetParserRuleContext(), p.GetState()) 876 | p.EnterRule(localctx, 8, DefineParserRULE_defineExpress) 877 | 878 | defer func() { 879 | p.ExitRule() 880 | }() 881 | 882 | defer func() { 883 | if err := recover(); err != nil { 884 | if v, ok := err.(antlr.RecognitionException); ok { 885 | localctx.SetException(v) 886 | p.GetErrorHandler().ReportError(p, v) 887 | p.GetErrorHandler().Recover(p, v) 888 | } else { 889 | panic(err) 890 | } 891 | } 892 | }() 893 | 894 | p.SetState(72) 895 | p.GetErrorHandler().Sync(p) 896 | 897 | switch p.GetTokenStream().LA(1) { 898 | case DefineParserDEFAULT_SYMBOL: 899 | p.EnterOuterAlt(localctx, 1) 900 | { 901 | p.SetState(70) 902 | p.DefineAttribute() 903 | } 904 | 905 | case DefineParserDEFAULT_TEMPLATE: 906 | p.EnterOuterAlt(localctx, 2) 907 | { 908 | p.SetState(71) 909 | p.DefineTemplate() 910 | } 911 | 912 | default: 913 | panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) 914 | } 915 | 916 | return localctx 917 | } 918 | 919 | // IDefineAttributeContext is an interface to support dynamic dispatch. 920 | type IDefineAttributeContext interface { 921 | antlr.ParserRuleContext 922 | 923 | // GetParser returns the parser. 924 | GetParser() antlr.Parser 925 | 926 | // IsDefineAttributeContext differentiates from other interfaces. 927 | IsDefineAttributeContext() 928 | } 929 | 930 | type DefineAttributeContext struct { 931 | *antlr.BaseParserRuleContext 932 | parser antlr.Parser 933 | } 934 | 935 | func NewEmptyDefineAttributeContext() *DefineAttributeContext { 936 | var p = new(DefineAttributeContext) 937 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 938 | p.RuleIndex = DefineParserRULE_defineAttribute 939 | return p 940 | } 941 | 942 | func (*DefineAttributeContext) IsDefineAttributeContext() {} 943 | 944 | func NewDefineAttributeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineAttributeContext { 945 | var p = new(DefineAttributeContext) 946 | 947 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 948 | 949 | p.parser = parser 950 | p.RuleIndex = DefineParserRULE_defineAttribute 951 | 952 | return p 953 | } 954 | 955 | func (s *DefineAttributeContext) GetParser() antlr.Parser { return s.parser } 956 | 957 | func (s *DefineAttributeContext) DEFAULT_SYMBOL() antlr.TerminalNode { 958 | return s.GetToken(DefineParserDEFAULT_SYMBOL, 0) 959 | } 960 | 961 | func (s *DefineAttributeContext) COLON() antlr.TerminalNode { 962 | return s.GetToken(DefineParserCOLON, 0) 963 | } 964 | 965 | func (s *DefineAttributeContext) SymbolKey() ISymbolKeyContext { 966 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ISymbolKeyContext)(nil)).Elem(), 0) 967 | 968 | if t == nil { 969 | return nil 970 | } 971 | 972 | return t.(ISymbolKeyContext) 973 | } 974 | 975 | func (s *DefineAttributeContext) SymbolValue() ISymbolValueContext { 976 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ISymbolValueContext)(nil)).Elem(), 0) 977 | 978 | if t == nil { 979 | return nil 980 | } 981 | 982 | return t.(ISymbolValueContext) 983 | } 984 | 985 | func (s *DefineAttributeContext) GetRuleContext() antlr.RuleContext { 986 | return s 987 | } 988 | 989 | func (s *DefineAttributeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 990 | return antlr.TreesStringTree(s, ruleNames, recog) 991 | } 992 | 993 | func (s *DefineAttributeContext) EnterRule(listener antlr.ParseTreeListener) { 994 | if listenerT, ok := listener.(DefineListener); ok { 995 | listenerT.EnterDefineAttribute(s) 996 | } 997 | } 998 | 999 | func (s *DefineAttributeContext) ExitRule(listener antlr.ParseTreeListener) { 1000 | if listenerT, ok := listener.(DefineListener); ok { 1001 | listenerT.ExitDefineAttribute(s) 1002 | } 1003 | } 1004 | 1005 | func (s *DefineAttributeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1006 | switch t := visitor.(type) { 1007 | case DefineVisitor: 1008 | return t.VisitDefineAttribute(s) 1009 | 1010 | default: 1011 | return t.VisitChildren(s) 1012 | } 1013 | } 1014 | 1015 | func (p *DefineParser) DefineAttribute() (localctx IDefineAttributeContext) { 1016 | localctx = NewDefineAttributeContext(p, p.GetParserRuleContext(), p.GetState()) 1017 | p.EnterRule(localctx, 10, DefineParserRULE_defineAttribute) 1018 | 1019 | defer func() { 1020 | p.ExitRule() 1021 | }() 1022 | 1023 | defer func() { 1024 | if err := recover(); err != nil { 1025 | if v, ok := err.(antlr.RecognitionException); ok { 1026 | localctx.SetException(v) 1027 | p.GetErrorHandler().ReportError(p, v) 1028 | p.GetErrorHandler().Recover(p, v) 1029 | } else { 1030 | panic(err) 1031 | } 1032 | } 1033 | }() 1034 | 1035 | p.EnterOuterAlt(localctx, 1) 1036 | { 1037 | p.SetState(74) 1038 | p.Match(DefineParserDEFAULT_SYMBOL) 1039 | } 1040 | { 1041 | p.SetState(75) 1042 | p.Match(DefineParserCOLON) 1043 | } 1044 | { 1045 | p.SetState(76) 1046 | p.SymbolKey() 1047 | } 1048 | { 1049 | p.SetState(77) 1050 | p.SymbolValue() 1051 | } 1052 | 1053 | return localctx 1054 | } 1055 | 1056 | // IDefineTemplateContext is an interface to support dynamic dispatch. 1057 | type IDefineTemplateContext interface { 1058 | antlr.ParserRuleContext 1059 | 1060 | // GetParser returns the parser. 1061 | GetParser() antlr.Parser 1062 | 1063 | // IsDefineTemplateContext differentiates from other interfaces. 1064 | IsDefineTemplateContext() 1065 | } 1066 | 1067 | type DefineTemplateContext struct { 1068 | *antlr.BaseParserRuleContext 1069 | parser antlr.Parser 1070 | } 1071 | 1072 | func NewEmptyDefineTemplateContext() *DefineTemplateContext { 1073 | var p = new(DefineTemplateContext) 1074 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1075 | p.RuleIndex = DefineParserRULE_defineTemplate 1076 | return p 1077 | } 1078 | 1079 | func (*DefineTemplateContext) IsDefineTemplateContext() {} 1080 | 1081 | func NewDefineTemplateContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineTemplateContext { 1082 | var p = new(DefineTemplateContext) 1083 | 1084 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1085 | 1086 | p.parser = parser 1087 | p.RuleIndex = DefineParserRULE_defineTemplate 1088 | 1089 | return p 1090 | } 1091 | 1092 | func (s *DefineTemplateContext) GetParser() antlr.Parser { return s.parser } 1093 | 1094 | func (s *DefineTemplateContext) DEFAULT_TEMPLATE() antlr.TerminalNode { 1095 | return s.GetToken(DefineParserDEFAULT_TEMPLATE, 0) 1096 | } 1097 | 1098 | func (s *DefineTemplateContext) LPAREN() antlr.TerminalNode { 1099 | return s.GetToken(DefineParserLPAREN, 0) 1100 | } 1101 | 1102 | func (s *DefineTemplateContext) IDENTIFIER() antlr.TerminalNode { 1103 | return s.GetToken(DefineParserIDENTIFIER, 0) 1104 | } 1105 | 1106 | func (s *DefineTemplateContext) RPAREN() antlr.TerminalNode { 1107 | return s.GetToken(DefineParserRPAREN, 0) 1108 | } 1109 | 1110 | func (s *DefineTemplateContext) LBRACE() antlr.TerminalNode { 1111 | return s.GetToken(DefineParserLBRACE, 0) 1112 | } 1113 | 1114 | func (s *DefineTemplateContext) DefineBody() IDefineBodyContext { 1115 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineBodyContext)(nil)).Elem(), 0) 1116 | 1117 | if t == nil { 1118 | return nil 1119 | } 1120 | 1121 | return t.(IDefineBodyContext) 1122 | } 1123 | 1124 | func (s *DefineTemplateContext) RBRACE() antlr.TerminalNode { 1125 | return s.GetToken(DefineParserRBRACE, 0) 1126 | } 1127 | 1128 | func (s *DefineTemplateContext) GetRuleContext() antlr.RuleContext { 1129 | return s 1130 | } 1131 | 1132 | func (s *DefineTemplateContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1133 | return antlr.TreesStringTree(s, ruleNames, recog) 1134 | } 1135 | 1136 | func (s *DefineTemplateContext) EnterRule(listener antlr.ParseTreeListener) { 1137 | if listenerT, ok := listener.(DefineListener); ok { 1138 | listenerT.EnterDefineTemplate(s) 1139 | } 1140 | } 1141 | 1142 | func (s *DefineTemplateContext) ExitRule(listener antlr.ParseTreeListener) { 1143 | if listenerT, ok := listener.(DefineListener); ok { 1144 | listenerT.ExitDefineTemplate(s) 1145 | } 1146 | } 1147 | 1148 | func (s *DefineTemplateContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1149 | switch t := visitor.(type) { 1150 | case DefineVisitor: 1151 | return t.VisitDefineTemplate(s) 1152 | 1153 | default: 1154 | return t.VisitChildren(s) 1155 | } 1156 | } 1157 | 1158 | func (p *DefineParser) DefineTemplate() (localctx IDefineTemplateContext) { 1159 | localctx = NewDefineTemplateContext(p, p.GetParserRuleContext(), p.GetState()) 1160 | p.EnterRule(localctx, 12, DefineParserRULE_defineTemplate) 1161 | 1162 | defer func() { 1163 | p.ExitRule() 1164 | }() 1165 | 1166 | defer func() { 1167 | if err := recover(); err != nil { 1168 | if v, ok := err.(antlr.RecognitionException); ok { 1169 | localctx.SetException(v) 1170 | p.GetErrorHandler().ReportError(p, v) 1171 | p.GetErrorHandler().Recover(p, v) 1172 | } else { 1173 | panic(err) 1174 | } 1175 | } 1176 | }() 1177 | 1178 | p.EnterOuterAlt(localctx, 1) 1179 | { 1180 | p.SetState(79) 1181 | p.Match(DefineParserDEFAULT_TEMPLATE) 1182 | } 1183 | { 1184 | p.SetState(80) 1185 | p.Match(DefineParserLPAREN) 1186 | } 1187 | { 1188 | p.SetState(81) 1189 | p.Match(DefineParserIDENTIFIER) 1190 | } 1191 | { 1192 | p.SetState(82) 1193 | p.Match(DefineParserRPAREN) 1194 | } 1195 | { 1196 | p.SetState(83) 1197 | p.Match(DefineParserLBRACE) 1198 | } 1199 | { 1200 | p.SetState(84) 1201 | p.DefineBody() 1202 | } 1203 | { 1204 | p.SetState(85) 1205 | p.Match(DefineParserRBRACE) 1206 | } 1207 | 1208 | return localctx 1209 | } 1210 | 1211 | // ISymbolKeyContext is an interface to support dynamic dispatch. 1212 | type ISymbolKeyContext interface { 1213 | antlr.ParserRuleContext 1214 | 1215 | // GetParser returns the parser. 1216 | GetParser() antlr.Parser 1217 | 1218 | // IsSymbolKeyContext differentiates from other interfaces. 1219 | IsSymbolKeyContext() 1220 | } 1221 | 1222 | type SymbolKeyContext struct { 1223 | *antlr.BaseParserRuleContext 1224 | parser antlr.Parser 1225 | } 1226 | 1227 | func NewEmptySymbolKeyContext() *SymbolKeyContext { 1228 | var p = new(SymbolKeyContext) 1229 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1230 | p.RuleIndex = DefineParserRULE_symbolKey 1231 | return p 1232 | } 1233 | 1234 | func (*SymbolKeyContext) IsSymbolKeyContext() {} 1235 | 1236 | func NewSymbolKeyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SymbolKeyContext { 1237 | var p = new(SymbolKeyContext) 1238 | 1239 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1240 | 1241 | p.parser = parser 1242 | p.RuleIndex = DefineParserRULE_symbolKey 1243 | 1244 | return p 1245 | } 1246 | 1247 | func (s *SymbolKeyContext) GetParser() antlr.Parser { return s.parser } 1248 | 1249 | func (s *SymbolKeyContext) IDENTIFIER() antlr.TerminalNode { 1250 | return s.GetToken(DefineParserIDENTIFIER, 0) 1251 | } 1252 | 1253 | func (s *SymbolKeyContext) GetRuleContext() antlr.RuleContext { 1254 | return s 1255 | } 1256 | 1257 | func (s *SymbolKeyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1258 | return antlr.TreesStringTree(s, ruleNames, recog) 1259 | } 1260 | 1261 | func (s *SymbolKeyContext) EnterRule(listener antlr.ParseTreeListener) { 1262 | if listenerT, ok := listener.(DefineListener); ok { 1263 | listenerT.EnterSymbolKey(s) 1264 | } 1265 | } 1266 | 1267 | func (s *SymbolKeyContext) ExitRule(listener antlr.ParseTreeListener) { 1268 | if listenerT, ok := listener.(DefineListener); ok { 1269 | listenerT.ExitSymbolKey(s) 1270 | } 1271 | } 1272 | 1273 | func (s *SymbolKeyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1274 | switch t := visitor.(type) { 1275 | case DefineVisitor: 1276 | return t.VisitSymbolKey(s) 1277 | 1278 | default: 1279 | return t.VisitChildren(s) 1280 | } 1281 | } 1282 | 1283 | func (p *DefineParser) SymbolKey() (localctx ISymbolKeyContext) { 1284 | localctx = NewSymbolKeyContext(p, p.GetParserRuleContext(), p.GetState()) 1285 | p.EnterRule(localctx, 14, DefineParserRULE_symbolKey) 1286 | 1287 | defer func() { 1288 | p.ExitRule() 1289 | }() 1290 | 1291 | defer func() { 1292 | if err := recover(); err != nil { 1293 | if v, ok := err.(antlr.RecognitionException); ok { 1294 | localctx.SetException(v) 1295 | p.GetErrorHandler().ReportError(p, v) 1296 | p.GetErrorHandler().Recover(p, v) 1297 | } else { 1298 | panic(err) 1299 | } 1300 | } 1301 | }() 1302 | 1303 | p.EnterOuterAlt(localctx, 1) 1304 | { 1305 | p.SetState(87) 1306 | p.Match(DefineParserIDENTIFIER) 1307 | } 1308 | 1309 | return localctx 1310 | } 1311 | 1312 | // ISymbolValueContext is an interface to support dynamic dispatch. 1313 | type ISymbolValueContext interface { 1314 | antlr.ParserRuleContext 1315 | 1316 | // GetParser returns the parser. 1317 | GetParser() antlr.Parser 1318 | 1319 | // IsSymbolValueContext differentiates from other interfaces. 1320 | IsSymbolValueContext() 1321 | } 1322 | 1323 | type SymbolValueContext struct { 1324 | *antlr.BaseParserRuleContext 1325 | parser antlr.Parser 1326 | } 1327 | 1328 | func NewEmptySymbolValueContext() *SymbolValueContext { 1329 | var p = new(SymbolValueContext) 1330 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1331 | p.RuleIndex = DefineParserRULE_symbolValue 1332 | return p 1333 | } 1334 | 1335 | func (*SymbolValueContext) IsSymbolValueContext() {} 1336 | 1337 | func NewSymbolValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SymbolValueContext { 1338 | var p = new(SymbolValueContext) 1339 | 1340 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1341 | 1342 | p.parser = parser 1343 | p.RuleIndex = DefineParserRULE_symbolValue 1344 | 1345 | return p 1346 | } 1347 | 1348 | func (s *SymbolValueContext) GetParser() antlr.Parser { return s.parser } 1349 | 1350 | func (s *SymbolValueContext) IDENTIFIER() antlr.TerminalNode { 1351 | return s.GetToken(DefineParserIDENTIFIER, 0) 1352 | } 1353 | 1354 | func (s *SymbolValueContext) GetRuleContext() antlr.RuleContext { 1355 | return s 1356 | } 1357 | 1358 | func (s *SymbolValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1359 | return antlr.TreesStringTree(s, ruleNames, recog) 1360 | } 1361 | 1362 | func (s *SymbolValueContext) EnterRule(listener antlr.ParseTreeListener) { 1363 | if listenerT, ok := listener.(DefineListener); ok { 1364 | listenerT.EnterSymbolValue(s) 1365 | } 1366 | } 1367 | 1368 | func (s *SymbolValueContext) ExitRule(listener antlr.ParseTreeListener) { 1369 | if listenerT, ok := listener.(DefineListener); ok { 1370 | listenerT.ExitSymbolValue(s) 1371 | } 1372 | } 1373 | 1374 | func (s *SymbolValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1375 | switch t := visitor.(type) { 1376 | case DefineVisitor: 1377 | return t.VisitSymbolValue(s) 1378 | 1379 | default: 1380 | return t.VisitChildren(s) 1381 | } 1382 | } 1383 | 1384 | func (p *DefineParser) SymbolValue() (localctx ISymbolValueContext) { 1385 | localctx = NewSymbolValueContext(p, p.GetParserRuleContext(), p.GetState()) 1386 | p.EnterRule(localctx, 16, DefineParserRULE_symbolValue) 1387 | 1388 | defer func() { 1389 | p.ExitRule() 1390 | }() 1391 | 1392 | defer func() { 1393 | if err := recover(); err != nil { 1394 | if v, ok := err.(antlr.RecognitionException); ok { 1395 | localctx.SetException(v) 1396 | p.GetErrorHandler().ReportError(p, v) 1397 | p.GetErrorHandler().Recover(p, v) 1398 | } else { 1399 | panic(err) 1400 | } 1401 | } 1402 | }() 1403 | 1404 | p.EnterOuterAlt(localctx, 1) 1405 | { 1406 | p.SetState(89) 1407 | p.Match(DefineParserIDENTIFIER) 1408 | } 1409 | 1410 | return localctx 1411 | } 1412 | 1413 | // IDefineBodyContext is an interface to support dynamic dispatch. 1414 | type IDefineBodyContext interface { 1415 | antlr.ParserRuleContext 1416 | 1417 | // GetParser returns the parser. 1418 | GetParser() antlr.Parser 1419 | 1420 | // IsDefineBodyContext differentiates from other interfaces. 1421 | IsDefineBodyContext() 1422 | } 1423 | 1424 | type DefineBodyContext struct { 1425 | *antlr.BaseParserRuleContext 1426 | parser antlr.Parser 1427 | } 1428 | 1429 | func NewEmptyDefineBodyContext() *DefineBodyContext { 1430 | var p = new(DefineBodyContext) 1431 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1432 | p.RuleIndex = DefineParserRULE_defineBody 1433 | return p 1434 | } 1435 | 1436 | func (*DefineBodyContext) IsDefineBodyContext() {} 1437 | 1438 | func NewDefineBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineBodyContext { 1439 | var p = new(DefineBodyContext) 1440 | 1441 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1442 | 1443 | p.parser = parser 1444 | p.RuleIndex = DefineParserRULE_defineBody 1445 | 1446 | return p 1447 | } 1448 | 1449 | func (s *DefineBodyContext) GetParser() antlr.Parser { return s.parser } 1450 | 1451 | func (s *DefineBodyContext) AllSymbolKey() []ISymbolKeyContext { 1452 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISymbolKeyContext)(nil)).Elem()) 1453 | var tst = make([]ISymbolKeyContext, len(ts)) 1454 | 1455 | for i, t := range ts { 1456 | if t != nil { 1457 | tst[i] = t.(ISymbolKeyContext) 1458 | } 1459 | } 1460 | 1461 | return tst 1462 | } 1463 | 1464 | func (s *DefineBodyContext) SymbolKey(i int) ISymbolKeyContext { 1465 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ISymbolKeyContext)(nil)).Elem(), i) 1466 | 1467 | if t == nil { 1468 | return nil 1469 | } 1470 | 1471 | return t.(ISymbolKeyContext) 1472 | } 1473 | 1474 | func (s *DefineBodyContext) STRING_LITERAL() antlr.TerminalNode { 1475 | return s.GetToken(DefineParserSTRING_LITERAL, 0) 1476 | } 1477 | 1478 | func (s *DefineBodyContext) TemplateData() ITemplateDataContext { 1479 | var t = s.GetTypedRuleContext(reflect.TypeOf((*ITemplateDataContext)(nil)).Elem(), 0) 1480 | 1481 | if t == nil { 1482 | return nil 1483 | } 1484 | 1485 | return t.(ITemplateDataContext) 1486 | } 1487 | 1488 | func (s *DefineBodyContext) GetRuleContext() antlr.RuleContext { 1489 | return s 1490 | } 1491 | 1492 | func (s *DefineBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1493 | return antlr.TreesStringTree(s, ruleNames, recog) 1494 | } 1495 | 1496 | func (s *DefineBodyContext) EnterRule(listener antlr.ParseTreeListener) { 1497 | if listenerT, ok := listener.(DefineListener); ok { 1498 | listenerT.EnterDefineBody(s) 1499 | } 1500 | } 1501 | 1502 | func (s *DefineBodyContext) ExitRule(listener antlr.ParseTreeListener) { 1503 | if listenerT, ok := listener.(DefineListener); ok { 1504 | listenerT.ExitDefineBody(s) 1505 | } 1506 | } 1507 | 1508 | func (s *DefineBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1509 | switch t := visitor.(type) { 1510 | case DefineVisitor: 1511 | return t.VisitDefineBody(s) 1512 | 1513 | default: 1514 | return t.VisitChildren(s) 1515 | } 1516 | } 1517 | 1518 | func (p *DefineParser) DefineBody() (localctx IDefineBodyContext) { 1519 | localctx = NewDefineBodyContext(p, p.GetParserRuleContext(), p.GetState()) 1520 | p.EnterRule(localctx, 18, DefineParserRULE_defineBody) 1521 | 1522 | defer func() { 1523 | p.ExitRule() 1524 | }() 1525 | 1526 | defer func() { 1527 | if err := recover(); err != nil { 1528 | if v, ok := err.(antlr.RecognitionException); ok { 1529 | localctx.SetException(v) 1530 | p.GetErrorHandler().ReportError(p, v) 1531 | p.GetErrorHandler().Recover(p, v) 1532 | } else { 1533 | panic(err) 1534 | } 1535 | } 1536 | }() 1537 | 1538 | var _alt int 1539 | 1540 | p.EnterOuterAlt(localctx, 1) 1541 | { 1542 | p.SetState(91) 1543 | p.SymbolKey() 1544 | } 1545 | { 1546 | p.SetState(92) 1547 | p.Match(DefineParserSTRING_LITERAL) 1548 | } 1549 | p.SetState(96) 1550 | p.GetErrorHandler().Sync(p) 1551 | _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 6, p.GetParserRuleContext()) 1552 | 1553 | for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { 1554 | if _alt == 1 { 1555 | { 1556 | p.SetState(93) 1557 | p.SymbolKey() 1558 | } 1559 | 1560 | } 1561 | p.SetState(98) 1562 | p.GetErrorHandler().Sync(p) 1563 | _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 6, p.GetParserRuleContext()) 1564 | } 1565 | { 1566 | p.SetState(99) 1567 | p.TemplateData() 1568 | } 1569 | { 1570 | p.SetState(100) 1571 | p.SymbolKey() 1572 | } 1573 | 1574 | return localctx 1575 | } 1576 | 1577 | // ITemplateDataContext is an interface to support dynamic dispatch. 1578 | type ITemplateDataContext interface { 1579 | antlr.ParserRuleContext 1580 | 1581 | // GetParser returns the parser. 1582 | GetParser() antlr.Parser 1583 | 1584 | // IsTemplateDataContext differentiates from other interfaces. 1585 | IsTemplateDataContext() 1586 | } 1587 | 1588 | type TemplateDataContext struct { 1589 | *antlr.BaseParserRuleContext 1590 | parser antlr.Parser 1591 | } 1592 | 1593 | func NewEmptyTemplateDataContext() *TemplateDataContext { 1594 | var p = new(TemplateDataContext) 1595 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1596 | p.RuleIndex = DefineParserRULE_templateData 1597 | return p 1598 | } 1599 | 1600 | func (*TemplateDataContext) IsTemplateDataContext() {} 1601 | 1602 | func NewTemplateDataContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TemplateDataContext { 1603 | var p = new(TemplateDataContext) 1604 | 1605 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1606 | 1607 | p.parser = parser 1608 | p.RuleIndex = DefineParserRULE_templateData 1609 | 1610 | return p 1611 | } 1612 | 1613 | func (s *TemplateDataContext) GetParser() antlr.Parser { return s.parser } 1614 | 1615 | func (s *TemplateDataContext) IDENTIFIER() antlr.TerminalNode { 1616 | return s.GetToken(DefineParserIDENTIFIER, 0) 1617 | } 1618 | 1619 | func (s *TemplateDataContext) GetRuleContext() antlr.RuleContext { 1620 | return s 1621 | } 1622 | 1623 | func (s *TemplateDataContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1624 | return antlr.TreesStringTree(s, ruleNames, recog) 1625 | } 1626 | 1627 | func (s *TemplateDataContext) EnterRule(listener antlr.ParseTreeListener) { 1628 | if listenerT, ok := listener.(DefineListener); ok { 1629 | listenerT.EnterTemplateData(s) 1630 | } 1631 | } 1632 | 1633 | func (s *TemplateDataContext) ExitRule(listener antlr.ParseTreeListener) { 1634 | if listenerT, ok := listener.(DefineListener); ok { 1635 | listenerT.ExitTemplateData(s) 1636 | } 1637 | } 1638 | 1639 | func (s *TemplateDataContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1640 | switch t := visitor.(type) { 1641 | case DefineVisitor: 1642 | return t.VisitTemplateData(s) 1643 | 1644 | default: 1645 | return t.VisitChildren(s) 1646 | } 1647 | } 1648 | 1649 | func (p *DefineParser) TemplateData() (localctx ITemplateDataContext) { 1650 | localctx = NewTemplateDataContext(p, p.GetParserRuleContext(), p.GetState()) 1651 | p.EnterRule(localctx, 20, DefineParserRULE_templateData) 1652 | 1653 | defer func() { 1654 | p.ExitRule() 1655 | }() 1656 | 1657 | defer func() { 1658 | if err := recover(); err != nil { 1659 | if v, ok := err.(antlr.RecognitionException); ok { 1660 | localctx.SetException(v) 1661 | p.GetErrorHandler().ReportError(p, v) 1662 | p.GetErrorHandler().Recover(p, v) 1663 | } else { 1664 | panic(err) 1665 | } 1666 | } 1667 | }() 1668 | 1669 | p.EnterOuterAlt(localctx, 1) 1670 | { 1671 | p.SetState(102) 1672 | p.Match(DefineParserIDENTIFIER) 1673 | } 1674 | 1675 | return localctx 1676 | } 1677 | 1678 | // ISystemDeclarationContext is an interface to support dynamic dispatch. 1679 | type ISystemDeclarationContext interface { 1680 | antlr.ParserRuleContext 1681 | 1682 | // GetParser returns the parser. 1683 | GetParser() antlr.Parser 1684 | 1685 | // IsSystemDeclarationContext differentiates from other interfaces. 1686 | IsSystemDeclarationContext() 1687 | } 1688 | 1689 | type SystemDeclarationContext struct { 1690 | *antlr.BaseParserRuleContext 1691 | parser antlr.Parser 1692 | } 1693 | 1694 | func NewEmptySystemDeclarationContext() *SystemDeclarationContext { 1695 | var p = new(SystemDeclarationContext) 1696 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1697 | p.RuleIndex = DefineParserRULE_systemDeclaration 1698 | return p 1699 | } 1700 | 1701 | func (*SystemDeclarationContext) IsSystemDeclarationContext() {} 1702 | 1703 | func NewSystemDeclarationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SystemDeclarationContext { 1704 | var p = new(SystemDeclarationContext) 1705 | 1706 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1707 | 1708 | p.parser = parser 1709 | p.RuleIndex = DefineParserRULE_systemDeclaration 1710 | 1711 | return p 1712 | } 1713 | 1714 | func (s *SystemDeclarationContext) GetParser() antlr.Parser { return s.parser } 1715 | 1716 | func (s *SystemDeclarationContext) DefineKey() IDefineKeyContext { 1717 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineKeyContext)(nil)).Elem(), 0) 1718 | 1719 | if t == nil { 1720 | return nil 1721 | } 1722 | 1723 | return t.(IDefineKeyContext) 1724 | } 1725 | 1726 | func (s *SystemDeclarationContext) COLON() antlr.TerminalNode { 1727 | return s.GetToken(DefineParserCOLON, 0) 1728 | } 1729 | 1730 | func (s *SystemDeclarationContext) DefineValue() IDefineValueContext { 1731 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IDefineValueContext)(nil)).Elem(), 0) 1732 | 1733 | if t == nil { 1734 | return nil 1735 | } 1736 | 1737 | return t.(IDefineValueContext) 1738 | } 1739 | 1740 | func (s *SystemDeclarationContext) GetRuleContext() antlr.RuleContext { 1741 | return s 1742 | } 1743 | 1744 | func (s *SystemDeclarationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1745 | return antlr.TreesStringTree(s, ruleNames, recog) 1746 | } 1747 | 1748 | func (s *SystemDeclarationContext) EnterRule(listener antlr.ParseTreeListener) { 1749 | if listenerT, ok := listener.(DefineListener); ok { 1750 | listenerT.EnterSystemDeclaration(s) 1751 | } 1752 | } 1753 | 1754 | func (s *SystemDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { 1755 | if listenerT, ok := listener.(DefineListener); ok { 1756 | listenerT.ExitSystemDeclaration(s) 1757 | } 1758 | } 1759 | 1760 | func (s *SystemDeclarationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1761 | switch t := visitor.(type) { 1762 | case DefineVisitor: 1763 | return t.VisitSystemDeclaration(s) 1764 | 1765 | default: 1766 | return t.VisitChildren(s) 1767 | } 1768 | } 1769 | 1770 | func (p *DefineParser) SystemDeclaration() (localctx ISystemDeclarationContext) { 1771 | localctx = NewSystemDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) 1772 | p.EnterRule(localctx, 22, DefineParserRULE_systemDeclaration) 1773 | 1774 | defer func() { 1775 | p.ExitRule() 1776 | }() 1777 | 1778 | defer func() { 1779 | if err := recover(); err != nil { 1780 | if v, ok := err.(antlr.RecognitionException); ok { 1781 | localctx.SetException(v) 1782 | p.GetErrorHandler().ReportError(p, v) 1783 | p.GetErrorHandler().Recover(p, v) 1784 | } else { 1785 | panic(err) 1786 | } 1787 | } 1788 | }() 1789 | 1790 | p.EnterOuterAlt(localctx, 1) 1791 | { 1792 | p.SetState(104) 1793 | p.DefineKey() 1794 | } 1795 | { 1796 | p.SetState(105) 1797 | p.Match(DefineParserCOLON) 1798 | } 1799 | { 1800 | p.SetState(106) 1801 | p.DefineValue() 1802 | } 1803 | 1804 | return localctx 1805 | } 1806 | 1807 | // IDefineKeyContext is an interface to support dynamic dispatch. 1808 | type IDefineKeyContext interface { 1809 | antlr.ParserRuleContext 1810 | 1811 | // GetParser returns the parser. 1812 | GetParser() antlr.Parser 1813 | 1814 | // IsDefineKeyContext differentiates from other interfaces. 1815 | IsDefineKeyContext() 1816 | } 1817 | 1818 | type DefineKeyContext struct { 1819 | *antlr.BaseParserRuleContext 1820 | parser antlr.Parser 1821 | } 1822 | 1823 | func NewEmptyDefineKeyContext() *DefineKeyContext { 1824 | var p = new(DefineKeyContext) 1825 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1826 | p.RuleIndex = DefineParserRULE_defineKey 1827 | return p 1828 | } 1829 | 1830 | func (*DefineKeyContext) IsDefineKeyContext() {} 1831 | 1832 | func NewDefineKeyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineKeyContext { 1833 | var p = new(DefineKeyContext) 1834 | 1835 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1836 | 1837 | p.parser = parser 1838 | p.RuleIndex = DefineParserRULE_defineKey 1839 | 1840 | return p 1841 | } 1842 | 1843 | func (s *DefineKeyContext) GetParser() antlr.Parser { return s.parser } 1844 | 1845 | func (s *DefineKeyContext) IDENTIFIER() antlr.TerminalNode { 1846 | return s.GetToken(DefineParserIDENTIFIER, 0) 1847 | } 1848 | 1849 | func (s *DefineKeyContext) GetRuleContext() antlr.RuleContext { 1850 | return s 1851 | } 1852 | 1853 | func (s *DefineKeyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1854 | return antlr.TreesStringTree(s, ruleNames, recog) 1855 | } 1856 | 1857 | func (s *DefineKeyContext) EnterRule(listener antlr.ParseTreeListener) { 1858 | if listenerT, ok := listener.(DefineListener); ok { 1859 | listenerT.EnterDefineKey(s) 1860 | } 1861 | } 1862 | 1863 | func (s *DefineKeyContext) ExitRule(listener antlr.ParseTreeListener) { 1864 | if listenerT, ok := listener.(DefineListener); ok { 1865 | listenerT.ExitDefineKey(s) 1866 | } 1867 | } 1868 | 1869 | func (s *DefineKeyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1870 | switch t := visitor.(type) { 1871 | case DefineVisitor: 1872 | return t.VisitDefineKey(s) 1873 | 1874 | default: 1875 | return t.VisitChildren(s) 1876 | } 1877 | } 1878 | 1879 | func (p *DefineParser) DefineKey() (localctx IDefineKeyContext) { 1880 | localctx = NewDefineKeyContext(p, p.GetParserRuleContext(), p.GetState()) 1881 | p.EnterRule(localctx, 24, DefineParserRULE_defineKey) 1882 | 1883 | defer func() { 1884 | p.ExitRule() 1885 | }() 1886 | 1887 | defer func() { 1888 | if err := recover(); err != nil { 1889 | if v, ok := err.(antlr.RecognitionException); ok { 1890 | localctx.SetException(v) 1891 | p.GetErrorHandler().ReportError(p, v) 1892 | p.GetErrorHandler().Recover(p, v) 1893 | } else { 1894 | panic(err) 1895 | } 1896 | } 1897 | }() 1898 | 1899 | p.EnterOuterAlt(localctx, 1) 1900 | { 1901 | p.SetState(108) 1902 | p.Match(DefineParserIDENTIFIER) 1903 | } 1904 | 1905 | return localctx 1906 | } 1907 | 1908 | // IDefineValueContext is an interface to support dynamic dispatch. 1909 | type IDefineValueContext interface { 1910 | antlr.ParserRuleContext 1911 | 1912 | // GetParser returns the parser. 1913 | GetParser() antlr.Parser 1914 | 1915 | // IsDefineValueContext differentiates from other interfaces. 1916 | IsDefineValueContext() 1917 | } 1918 | 1919 | type DefineValueContext struct { 1920 | *antlr.BaseParserRuleContext 1921 | parser antlr.Parser 1922 | } 1923 | 1924 | func NewEmptyDefineValueContext() *DefineValueContext { 1925 | var p = new(DefineValueContext) 1926 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 1927 | p.RuleIndex = DefineParserRULE_defineValue 1928 | return p 1929 | } 1930 | 1931 | func (*DefineValueContext) IsDefineValueContext() {} 1932 | 1933 | func NewDefineValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DefineValueContext { 1934 | var p = new(DefineValueContext) 1935 | 1936 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 1937 | 1938 | p.parser = parser 1939 | p.RuleIndex = DefineParserRULE_defineValue 1940 | 1941 | return p 1942 | } 1943 | 1944 | func (s *DefineValueContext) GetParser() antlr.Parser { return s.parser } 1945 | 1946 | func (s *DefineValueContext) IDENTIFIER() antlr.TerminalNode { 1947 | return s.GetToken(DefineParserIDENTIFIER, 0) 1948 | } 1949 | 1950 | func (s *DefineValueContext) GetRuleContext() antlr.RuleContext { 1951 | return s 1952 | } 1953 | 1954 | func (s *DefineValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 1955 | return antlr.TreesStringTree(s, ruleNames, recog) 1956 | } 1957 | 1958 | func (s *DefineValueContext) EnterRule(listener antlr.ParseTreeListener) { 1959 | if listenerT, ok := listener.(DefineListener); ok { 1960 | listenerT.EnterDefineValue(s) 1961 | } 1962 | } 1963 | 1964 | func (s *DefineValueContext) ExitRule(listener antlr.ParseTreeListener) { 1965 | if listenerT, ok := listener.(DefineListener); ok { 1966 | listenerT.ExitDefineValue(s) 1967 | } 1968 | } 1969 | 1970 | func (s *DefineValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 1971 | switch t := visitor.(type) { 1972 | case DefineVisitor: 1973 | return t.VisitDefineValue(s) 1974 | 1975 | default: 1976 | return t.VisitChildren(s) 1977 | } 1978 | } 1979 | 1980 | func (p *DefineParser) DefineValue() (localctx IDefineValueContext) { 1981 | localctx = NewDefineValueContext(p, p.GetParserRuleContext(), p.GetState()) 1982 | p.EnterRule(localctx, 26, DefineParserRULE_defineValue) 1983 | 1984 | defer func() { 1985 | p.ExitRule() 1986 | }() 1987 | 1988 | defer func() { 1989 | if err := recover(); err != nil { 1990 | if v, ok := err.(antlr.RecognitionException); ok { 1991 | localctx.SetException(v) 1992 | p.GetErrorHandler().ReportError(p, v) 1993 | p.GetErrorHandler().Recover(p, v) 1994 | } else { 1995 | panic(err) 1996 | } 1997 | } 1998 | }() 1999 | 2000 | p.EnterOuterAlt(localctx, 1) 2001 | { 2002 | p.SetState(110) 2003 | p.Match(DefineParserIDENTIFIER) 2004 | } 2005 | 2006 | return localctx 2007 | } 2008 | 2009 | // IModuleDeclarationContext is an interface to support dynamic dispatch. 2010 | type IModuleDeclarationContext interface { 2011 | antlr.ParserRuleContext 2012 | 2013 | // GetParser returns the parser. 2014 | GetParser() antlr.Parser 2015 | 2016 | // IsModuleDeclarationContext differentiates from other interfaces. 2017 | IsModuleDeclarationContext() 2018 | } 2019 | 2020 | type ModuleDeclarationContext struct { 2021 | *antlr.BaseParserRuleContext 2022 | parser antlr.Parser 2023 | } 2024 | 2025 | func NewEmptyModuleDeclarationContext() *ModuleDeclarationContext { 2026 | var p = new(ModuleDeclarationContext) 2027 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 2028 | p.RuleIndex = DefineParserRULE_moduleDeclaration 2029 | return p 2030 | } 2031 | 2032 | func (*ModuleDeclarationContext) IsModuleDeclarationContext() {} 2033 | 2034 | func NewModuleDeclarationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ModuleDeclarationContext { 2035 | var p = new(ModuleDeclarationContext) 2036 | 2037 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 2038 | 2039 | p.parser = parser 2040 | p.RuleIndex = DefineParserRULE_moduleDeclaration 2041 | 2042 | return p 2043 | } 2044 | 2045 | func (s *ModuleDeclarationContext) GetParser() antlr.Parser { return s.parser } 2046 | 2047 | func (s *ModuleDeclarationContext) MODULE() antlr.TerminalNode { 2048 | return s.GetToken(DefineParserMODULE, 0) 2049 | } 2050 | 2051 | func (s *ModuleDeclarationContext) IDENTIFIER() antlr.TerminalNode { 2052 | return s.GetToken(DefineParserIDENTIFIER, 0) 2053 | } 2054 | 2055 | func (s *ModuleDeclarationContext) LBRACE() antlr.TerminalNode { 2056 | return s.GetToken(DefineParserLBRACE, 0) 2057 | } 2058 | 2059 | func (s *ModuleDeclarationContext) RBRACE() antlr.TerminalNode { 2060 | return s.GetToken(DefineParserRBRACE, 0) 2061 | } 2062 | 2063 | func (s *ModuleDeclarationContext) AllModuleDefines() []IModuleDefinesContext { 2064 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IModuleDefinesContext)(nil)).Elem()) 2065 | var tst = make([]IModuleDefinesContext, len(ts)) 2066 | 2067 | for i, t := range ts { 2068 | if t != nil { 2069 | tst[i] = t.(IModuleDefinesContext) 2070 | } 2071 | } 2072 | 2073 | return tst 2074 | } 2075 | 2076 | func (s *ModuleDeclarationContext) ModuleDefines(i int) IModuleDefinesContext { 2077 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IModuleDefinesContext)(nil)).Elem(), i) 2078 | 2079 | if t == nil { 2080 | return nil 2081 | } 2082 | 2083 | return t.(IModuleDefinesContext) 2084 | } 2085 | 2086 | func (s *ModuleDeclarationContext) GetRuleContext() antlr.RuleContext { 2087 | return s 2088 | } 2089 | 2090 | func (s *ModuleDeclarationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 2091 | return antlr.TreesStringTree(s, ruleNames, recog) 2092 | } 2093 | 2094 | func (s *ModuleDeclarationContext) EnterRule(listener antlr.ParseTreeListener) { 2095 | if listenerT, ok := listener.(DefineListener); ok { 2096 | listenerT.EnterModuleDeclaration(s) 2097 | } 2098 | } 2099 | 2100 | func (s *ModuleDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { 2101 | if listenerT, ok := listener.(DefineListener); ok { 2102 | listenerT.ExitModuleDeclaration(s) 2103 | } 2104 | } 2105 | 2106 | func (s *ModuleDeclarationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 2107 | switch t := visitor.(type) { 2108 | case DefineVisitor: 2109 | return t.VisitModuleDeclaration(s) 2110 | 2111 | default: 2112 | return t.VisitChildren(s) 2113 | } 2114 | } 2115 | 2116 | func (p *DefineParser) ModuleDeclaration() (localctx IModuleDeclarationContext) { 2117 | localctx = NewModuleDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) 2118 | p.EnterRule(localctx, 28, DefineParserRULE_moduleDeclaration) 2119 | var _la int 2120 | 2121 | defer func() { 2122 | p.ExitRule() 2123 | }() 2124 | 2125 | defer func() { 2126 | if err := recover(); err != nil { 2127 | if v, ok := err.(antlr.RecognitionException); ok { 2128 | localctx.SetException(v) 2129 | p.GetErrorHandler().ReportError(p, v) 2130 | p.GetErrorHandler().Recover(p, v) 2131 | } else { 2132 | panic(err) 2133 | } 2134 | } 2135 | }() 2136 | 2137 | p.EnterOuterAlt(localctx, 1) 2138 | { 2139 | p.SetState(112) 2140 | p.Match(DefineParserMODULE) 2141 | } 2142 | { 2143 | p.SetState(113) 2144 | p.Match(DefineParserIDENTIFIER) 2145 | } 2146 | { 2147 | p.SetState(114) 2148 | p.Match(DefineParserLBRACE) 2149 | } 2150 | p.SetState(118) 2151 | p.GetErrorHandler().Sync(p) 2152 | _la = p.GetTokenStream().LA(1) 2153 | 2154 | for _la == DefineParserIDENTIFIER { 2155 | { 2156 | p.SetState(115) 2157 | p.ModuleDefines() 2158 | } 2159 | 2160 | p.SetState(120) 2161 | p.GetErrorHandler().Sync(p) 2162 | _la = p.GetTokenStream().LA(1) 2163 | } 2164 | { 2165 | p.SetState(121) 2166 | p.Match(DefineParserRBRACE) 2167 | } 2168 | 2169 | return localctx 2170 | } 2171 | 2172 | // IModuleDefinesContext is an interface to support dynamic dispatch. 2173 | type IModuleDefinesContext interface { 2174 | antlr.ParserRuleContext 2175 | 2176 | // GetParser returns the parser. 2177 | GetParser() antlr.Parser 2178 | 2179 | // IsModuleDefinesContext differentiates from other interfaces. 2180 | IsModuleDefinesContext() 2181 | } 2182 | 2183 | type ModuleDefinesContext struct { 2184 | *antlr.BaseParserRuleContext 2185 | parser antlr.Parser 2186 | } 2187 | 2188 | func NewEmptyModuleDefinesContext() *ModuleDefinesContext { 2189 | var p = new(ModuleDefinesContext) 2190 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 2191 | p.RuleIndex = DefineParserRULE_moduleDefines 2192 | return p 2193 | } 2194 | 2195 | func (*ModuleDefinesContext) IsModuleDefinesContext() {} 2196 | 2197 | func NewModuleDefinesContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ModuleDefinesContext { 2198 | var p = new(ModuleDefinesContext) 2199 | 2200 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 2201 | 2202 | p.parser = parser 2203 | p.RuleIndex = DefineParserRULE_moduleDefines 2204 | 2205 | return p 2206 | } 2207 | 2208 | func (s *ModuleDefinesContext) GetParser() antlr.Parser { return s.parser } 2209 | 2210 | func (s *ModuleDefinesContext) IDENTIFIER() antlr.TerminalNode { 2211 | return s.GetToken(DefineParserIDENTIFIER, 0) 2212 | } 2213 | 2214 | func (s *ModuleDefinesContext) LBRACE() antlr.TerminalNode { 2215 | return s.GetToken(DefineParserLBRACE, 0) 2216 | } 2217 | 2218 | func (s *ModuleDefinesContext) RBRACE() antlr.TerminalNode { 2219 | return s.GetToken(DefineParserRBRACE, 0) 2220 | } 2221 | 2222 | func (s *ModuleDefinesContext) AllModuleAttribute() []IModuleAttributeContext { 2223 | var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IModuleAttributeContext)(nil)).Elem()) 2224 | var tst = make([]IModuleAttributeContext, len(ts)) 2225 | 2226 | for i, t := range ts { 2227 | if t != nil { 2228 | tst[i] = t.(IModuleAttributeContext) 2229 | } 2230 | } 2231 | 2232 | return tst 2233 | } 2234 | 2235 | func (s *ModuleDefinesContext) ModuleAttribute(i int) IModuleAttributeContext { 2236 | var t = s.GetTypedRuleContext(reflect.TypeOf((*IModuleAttributeContext)(nil)).Elem(), i) 2237 | 2238 | if t == nil { 2239 | return nil 2240 | } 2241 | 2242 | return t.(IModuleAttributeContext) 2243 | } 2244 | 2245 | func (s *ModuleDefinesContext) GetRuleContext() antlr.RuleContext { 2246 | return s 2247 | } 2248 | 2249 | func (s *ModuleDefinesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 2250 | return antlr.TreesStringTree(s, ruleNames, recog) 2251 | } 2252 | 2253 | func (s *ModuleDefinesContext) EnterRule(listener antlr.ParseTreeListener) { 2254 | if listenerT, ok := listener.(DefineListener); ok { 2255 | listenerT.EnterModuleDefines(s) 2256 | } 2257 | } 2258 | 2259 | func (s *ModuleDefinesContext) ExitRule(listener antlr.ParseTreeListener) { 2260 | if listenerT, ok := listener.(DefineListener); ok { 2261 | listenerT.ExitModuleDefines(s) 2262 | } 2263 | } 2264 | 2265 | func (s *ModuleDefinesContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 2266 | switch t := visitor.(type) { 2267 | case DefineVisitor: 2268 | return t.VisitModuleDefines(s) 2269 | 2270 | default: 2271 | return t.VisitChildren(s) 2272 | } 2273 | } 2274 | 2275 | func (p *DefineParser) ModuleDefines() (localctx IModuleDefinesContext) { 2276 | localctx = NewModuleDefinesContext(p, p.GetParserRuleContext(), p.GetState()) 2277 | p.EnterRule(localctx, 30, DefineParserRULE_moduleDefines) 2278 | var _la int 2279 | 2280 | defer func() { 2281 | p.ExitRule() 2282 | }() 2283 | 2284 | defer func() { 2285 | if err := recover(); err != nil { 2286 | if v, ok := err.(antlr.RecognitionException); ok { 2287 | localctx.SetException(v) 2288 | p.GetErrorHandler().ReportError(p, v) 2289 | p.GetErrorHandler().Recover(p, v) 2290 | } else { 2291 | panic(err) 2292 | } 2293 | } 2294 | }() 2295 | 2296 | p.EnterOuterAlt(localctx, 1) 2297 | { 2298 | p.SetState(123) 2299 | p.Match(DefineParserIDENTIFIER) 2300 | } 2301 | { 2302 | p.SetState(124) 2303 | p.Match(DefineParserLBRACE) 2304 | } 2305 | p.SetState(128) 2306 | p.GetErrorHandler().Sync(p) 2307 | _la = p.GetTokenStream().LA(1) 2308 | 2309 | for _la == DefineParserIMPORT || _la == DefineParserEQUAL { 2310 | { 2311 | p.SetState(125) 2312 | p.ModuleAttribute() 2313 | } 2314 | 2315 | p.SetState(130) 2316 | p.GetErrorHandler().Sync(p) 2317 | _la = p.GetTokenStream().LA(1) 2318 | } 2319 | { 2320 | p.SetState(131) 2321 | p.Match(DefineParserRBRACE) 2322 | } 2323 | 2324 | return localctx 2325 | } 2326 | 2327 | // IModuleAttributeContext is an interface to support dynamic dispatch. 2328 | type IModuleAttributeContext interface { 2329 | antlr.ParserRuleContext 2330 | 2331 | // GetParser returns the parser. 2332 | GetParser() antlr.Parser 2333 | 2334 | // IsModuleAttributeContext differentiates from other interfaces. 2335 | IsModuleAttributeContext() 2336 | } 2337 | 2338 | type ModuleAttributeContext struct { 2339 | *antlr.BaseParserRuleContext 2340 | parser antlr.Parser 2341 | } 2342 | 2343 | func NewEmptyModuleAttributeContext() *ModuleAttributeContext { 2344 | var p = new(ModuleAttributeContext) 2345 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) 2346 | p.RuleIndex = DefineParserRULE_moduleAttribute 2347 | return p 2348 | } 2349 | 2350 | func (*ModuleAttributeContext) IsModuleAttributeContext() {} 2351 | 2352 | func NewModuleAttributeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ModuleAttributeContext { 2353 | var p = new(ModuleAttributeContext) 2354 | 2355 | p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) 2356 | 2357 | p.parser = parser 2358 | p.RuleIndex = DefineParserRULE_moduleAttribute 2359 | 2360 | return p 2361 | } 2362 | 2363 | func (s *ModuleAttributeContext) GetParser() antlr.Parser { return s.parser } 2364 | 2365 | func (s *ModuleAttributeContext) IMPORT() antlr.TerminalNode { 2366 | return s.GetToken(DefineParserIMPORT, 0) 2367 | } 2368 | 2369 | func (s *ModuleAttributeContext) STRING_LITERAL() antlr.TerminalNode { 2370 | return s.GetToken(DefineParserSTRING_LITERAL, 0) 2371 | } 2372 | 2373 | func (s *ModuleAttributeContext) EQUAL() antlr.TerminalNode { 2374 | return s.GetToken(DefineParserEQUAL, 0) 2375 | } 2376 | 2377 | func (s *ModuleAttributeContext) GetRuleContext() antlr.RuleContext { 2378 | return s 2379 | } 2380 | 2381 | func (s *ModuleAttributeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { 2382 | return antlr.TreesStringTree(s, ruleNames, recog) 2383 | } 2384 | 2385 | func (s *ModuleAttributeContext) EnterRule(listener antlr.ParseTreeListener) { 2386 | if listenerT, ok := listener.(DefineListener); ok { 2387 | listenerT.EnterModuleAttribute(s) 2388 | } 2389 | } 2390 | 2391 | func (s *ModuleAttributeContext) ExitRule(listener antlr.ParseTreeListener) { 2392 | if listenerT, ok := listener.(DefineListener); ok { 2393 | listenerT.ExitModuleAttribute(s) 2394 | } 2395 | } 2396 | 2397 | func (s *ModuleAttributeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { 2398 | switch t := visitor.(type) { 2399 | case DefineVisitor: 2400 | return t.VisitModuleAttribute(s) 2401 | 2402 | default: 2403 | return t.VisitChildren(s) 2404 | } 2405 | } 2406 | 2407 | func (p *DefineParser) ModuleAttribute() (localctx IModuleAttributeContext) { 2408 | localctx = NewModuleAttributeContext(p, p.GetParserRuleContext(), p.GetState()) 2409 | p.EnterRule(localctx, 32, DefineParserRULE_moduleAttribute) 2410 | 2411 | defer func() { 2412 | p.ExitRule() 2413 | }() 2414 | 2415 | defer func() { 2416 | if err := recover(); err != nil { 2417 | if v, ok := err.(antlr.RecognitionException); ok { 2418 | localctx.SetException(v) 2419 | p.GetErrorHandler().ReportError(p, v) 2420 | p.GetErrorHandler().Recover(p, v) 2421 | } else { 2422 | panic(err) 2423 | } 2424 | } 2425 | }() 2426 | 2427 | p.SetState(137) 2428 | p.GetErrorHandler().Sync(p) 2429 | 2430 | switch p.GetTokenStream().LA(1) { 2431 | case DefineParserIMPORT: 2432 | p.EnterOuterAlt(localctx, 1) 2433 | { 2434 | p.SetState(133) 2435 | p.Match(DefineParserIMPORT) 2436 | } 2437 | { 2438 | p.SetState(134) 2439 | p.Match(DefineParserSTRING_LITERAL) 2440 | } 2441 | 2442 | case DefineParserEQUAL: 2443 | p.EnterOuterAlt(localctx, 2) 2444 | { 2445 | p.SetState(135) 2446 | p.Match(DefineParserEQUAL) 2447 | } 2448 | { 2449 | p.SetState(136) 2450 | p.Match(DefineParserSTRING_LITERAL) 2451 | } 2452 | 2453 | default: 2454 | panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) 2455 | } 2456 | 2457 | return localctx 2458 | } 2459 | --------------------------------------------------------------------------------