Minor fixes
This commit is contained in:
parent
e6a0cce6db
commit
a2e6ee7570
|
@ -28,7 +28,7 @@ type IATNConfig interface {
|
|||
GetReachesIntoOuterContext() int
|
||||
SetReachesIntoOuterContext(int)
|
||||
|
||||
toString() string
|
||||
String() string
|
||||
}
|
||||
|
||||
type ATNConfig struct {
|
||||
|
@ -151,7 +151,7 @@ func (this *ATNConfig) equals(other interface{}) bool {
|
|||
}
|
||||
|
||||
func (this *ATNConfig) shortHashString() string {
|
||||
return "" + strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + this.semanticContext.toString()
|
||||
return "" + strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + this.semanticContext.String()
|
||||
}
|
||||
|
||||
func (this *ATNConfig) hashString() string {
|
||||
|
@ -163,10 +163,10 @@ func (this *ATNConfig) hashString() string {
|
|||
c = this.context.hashString()
|
||||
}
|
||||
|
||||
return "" + strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + c + "/" + this.semanticContext.toString()
|
||||
return "" + strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + c + "/" + this.semanticContext.String()
|
||||
}
|
||||
|
||||
func (this *ATNConfig) toString() string {
|
||||
func (this *ATNConfig) String() string {
|
||||
|
||||
var a string
|
||||
if this.context != nil {
|
||||
|
|
|
@ -250,16 +250,18 @@ func (this *ATNConfigSet) setReadonly(readOnly bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *ATNConfigSet) toString() string {
|
||||
s := ""
|
||||
func (this *ATNConfigSet) String() string {
|
||||
s := "["
|
||||
|
||||
for i,c := range this.configs {
|
||||
s += c.toString()
|
||||
s += c.String()
|
||||
if (i != len(this.configs)-1){
|
||||
s += ","
|
||||
}
|
||||
}
|
||||
|
||||
s += "]"
|
||||
|
||||
if (this.hasSemanticContext){
|
||||
s += ",hasSemanticContext=" + fmt.Sprint(this.hasSemanticContext)
|
||||
}
|
||||
|
@ -269,7 +271,7 @@ func (this *ATNConfigSet) toString() string {
|
|||
}
|
||||
|
||||
if ( this.conflictingAlts != nil ){
|
||||
s += ",conflictingAlts=" + this.conflictingAlts.toString()
|
||||
s += ",conflictingAlts=" + this.conflictingAlts.String()
|
||||
}
|
||||
|
||||
if (this.dipsIntoOuterContext) {
|
||||
|
|
|
@ -59,7 +59,7 @@ type IATNState interface {
|
|||
SetTransitions([]ITransition)
|
||||
AddTransition(ITransition, int)
|
||||
|
||||
toString() string
|
||||
String() string
|
||||
}
|
||||
|
||||
type ATNState struct {
|
||||
|
@ -140,7 +140,7 @@ func (as *ATNState) SetNextTokenWithinRule(v *IntervalSet) {
|
|||
as.nextTokenWithinRule = v
|
||||
}
|
||||
|
||||
func (this *ATNState) toString() string {
|
||||
func (this *ATNState) String() string {
|
||||
return strconv.Itoa(this.stateNumber)
|
||||
}
|
||||
|
||||
|
|
|
@ -129,12 +129,12 @@ func (this *DFA) sortedStates() []*DFAState {
|
|||
return vs
|
||||
}
|
||||
|
||||
func (this *DFA) toString(literalNames []string, symbolicNames []string) string {
|
||||
func (this *DFA) String(literalNames []string, symbolicNames []string) string {
|
||||
if this.s0 == nil {
|
||||
return ""
|
||||
}
|
||||
var serializer = NewDFASerializer(this, literalNames, symbolicNames)
|
||||
return serializer.toString()
|
||||
return serializer.String()
|
||||
}
|
||||
|
||||
func (this *DFA) toLexerString() string {
|
||||
|
@ -142,5 +142,5 @@ func (this *DFA) toLexerString() string {
|
|||
return ""
|
||||
}
|
||||
var serializer = NewLexerDFASerializer(this)
|
||||
return serializer.toString()
|
||||
return serializer.String()
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func NewDFASerializer(dfa *DFA, literalNames, symbolicNames []string) *DFASerial
|
|||
return this
|
||||
}
|
||||
|
||||
func (this *DFASerializer) toString() string {
|
||||
func (this *DFASerializer) String() string {
|
||||
|
||||
if this.dfa.s0 == nil {
|
||||
return ""
|
||||
|
|
|
@ -21,7 +21,7 @@ func NewPredPrediction(pred SemanticContext, alt int) *PredPrediction {
|
|||
return this
|
||||
}
|
||||
|
||||
func (this *PredPrediction) toString() string {
|
||||
func (this *PredPrediction) String() string {
|
||||
return "(" + fmt.Sprint(this.pred) + ", " + fmt.Sprint(this.alt) + ")"
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ func (this *DFAState) equals(other interface{}) bool {
|
|||
return this.configs.equals(other.(*DFAState).configs)
|
||||
}
|
||||
|
||||
func (this *DFAState) toString() string {
|
||||
func (this *DFAState) String() string {
|
||||
return strconv.Itoa(this.stateNumber) + ":" + this.hashString()
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func (this *DiagnosticErrorListener) ReportAmbiguity(recognizer *Parser, dfa *DF
|
|||
var msg = "ReportAmbiguity d=" +
|
||||
this.getDecisionDescription(recognizer, dfa) +
|
||||
": ambigAlts=" +
|
||||
this.getConflictingAlts(ambigAlts, configs).toString() +
|
||||
this.getConflictingAlts(ambigAlts, configs).String() +
|
||||
", input='" +
|
||||
recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'"
|
||||
recognizer.notifyErrorListeners(msg, nil, nil)
|
||||
|
|
|
@ -278,7 +278,7 @@ func (this *DefaultErrorStrategy) ReportNoViableAlternative(recognizer IParser,
|
|||
//
|
||||
func (this *DefaultErrorStrategy) ReportInputMisMatch(recognizer IParser, e *InputMisMatchException) {
|
||||
var msg = "misMatched input " + this.GetTokenErrorDisplay(e.offendingToken) +
|
||||
" expecting " + e.getExpectedTokens().toStringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false)
|
||||
" expecting " + e.getExpectedTokens().StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false)
|
||||
recognizer.notifyErrorListeners(msg, e.offendingToken, e)
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ func (this *DefaultErrorStrategy) ReportUnwantedToken(recognizer IParser) {
|
|||
var tokenName = this.GetTokenErrorDisplay(t)
|
||||
var expecting = this.getExpectedTokens(recognizer)
|
||||
var msg = "extraneous input " + tokenName + " expecting " +
|
||||
expecting.toStringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false)
|
||||
expecting.StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false)
|
||||
recognizer.notifyErrorListeners(msg, t, nil)
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ func (this *DefaultErrorStrategy) ReportMissingToken(recognizer IParser) {
|
|||
this.beginErrorCondition(recognizer)
|
||||
var t = recognizer.getCurrentToken()
|
||||
var expecting = this.getExpectedTokens(recognizer)
|
||||
var msg = "missing " + expecting.toStringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false) +
|
||||
var msg = "missing " + expecting.StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false) +
|
||||
" at " + this.GetTokenErrorDisplay(t)
|
||||
recognizer.notifyErrorListeners(msg, t, nil)
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ func (this *DefaultErrorStrategy) getExpectedTokens(recognizer IParser) *Interva
|
|||
// How should a token be displayed in an error message? The default
|
||||
// is to display just the text, but during development you might
|
||||
// want to have a lot of information spit out. Override in that case
|
||||
// to use t.toString() (which, for CommonToken, dumps everything about
|
||||
// to use t.String() (which, for CommonToken, dumps everything about
|
||||
// the token). This is better than forcing you to override a method in
|
||||
// your token objects because you don't have to go modify your lexer
|
||||
// so that it creates a NewJava type.
|
||||
|
|
|
@ -90,7 +90,7 @@ func (this *RecognitionException) getExpectedTokens() *IntervalSet {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *RecognitionException) toString() string {
|
||||
func (this *RecognitionException) String() string {
|
||||
return this.message
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func NewLexerNoViableAltException(lexer ILexer, input CharStream, startIndex int
|
|||
return this
|
||||
}
|
||||
|
||||
func (this *LexerNoViableAltException) toString() string {
|
||||
func (this *LexerNoViableAltException) String() string {
|
||||
var symbol = ""
|
||||
if this.startIndex >= 0 && this.startIndex < this.input.Size() {
|
||||
symbol = this.input.(CharStream).GetTextFromInterval(NewInterval(this.startIndex, this.startIndex))
|
||||
|
|
|
@ -89,6 +89,6 @@ func (is *InputStream) GetTextFromInterval(i *Interval) string {
|
|||
return is.GetText(i.start, i.stop)
|
||||
}
|
||||
|
||||
func (is *InputStream) toString() string {
|
||||
func (is *InputStream) String() string {
|
||||
return string(is.data)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func (i *Interval) contains(item int) bool {
|
|||
return item >= i.start && item < i.stop
|
||||
}
|
||||
|
||||
func (i *Interval) toString() string {
|
||||
func (i *Interval) String() string {
|
||||
if i.start == i.stop-1 {
|
||||
return strconv.Itoa(i.start)
|
||||
} else {
|
||||
|
@ -209,11 +209,11 @@ func (is *IntervalSet) removeOne(v int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (i *IntervalSet) toString() string {
|
||||
return i.toStringVerbose(nil, nil, false)
|
||||
func (i *IntervalSet) String() string {
|
||||
return i.StringVerbose(nil, nil, false)
|
||||
}
|
||||
|
||||
func (i *IntervalSet) toStringVerbose(literalNames []string, symbolicNames []string, elemsAreChar bool) string {
|
||||
func (i *IntervalSet) StringVerbose(literalNames []string, symbolicNames []string, elemsAreChar bool) string {
|
||||
|
||||
if i.intervals == nil {
|
||||
return "{}"
|
||||
|
|
|
@ -135,7 +135,7 @@ func (this *LexerATNSimulator) MatchATN(input CharStream) int {
|
|||
var startState = this.atn.modeToStartState[this.mode]
|
||||
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Println("MatchATN mode " + strconv.Itoa(this.mode) + " start: " + startState.toString())
|
||||
fmt.Println("MatchATN mode " + strconv.Itoa(this.mode) + " start: " + startState.String())
|
||||
}
|
||||
var old_mode = this.mode
|
||||
var s0_closure = this.computeStartState(input, startState)
|
||||
|
@ -158,7 +158,7 @@ func (this *LexerATNSimulator) MatchATN(input CharStream) int {
|
|||
|
||||
func (this *LexerATNSimulator) execATN(input CharStream, ds0 *DFAState) int {
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Println("start state closure=" + ds0.configs.toString())
|
||||
fmt.Println("start state closure=" + ds0.configs.String())
|
||||
}
|
||||
if ds0.isAcceptState {
|
||||
// allow zero-length tokens
|
||||
|
@ -169,7 +169,7 @@ func (this *LexerATNSimulator) execATN(input CharStream, ds0 *DFAState) int {
|
|||
|
||||
for true { // while more work
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Println("execATN loop starting closure: " + s.configs.toString())
|
||||
fmt.Println("execATN loop starting closure: " + s.configs.String())
|
||||
}
|
||||
|
||||
// As we move src->trg, src->trg, we keep track of the previous trg to
|
||||
|
@ -300,7 +300,7 @@ func (this *LexerATNSimulator) getReachableConfigSet(input CharStream, closure *
|
|||
continue
|
||||
}
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Printf("testing %s at %s\n", this.GetTokenName(t), cfg.toString()) // this.recog, true))
|
||||
fmt.Printf("testing %s at %s\n", this.GetTokenName(t), cfg.String()) // this.recog, true))
|
||||
}
|
||||
for j := 0; j < len(cfg.GetState().GetTransitions()); j++ {
|
||||
var trans = cfg.GetState().GetTransitions()[j] // for each transition
|
||||
|
@ -367,7 +367,7 @@ func (this *LexerATNSimulator) closure(input CharStream, config *LexerATNConfig,
|
|||
currentAltReachedAcceptState, speculative, treatEofAsEpsilon bool) bool {
|
||||
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Println("closure(" + config.toString() + ")") // config.toString(this.recog, true) + ")")
|
||||
fmt.Println("closure(" + config.String() + ")") // config.String(this.recog, true) + ")")
|
||||
}
|
||||
|
||||
_, ok := config.state.(*RuleStopState)
|
||||
|
@ -572,7 +572,7 @@ func (this *LexerATNSimulator) addDFAEdge(from_ *DFAState, tk int, to *DFAState,
|
|||
return to
|
||||
}
|
||||
if LexerATNSimulatordebug {
|
||||
fmt.Println("EDGE " + from_.toString() + " -> " + to.toString() + " upon " + strconv.Itoa(tk))
|
||||
fmt.Println("EDGE " + from_.String() + " -> " + to.String() + " upon " + strconv.Itoa(tk))
|
||||
}
|
||||
if from_.edges == nil {
|
||||
// make room for tokens 1..n and -1 masquerading as index 0
|
||||
|
|
|
@ -78,7 +78,7 @@ func (this *LexerSkipAction) execute(lexer ILexer) {
|
|||
lexer.skip()
|
||||
}
|
||||
|
||||
func (this *LexerSkipAction) toString() string {
|
||||
func (this *LexerSkipAction) String() string {
|
||||
return "skip"
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ func (this *LexerTypeAction) equals(other ILexerAction) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *LexerTypeAction) toString() string {
|
||||
func (this *LexerTypeAction) String() string {
|
||||
return "actionType(" + strconv.Itoa(this._type) + ")"
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ func (this *LexerPushModeAction) equals(other ILexerAction) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *LexerPushModeAction) toString() string {
|
||||
func (this *LexerPushModeAction) String() string {
|
||||
return "pushMode(" + strconv.Itoa(this.mode) + ")"
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ func (this *LexerPopModeAction) execute(lexer ILexer) {
|
|||
lexer.popMode()
|
||||
}
|
||||
|
||||
func (this *LexerPopModeAction) toString() string {
|
||||
func (this *LexerPopModeAction) String() string {
|
||||
return "popMode"
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ func (this *LexerMoreAction) execute(lexer ILexer) {
|
|||
lexer.more()
|
||||
}
|
||||
|
||||
func (this *LexerMoreAction) toString() string {
|
||||
func (this *LexerMoreAction) String() string {
|
||||
return "more"
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ func (this *LexerModeAction) equals(other ILexerAction) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *LexerModeAction) toString() string {
|
||||
func (this *LexerModeAction) String() string {
|
||||
return "mode(" + strconv.Itoa(this.mode) + ")"
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ func (this *LexerChannelAction) equals(other ILexerAction) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *LexerChannelAction) toString() string {
|
||||
func (this *LexerChannelAction) String() string {
|
||||
return "channel(" + strconv.Itoa(this.channel) + ")"
|
||||
}
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ func (this *Parser) getRuleInvocationStack(p IParserRuleContext) []string {
|
|||
// For debugging and other purposes.//
|
||||
func (p *Parser) getDFAStrings() {
|
||||
panic("dumpDFA Not implemented!")
|
||||
// return p._interp.decisionToDFA.toString()
|
||||
// return p._interp.decisionToDFA.String()
|
||||
}
|
||||
|
||||
// For debugging and other purposes.//
|
||||
|
@ -669,7 +669,7 @@ func (p *Parser) dumpDFA() {
|
|||
// fmt.Println()
|
||||
// }
|
||||
// p.printer.println("Decision " + dfa.decision + ":")
|
||||
// p.printer.print(dfa.toString(p.LiteralNames, p.SymbolicNames))
|
||||
// p.printer.print(dfa.String(p.LiteralNames, p.SymbolicNames))
|
||||
// seenOne = true
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -47,17 +47,17 @@ func NewParserATNSimulator(parser IParser, atn *ATN, decisionToDFA []*DFA, share
|
|||
return this
|
||||
}
|
||||
|
||||
var ParserATNSimulatorprototypedebug = true
|
||||
var ParserATNSimulatorprototypedebug_list_atn_decisions = true
|
||||
var ParserATNSimulatorprototypedfa_debug = true
|
||||
var ParserATNSimulatorprototyperetry_debug = true
|
||||
var ParserATNSimulatorDebug = true
|
||||
var ParserATNSimulatorListATNDecisions = true
|
||||
var ParserATNSimulatorDFADebug = true
|
||||
var ParserATNSimulatorRetryDebug = true
|
||||
|
||||
func (this *ParserATNSimulator) reset() {
|
||||
}
|
||||
|
||||
func (this *ParserATNSimulator) AdaptivePredict(input TokenStream, decision int, outerContext IParserRuleContext) int {
|
||||
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedebug_list_atn_decisions {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorListATNDecisions {
|
||||
fmt.Println("AdaptivePredict decision " + strconv.Itoa(decision) +
|
||||
" exec LA(1)==" + this.getLookaheadName(input) +
|
||||
" line " + strconv.Itoa(input.LT(1).line) + ":" +
|
||||
|
@ -96,10 +96,10 @@ func (this *ParserATNSimulator) AdaptivePredict(input TokenStream, decision int,
|
|||
if outerContext == nil {
|
||||
outerContext = RuleContextEMPTY
|
||||
}
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedebug_list_atn_decisions {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorListATNDecisions {
|
||||
fmt.Println("predictATN decision " + strconv.Itoa(dfa.decision) +
|
||||
" exec LA(1)==" + this.getLookaheadName(input) +
|
||||
", outerContext=" + outerContext.toString(this.parser.GetRuleNames(), nil))
|
||||
", outerContext=" + outerContext.String(this.parser.GetRuleNames(), nil))
|
||||
}
|
||||
// If this is not a precedence DFA, we check the ATN start state
|
||||
// to determine if this ATN start state is the decision for the
|
||||
|
@ -132,8 +132,8 @@ func (this *ParserATNSimulator) AdaptivePredict(input TokenStream, decision int,
|
|||
}
|
||||
}
|
||||
var alt = this.execATN(dfa, s0, input, index, outerContext)
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("DFA after predictATN: " + dfa.toString(this.parser.GetLiteralNames(), nil))
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("DFA after predictATN: " + dfa.String(this.parser.GetLiteralNames(), nil))
|
||||
}
|
||||
return alt
|
||||
|
||||
|
@ -171,7 +171,7 @@ func (this *ParserATNSimulator) AdaptivePredict(input TokenStream, decision int,
|
|||
//
|
||||
func (this *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStream, startIndex int, outerContext IParserRuleContext) int {
|
||||
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedebug_list_atn_decisions {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorListATNDecisions {
|
||||
fmt.Println("execATN decision " + strconv.Itoa(dfa.decision) +
|
||||
" exec LA(1)==" + this.getLookaheadName(input) +
|
||||
" line " + strconv.Itoa(input.LT(1).line) + ":" + strconv.Itoa(input.LT(1).column))
|
||||
|
@ -179,8 +179,8 @@ func (this *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStrea
|
|||
|
||||
var previousD = s0
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("s0 = " + s0.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("s0 = " + s0.String())
|
||||
}
|
||||
var t = input.LA(1)
|
||||
for true { // for more work
|
||||
|
@ -211,7 +211,7 @@ func (this *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStrea
|
|||
// IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error)
|
||||
var conflictingAlts *BitSet = D.configs.conflictingAlts
|
||||
if D.predicates != nil {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("DFA state has preds in DFA sim LL failover")
|
||||
}
|
||||
var conflictIndex = input.Index()
|
||||
|
@ -220,7 +220,7 @@ func (this *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStrea
|
|||
}
|
||||
conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true)
|
||||
if conflictingAlts.length() == 1 {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("Full LL avoided")
|
||||
}
|
||||
return conflictingAlts.minValue()
|
||||
|
@ -231,8 +231,8 @@ func (this *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStrea
|
|||
input.Seek(conflictIndex)
|
||||
}
|
||||
}
|
||||
if ParserATNSimulatorprototypedfa_debug {
|
||||
fmt.Println("ctx sensitive state " + outerContext.toString(nil, nil) + " in " + D.toString())
|
||||
if ParserATNSimulatorDFADebug {
|
||||
fmt.Println("ctx sensitive state " + outerContext.String(nil, nil) + " in " + D.String())
|
||||
}
|
||||
var fullCtx = true
|
||||
var s0_closure = this.computeStartState(dfa.atnStartState, outerContext, fullCtx)
|
||||
|
@ -310,15 +310,15 @@ func (this *ParserATNSimulator) computeTargetState(dfa *DFA, previousD *DFAState
|
|||
|
||||
var predictedAlt = this.getUniqueAlt(reach)
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
var altSubSets = PredictionModegetConflictingAltSubsets(reach)
|
||||
fmt.Println("SLL altSubSets=" + fmt.Sprint(altSubSets) +
|
||||
", previous=" + previousD.configs.toString() +
|
||||
", configs=" + reach.toString() +
|
||||
", previous=" + previousD.configs.String() +
|
||||
", configs=" + reach.String() +
|
||||
", predict=" + strconv.Itoa(predictedAlt) +
|
||||
", allSubsetsConflict=" +
|
||||
fmt.Sprint(PredictionModeallSubsetsConflict(altSubSets)) +
|
||||
", conflictingAlts=" + this.getConflictingAlts(reach).toString())
|
||||
", conflictingAlts=" + this.getConflictingAlts(reach).String())
|
||||
}
|
||||
if predictedAlt != ATNINVALID_ALT_NUMBER {
|
||||
// NO CONFLICT, UNIQUELY PREDICTED ALT
|
||||
|
@ -366,8 +366,8 @@ func (this *ParserATNSimulator) predicateDFAState(dfaState *DFAState, decisionSt
|
|||
// comes back with reach.uniqueAlt set to a valid alt
|
||||
func (this *ParserATNSimulator) execATNWithFullContext(dfa *DFA, D *DFAState, s0 *ATNConfigSet, input TokenStream, startIndex int, outerContext IParserRuleContext) int {
|
||||
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedebug_list_atn_decisions {
|
||||
fmt.Println("execATNWithFullContext " + s0.toString())
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorListATNDecisions {
|
||||
fmt.Println("execATNWithFullContext " + s0.String())
|
||||
}
|
||||
|
||||
var fullCtx = true
|
||||
|
@ -400,7 +400,7 @@ func (this *ParserATNSimulator) execATNWithFullContext(dfa *DFA, D *DFAState, s0
|
|||
}
|
||||
}
|
||||
var altSubSets = PredictionModegetConflictingAltSubsets(reach)
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("LL altSubSets=" + fmt.Sprint(altSubSets) + ", predict=" +
|
||||
strconv.Itoa(PredictionModegetUniqueAlt(altSubSets)) + ", resolvesToJustOneViableAlt=" +
|
||||
fmt.Sprint(PredictionModeresolvesToJustOneViableAlt(altSubSets)))
|
||||
|
@ -473,8 +473,8 @@ func (this *ParserATNSimulator) execATNWithFullContext(dfa *DFA, D *DFAState, s0
|
|||
}
|
||||
|
||||
func (this *ParserATNSimulator) computeReachSet(closure *ATNConfigSet, t int, fullCtx bool) *ATNConfigSet {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("in computeReachSet, starting closure: " + closure.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("in computeReachSet, starting closure: " + closure.String())
|
||||
}
|
||||
if this.mergeCache == nil {
|
||||
this.mergeCache = NewDoubleDict()
|
||||
|
@ -497,8 +497,8 @@ func (this *ParserATNSimulator) computeReachSet(closure *ATNConfigSet, t int, fu
|
|||
for i := 0; i < len(closure.configs); i++ {
|
||||
|
||||
var c = closure.configs[i]
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("testing " + this.GetTokenName(t) + " at " + c.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("testing " + this.GetTokenName(t) + " at " + c.String())
|
||||
}
|
||||
|
||||
_, ok := c.GetState().(*RuleStopState)
|
||||
|
@ -509,8 +509,8 @@ func (this *ParserATNSimulator) computeReachSet(closure *ATNConfigSet, t int, fu
|
|||
skippedStopStates = make([]*ATNConfig, 0)
|
||||
}
|
||||
skippedStopStates = append(skippedStopStates, c.(*ATNConfig))
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("added " + c.toString() + " to skippedStopStates")
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("added " + c.String() + " to skippedStopStates")
|
||||
}
|
||||
}
|
||||
continue
|
||||
|
@ -522,8 +522,8 @@ func (this *ParserATNSimulator) computeReachSet(closure *ATNConfigSet, t int, fu
|
|||
if target != nil {
|
||||
var cfg = NewATNConfig4(c, target)
|
||||
intermediate.add(cfg, this.mergeCache)
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("added " + cfg.toString() + " to intermediate")
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("added " + cfg.String() + " to intermediate")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ func (this *ParserATNSimulator) getPredsForAmbigAlts(ambigAlts *BitSet, configs
|
|||
if nPredAlts == 0 {
|
||||
altToPred = nil
|
||||
}
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("getPredsForAmbigAlts result " + fmt.Sprint(altToPred))
|
||||
}
|
||||
return altToPred
|
||||
|
@ -950,11 +950,11 @@ func (this *ParserATNSimulator) evalSemanticContext(predPredictions []*PredPredi
|
|||
continue
|
||||
}
|
||||
var predicateEvaluationResult = pair.pred.evaluate(this.parser, outerContext)
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedfa_debug {
|
||||
fmt.Println("eval pred " + pair.toString() + "=" + fmt.Sprint(predicateEvaluationResult))
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorDFADebug {
|
||||
fmt.Println("eval pred " + pair.String() + "=" + fmt.Sprint(predicateEvaluationResult))
|
||||
}
|
||||
if predicateEvaluationResult {
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototypedfa_debug {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorDFADebug {
|
||||
fmt.Println("PREDICT " + fmt.Sprint(pair.alt))
|
||||
}
|
||||
predictions.add(pair.alt)
|
||||
|
@ -981,9 +981,9 @@ func (this *ParserATNSimulator) closure(config IATNConfig, configs *ATNConfigSet
|
|||
|
||||
func (this *ParserATNSimulator) closureCheckingStopState(config IATNConfig, configs *ATNConfigSet, closureBusy *Set, collectPredicates, fullCtx bool, depth int, treatEofAsEpsilon bool) {
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("closure(" + config.toString() + ")") //config.toString(this.parser,true) + ")")
|
||||
fmt.Println("configs(" + configs.toString() + ")")
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("closure(" + config.String() + ")") //config.String(this.parser,true) + ")")
|
||||
fmt.Println("configs(" + configs.String() + ")")
|
||||
if config.GetReachesIntoOuterContext() > 50 {
|
||||
panic("problem")
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ func (this *ParserATNSimulator) closureCheckingStopState(config IATNConfig, conf
|
|||
continue
|
||||
} else {
|
||||
// we have no context info, just chase follow links (if greedy)
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("FALLING off rule " + this.getRuleName(config.GetState().GetRuleIndex()))
|
||||
}
|
||||
this.closure_(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon)
|
||||
|
@ -1025,7 +1025,7 @@ func (this *ParserATNSimulator) closureCheckingStopState(config IATNConfig, conf
|
|||
return
|
||||
} else {
|
||||
// else if we have no context info, just chase follow links (if greedy)
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("FALLING off rule " + this.getRuleName(config.GetState().GetRuleIndex()))
|
||||
}
|
||||
}
|
||||
|
@ -1053,8 +1053,8 @@ func (this *ParserATNSimulator) closure_(config IATNConfig, configs *ATNConfigSe
|
|||
continue
|
||||
}
|
||||
var newDepth = depth
|
||||
t2, ok := t.(*EpsilonTransition)
|
||||
if ok {
|
||||
|
||||
if _, ok := config.GetState().(*RuleStopState); ok {
|
||||
// target fell off end of rule mark resulting c as having dipped into outer context
|
||||
// We can't get here if incoming config was rule stop and we had context
|
||||
// track how far we dip into outer context. Might
|
||||
|
@ -1067,7 +1067,7 @@ func (this *ParserATNSimulator) closure_(config IATNConfig, configs *ATNConfigSe
|
|||
}
|
||||
|
||||
if this._dfa != nil && this._dfa.precedenceDfa {
|
||||
if t2.outermostPrecedenceReturn == this._dfa.atnStartState.GetRuleIndex() {
|
||||
if t.(*EpsilonTransition).outermostPrecedenceReturn == this._dfa.atnStartState.GetRuleIndex() {
|
||||
c.precedenceFilterSuppressed = true
|
||||
}
|
||||
}
|
||||
|
@ -1075,8 +1075,8 @@ func (this *ParserATNSimulator) closure_(config IATNConfig, configs *ATNConfigSe
|
|||
c.SetReachesIntoOuterContext(c.GetReachesIntoOuterContext() + 1)
|
||||
configs.dipsIntoOuterContext = true // TODO: can remove? only care when we add to set per middle of this method
|
||||
newDepth -= 1
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("dips into outer ctx: " + c.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("dips into outer ctx: " + c.String())
|
||||
}
|
||||
} else if _, ok := t.(*RuleTransition); ok {
|
||||
// latch when newDepth goes negative - once we step out of the entry context we can't return
|
||||
|
@ -1143,7 +1143,7 @@ func (this *ParserATNSimulator) getEpsilonTarget(config IATNConfig, t ITransitio
|
|||
}
|
||||
|
||||
func (this *ParserATNSimulator) actionTransition(config IATNConfig, t *ActionTransition) *ATNConfig {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("ACTION edge " + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.actionIndex))
|
||||
}
|
||||
return NewATNConfig4(config, t.getTarget())
|
||||
|
@ -1152,7 +1152,7 @@ func (this *ParserATNSimulator) actionTransition(config IATNConfig, t *ActionTra
|
|||
func (this *ParserATNSimulator) precedenceTransition(config IATNConfig,
|
||||
pt *PrecedencePredicateTransition, collectPredicates, inContext, fullCtx bool) *ATNConfig {
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("PRED (collectPredicates=" + fmt.Sprint(collectPredicates) + ") " +
|
||||
strconv.Itoa(pt.precedence) + ">=_p, ctx dependent=true")
|
||||
if this.parser != nil {
|
||||
|
@ -1180,15 +1180,15 @@ func (this *ParserATNSimulator) precedenceTransition(config IATNConfig,
|
|||
} else {
|
||||
c = NewATNConfig4(config, pt.getTarget())
|
||||
}
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("config from pred transition=" + c.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("config from pred transition=" + c.String())
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (this *ParserATNSimulator) predTransition(config IATNConfig, pt *PredicateTransition, collectPredicates, inContext, fullCtx bool) *ATNConfig {
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("PRED (collectPredicates=" + fmt.Sprint(collectPredicates) + ") " + strconv.Itoa(pt.ruleIndex) +
|
||||
":" + strconv.Itoa(pt.predIndex) + ", ctx dependent=" + fmt.Sprint(pt.isCtxDependent))
|
||||
if this.parser != nil {
|
||||
|
@ -1216,15 +1216,15 @@ func (this *ParserATNSimulator) predTransition(config IATNConfig, pt *PredicateT
|
|||
} else {
|
||||
c = NewATNConfig4(config, pt.getTarget())
|
||||
}
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("config from pred transition=" + c.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("config from pred transition=" + c.String())
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (this *ParserATNSimulator) ruleTransition(config IATNConfig, t *RuleTransition) *ATNConfig {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("CALL rule " + this.getRuleName(t.getTarget().GetRuleIndex()) + ", ctx=" + config.GetContext().toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("CALL rule " + this.getRuleName(t.getTarget().GetRuleIndex()) + ", ctx=" + config.GetContext().String())
|
||||
}
|
||||
var returnState = t.followState
|
||||
var newContext = SingletonPredictionContextCreate(config.GetContext(), returnState.GetStateNumber())
|
||||
|
@ -1333,7 +1333,7 @@ func (this *ParserATNSimulator) dumpDeadEndConfigs(nvae *NoViableAltException) {
|
|||
// trans = s + "Set " + t3.set
|
||||
// }
|
||||
// }
|
||||
// fmt.Errorf(c.toString(this.parser, true) + ":" + trans)
|
||||
// fmt.Errorf(c.String(this.parser, true) + ":" + trans)
|
||||
// }
|
||||
}
|
||||
|
||||
|
@ -1375,8 +1375,8 @@ func (this *ParserATNSimulator) getUniqueAlt(configs *ATNConfigSet) int {
|
|||
// on {@code to}
|
||||
//
|
||||
func (this *ParserATNSimulator) addDFAEdge(dfa *DFA, from_ *DFAState, t int, to *DFAState) *DFAState {
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("EDGE " + from_.toString() + " -> " + to.toString() + " upon " + this.GetTokenName(t))
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("EDGE " + from_.String() + " -> " + to.String() + " upon " + this.GetTokenName(t))
|
||||
}
|
||||
if to == nil {
|
||||
return nil
|
||||
|
@ -1390,13 +1390,13 @@ func (this *ParserATNSimulator) addDFAEdge(dfa *DFA, from_ *DFAState, t int, to
|
|||
}
|
||||
from_.edges[t+1] = to // connect
|
||||
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
if ParserATNSimulatorDebug {
|
||||
var names []string
|
||||
if this.parser != nil {
|
||||
names = this.parser.GetLiteralNames()
|
||||
}
|
||||
|
||||
fmt.Println("DFA=\n" + dfa.toString(names, nil))
|
||||
fmt.Println("DFA=\n" + dfa.String(names, nil))
|
||||
}
|
||||
return to
|
||||
}
|
||||
|
@ -1431,16 +1431,16 @@ func (this *ParserATNSimulator) addDFAState(dfa *DFA, D *DFAState) *DFAState {
|
|||
D.configs.setReadonly(true)
|
||||
}
|
||||
dfa.GetStates()[hash] = D
|
||||
if ParserATNSimulatorprototypedebug {
|
||||
fmt.Println("adding NewDFA state: " + D.toString())
|
||||
if ParserATNSimulatorDebug {
|
||||
fmt.Println("adding NewDFA state: " + D.String())
|
||||
}
|
||||
return D
|
||||
}
|
||||
|
||||
func (this *ParserATNSimulator) ReportAttemptingFullContext(dfa *DFA, conflictingAlts *BitSet, configs *ATNConfigSet, startIndex, stopIndex int) {
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototyperetry_debug {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorRetryDebug {
|
||||
var interval = NewInterval(startIndex, stopIndex+1)
|
||||
fmt.Println("ReportAttemptingFullContext decision=" + strconv.Itoa(dfa.decision) + ":" + configs.toString() +
|
||||
fmt.Println("ReportAttemptingFullContext decision=" + strconv.Itoa(dfa.decision) + ":" + configs.String() +
|
||||
", input=" + this.parser.GetTokenStream().GetTextFromInterval(interval))
|
||||
}
|
||||
if this.parser != nil {
|
||||
|
@ -1449,9 +1449,9 @@ func (this *ParserATNSimulator) ReportAttemptingFullContext(dfa *DFA, conflictin
|
|||
}
|
||||
|
||||
func (this *ParserATNSimulator) ReportContextSensitivity(dfa *DFA, prediction int, configs *ATNConfigSet, startIndex, stopIndex int) {
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototyperetry_debug {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorRetryDebug {
|
||||
var interval = NewInterval(startIndex, stopIndex+1)
|
||||
fmt.Println("ReportContextSensitivity decision=" + strconv.Itoa(dfa.decision) + ":" + configs.toString() +
|
||||
fmt.Println("ReportContextSensitivity decision=" + strconv.Itoa(dfa.decision) + ":" + configs.String() +
|
||||
", input=" + this.parser.GetTokenStream().GetTextFromInterval(interval))
|
||||
}
|
||||
if this.parser != nil {
|
||||
|
@ -1462,9 +1462,9 @@ func (this *ParserATNSimulator) ReportContextSensitivity(dfa *DFA, prediction in
|
|||
// If context sensitive parsing, we know it's ambiguity not conflict//
|
||||
func (this *ParserATNSimulator) ReportAmbiguity(dfa *DFA, D *DFAState, startIndex, stopIndex int,
|
||||
exact bool, ambigAlts *BitSet, configs *ATNConfigSet) {
|
||||
if ParserATNSimulatorprototypedebug || ParserATNSimulatorprototyperetry_debug {
|
||||
if ParserATNSimulatorDebug || ParserATNSimulatorRetryDebug {
|
||||
var interval = NewInterval(startIndex, stopIndex+1)
|
||||
fmt.Println("ReportAmbiguity " + ambigAlts.toString() + ":" + configs.toString() +
|
||||
fmt.Println("ReportAmbiguity " + ambigAlts.String() + ":" + configs.String() +
|
||||
", input=" + this.parser.GetTokenStream().GetTextFromInterval(interval))
|
||||
}
|
||||
if this.parser != nil {
|
||||
|
|
|
@ -13,7 +13,7 @@ type IPredictionContext interface {
|
|||
length() int
|
||||
isEmpty() bool
|
||||
hasEmptyPath() bool
|
||||
toString() string
|
||||
String() string
|
||||
}
|
||||
|
||||
type PredictionContext struct {
|
||||
|
@ -81,14 +81,14 @@ func (this *PredictionContext) hashString() string {
|
|||
}
|
||||
|
||||
func calculateHashString(parent IPredictionContext, returnState int) string {
|
||||
return parent.toString() + strconv.Itoa(returnState)
|
||||
return parent.String() + strconv.Itoa(returnState)
|
||||
}
|
||||
|
||||
func calculateEmptyHashString() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *PredictionContext) toString() string {
|
||||
func (this *PredictionContext) String() string {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
|
@ -216,13 +216,13 @@ func (this *SingletonPredictionContext) hashString() string {
|
|||
return this.cachedHashString
|
||||
}
|
||||
|
||||
func (this *SingletonPredictionContext) toString() string {
|
||||
func (this *SingletonPredictionContext) String() string {
|
||||
var up string
|
||||
|
||||
if this.parentCtx == nil {
|
||||
up = ""
|
||||
} else {
|
||||
up = this.parentCtx.toString()
|
||||
up = this.parentCtx.String()
|
||||
}
|
||||
|
||||
if len(up) == 0 {
|
||||
|
@ -267,7 +267,7 @@ func (this *EmptyPredictionContext) equals(other IPredictionContext) bool {
|
|||
return this == other
|
||||
}
|
||||
|
||||
func (this *EmptyPredictionContext) toString() string {
|
||||
func (this *EmptyPredictionContext) String() string {
|
||||
return "$"
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ func (this *ArrayPredictionContext) equals(other IPredictionContext) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *ArrayPredictionContext) toString() string {
|
||||
func (this *ArrayPredictionContext) String() string {
|
||||
if this.isEmpty() {
|
||||
return "[]"
|
||||
} else {
|
||||
|
@ -347,7 +347,7 @@ func (this *ArrayPredictionContext) toString() string {
|
|||
}
|
||||
s = s + strconv.Itoa(this.returnStates[i])
|
||||
if this.parents[i] != nil {
|
||||
s = s + " " + this.parents[i].toString()
|
||||
s = s + " " + this.parents[i].String()
|
||||
} else {
|
||||
s = s + "nil"
|
||||
}
|
||||
|
|
|
@ -495,7 +495,7 @@ func PredictionModegetConflictingAltSubsets(configs *ATNConfigSet) []*BitSet {
|
|||
|
||||
for i := 0; i < len(configs.configs); i++ {
|
||||
var c = configs.configs[i]
|
||||
var key = "key_" + strconv.Itoa(c.GetState().GetStateNumber()) + "/" + c.GetContext().toString()
|
||||
var key = "key_" + strconv.Itoa(c.GetState().GetStateNumber()) + "/" + c.GetContext().String()
|
||||
var alts = configToAlts[key]
|
||||
if alts == nil {
|
||||
alts = NewBitSet()
|
||||
|
@ -527,10 +527,10 @@ func PredictionModeGetStateToAltMap(configs *ATNConfigSet) *AltDict {
|
|||
var m = NewAltDict()
|
||||
|
||||
for _, c := range configs.configs {
|
||||
var alts = m.Get(c.GetState().toString())
|
||||
var alts = m.Get(c.GetState().String())
|
||||
if alts == nil {
|
||||
alts = NewBitSet()
|
||||
m.put(c.GetState().toString(), alts)
|
||||
m.put(c.GetState().String(), alts)
|
||||
}
|
||||
alts.(*BitSet).add(c.GetAlt())
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func (this *Recognizer) getErrorHeader(e IRecognitionException) string {
|
|||
// How should a token be displayed in an error message? The default
|
||||
// is to display just the text, but during development you might
|
||||
// want to have a lot of information spit out. Override in that case
|
||||
// to use t.toString() (which, for CommonToken, dumps everything about
|
||||
// to use t.String() (which, for CommonToken, dumps everything about
|
||||
// the token). This is better than forcing you to override a method in
|
||||
// your token objects because you don't have to go modify your lexer
|
||||
// so that it creates a NewJava type.
|
||||
|
|
|
@ -35,7 +35,7 @@ type IRuleContext interface {
|
|||
|
||||
isEmpty() bool
|
||||
|
||||
toString([]string, IRuleContext) string
|
||||
String([]string, IRuleContext) string
|
||||
}
|
||||
|
||||
type RuleContext struct {
|
||||
|
@ -160,11 +160,11 @@ func (this *RuleContext) accept(Visitor ParseTreeVisitor) interface{} {
|
|||
// (root child1 .. childN). Print just a node if this is a leaf.
|
||||
//
|
||||
|
||||
func (this *RuleContext) toStringTree(ruleNames []string, recog IRecognizer) string {
|
||||
return TreestoStringTree(this, ruleNames, recog)
|
||||
func (this *RuleContext) StringTree(ruleNames []string, recog IRecognizer) string {
|
||||
return TreesStringTree(this, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (this *RuleContext) toString(ruleNames []string, stop IRuleContext) string {
|
||||
func (this *RuleContext) String(ruleNames []string, stop IRuleContext) string {
|
||||
|
||||
var p IRuleContext = this
|
||||
var s = "["
|
||||
|
|
|
@ -17,7 +17,7 @@ type SemanticContext interface {
|
|||
evaluate(parser IRecognizer, outerContext IRuleContext) bool
|
||||
evalPrecedence(parser IRecognizer, outerContext IRuleContext) SemanticContext
|
||||
equals(interface{}) bool
|
||||
toString() string
|
||||
String() string
|
||||
}
|
||||
|
||||
func SemanticContextandContext(a, b SemanticContext) SemanticContext {
|
||||
|
@ -104,7 +104,7 @@ func (this *Predicate) equals(other interface{}) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *Predicate) toString() string {
|
||||
func (this *Predicate) String() string {
|
||||
return "{" + strconv.Itoa(this.ruleIndex) + ":" + strconv.Itoa(this.predIndex) + "}?"
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ func (this *PrecedencePredicate) equals(other interface{}) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *PrecedencePredicate) toString() string {
|
||||
func (this *PrecedencePredicate) String() string {
|
||||
return "{" + strconv.Itoa(this.precedence) + ">=prec}?"
|
||||
}
|
||||
|
||||
|
@ -290,11 +290,11 @@ func (this *AND) evalPrecedence(parser IRecognizer, outerContext IRuleContext) S
|
|||
return result
|
||||
}
|
||||
|
||||
func (this *AND) toString() string {
|
||||
func (this *AND) String() string {
|
||||
var s = ""
|
||||
|
||||
for _, o := range this.opnds {
|
||||
s += "&& " + o.toString()
|
||||
s += "&& " + o.String()
|
||||
}
|
||||
|
||||
if len(s) > 3 {
|
||||
|
@ -423,11 +423,11 @@ func (this *OR) evalPrecedence(parser IRecognizer, outerContext IRuleContext) Se
|
|||
return result
|
||||
}
|
||||
|
||||
func (this *OR) toString() string {
|
||||
func (this *OR) String() string {
|
||||
var s = ""
|
||||
|
||||
for _, o := range this.opnds {
|
||||
s += "|| " + o.toString()
|
||||
s += "|| " + o.String()
|
||||
}
|
||||
|
||||
if len(s) > 3 {
|
||||
|
|
|
@ -152,7 +152,7 @@ func (this *CommonToken) setText(text string) {
|
|||
this._text = text
|
||||
}
|
||||
|
||||
func (this *CommonToken) toString() string {
|
||||
func (this *CommonToken) String() string {
|
||||
var txt = this.text()
|
||||
if txt != "" {
|
||||
txt = strings.Replace(txt, "\n", "", -1)
|
||||
|
|
|
@ -150,7 +150,7 @@ func (t *AtomTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) boo
|
|||
return t.label_ == symbol
|
||||
}
|
||||
|
||||
func (t *AtomTransition) toString() string {
|
||||
func (t *AtomTransition) String() string {
|
||||
return strconv.Itoa(t.label_)
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ func (t *EpsilonTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int)
|
|||
return false
|
||||
}
|
||||
|
||||
func (t *EpsilonTransition) toString() string {
|
||||
func (t *EpsilonTransition) String() string {
|
||||
return "epsilon"
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ func (t *RangeTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) bo
|
|||
return symbol >= t.start && symbol <= t.stop
|
||||
}
|
||||
|
||||
func (t *RangeTransition) toString() string {
|
||||
func (t *RangeTransition) String() string {
|
||||
return "'" + string(t.start) + "'..'" + string(t.stop) + "'"
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ func (t *PredicateTransition) getPredicate() *Predicate {
|
|||
return NewPredicate(t.ruleIndex, t.predIndex, t.isCtxDependent)
|
||||
}
|
||||
|
||||
func (t *PredicateTransition) toString() string {
|
||||
func (t *PredicateTransition) String() string {
|
||||
return "pred_" + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.predIndex)
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ func (t *ActionTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) b
|
|||
return false
|
||||
}
|
||||
|
||||
func (t *ActionTransition) toString() string {
|
||||
func (t *ActionTransition) String() string {
|
||||
return "action_" + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.actionIndex)
|
||||
}
|
||||
|
||||
|
@ -333,8 +333,8 @@ func (t *SetTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) bool
|
|||
return t.label.contains(symbol)
|
||||
}
|
||||
|
||||
func (t *SetTransition) toString() string {
|
||||
return t.label.toString()
|
||||
func (t *SetTransition) String() string {
|
||||
return t.label.String()
|
||||
}
|
||||
|
||||
type NotSetTransition struct {
|
||||
|
@ -356,8 +356,8 @@ func (t *NotSetTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) b
|
|||
return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && !t.label.contains(symbol)
|
||||
}
|
||||
|
||||
func (t *NotSetTransition) toString() string {
|
||||
return "~" + t.label.toString()
|
||||
func (t *NotSetTransition) String() string {
|
||||
return "~" + t.label.String()
|
||||
}
|
||||
|
||||
type WildcardTransition struct {
|
||||
|
@ -377,7 +377,7 @@ func (t *WildcardTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int)
|
|||
return symbol >= minVocabSymbol && symbol <= maxVocabSymbol
|
||||
}
|
||||
|
||||
func (t *WildcardTransition) toString() string {
|
||||
func (t *WildcardTransition) String() string {
|
||||
return "."
|
||||
}
|
||||
|
||||
|
@ -407,6 +407,6 @@ func (t *PrecedencePredicateTransition) getPredicate() *PrecedencePredicate {
|
|||
return NewPrecedencePredicate(t.precedence)
|
||||
}
|
||||
|
||||
func (t *PrecedencePredicateTransition) toString() string {
|
||||
func (t *PrecedencePredicateTransition) String() string {
|
||||
return fmt.Sprint(t.precedence) + " >= _p"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type Tree interface {
|
|||
getChildCount() int
|
||||
getChildren() []Tree
|
||||
setChildren([]Tree)
|
||||
// toStringTree() string
|
||||
// StringTree() string
|
||||
}
|
||||
|
||||
type SyntaxTree interface {
|
||||
|
@ -29,7 +29,7 @@ type ParseTree interface {
|
|||
// <T> T accept(ParseTreeVisitor<? extends T> Visitor);
|
||||
accept(Visitor ParseTreeVisitor) interface{}
|
||||
GetText() string
|
||||
// toStringTree([]string, IRecognizer) string
|
||||
// StringTree([]string, IRecognizer) string
|
||||
}
|
||||
|
||||
type RuleNode interface {
|
||||
|
@ -148,7 +148,7 @@ func (this *TerminalNodeImpl) GetText() string {
|
|||
return this.symbol.text()
|
||||
}
|
||||
|
||||
func (this *TerminalNodeImpl) toString() string {
|
||||
func (this *TerminalNodeImpl) String() string {
|
||||
if this.symbol.tokenType == TokenEOF {
|
||||
return "<EOF>"
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ import "fmt"
|
|||
// Print out a whole tree in LISP form. {@link //getNodeText} is used on the
|
||||
// node payloads to get the text for the nodes. Detect
|
||||
// parse trees and extract data appropriately.
|
||||
func TreestoStringTree(tree Tree, ruleNames []string, recog IRecognizer) string {
|
||||
func TreesStringTree(tree Tree, ruleNames []string, recog IRecognizer) string {
|
||||
|
||||
if recog != nil {
|
||||
ruleNames = recog.GetRuleNames()
|
||||
|
@ -22,11 +22,11 @@ func TreestoStringTree(tree Tree, ruleNames []string, recog IRecognizer) string
|
|||
}
|
||||
var res = "(" + s + " "
|
||||
if c > 0 {
|
||||
s = TreestoStringTree(tree.getChild(0), ruleNames, nil)
|
||||
s = TreesStringTree(tree.getChild(0), ruleNames, nil)
|
||||
res += s
|
||||
}
|
||||
for i := 1; i < c; i++ {
|
||||
s = TreestoStringTree(tree.getChild(i), ruleNames, nil)
|
||||
s = TreesStringTree(tree.getChild(i), ruleNames, nil)
|
||||
res += (" " + s)
|
||||
}
|
||||
res += ")"
|
||||
|
|
|
@ -44,7 +44,7 @@ func (s *IntStack) Push(e int) {
|
|||
*s = append(*s, e)
|
||||
}
|
||||
|
||||
func arrayToString(a []interface{}) string {
|
||||
func arrayString(a []interface{}) string {
|
||||
return fmt.Sprint(a)
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ func (this *Set) values() []interface{} {
|
|||
return l
|
||||
}
|
||||
|
||||
func (this *Set) toString() string {
|
||||
func (this *Set) String() string {
|
||||
return fmt.Sprint(this.data)
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ func (this *BitSet) length() int {
|
|||
return len(this.data)
|
||||
}
|
||||
|
||||
func (this *BitSet) toString() string {
|
||||
func (this *BitSet) String() string {
|
||||
return fmt.Sprint(this.data)
|
||||
}
|
||||
|
||||
|
|
|
@ -980,10 +980,6 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
|
||||
/* parrt internal source braindump that doesn't mess up
|
||||
* external API spec.
|
||||
|
||||
applyPrecedenceFilter is an optimization to avoid highly
|
||||
nonlinear prediction of expressions and other left recursive
|
||||
rules. The precedence predicates such as {3>=prec}? Are highly
|
||||
context-sensitive in that they can only be properly evaluated
|
||||
in the context of the proper prec argument. Without pruning,
|
||||
these predicates are normal predicates evaluated when we reach
|
||||
|
|
|
@ -318,6 +318,7 @@ ParserATNSimulator.prototype.debug_list_atn_decisions = true;
|
|||
ParserATNSimulator.prototype.dfa_debug = true;
|
||||
ParserATNSimulator.prototype.retry_debug = true;
|
||||
|
||||
|
||||
ParserATNSimulator.prototype.reset = function() {
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue