forked from jasder/antlr
go fmt the whole project
This commit is contained in:
parent
39c1321d40
commit
805f706f02
|
@ -5,14 +5,10 @@ import (
|
|||
"parser"
|
||||
)
|
||||
|
||||
|
||||
type MyErrorListener struct {
|
||||
*MyErrorListener
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
a := antlr4.NewFileStream("foo.txt")
|
||||
|
@ -27,12 +23,4 @@ func main() {
|
|||
|
||||
p.Equation()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,10 +363,10 @@ 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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package antlr4
|
|||
import "strconv"
|
||||
|
||||
const (
|
||||
// constants for serialization
|
||||
// constants for serialization
|
||||
ATNStateInvalidType = 0
|
||||
ATNStateBasic = 1
|
||||
ATNStateRuleStart = 2
|
||||
|
@ -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
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
|
||||
package antlr4
|
||||
|
||||
import "fmt"
|
||||
|
||||
type TokenFactory interface {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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++
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
@ -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}
|
||||
//
|
||||
// <p>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 {
|
||||
|
|
|
@ -2,9 +2,9 @@ package antlr4
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
//
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package antlr4
|
||||
|
||||
import "fmt"
|
||||
|
||||
type InputStream struct {
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package antlr4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Interval struct {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
///
|
||||
|
||||
type Lexer interface {
|
||||
|
||||
TokenSource
|
||||
Recognizer
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ func NewBaseLexerAction(action int) *BaseLexerAction {
|
|||
return la
|
||||
}
|
||||
|
||||
|
||||
func (this *BaseLexerAction) execute(lexer Lexer) {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package antlr4
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Parser interface {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
)
|
||||
|
||||
type Recognizer interface {
|
||||
|
||||
GetLiteralNames() []string
|
||||
GetSymbolicNames() []string
|
||||
GetRuleNames() []string
|
||||
|
@ -20,7 +19,6 @@ type Recognizer interface {
|
|||
Action(_localctx RuleContext, ruleIndex, actionIndex int)
|
||||
GetATN() *ATN
|
||||
getErrorListenerDispatch() ErrorListener
|
||||
|
||||
}
|
||||
|
||||
type BaseRecognizer struct {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ func NewBasePredicateTransition(target ATNState) *BaseAbstractPredicateTransitio
|
|||
return t
|
||||
}
|
||||
|
||||
func (a *BaseAbstractPredicateTransition) IAbstractPredicateTransitionFoo(){}
|
||||
func (a *BaseAbstractPredicateTransition) IAbstractPredicateTransitionFoo() {}
|
||||
|
||||
type PredicateTransition struct {
|
||||
*BaseAbstractPredicateTransition
|
||||
|
|
|
@ -99,7 +99,6 @@ func NewTerminalNodeImpl(symbol Token) *TerminalNodeImpl {
|
|||
return tn
|
||||
}
|
||||
|
||||
|
||||
func (this *TerminalNodeImpl) getChild(i int) Tree {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue