forked from jasder/antlr
Format
This commit is contained in:
parent
baaf1fe72f
commit
21fa2d1310
|
@ -172,7 +172,7 @@ func (this *BaseATNConfig) equals(o interface{}) bool {
|
|||
this.alt == other.alt &&
|
||||
this.semanticContext.equals(other.semanticContext) &&
|
||||
this.precedenceFilterSuppressed == other.precedenceFilterSuppressed &&
|
||||
b;
|
||||
b
|
||||
}
|
||||
|
||||
func (this *BaseATNConfig) shortHash() string {
|
||||
|
|
|
@ -71,7 +71,7 @@ func (this *DFA) setPrecedenceStartState(precedence int, startState *DFAState) {
|
|||
// s0.edges is never nil for a precedence DFA
|
||||
|
||||
// s0.edges is never null for a precedence DFA
|
||||
if (precedence >= len(this.s0.edges)) {
|
||||
if precedence >= len(this.s0.edges) {
|
||||
// enlarge the slice
|
||||
this.s0.edges = append(this.s0.edges, make([]*DFAState, precedence+1-len(this.s0.edges))...)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package antlr
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Provides an empty default implementation of {@link ANTLRErrorListener}. The
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package antlr
|
||||
|
||||
import ()
|
||||
|
||||
// The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
|
||||
// 3 kinds of errors: prediction errors, failed predicate errors, and
|
||||
// misMatched input errors. In each case, the parser knows where it is
|
||||
|
|
|
@ -94,11 +94,11 @@ func (is *InputStream) GetText(start int, stop int) string {
|
|||
}
|
||||
|
||||
func (is *InputStream) GetTextFromTokens(start, stop Token) string {
|
||||
if ( start!=nil && stop !=nil ) {
|
||||
return is.GetTextFromInterval(NewInterval(start.GetTokenIndex(), stop.GetTokenIndex()));
|
||||
if start != nil && stop != nil {
|
||||
return is.GetTextFromInterval(NewInterval(start.GetTokenIndex(), stop.GetTokenIndex()))
|
||||
}
|
||||
|
||||
return "";
|
||||
return ""
|
||||
}
|
||||
|
||||
func (is *InputStream) GetTextFromInterval(i *Interval) string {
|
||||
|
|
|
@ -41,7 +41,6 @@ type BaseLexer struct {
|
|||
_modeStack IntStack
|
||||
_mode int
|
||||
_text string
|
||||
|
||||
}
|
||||
|
||||
func NewBaseLexer(input CharStream) *BaseLexer {
|
||||
|
|
|
@ -698,8 +698,8 @@ func (p *BaseParser) GetDFAStrings() string {
|
|||
func (p *BaseParser) DumpDFA() {
|
||||
var seenOne = false
|
||||
for _, dfa := range p.Interpreter.DecisionToDFA {
|
||||
if ( len(dfa.GetStates()) > 0) {
|
||||
if (seenOne) {
|
||||
if len(dfa.GetStates()) > 0 {
|
||||
if seenOne {
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println("Decision " + strconv.Itoa(dfa.decision) + ":")
|
||||
|
|
|
@ -238,7 +238,7 @@ func (prc *BaseParserRuleContext) GetPayload() interface{}{
|
|||
}
|
||||
|
||||
func (prc *BaseParserRuleContext) getChild(ctxType reflect.Type, i int) RuleContext {
|
||||
if ( prc.children==nil || i < 0 || i >= len(prc.children) ) {
|
||||
if prc.children == nil || i < 0 || i >= len(prc.children) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -247,15 +247,16 @@ func (prc *BaseParserRuleContext) getChild(ctxType reflect.Type, i int) RuleCont
|
|||
|
||||
childType := reflect.TypeOf(o)
|
||||
|
||||
if ( childType.Implements(ctxType) ) {
|
||||
if childType.Implements(ctxType) {
|
||||
j++
|
||||
if ( j == i ) {
|
||||
if j == i {
|
||||
return o.(RuleContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Go lacks generics, so it's not possible for us to return the child with the correct type, but we do
|
||||
// check for convertibility
|
||||
|
||||
|
@ -335,11 +336,8 @@ func (this *BaseParserRuleContext) String(ruleNames []string, stop RuleContext)
|
|||
return s
|
||||
}
|
||||
|
||||
|
||||
var RuleContextEmpty = NewBaseParserRuleContext(nil, -1)
|
||||
|
||||
|
||||
|
||||
type InterpreterRuleContext interface {
|
||||
ParserRuleContext
|
||||
}
|
||||
|
|
|
@ -34,11 +34,9 @@ type RuleContext interface {
|
|||
}
|
||||
|
||||
type BaseRuleContext struct {
|
||||
|
||||
parentCtx RuleContext
|
||||
invokingState int
|
||||
RuleIndex int
|
||||
|
||||
}
|
||||
|
||||
func NewBaseRuleContext(parent RuleContext, invokingState int) *BaseRuleContext {
|
||||
|
|
|
@ -90,6 +90,7 @@ type ParseTreeListener interface {
|
|||
}
|
||||
|
||||
type BaseParseTreeListener struct{}
|
||||
|
||||
func (l *BaseParseTreeListener) VisitTerminal(node TerminalNode) {}
|
||||
func (l *BaseParseTreeListener) VisitErrorNode(node ErrorNode) {}
|
||||
func (l *BaseParseTreeListener) EnterEveryRule(ctx ParserRuleContext) {}
|
||||
|
|
|
@ -114,7 +114,6 @@ func hashCode(s string) string {
|
|||
return fmt.Sprint(h.Sum32())
|
||||
}
|
||||
|
||||
|
||||
func (this *Set) length() int {
|
||||
return len(this.data)
|
||||
}
|
||||
|
@ -267,7 +266,7 @@ func (this *BitSet) String() string {
|
|||
for i, val := range vals {
|
||||
valsS[i] = strconv.Itoa(val)
|
||||
}
|
||||
return "{" + strings.Join(valsS, ", ") + "}";
|
||||
return "{" + strings.Join(valsS, ", ") + "}"
|
||||
}
|
||||
|
||||
type AltDict struct {
|
||||
|
|
Loading…
Reference in New Issue