diff --git a/pb/src/parserTest/test.go b/pb/src/parserTest/test.go index 937d50970..2bf4e58a4 100644 --- a/pb/src/parserTest/test.go +++ b/pb/src/parserTest/test.go @@ -5,14 +5,10 @@ import ( "parser" ) - type MyErrorListener struct { *MyErrorListener } - - - func main() { a := antlr4.NewFileStream("foo.txt") @@ -23,16 +19,8 @@ func main() { p := parser.NewArithmeticParser(s) - p.BuildParseTrees = true + p.BuildParseTrees = true p.Equation() - - - - } - - - - diff --git a/runtime/Go/src/antlr4/ATN.go b/runtime/Go/src/antlr4/ATN.go index c7e5fb452..0a6c755b2 100644 --- a/runtime/Go/src/antlr4/ATN.go +++ b/runtime/Go/src/antlr4/ATN.go @@ -1,4 +1,5 @@ package antlr4 + import "fmt" // Temporary - for debugging purposes of the Go port @@ -9,7 +10,6 @@ const ( var ATNInvalidAltNumber = 0 type ATN struct { - DecisionToState []DecisionState grammarType int maxTokenType int @@ -20,7 +20,6 @@ type ATN struct { modeToStartState []*TokensStartState ruleToTokenType []int lexerActions []LexerAction - } func NewATN(grammarType int, maxTokenType int) *ATN { @@ -108,7 +107,7 @@ func (this *ATN) removeState(state ATNState) { func (this *ATN) defineDecisionState(s DecisionState) int { this.DecisionToState = append(this.DecisionToState, s) - s.setDecision( len(this.DecisionToState) - 1 ) + s.setDecision(len(this.DecisionToState) - 1) return s.getDecision() } @@ -163,4 +162,3 @@ func (this *ATN) getExpectedTokens(stateNumber int, ctx RuleContext) *IntervalSe } return expected } - diff --git a/runtime/Go/src/antlr4/ATNConfig.go b/runtime/Go/src/antlr4/ATNConfig.go index fb97e7c82..1749324e1 100644 --- a/runtime/Go/src/antlr4/ATNConfig.go +++ b/runtime/Go/src/antlr4/ATNConfig.go @@ -37,9 +37,9 @@ type ATNConfig interface { type BaseATNConfig struct { precedenceFilterSuppressed bool - state ATNState + state ATNState alt int - context PredictionContext + context PredictionContext semanticContext SemanticContext reachesIntoOuterContext int } @@ -61,7 +61,7 @@ func NewBaseATNConfig6(state ATNState, alt int, context PredictionContext) *Base func NewBaseATNConfig5(state ATNState, alt int, context PredictionContext, semanticContext SemanticContext) *BaseATNConfig { a := new(BaseATNConfig) - if (semanticContext == nil){ + if semanticContext == nil { panic("SemanticContext cannot be null!") } @@ -92,7 +92,7 @@ func NewBaseATNConfig1(c ATNConfig, state ATNState, context PredictionContext) * func NewBaseATNConfig(c ATNConfig, state ATNState, context PredictionContext, semanticContext SemanticContext) *BaseATNConfig { a := new(BaseATNConfig) - if (semanticContext == nil){ + if semanticContext == nil { panic("SemanticContext cannot be null!") } @@ -190,10 +190,6 @@ func (this *BaseATNConfig) String() string { return "(" + fmt.Sprint(this.state) + "," + strconv.Itoa(this.alt) + a + b + c + ")" } - - - - type LexerATNConfig struct { *BaseATNConfig diff --git a/runtime/Go/src/antlr4/ATNConfigSet.go b/runtime/Go/src/antlr4/ATNConfigSet.go index d44e56eba..0d6fc5840 100644 --- a/runtime/Go/src/antlr4/ATNConfigSet.go +++ b/runtime/Go/src/antlr4/ATNConfigSet.go @@ -207,12 +207,12 @@ func (this *BaseATNConfigSet) Equals(other interface{}) bool { other2 := other.(*BaseATNConfigSet) return this.configs != nil && - // this.configs.equals(other2.configs) && // TODO is this necessary? - this.fullCtx == other2.fullCtx && - this.uniqueAlt == other2.uniqueAlt && - this.conflictingAlts == other2.conflictingAlts && - this.hasSemanticContext == other2.hasSemanticContext && - this.dipsIntoOuterContext == other2.dipsIntoOuterContext + // this.configs.equals(other2.configs) && // TODO is this necessary? + this.fullCtx == other2.fullCtx && + this.uniqueAlt == other2.uniqueAlt && + this.conflictingAlts == other2.conflictingAlts && + this.hasSemanticContext == other2.hasSemanticContext && + this.dipsIntoOuterContext == other2.dipsIntoOuterContext } func (this *BaseATNConfigSet) Hash() string { @@ -307,37 +307,34 @@ func (this *BaseATNConfigSet) SetReadOnly(readOnly bool) { func (this *BaseATNConfigSet) String() string { s := "[" - for i,c := range this.configs { + for i, c := range this.configs { s += c.String() - if (i != len(this.configs)-1){ + if i != len(this.configs)-1 { s += "," } } s += "]" - if (this.hasSemanticContext){ + if this.hasSemanticContext { s += ",hasSemanticContext=" + fmt.Sprint(this.hasSemanticContext) } - if (this.uniqueAlt != ATNInvalidAltNumber ){ + if this.uniqueAlt != ATNInvalidAltNumber { s += ",uniqueAlt=" + fmt.Sprint(this.uniqueAlt) } - if ( this.conflictingAlts != nil ){ + if this.conflictingAlts != nil { s += ",conflictingAlts=" + this.conflictingAlts.String() } - if (this.dipsIntoOuterContext) { + if this.dipsIntoOuterContext { s += ",dipsIntoOuterContext" } return s } - - - type OrderedATNConfigSet struct { *BaseATNConfigSet } @@ -352,7 +349,6 @@ func NewOrderedATNConfigSet() *OrderedATNConfigSet { return this } - func hashATNConfig(c interface{}) string { return c.(ATNConfig).shortHash() } @@ -367,14 +363,14 @@ func equalATNConfigs(a, b interface{}) bool { return true } - ai,ok := a.(ATNConfig) - bi,ok1 := b.(ATNConfig) + ai, ok := a.(ATNConfig) + bi, ok1 := b.(ATNConfig) - if (!ok || !ok1) { + if !ok || !ok1 { return false } return ai.GetState().GetStateNumber() == bi.GetState().GetStateNumber() && - ai.GetAlt() == bi.GetAlt() && - ai.GetSemanticContext().equals(bi.GetSemanticContext()) + ai.GetAlt() == bi.GetAlt() && + ai.GetSemanticContext().equals(bi.GetSemanticContext()) } diff --git a/runtime/Go/src/antlr4/ATNDeserializer.go b/runtime/Go/src/antlr4/ATNDeserializer.go index 50c2666cc..99f112ae8 100644 --- a/runtime/Go/src/antlr4/ATNDeserializer.go +++ b/runtime/Go/src/antlr4/ATNDeserializer.go @@ -83,7 +83,7 @@ func (this *ATNDeserializer) isFeatureSupported(feature, actualUuid string) bool func (this *ATNDeserializer) DeserializeFromUInt16(data []uint16) *ATN { - this.reset( utf16.Decode(data) ) + this.reset(utf16.Decode(data)) this.checkVersion() this.checkUUID() var atn = this.readATN() @@ -186,7 +186,7 @@ func (this *ATNDeserializer) readStates(atn *ATN) { var numNonGreedyStates = this.readInt() for j := 0; j < numNonGreedyStates; j++ { stateNumber := this.readInt() - atn.states[stateNumber].(DecisionState).setNonGreedy( true ) + atn.states[stateNumber].(DecisionState).setNonGreedy(true) } var numPrecedenceStates = this.readInt() @@ -325,7 +325,7 @@ func (this *ATNDeserializer) readDecisions(atn *ATN) { var s = this.readInt() var decState = atn.states[s].(DecisionState) atn.DecisionToState = append(atn.DecisionToState, decState) - decState.setDecision( i ) + decState.setDecision(i) } } diff --git a/runtime/Go/src/antlr4/ATNState.go b/runtime/Go/src/antlr4/ATNState.go index ccdce079f..dba59f259 100644 --- a/runtime/Go/src/antlr4/ATNState.go +++ b/runtime/Go/src/antlr4/ATNState.go @@ -3,20 +3,20 @@ package antlr4 import "strconv" const ( -// constants for serialization - ATNStateInvalidType = 0 - ATNStateBasic = 1 - ATNStateRuleStart = 2 - ATNStateBlockStart = 3 + // constants for serialization + ATNStateInvalidType = 0 + ATNStateBasic = 1 + ATNStateRuleStart = 2 + ATNStateBlockStart = 3 ATNStatePlusBlockStart = 4 ATNStateStarBlockStart = 5 - ATNStateTokenStart = 6 - ATNStateRuleStop = 7 - ATNStateBlockEnd = 8 - ATNStateStarLoopBack = 9 - ATNStateStarLoopEntry = 10 - ATNStatePlusLoopBack = 11 - ATNStateLoopEnd = 12 + ATNStateTokenStart = 6 + ATNStateRuleStop = 7 + ATNStateBlockEnd = 8 + ATNStateStarLoopBack = 9 + ATNStateStarLoopEntry = 10 + ATNStatePlusLoopBack = 11 + ATNStateLoopEnd = 12 ATNStateInvalidStateNumber = -1 ) @@ -168,7 +168,6 @@ func NewBasicState() *BasicState { } type DecisionState interface { - ATNState getDecision() int @@ -176,7 +175,6 @@ type DecisionState interface { getNonGreedy() bool setNonGreedy(bool) - } type BaseDecisionState struct { @@ -215,12 +213,10 @@ func (s *BaseDecisionState) setNonGreedy(b bool) { } type IBlockStartState interface { - DecisionState getEndState() *BlockEndState setEndState(*BlockEndState) - } // The start of a regular {@code (...)} block. @@ -262,7 +258,6 @@ func NewBasicBlockStartState() *BasicBlockStartState { return this } - // Terminal node of a simple {@code (a|b|c)} block. type BlockEndState struct { *BaseATNState @@ -301,7 +296,7 @@ func NewRuleStopState() *RuleStopState { type RuleStartState struct { *BaseATNState - stopState ATNState + stopState ATNState isPrecedenceRule bool } @@ -390,7 +385,7 @@ func NewStarLoopbackState() *StarLoopbackState { type StarLoopEntryState struct { *BaseDecisionState - loopBackState ATNState + loopBackState ATNState precedenceRuleDecision bool } diff --git a/runtime/Go/src/antlr4/CommonTokenFactory.go b/runtime/Go/src/antlr4/CommonTokenFactory.go index 7d92b1817..b715e45a0 100644 --- a/runtime/Go/src/antlr4/CommonTokenFactory.go +++ b/runtime/Go/src/antlr4/CommonTokenFactory.go @@ -4,6 +4,7 @@ // package antlr4 + import "fmt" type TokenFactory interface { diff --git a/runtime/Go/src/antlr4/CommonTokenStream.go b/runtime/Go/src/antlr4/CommonTokenStream.go index 91dcf1e52..0491d7c22 100644 --- a/runtime/Go/src/antlr4/CommonTokenStream.go +++ b/runtime/Go/src/antlr4/CommonTokenStream.go @@ -12,11 +12,10 @@ package antlr4 import ( - "strconv" "fmt" + "strconv" ) - func (bt *CommonTokenStream) Mark() int { return 0 } @@ -101,7 +100,7 @@ func (bt *CommonTokenStream) fetch(n int) int { if PortDebug { fmt.Println("fetch loop") } - t.SetTokenIndex( len(bt.tokens) ) + t.SetTokenIndex(len(bt.tokens)) bt.tokens = append(bt.tokens, t) if t.GetTokenType() == TokenEOF { bt.fetchedEOF = true @@ -312,8 +311,6 @@ func (bt *CommonTokenStream) fill() { } } - - type CommonTokenStream struct { tokenSource TokenSource diff --git a/runtime/Go/src/antlr4/DFA.go b/runtime/Go/src/antlr4/DFA.go index 80d25b671..9cbafafae 100644 --- a/runtime/Go/src/antlr4/DFA.go +++ b/runtime/Go/src/antlr4/DFA.go @@ -1,4 +1,5 @@ package antlr4 + import "sort" type DFA struct { @@ -120,7 +121,7 @@ func (this *DFA) sortedStates() []*DFAState { // extract the values vs := make([]*DFAState, len(this._states)) i := 0 - for _,v := range this._states { + for _, v := range this._states { vs[i] = v i++ } diff --git a/runtime/Go/src/antlr4/DFASerializer.go b/runtime/Go/src/antlr4/DFASerializer.go index c54f90e7a..f83908454 100644 --- a/runtime/Go/src/antlr4/DFASerializer.go +++ b/runtime/Go/src/antlr4/DFASerializer.go @@ -39,7 +39,7 @@ func (this *DFASerializer) String() string { var buf = "" var states = this.dfa.sortedStates() - for _,s := range states { + for _, s := range states { if s.edges != nil { var n = len(s.edges) for j := 0; j < n; j++ { @@ -65,12 +65,12 @@ func (this *DFASerializer) String() string { func (this *DFASerializer) getEdgeLabel(i int) string { if i == 0 { return "EOF" - } else if this.literalNames != nil && i - 1 < len(this.literalNames) { + } else if this.literalNames != nil && i-1 < len(this.literalNames) { return this.literalNames[i-1] - } else if this.symbolicNames != nil && i - 1 < len(this.symbolicNames) { + } else if this.symbolicNames != nil && i-1 < len(this.symbolicNames) { return this.symbolicNames[i-1] } else { - return strconv.Itoa(i-1) + return strconv.Itoa(i - 1) } } @@ -98,8 +98,6 @@ func (this *DFASerializer) GetStateString(s *DFAState) string { } } - - type LexerDFASerializer struct { *DFASerializer } diff --git a/runtime/Go/src/antlr4/DFAState.go b/runtime/Go/src/antlr4/DFAState.go index 4e8aab129..c3f2639c5 100644 --- a/runtime/Go/src/antlr4/DFAState.go +++ b/runtime/Go/src/antlr4/DFAState.go @@ -52,7 +52,7 @@ func (this *PredPrediction) String() string { type DFAState struct { stateNumber int - configs ATNConfigSet + configs ATNConfigSet edges []*DFAState isAcceptState bool prediction int @@ -109,7 +109,7 @@ func NewDFAState(stateNumber int, configs ATNConfigSet) *DFAState { func (this *DFAState) GetAltSet() *Set { var alts = NewSet(nil, nil) if this.configs != nil { - for _,c := range this.configs.GetItems() { + for _, c := range this.configs.GetItems() { alts.add(c.GetAlt()) } } diff --git a/runtime/Go/src/antlr4/DiagnosticErrorListener.go b/runtime/Go/src/antlr4/DiagnosticErrorListener.go index 0c3eb3be9..df0886825 100644 --- a/runtime/Go/src/antlr4/DiagnosticErrorListener.go +++ b/runtime/Go/src/antlr4/DiagnosticErrorListener.go @@ -99,7 +99,7 @@ func (this *DiagnosticErrorListener) getConflictingAlts(ReportedAlts *BitSet, se return ReportedAlts } var result = NewBitSet() - for _,c := range set.GetItems() { + for _, c := range set.GetItems() { result.add(c.GetAlt()) } diff --git a/runtime/Go/src/antlr4/ErrorStrategy.go b/runtime/Go/src/antlr4/ErrorStrategy.go index f868d54e0..b6472fb19 100644 --- a/runtime/Go/src/antlr4/ErrorStrategy.go +++ b/runtime/Go/src/antlr4/ErrorStrategy.go @@ -21,7 +21,6 @@ type ErrorStrategy interface { // error Reporting and recovery in ANTLR parsers. // type DefaultErrorStrategy struct { - errorRecoveryMode bool lastErrorIndex int lastErrorStates *IntervalSet @@ -132,7 +131,6 @@ func (this *DefaultErrorStrategy) ReportError(recognizer Parser, e RecognitionEx } } - // {@inheritDoc} // //
The default implementation reSynchronizes the parser by consuming tokens @@ -558,7 +556,7 @@ func (this *DefaultErrorStrategy) getMissingSymbol(recognizer Parser) Token { if PortDebug { fmt.Println("Missing symbol error") } - return tf.Create( current.GetSource(), expectedTokenType, tokenText, TokenDefaultChannel, -1, -1, current.GetLine(), current.GetColumn()) + return tf.Create(current.GetSource(), expectedTokenType, tokenText, TokenDefaultChannel, -1, -1, current.GetLine(), current.GetColumn()) } func (this *DefaultErrorStrategy) getExpectedTokens(recognizer Parser) *IntervalSet { diff --git a/runtime/Go/src/antlr4/Errors.go b/runtime/Go/src/antlr4/Errors.go index 3c8ff91e6..95e2981b4 100644 --- a/runtime/Go/src/antlr4/Errors.go +++ b/runtime/Go/src/antlr4/Errors.go @@ -16,10 +16,10 @@ type RecognitionException interface { type BaseRecognitionException struct { message string - recognizer Recognizer + recognizer Recognizer offendingToken Token offendingState int - ctx RuleContext + ctx RuleContext input IntStream } @@ -126,7 +126,7 @@ type NoViableAltException struct { startToken Token offendingToken Token - ctx ParserRuleContext + ctx ParserRuleContext deadEndConfigs ATNConfigSet } diff --git a/runtime/Go/src/antlr4/FileStream.go b/runtime/Go/src/antlr4/FileStream.go index fa3b4182b..dd7a5350d 100644 --- a/runtime/Go/src/antlr4/FileStream.go +++ b/runtime/Go/src/antlr4/FileStream.go @@ -2,9 +2,9 @@ package antlr4 import ( "bytes" + "fmt" "io" "os" - "fmt" ) // diff --git a/runtime/Go/src/antlr4/InputStream.go b/runtime/Go/src/antlr4/InputStream.go index ecaec0ed4..92adeecf6 100644 --- a/runtime/Go/src/antlr4/InputStream.go +++ b/runtime/Go/src/antlr4/InputStream.go @@ -1,4 +1,5 @@ package antlr4 + import "fmt" type InputStream struct { diff --git a/runtime/Go/src/antlr4/IntStream.go b/runtime/Go/src/antlr4/IntStream.go index e22b17f53..e293442b7 100644 --- a/runtime/Go/src/antlr4/IntStream.go +++ b/runtime/Go/src/antlr4/IntStream.go @@ -1,7 +1,6 @@ package antlr4 type IntStream interface { - Consume() LA(int) int Mark() int @@ -10,5 +9,4 @@ type IntStream interface { Seek(index int) Size() int GetSourceName() string - } diff --git a/runtime/Go/src/antlr4/IntervalSet.go b/runtime/Go/src/antlr4/IntervalSet.go index 26ff9baa0..6a46ee7a7 100644 --- a/runtime/Go/src/antlr4/IntervalSet.go +++ b/runtime/Go/src/antlr4/IntervalSet.go @@ -1,9 +1,9 @@ package antlr4 import ( + "fmt" "strconv" "strings" - "fmt" ) type Interval struct { diff --git a/runtime/Go/src/antlr4/LL1Analyzer.go b/runtime/Go/src/antlr4/LL1Analyzer.go index 617a8f5b8..e11e84ae0 100644 --- a/runtime/Go/src/antlr4/LL1Analyzer.go +++ b/runtime/Go/src/antlr4/LL1Analyzer.go @@ -122,8 +122,7 @@ func (la *LL1Analyzer) LOOK(s, stopState ATNState, ctx RuleContext) *IntervalSet // outermost context is reached. This parameter has no effect if {@code ctx} // is {@code nil}. - -func (la *LL1Analyzer) __LOOK(s, stopState ATNState, ctx PredictionContext, look *IntervalSet, lookBusy *Set, calledRuleStack *BitSet, seeThruPreds, addEOF bool, i int){ +func (la *LL1Analyzer) __LOOK(s, stopState ATNState, ctx PredictionContext, look *IntervalSet, lookBusy *Set, calledRuleStack *BitSet, seeThruPreds, addEOF bool, i int) { returnState := la.atn.states[ctx.getReturnState(i)] @@ -260,5 +259,4 @@ func (la *LL1Analyzer) ___LOOK(stopState ATNState, ctx PredictionContext, look * calledRuleStack.add(t1.getTarget().GetRuleIndex()) la._LOOK(t1.getTarget(), stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) - } diff --git a/runtime/Go/src/antlr4/Lexer.go b/runtime/Go/src/antlr4/Lexer.go index 0d9d458dd..83db1cea2 100644 --- a/runtime/Go/src/antlr4/Lexer.go +++ b/runtime/Go/src/antlr4/Lexer.go @@ -12,7 +12,6 @@ import ( /// type Lexer interface { - TokenSource Recognizer @@ -31,7 +30,7 @@ type BaseLexer struct { _input CharStream _factory TokenFactory _tokenFactorySourcePair *TokenSourceCharStreamPair - _token Token + _token Token _tokenStartCharIndex int _tokenStartLine int _tokenStartColumn int diff --git a/runtime/Go/src/antlr4/LexerATNSimulator.go b/runtime/Go/src/antlr4/LexerATNSimulator.go index f1260988c..56f140c91 100644 --- a/runtime/Go/src/antlr4/LexerATNSimulator.go +++ b/runtime/Go/src/antlr4/LexerATNSimulator.go @@ -50,7 +50,7 @@ func (this *SimState) reset() { type LexerATNSimulator struct { *BaseATNSimulator - recog Lexer + recog Lexer predictionMode int decisionToDFA []*DFA mergeCache DoubleDict @@ -487,7 +487,7 @@ func (this *LexerATNSimulator) getEpsilonTarget(input CharStream, config *LexerA if LexerATNSimulatorDebug { fmt.Println("EVAL rule " + strconv.Itoa(trans.(*PredicateTransition).ruleIndex) + ":" + strconv.Itoa(pt.predIndex)) } - configs.SetHasSemanticContext( true ) + configs.SetHasSemanticContext(true) if this.evaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative) { cfg = NewLexerATNConfig4(config, trans.getTarget()) } @@ -590,7 +590,7 @@ func (this *LexerATNSimulator) addDFAEdge(from_ *DFAState, tk int, to *DFAState, // state, we can continue in pure DFA mode from there. // / var suppressEdge = cfgs.HasSemanticContext() - cfgs.SetHasSemanticContext( false ) + cfgs.SetHasSemanticContext(false) to = this.addDFAState(cfgs) diff --git a/runtime/Go/src/antlr4/LexerAction.go b/runtime/Go/src/antlr4/LexerAction.go index 9fafe813b..644c6b54e 100644 --- a/runtime/Go/src/antlr4/LexerAction.go +++ b/runtime/Go/src/antlr4/LexerAction.go @@ -3,14 +3,14 @@ package antlr4 import "strconv" const ( - LexerActionTypeChannel = 0 //The type of a {@link LexerChannelAction} action. - LexerActionTypeCustom = 1 //The type of a {@link LexerCustomAction} action. - LexerActionTypeMode = 2 //The type of a {@link LexerModeAction} action. - LexerActionTypeMore = 3 //The type of a {@link LexerMoreAction} action. - LexerActionTypePopMode = 4 //The type of a {@link LexerPopModeAction} action. + LexerActionTypeChannel = 0 //The type of a {@link LexerChannelAction} action. + LexerActionTypeCustom = 1 //The type of a {@link LexerCustomAction} action. + LexerActionTypeMode = 2 //The type of a {@link LexerModeAction} action. + LexerActionTypeMore = 3 //The type of a {@link LexerMoreAction} action. + LexerActionTypePopMode = 4 //The type of a {@link LexerPopModeAction} action. LexerActionTypePushMode = 5 //The type of a {@link LexerPushModeAction} action. - LexerActionTypeSkip = 6 //The type of a {@link LexerSkipAction} action. - LexerActionTypeType = 7 //The type of a {@link LexerTypeAction} action. + LexerActionTypeSkip = 6 //The type of a {@link LexerSkipAction} action. + LexerActionTypeType = 7 //The type of a {@link LexerTypeAction} action. ) type LexerAction interface { @@ -35,7 +35,6 @@ func NewBaseLexerAction(action int) *BaseLexerAction { return la } - func (this *BaseLexerAction) execute(lexer Lexer) { panic("Not implemented") } @@ -370,7 +369,7 @@ type LexerIndexedCustomAction struct { *BaseLexerAction offset int - lexerAction LexerAction + lexerAction LexerAction isPositionDependent bool } diff --git a/runtime/Go/src/antlr4/Parser.go b/runtime/Go/src/antlr4/Parser.go index b7a35ce61..13d4cf6a5 100644 --- a/runtime/Go/src/antlr4/Parser.go +++ b/runtime/Go/src/antlr4/Parser.go @@ -1,4 +1,5 @@ package antlr4 + import "fmt" type Parser interface { @@ -28,9 +29,9 @@ type BaseParser struct { BuildParseTrees bool _input TokenStream - _errHandler ErrorStrategy + _errHandler ErrorStrategy _precedenceStack IntStack - _ctx ParserRuleContext + _ctx ParserRuleContext _tracer *TraceListener _parseListeners []ParseTreeListener diff --git a/runtime/Go/src/antlr4/ParserATNSimulator.go b/runtime/Go/src/antlr4/ParserATNSimulator.go index eed32d707..313d08702 100644 --- a/runtime/Go/src/antlr4/ParserATNSimulator.go +++ b/runtime/Go/src/antlr4/ParserATNSimulator.go @@ -9,14 +9,14 @@ import ( type ParserATNSimulator struct { *BaseATNSimulator - parser Parser + parser Parser predictionMode int _input TokenStream _startIndex int _dfa *DFA decisionToDFA []*DFA mergeCache *DoubleDict - _outerContext ParserRuleContext + _outerContext ParserRuleContext } func NewParserATNSimulator(parser Parser, atn *ATN, decisionToDFA []*DFA, sharedContextCache *PredictionContextCache) *ParserATNSimulator { @@ -328,15 +328,15 @@ func (this *ParserATNSimulator) computeTargetState(dfa *DFA, previousD *DFAState if predictedAlt != ATNInvalidAltNumber { // NO CONFLICT, UNIQUELY PREDICTED ALT D.isAcceptState = true - D.configs.SetUniqueAlt( predictedAlt ) - D.setPrediction( predictedAlt ) + D.configs.SetUniqueAlt(predictedAlt) + D.setPrediction(predictedAlt) } else if PredictionModehasSLLConflictTerminatingPrediction(this.predictionMode, reach) { // MORE THAN ONE VIABLE ALTERNATIVE - D.configs.SetConflictingAlts( this.getConflictingAlts(reach) ) + D.configs.SetConflictingAlts(this.getConflictingAlts(reach)) D.requiresFullContext = true // in SLL-only mode, we will stop at this state and return the minimum alt D.isAcceptState = true - D.setPrediction( D.configs.GetConflictingAlts().minValue() ) + D.setPrediction(D.configs.GetConflictingAlts().minValue()) } if D.isAcceptState && D.configs.HasSemanticContext() { this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision)) @@ -364,7 +364,7 @@ func (this *ParserATNSimulator) predicateDFAState(dfaState *DFAState, decisionSt // There are preds in configs but they might go away // when OR'd together like {p}? || NONE == NONE. If neither // alt has preds, resolve to min alt - dfaState.setPrediction( altsToCollectPredsFrom.minValue() ) + dfaState.setPrediction(altsToCollectPredsFrom.minValue()) } } @@ -410,7 +410,7 @@ func (this *ParserATNSimulator) execATNWithFullContext(dfa *DFA, D *DFAState, s0 strconv.Itoa(PredictionModegetUniqueAlt(altSubSets)) + ", resolvesToJustOneViableAlt=" + fmt.Sprint(PredictionModeresolvesToJustOneViableAlt(altSubSets))) } - reach.SetUniqueAlt( this.getUniqueAlt(reach) ) + reach.SetUniqueAlt(this.getUniqueAlt(reach)) // unique prediction? if reach.GetUniqueAlt() != ATNInvalidAltNumber { predictedAlt = reach.GetUniqueAlt() @@ -499,7 +499,7 @@ func (this *ParserATNSimulator) computeReachSet(closure ATNConfigSet, t int, ful var skippedStopStates []*BaseATNConfig = nil // First figure out where we can reach on input t - for _,c := range closure.GetItems() { + for _, c := range closure.GetItems() { if ParserATNSimulatorDebug { fmt.Println("testing " + this.GetTokenName(t) + " at " + c.String()) } @@ -632,7 +632,7 @@ func (this *ParserATNSimulator) removeAllConfigsNotInRuleStopState(configs ATNCo return configs } var result = NewBaseATNConfigSet(configs.FullContext()) - for _,config := range configs.GetItems() { + for _, config := range configs.GetItems() { _, ok := config.GetState().(*RuleStopState) @@ -725,7 +725,7 @@ func (this *ParserATNSimulator) applyPrecedenceFilter(configs ATNConfigSet) ATNC var statesFromAlt1 = make(map[int]PredictionContext) var configSet = NewBaseATNConfigSet(configs.FullContext()) - for _,config := range configs.GetItems() { + for _, config := range configs.GetItems() { // handle alt 1 first if config.GetAlt() != 1 { continue @@ -742,7 +742,7 @@ func (this *ParserATNSimulator) applyPrecedenceFilter(configs ATNConfigSet) ATNC configSet.Add(config, this.mergeCache) } } - for _,config := range configs.GetItems() { + for _, config := range configs.GetItems() { if config.GetAlt() == 1 { // already handled continue @@ -883,7 +883,7 @@ func (this *ParserATNSimulator) getSynValidOrSemInvalidAltThatFinishedDecisionEn func (this *ParserATNSimulator) GetAltThatFinishedDecisionEntryRule(configs ATNConfigSet) int { var alts = NewIntervalSet() - for _,c := range configs.GetItems() { + for _, c := range configs.GetItems() { _, ok := c.GetState().(*RuleStopState) if c.GetReachesIntoOuterContext() > 0 || (ok && c.GetContext().hasEmptyPath()) { @@ -1090,7 +1090,7 @@ func (this *ParserATNSimulator) closure_(config ATNConfig, configs ATNConfigSet, } c.SetReachesIntoOuterContext(c.GetReachesIntoOuterContext() + 1) - configs.SetDipsIntoOuterContext( true ) // TODO: can remove? only care when we add to set per middle of this method + configs.SetDipsIntoOuterContext(true) // TODO: can remove? only care when we add to set per middle of this method newDepth -= 1 if ParserATNSimulatorDebug { fmt.Println("dips into outer ctx: " + c.String()) @@ -1313,7 +1313,7 @@ func (this *ParserATNSimulator) GetTokenName(t int) string { if this.parser != nil && this.parser.GetLiteralNames() != nil { if t >= len(this.parser.GetLiteralNames()) { fmt.Println(strconv.Itoa(t) + " ttype out of range: " + strings.Join(this.parser.GetLiteralNames(), ",")) -// fmt.Println(this.parser.GetInputStream().(TokenStream).GetAllText()) // this seems incorrect + // fmt.Println(this.parser.GetInputStream().(TokenStream).GetAllText()) // this seems incorrect } else { return this.parser.GetLiteralNames()[t] + "<" + strconv.Itoa(t) + ">" } @@ -1366,7 +1366,7 @@ func (this *ParserATNSimulator) noViableAlt(input TokenStream, outerContext Pars func (this *ParserATNSimulator) getUniqueAlt(configs ATNConfigSet) int { var alt = ATNInvalidAltNumber - for _,c := range configs.GetItems() { + for _, c := range configs.GetItems() { if alt == ATNInvalidAltNumber { alt = c.GetAlt() // found first alt } else if c.GetAlt() != alt { diff --git a/runtime/Go/src/antlr4/ParserRuleContext.go b/runtime/Go/src/antlr4/ParserRuleContext.go index 3550d7c9d..30140d67e 100644 --- a/runtime/Go/src/antlr4/ParserRuleContext.go +++ b/runtime/Go/src/antlr4/ParserRuleContext.go @@ -28,7 +28,7 @@ type BaseParserRuleContext struct { children []ParseTree start, stop Token - exception RecognitionException + exception RecognitionException } func NewBaseParserRuleContext(parent ParserRuleContext, invokingStateNumber int) *BaseParserRuleContext { diff --git a/runtime/Go/src/antlr4/PredictionContext.go b/runtime/Go/src/antlr4/PredictionContext.go index 5709690ac..1b6aef0c0 100644 --- a/runtime/Go/src/antlr4/PredictionContext.go +++ b/runtime/Go/src/antlr4/PredictionContext.go @@ -129,7 +129,7 @@ type SingletonPredictionContext interface { type BaseSingletonPredictionContext struct { *BasePredictionContext - parentCtx PredictionContext + parentCtx PredictionContext returnState int } @@ -721,15 +721,15 @@ func combineCommonParents(parents []PredictionContext) { func getCachedBasePredictionContext(context PredictionContext, contextCache *PredictionContextCache, visited map[PredictionContext]PredictionContext) PredictionContext { - if (context.isEmpty()) { + if context.isEmpty() { return context } var existing = visited[context] - if (existing != nil) { + if existing != nil { return existing } existing = contextCache.Get(context) - if (existing != nil) { + if existing != nil { visited[context] = existing return existing } @@ -737,8 +737,8 @@ func getCachedBasePredictionContext(context PredictionContext, contextCache *Pre var parents = make([]PredictionContext, context.length()) for i := 0; i < len(parents); i++ { var parent = getCachedBasePredictionContext(context.GetParent(i), contextCache, visited) - if (changed || parent != context.GetParent(i)) { - if (!changed) { + if changed || parent != context.GetParent(i) { + if !changed { parents = make([]PredictionContext, context.length()) for j := 0; j < context.length(); j++ { parents[j] = context.GetParent(j) @@ -748,15 +748,15 @@ func getCachedBasePredictionContext(context PredictionContext, contextCache *Pre parents[i] = parent } } - if (!changed) { + if !changed { contextCache.add(context) visited[context] = context return context } var updated PredictionContext = nil - if (len(parents) == 0) { + if len(parents) == 0 { updated = BasePredictionContextEMPTY - } else if (len(parents) == 1) { + } else if len(parents) == 1 { updated = SingletonBasePredictionContextCreate(parents[0], context.getReturnState(0)) } else { updated = NewArrayPredictionContext(parents, context.(*ArrayPredictionContext).GetReturnStates()) diff --git a/runtime/Go/src/antlr4/Recognizer.go b/runtime/Go/src/antlr4/Recognizer.go index e352265c6..f8f96e29f 100644 --- a/runtime/Go/src/antlr4/Recognizer.go +++ b/runtime/Go/src/antlr4/Recognizer.go @@ -8,7 +8,6 @@ import ( ) type Recognizer interface { - GetLiteralNames() []string GetSymbolicNames() []string GetRuleNames() []string @@ -20,16 +19,15 @@ type Recognizer interface { Action(_localctx RuleContext, ruleIndex, actionIndex int) GetATN() *ATN getErrorListenerDispatch() ErrorListener - } type BaseRecognizer struct { _listeners []ErrorListener state int - RuleNames []string - LiteralNames []string - SymbolicNames []string + RuleNames []string + LiteralNames []string + SymbolicNames []string GrammarFileName string } @@ -84,7 +82,7 @@ func (this *BaseRecognizer) GetState() int { func (this *BaseRecognizer) SetState(v int) { if PortDebug { - fmt.Println("SETTING STATE " + strconv.Itoa(v) + " from " + strconv.Itoa(this.state)) + fmt.Println("SETTING STATE " + strconv.Itoa(v) + " from " + strconv.Itoa(this.state)) } this.state = v diff --git a/runtime/Go/src/antlr4/RuleContext.go b/runtime/Go/src/antlr4/RuleContext.go index 5a2d25a6c..81db4477e 100644 --- a/runtime/Go/src/antlr4/RuleContext.go +++ b/runtime/Go/src/antlr4/RuleContext.go @@ -39,7 +39,7 @@ type RuleContext interface { } type BaseRuleContext struct { - parentCtx RuleContext + parentCtx RuleContext invokingState int RuleIndex int children []Tree @@ -187,7 +187,7 @@ func (this *BaseRuleContext) String(ruleNames []string, stop RuleContext) string s += " " } pi := p.GetParent() - if (pi != nil){ + if pi != nil { p = pi.(RuleContext) } else { p = nil diff --git a/runtime/Go/src/antlr4/Token.go b/runtime/Go/src/antlr4/Token.go index c5a6c559e..73a8d4162 100644 --- a/runtime/Go/src/antlr4/Token.go +++ b/runtime/Go/src/antlr4/Token.go @@ -14,7 +14,6 @@ type TokenSourceCharStreamPair struct { // (so we can ignore tabs), token channel, index, and source from which // we obtained this token. - type Token interface { GetSource() *TokenSourceCharStreamPair GetTokenType() int @@ -94,7 +93,7 @@ func (this *BaseToken) GetTokenType() int { return this.tokenType } -func (this *BaseToken) GetSource() *TokenSourceCharStreamPair{ +func (this *BaseToken) GetSource() *TokenSourceCharStreamPair { return this.source } diff --git a/runtime/Go/src/antlr4/Transition.go b/runtime/Go/src/antlr4/Transition.go index 12c9bb3ab..428e6763f 100644 --- a/runtime/Go/src/antlr4/Transition.go +++ b/runtime/Go/src/antlr4/Transition.go @@ -24,10 +24,10 @@ type Transition interface { } type BaseTransition struct { - target ATNState + target ATNState isEpsilon bool - label_ int - label *IntervalSet + label_ int + label *IntervalSet serializationType int } @@ -156,7 +156,7 @@ func (t *AtomTransition) String() string { type RuleTransition struct { *BaseTransition - followState ATNState + followState ATNState ruleIndex, precedence int } @@ -252,7 +252,7 @@ func NewBasePredicateTransition(target ATNState) *BaseAbstractPredicateTransitio return t } -func (a *BaseAbstractPredicateTransition) IAbstractPredicateTransitionFoo(){} +func (a *BaseAbstractPredicateTransition) IAbstractPredicateTransitionFoo() {} type PredicateTransition struct { *BaseAbstractPredicateTransition diff --git a/runtime/Go/src/antlr4/Tree.go b/runtime/Go/src/antlr4/Tree.go index 5ddcdc4f7..7664d701b 100644 --- a/runtime/Go/src/antlr4/Tree.go +++ b/runtime/Go/src/antlr4/Tree.go @@ -99,7 +99,6 @@ func NewTerminalNodeImpl(symbol Token) *TerminalNodeImpl { return tn } - func (this *TerminalNodeImpl) getChild(i int) Tree { return nil } diff --git a/runtime/Go/src/antlr4/Utils.go b/runtime/Go/src/antlr4/Utils.go index 686ede2b7..59b2b2e01 100644 --- a/runtime/Go/src/antlr4/Utils.go +++ b/runtime/Go/src/antlr4/Utils.go @@ -6,8 +6,8 @@ import ( "hash/fnv" "strings" // "regexp" -// "bytes" -// "encoding/gob" + // "bytes" + // "encoding/gob" ) func intMin(a, b int) int { @@ -44,7 +44,6 @@ func (s *IntStack) Push(e int) { *s = append(*s, e) } - type Set struct { data map[string][]interface{} hashFunction func(interface{}) string @@ -92,7 +91,6 @@ func standardHashFunction(a interface{}) string { // return buf.Bytes(), nil //} - type Hasher interface { Hash() string } @@ -167,8 +165,8 @@ func (this *Set) String() string { s := "" - for _,av := range this.data { - for _,v := range av { + for _, av := range this.data { + for _, v := range av { s += fmt.Sprint(v) } }