diff --git a/runtime/Go/src/antlr4/1.stg b/runtime/Go/src/antlr4/1.stg deleted file mode 100644 index d3c2dad78..000000000 --- a/runtime/Go/src/antlr4/1.stg +++ /dev/null @@ -1,869 +0,0 @@ -/** ANTLR tool checks output templates are compatible with tool code generation. - * For now, a simple string Match used on x.y of x.y.z scheme. - * Must Match Tool.VERSION during load to templates. - * - * REQUIRED. - */ - -fileHeader(grammarFileName, ANTLRVersion) ::= << -// Generated from by ANTLR ->> - -// args must be , - -ParserFile(file, parser, namedActions) ::= << - -package parser // - -import ( - "antlr4" - "reflect" -) - - - - - ->> - - - -ListenerFile(file, header) ::= << - -package parser // - -import "antlr4" - -// This class defines a complete listener for a parse tree produced by - -type Listener struct { - -} - -func (l *Listener) EnterEveryRule(node antlr4.IParserRuleContext) { -\} - -func (l *Listener) ExitEveryRule(node antlr4.IParserRuleContext) { -\} - -func (l *Listener) VisitTerminal(ctx antlr4.TerminalNode) { -\} - -func (l *Listener) VisitErrorNode(ctx antlr4.ErrorNode) { -\} - -#. -func (l *Listener) Enter(ctx antlr4.IParserRuleContext) { -\} - -// Exit a parse tree produced by #. -func (l *Listener) Exit(ctx antlr4.IParserRuleContext) { -\} - -}; separator="\n"> - - - - - ->> - - -VisitorFile(file, header) ::= << - -package parser // - -import "antlr4" - -
- -// This class defines a complete generic Visitor for a parse tree produced by . - -type Visitor struct { - -} - -#. -func (l Visitor) Visit(ctx IParserRuleContext) { -\} - -}; separator="\n"> - ->> - -Parser(parser, funcs, atn, sempredFuncs, superClass) ::= << - - -var = require('./'). // TODO - - -var parserATN = -var deserializer = antlr4.NewATNDeserializer(nil) -var deserializedATN = deserializer.DeserializeFromUInt16( parserATN ) - -var literalNames = []string{ }; null="\"\"", separator=", ", wrap, anchor> } -var symbolicNames = []string{ }; null="\"\"", separator=", ", wrap, anchor> } -var ruleNames = []string{ "}; separator=", ", wrap, anchor> } - -type struct { - -} - -func New(input antlr4.TokenStream) * { - - var decisionToDFA = make([]*antlr4.DFA,len(deserializedATN.DecisionToState)) - var sharedContextCache = antlr4.NewPredictionContextCache() - - for index, ds := range deserializedATN.DecisionToState { - decisionToDFA[index] = antlr4.NewDFA(ds, index) - } - - parser := new() - - parser.Parser = NewParser(input) - - parser.Interpreter = antlr4.NewParserATNSimulator(parser, deserializedATN, decisionToDFA, sharedContextCache) - parser.RuleNames = ruleNames - parser.LiteralNames = literalNames - parser.SymbolicNames = symbolicNames - - parser.GrammarFileName = "" - - return parser -} - -const( - EOF = antlr4.TokenEOF - - = }; separator="\n", wrap, anchor> - -) - -const ( - RULE_ = }; separator="\n", wrap, anchor> -) - - - - -func (p *) Sempred(localctx, ruleIndex int, predIndex int) { - switch ruleIndex { - : - return p._Sempred(localctx, predIndex);}; separator="\n"> - default: - panic("No predicate with index:" + ruleIndex) - } -} - - - - ->> - -dumpActions(recog, argFuncs, actionFuncs, sempredFuncs) ::= << - -func (l *) Action(localctx, ruleIndex int, actionIndex int) { - switch ruleIndex { - : - p._Action(localctx, actionIndex) - }; separator="\n"> - default: - panic("No registered action for:" + ruleIndex) - } -} - - - - -func (l *) Sempred(localctx, ruleIndex, predIndex) { - switch ruleIndex { - : - return l._Sempred(localctx, predIndex);}; separator="\n"> - default: - panic("No registered predicate for:" + ruleIndex) - } -} - - - ->> - - -/* This generates a private method since the actionIndex is generated, making an - * overriding implementation impossible to maintain. - */ -RuleActionFunction(r, actions) ::= << - -func (l *) _Action(localctx , actionIndex) { - switch actionIndex { - : - - }; separator="\n"> - default: - panic("No registered action for:" + actionIndex) - } -} ->> - -/* This generates a private method since the predIndex is generated, making an - * overriding implementation impossible to maintain. - */ -RuleSempredFunction(r, actions) ::= << -func (s *) _Sempred(localctx, predIndex int) { - switch predIndex { - : - return ;}; separator="\n"> - default: - panic("No predicate with index:" + predIndex) - } -} - ->> - - - -RuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,namedActions,finallyAction,postamble,exceptions) ::= << - - - -}; separator="\n"> - -func (p *) (}; separator=", ">) * { - - localctx := New(p, p.GetParserRuleContext(), p.GetState()}>) - p.EnterRule(localctx, , RULE_) - - - - defer func(){ - - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - - - - if v, ok := err.(antlr4.IRecognitionException); ok { - localctx.SetException( v ) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - - } - }() - - - - - - return localctx -} - ->> - -LeftRecursiveRuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs, - namedActions,finallyAction,postamble) ::= -<< - - -}; separator="\n"> - -func (p *) (_p, }>) * { - - _parentctx := p.GetParent().(IParserRuleContext) - _parentState := p.GetState() - localctx := New(p, p.GetParserRuleContext(), _parentState}>) - _prevctx := localctx - _startState := - p.EnterRecursionRule(localctx, , RULE_, _p) - - - - defer func(){ - - p.UnrollRecursionContexts(_parentctx) - }() - - defer func(){ - if err := recover(); err != nil { - if v, ok := err.(antlr4.IRecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - - - - - return localctx -} - ->> - -CodeBlockForOuterMostAlt(currentOuterMostAltCodeBlock, locals, preamble, ops) ::= << -localctx = NewContext(p, localctx) -p.EnterOuterAlt(localctx, ) - ->> - -CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= << - - - ->> - -LL1AltBlock(choice, preamble, alts, error) ::= << -p.SetState() - = p.GetTokenStream().LT(1) - -switch p.GetTokenStream().LA(1) { - - - }; separator="\n"> -default: - -} ->> - -LL1OptionalBlock(choice, alts, error) ::= << -p.SetState() -switch p.GetTokenStream().LA(1) { - - - }; separator="\n"> -default: - -} ->> - -LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= << -p.SetState() - -if { - -} -) ) !> ->> - -LL1StarBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) - -for { - - p.SetState() - p.GetErrorHandler().Sync(p) - -} ->> - -LL1PlusBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) - -for ok := true; ok; ok = { - - p.SetState(); - p.GetErrorHandler().Sync(p) - -} ->> - -// LL(*) stuff - -AltBlock(choice, preamble, alts, error) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) - = _input.LT(1) - -la_ := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(),,p.GetParserRuleContext()) -switch la_ { -: - -}; separator="\n"> -} ->> - -OptionalBlock(choice, alts, error) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) -la_ := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(),,p.GetParserRuleContext()) -+1 { - -}; separator="} else "> -} ->> - -StarBlock(choice, alts, Sync, iteration) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) -_alt := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(),,p.GetParserRuleContext()) -for _alt!= && _alt!= antlr4.ATNINVALID_ALT_NUMBER { - if(_alt==1+1) { - - - } - p.SetState() - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(),,p.GetParserRuleContext()) -} - ->> - -PlusBlock(choice, alts, error) ::= << -p.SetState() -p.GetErrorHandler().Sync(p) -_alt := 1+1 -for ok := true; ok; ok = _alt!= && _alt!= antlr4.ATNINVALID_ALT_NUMBER { - switch _alt { - +1: - - //}; separator="\n"> - default: - - } - p.SetState() - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(),, p.GetParserRuleContext()) -} ->> - -Sync(s) ::= "Sync()" - -ThrowNoViableAlt(t) ::= "panic(NewNoViableAltException(p))" - -TestSetInline(s) ::= << -}; separator=" || "> ->> - -// Javascript language spec - shift operators are 32 bits long max -testShiftInRange(shiftAmount) ::= << -(() & 0x1f) == 0 ->> - -// produces smaller bytecode only when bits.ttypes contains more than two items -bitsetBitfieldComparison(s, bits) ::= <% -(})> && ((1 \<\< uint()) & ()}; separator=" | ">)) != 0) -%> - -isZero ::= [ -"0":true, -default:false -] - -offsetShiftVar(shiftAmount, offset) ::= <% -( - ) -%> - -offsetShiftType(shiftAmount, offset) ::= <% -( - ) -%> - -// produces more efficient bytecode when bits.ttypes contains at most two items -bitsetInlineComparison(s, bits) ::= <% -==}; separator=" || "> -%> - -cases(ttypes) ::= << -:}; separator="\n"> ->> - -InvokeRule(r, argExprsChunks) ::= << -p.SetState() - = }>p.(,) ->> - -MatchToken(m) ::= << -p.SetState() - = }>p.Match() ->> - -MatchSet(m, expr, capture) ::= "" - -MatchNotSet(m, expr, capture) ::= "" - -CommonSetStuff(m, expr, capture, invert) ::= << -p.SetState() - = }>p.GetTokenStream().LT(1); - -if \<=0 || if !() { - = }>p.GetErrorHandler().RecoverInline(p) -} else { - p.Consume() -} ->> - -Wildcard(w) ::= << -p.SetState() - = }>MatchWildcard() ->> - -// ACTION STUFF - -Action(a, foo, chunks) ::= "" - -ArgAction(a, chunks) ::= "" - -SemPred(p, chunks, failChunks) ::= << -p.SetState() -if !( ) { - panic( FailedPredicateException(p, , , )) -} ->> - -ExceptionClause(e, catchArg, catchAction) ::= << -catch () { - -} ->> - -// lexer actions are not associated with model objects - -LexerSkipCommand() ::= "p.skip()" -LexerMoreCommand() ::= "p.more()" -LexerPopModeCommand() ::= "p.popMode()" -LexerTypeCommand(arg) ::= "p._type = " -LexerChannelCommand(arg) ::= "p._channel = " -LexerModeCommand(arg) ::= "p._mode = " -LexerPushModeCommand(arg) ::= "p.pushMode()" - -ActionText(t) ::= "" -ActionTemplate(t) ::= "" -ArgRef(a) ::= "localctx." -LocalRef(a) ::= "localctx." -RetValueRef(a) ::= "localctx." -QRetValueRef(a) ::= ".." -/** How to translate $tokenLabel */ -TokenRef(t) ::= "." -LabelRef(t) ::= "." -ListLabelRef(t) ::= "." -SetAttr(s,rhsChunks) ::= ". = " - -TokenLabelType() ::= "" -InputSymbolType() ::= "" - -TokenPropertyRef_text(t) ::= "(.==null ? null : ..text)" -TokenPropertyRef_type(t) ::= "(. == null ? 0 : ..type)" -TokenPropertyRef_line(t) ::= "(. == null ? 0 : ..line)" -TokenPropertyRef_pos(t) ::= "(. == null ? 0 : ..column)" -TokenPropertyRef_channel(t) ::= "(. == null ? 0 : ..channel)" -TokenPropertyRef_index(t) ::= "(. == null ? 0 : ..tokenIndex)" -TokenPropertyRef_int(t) ::= "(. == null ? 0 : parseInt(..text))" - -RulePropertyRef_start(r) ::= "(.==null ? null : ..start)" -RulePropertyRef_stop(r) ::= "(.==null ? null : ..stop)" -RulePropertyRef_text(r) ::= "(.==null ? null : p.GetTokenStream().GetTextFromInterval(NewInterval(..GetStart(),..GetStop())))" -RulePropertyRef_ctx(r) ::= "." -RulePropertyRef_parser(r) ::= "this" - -ThisRulePropertyRef_start(r) ::= "localctx.start" -ThisRulePropertyRef_stop(r) ::= "localctx.stop" -ThisRulePropertyRef_text(r) ::= "p.GetTokenStream().GetTextFromInterval(NewInterval(localctx.GetStart(), p.GetTokenStream().LT(-1)))" -ThisRulePropertyRef_ctx(r) ::= "localctx" -ThisRulePropertyRef_parser(r) ::= "p" - -NonLocalAttrRef(s) ::= "getInvokingContext()." -SetNonLocalAttr(s, rhsChunks) ::= "getInvokingContext(). = " - -AddToLabelList(a) ::= ". = append(., push()" - -TokenDecl(t) ::= "p. = nil // " -TokenTypeDecl(t) ::= " := 0 // type" -TokenListDecl(t) ::= "p. = [] // of s" -RuleContextDecl(r) ::= "p. = nil // reflect.TypeOf((*)(nil)).Elem()" -RuleContextListDecl(rdecl) ::= "p. = [] // of s" - -ContextTokenGetterDecl(t) ::= << -() interface{} { - return s.GetToken(, 0) -} ->> - -// should never be called -ContextTokenListGetterDecl(t) ::= << -def _list(self): - return self.GetTokens() ->> - -ContextTokenListIndexedGetterDecl(t) ::= << -(i int) interface{} { - if i \< 0 { - return s.GetTokens() - } else { - return s.GetToken(, i) - } -} - ->> - -ContextRuleGetterDecl(r) ::= << -() interface{} { - return s.GetTypedRuleContext(reflect.TypeOf((*)(nil)).Elem(),0) -} ->> - -// should never be called -ContextRuleListGetterDecl(r) ::= << -func _list(self): - return s.GetTypedRuleContexts(reflect.TypeOf((*)(nil)).Elem()) - ->> - -ContextRuleListIndexedGetterDecl(r) ::= << -(i int) interface{} { - if i \< 0 { - return s.GetTypedRuleContexts(reflect.TypeOf((*)(nil)).Elem()) - } else { - return s.GetTypedRuleContext(reflect.TypeOf((*)(nil)).Elem(),i) - } -} ->> - -LexerRuleContext() ::= "RuleContext" - -/** The rule context name is the rule followed by a suffix; e.g., - * r becomes rContext. - */ -RuleContextNameSuffix() ::= "Context" - -ImplicitTokenLabel(tokenName) ::= "_" -ImplicitRuleLabel(ruleName) ::= "_" -ImplicitSetLabel(id) ::= "_tset" -ListLabelName(label) ::= "