forked from jasder/antlr
Generate several properties in place of methods
This commit is contained in:
parent
8007bf4012
commit
8ab7c20411
|
@ -88,9 +88,12 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetSourceName()
|
||||
public override string SourceName
|
||||
{
|
||||
return fileName;
|
||||
get
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,14 +233,20 @@ namespace Antlr4.Runtime
|
|||
/// last symbol has been read. The index is the index of char to
|
||||
/// be returned from LA(1).
|
||||
/// </remarks>
|
||||
public virtual int Index()
|
||||
public virtual int Index
|
||||
{
|
||||
return p;
|
||||
get
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Size()
|
||||
public virtual int Size
|
||||
{
|
||||
return n;
|
||||
get
|
||||
{
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>mark/release do nothing; we have entire buffer</summary>
|
||||
|
@ -295,9 +301,12 @@ namespace Antlr4.Runtime
|
|||
return new string(data, start, count);
|
||||
}
|
||||
|
||||
public virtual string GetSourceName()
|
||||
public virtual string SourceName
|
||||
{
|
||||
return name;
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -305,17 +305,17 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (left.Size() < right.Size())
|
||||
if (left.Size < right.Size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (right.IsEmpty())
|
||||
if (right.IsEmpty)
|
||||
{
|
||||
return left.HasEmpty();
|
||||
return left.HasEmpty;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < right.Size(); i++)
|
||||
for (int i = 0; i < right.Size; i++)
|
||||
{
|
||||
int index = left.FindReturnState(right.GetReturnState(i));
|
||||
if (index < 0)
|
||||
|
@ -394,7 +394,7 @@ namespace Antlr4.Runtime.Atn
|
|||
while (!workList.IsEmpty())
|
||||
{
|
||||
PredictionContext current = workList.Pop();
|
||||
for (int i = 0; i < current.Size(); i++)
|
||||
for (int i = 0; i < current.Size; i++)
|
||||
{
|
||||
builder.Append(" s").Append(Sharpen.Runtime.IdentityHashCode(current));
|
||||
builder.Append("->");
|
||||
|
|
|
@ -444,7 +444,7 @@ namespace Antlr4.Runtime.Atn
|
|||
RuleStartState startState = atn.ruleToStartState[i];
|
||||
ATNState middleState = startState;
|
||||
while (middleState.OnlyHasEpsilonTransitions() && middleState.GetNumberOfOptimizedTransitions
|
||||
() == 1 && middleState.GetOptimizedTransition(0).GetSerializationType() == Transition
|
||||
() == 1 && middleState.GetOptimizedTransition(0).SerializationType == Transition
|
||||
.Epsilon)
|
||||
{
|
||||
middleState = middleState.GetOptimizedTransition(0).target;
|
||||
|
@ -455,13 +455,13 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
Transition matchTransition = middleState.GetOptimizedTransition(0);
|
||||
ATNState matchTarget = matchTransition.target;
|
||||
if (matchTransition.IsEpsilon() || !matchTarget.OnlyHasEpsilonTransitions() || matchTarget
|
||||
if (matchTransition.IsEpsilon || !matchTarget.OnlyHasEpsilonTransitions() || matchTarget
|
||||
.GetNumberOfOptimizedTransitions() != 1 || !(matchTarget.GetOptimizedTransition(
|
||||
0).target is RuleStopState))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (matchTransition.GetSerializationType())
|
||||
switch (matchTransition.SerializationType)
|
||||
{
|
||||
case Transition.Atom:
|
||||
case Transition.Range:
|
||||
|
@ -529,7 +529,7 @@ namespace Antlr4.Runtime.Atn
|
|||
intermediateState.SetRuleIndex(target.ruleIndex);
|
||||
atn.AddState(intermediateState);
|
||||
optimizedTransitions.AddItem(new EpsilonTransition(intermediateState));
|
||||
switch (effective.GetSerializationType())
|
||||
switch (effective.SerializationType)
|
||||
{
|
||||
case Transition.Atom:
|
||||
{
|
||||
|
@ -547,7 +547,7 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
case Transition.Set:
|
||||
{
|
||||
intermediateState.AddTransition(new SetTransition(target, effective.Label()));
|
||||
intermediateState.AddTransition(new SetTransition(target, effective.Label));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -589,7 +589,7 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
Transition transition = state.GetOptimizedTransition(i);
|
||||
ATNState intermediate = transition.target;
|
||||
if (transition.GetSerializationType() != Transition.Epsilon || intermediate.GetStateType
|
||||
if (transition.SerializationType != Transition.Epsilon || intermediate.GetStateType
|
||||
() != ATNState.Basic || !intermediate.OnlyHasEpsilonTransitions())
|
||||
{
|
||||
if (optimizedTransitions != null)
|
||||
|
@ -600,7 +600,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
for (int j = 0; j < intermediate.GetNumberOfOptimizedTransitions(); j++)
|
||||
{
|
||||
if (intermediate.GetOptimizedTransition(j).GetSerializationType() != Transition.Epsilon)
|
||||
if (intermediate.GetOptimizedTransition(j).SerializationType != Transition.Epsilon)
|
||||
{
|
||||
if (optimizedTransitions != null)
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ nextState_break: ;
|
|||
}
|
||||
else
|
||||
{
|
||||
matchSet.AddAll(matchTransition.Label());
|
||||
matchSet.AddAll(matchTransition.Label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ nextState_break: ;
|
|||
.transitions;
|
||||
foreach (Transition t in transitions)
|
||||
{
|
||||
if (t.GetSerializationType() != Transition.Epsilon)
|
||||
if (t.SerializationType != Transition.Epsilon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -212,11 +212,11 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
if (transitions.IsEmpty())
|
||||
{
|
||||
epsilonOnlyTransitions = e.IsEpsilon();
|
||||
epsilonOnlyTransitions = e.IsEpsilon;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (epsilonOnlyTransitions != e.IsEpsilon())
|
||||
if (epsilonOnlyTransitions != e.IsEpsilon)
|
||||
{
|
||||
System.Console.Error.Format("ATN state %d has both epsilon and non-epsilon transitions.\n"
|
||||
, stateNumber);
|
||||
|
|
|
@ -54,14 +54,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.isCtxDependent = isCtxDependent;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Action;
|
||||
get
|
||||
{
|
||||
return Action;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEpsilon()
|
||||
public override bool IsEpsilon
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// we are to be ignored by analysis 'cept for predicates
|
||||
|
|
|
@ -79,24 +79,33 @@ namespace Antlr4.Runtime.Atn
|
|||
return System.Array.BinarySearch(returnStates, returnState);
|
||||
}
|
||||
|
||||
public override int Size()
|
||||
public override int Size
|
||||
{
|
||||
return returnStates.Length;
|
||||
get
|
||||
{
|
||||
return returnStates.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEmpty()
|
||||
public override bool IsEmpty
|
||||
{
|
||||
return false;
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasEmpty()
|
||||
public override bool HasEmpty
|
||||
{
|
||||
return returnStates[returnStates.Length - 1] == EmptyFullStateKey;
|
||||
get
|
||||
{
|
||||
return returnStates[returnStates.Length - 1] == EmptyFullStateKey;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override PredictionContext AddEmptyContext()
|
||||
{
|
||||
if (HasEmpty())
|
||||
if (HasEmpty)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
@ -109,7 +118,7 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
protected internal override PredictionContext RemoveEmptyContext()
|
||||
{
|
||||
if (!HasEmpty())
|
||||
if (!HasEmpty)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
@ -134,11 +143,11 @@ namespace Antlr4.Runtime.Atn
|
|||
private static PredictionContext AppendContext(PredictionContext context, PredictionContext
|
||||
suffix, PredictionContext.IdentityHashMap visited)
|
||||
{
|
||||
if (suffix.IsEmpty())
|
||||
if (suffix.IsEmpty)
|
||||
{
|
||||
if (IsEmptyLocal(suffix))
|
||||
{
|
||||
if (context.HasEmpty())
|
||||
if (context.HasEmpty)
|
||||
{
|
||||
return EmptyLocal;
|
||||
}
|
||||
|
@ -146,21 +155,21 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
return context;
|
||||
}
|
||||
if (suffix.Size() != 1)
|
||||
if (suffix.Size != 1)
|
||||
{
|
||||
throw new NotSupportedException("Appending a tree suffix is not yet supported.");
|
||||
}
|
||||
PredictionContext result = visited.Get(context);
|
||||
if (result == null)
|
||||
{
|
||||
if (context.IsEmpty())
|
||||
if (context.IsEmpty)
|
||||
{
|
||||
result = suffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
int parentCount = context.Size();
|
||||
if (context.HasEmpty())
|
||||
int parentCount = context.Size;
|
||||
if (context.HasEmpty)
|
||||
{
|
||||
parentCount--;
|
||||
}
|
||||
|
@ -185,7 +194,7 @@ namespace Antlr4.Runtime.Atn
|
|||
result = new Antlr4.Runtime.Atn.ArrayPredictionContext(updatedParents, updatedReturnStates
|
||||
);
|
||||
}
|
||||
if (context.HasEmpty())
|
||||
if (context.HasEmpty)
|
||||
{
|
||||
result = PredictionContext.Join(result, suffix);
|
||||
}
|
||||
|
@ -235,28 +244,28 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
continue;
|
||||
}
|
||||
int selfSize = operands.GetX().Size();
|
||||
int selfSize = operands.X.Size;
|
||||
if (selfSize == 0)
|
||||
{
|
||||
if (!operands.GetX().Equals(operands.GetY()))
|
||||
if (!operands.X.Equals(operands.Y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int otherSize = operands.GetY().Size();
|
||||
int otherSize = operands.Y.Size;
|
||||
if (selfSize != otherSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < selfSize; i++)
|
||||
{
|
||||
if (operands.GetX().GetReturnState(i) != operands.GetY().GetReturnState(i))
|
||||
if (operands.X.GetReturnState(i) != operands.Y.GetReturnState(i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
PredictionContext selfParent = operands.GetX().GetParent(i);
|
||||
PredictionContext otherParent = operands.GetY().GetParent(i);
|
||||
PredictionContext selfParent = operands.X.GetParent(i);
|
||||
PredictionContext otherParent = operands.Y.GetParent(i);
|
||||
if (selfParent.GetHashCode() != otherParent.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -45,15 +45,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Atom;
|
||||
get
|
||||
{
|
||||
return Atom;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
public override IntervalSet Label()
|
||||
public override IntervalSet Label
|
||||
{
|
||||
return IntervalSet.Of(label);
|
||||
get
|
||||
{
|
||||
return IntervalSet.Of(label);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -80,9 +80,12 @@ namespace Antlr4.Runtime.Atn
|
|||
return -1;
|
||||
}
|
||||
|
||||
public override int Size()
|
||||
public override int Size
|
||||
{
|
||||
return 0;
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override PredictionContext AppendContext(int returnContext, PredictionContextCache
|
||||
|
@ -97,14 +100,20 @@ namespace Antlr4.Runtime.Atn
|
|||
return suffix;
|
||||
}
|
||||
|
||||
public override bool IsEmpty()
|
||||
public override bool IsEmpty
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasEmpty()
|
||||
public override bool HasEmpty
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
|
|
|
@ -39,14 +39,20 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Epsilon;
|
||||
get
|
||||
{
|
||||
return Epsilon;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEpsilon()
|
||||
public override bool IsEpsilon
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -155,19 +155,19 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
else
|
||||
{
|
||||
if (ctx.IsEmpty() && addEOF)
|
||||
if (ctx.IsEmpty && addEOF)
|
||||
{
|
||||
look.Add(IToken.Eof);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ctx.Size(); i++)
|
||||
for (int i = 0; i < ctx.Size; i++)
|
||||
{
|
||||
if (ctx.GetReturnState(i) != PredictionContext.EmptyFullStateKey)
|
||||
{
|
||||
ATNState returnState = atn.states[ctx.GetReturnState(i)];
|
||||
// System.out.println("popping back to "+retState);
|
||||
for (int j = 0; j < ctx.Size(); j++)
|
||||
for (int j = 0; j < ctx.Size; j++)
|
||||
{
|
||||
Look(returnState, ctx.GetParent(j), look, lookBusy, seeThruPreds, addEOF);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
else
|
||||
{
|
||||
if (t.IsEpsilon())
|
||||
if (t.IsEpsilon)
|
||||
{
|
||||
Look(t.target, ctx, look, lookBusy, seeThruPreds, addEOF);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ namespace Antlr4.Runtime.Atn
|
|||
else
|
||||
{
|
||||
// System.out.println("adding "+ t);
|
||||
IntervalSet set = t.Label();
|
||||
IntervalSet set = t.Label;
|
||||
if (set != null)
|
||||
{
|
||||
if (t is NotSetTransition)
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace Antlr4.Runtime.Atn
|
|||
int mark = input.Mark();
|
||||
try
|
||||
{
|
||||
this.startIndex = input.Index();
|
||||
this.startIndex = input.Index;
|
||||
this.prevAccept.Reset();
|
||||
DFAState s0 = atn.modeToDFA[mode].s0.Get();
|
||||
if (s0 == null)
|
||||
|
@ -282,7 +282,7 @@ namespace Antlr4.Runtime.Atn
|
|||
else
|
||||
{
|
||||
// if no accept and EOF is first char, return EOF
|
||||
if (t == IIntStream.Eof && input.Index() == startIndex)
|
||||
if (t == IIntStream.Eof && input.Index == startIndex)
|
||||
{
|
||||
return IToken.Eof;
|
||||
}
|
||||
|
@ -400,20 +400,20 @@ namespace Antlr4.Runtime.Atn
|
|||
if (config.GetState() is RuleStopState)
|
||||
{
|
||||
PredictionContext context = config.GetContext();
|
||||
if (context.IsEmpty())
|
||||
if (context.IsEmpty)
|
||||
{
|
||||
configs.AddItem(config);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context.HasEmpty())
|
||||
if (context.HasEmpty)
|
||||
{
|
||||
configs.AddItem(config.Transform(config.GetState(), PredictionContext.EmptyFull));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < context.Size(); i++)
|
||||
for (int i = 0; i < context.Size; i++)
|
||||
{
|
||||
int returnStateNumber = context.GetReturnState(i);
|
||||
if (returnStateNumber == PredictionContext.EmptyFullStateKey)
|
||||
|
@ -458,13 +458,13 @@ namespace Antlr4.Runtime.Atn
|
|||
t, ATNConfigSet configs, bool speculative)
|
||||
{
|
||||
ATNConfig c;
|
||||
switch (t.GetSerializationType())
|
||||
switch (t.SerializationType)
|
||||
{
|
||||
case Transition.Rule:
|
||||
{
|
||||
RuleTransition ruleTransition = (RuleTransition)t;
|
||||
if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.GetContext
|
||||
().HasEmpty())
|
||||
().HasEmpty)
|
||||
{
|
||||
c = config.Transform(t.target);
|
||||
}
|
||||
|
@ -539,11 +539,10 @@ namespace Antlr4.Runtime.Atn
|
|||
/// sensitive values, including
|
||||
/// <see cref="Antlr4.Runtime.Lexer.GetText()">Antlr4.Runtime.Lexer.GetText()</see>
|
||||
/// ,
|
||||
/// <see cref="Antlr4.Runtime.Lexer.GetLine()">Antlr4.Runtime.Lexer.GetLine()</see>
|
||||
/// <see cref="Antlr4.Runtime.Lexer.Line()">Antlr4.Runtime.Lexer.Line()</see>
|
||||
/// ,
|
||||
/// and
|
||||
/// <see cref="Antlr4.Runtime.Lexer.GetCharPositionInLine()">Antlr4.Runtime.Lexer.GetCharPositionInLine()
|
||||
/// </see>
|
||||
/// <see cref="Antlr4.Runtime.Lexer.Column()">Antlr4.Runtime.Lexer.Column()</see>
|
||||
/// , properly reflect the current
|
||||
/// lexer state. This method should restore
|
||||
/// <code>input</code>
|
||||
|
@ -586,7 +585,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
int savedCharPositionInLine = charPositionInLine;
|
||||
int savedLine = line;
|
||||
int index = input.Index();
|
||||
int index = input.Index;
|
||||
int marker = input.Mark();
|
||||
try
|
||||
{
|
||||
|
@ -605,7 +604,7 @@ namespace Antlr4.Runtime.Atn
|
|||
protected internal virtual void CaptureSimState(LexerATNSimulator.SimState settings
|
||||
, ICharStream input, DFAState dfaState)
|
||||
{
|
||||
settings.index = input.Index();
|
||||
settings.index = input.Index;
|
||||
settings.line = line;
|
||||
settings.charPos = charPositionInLine;
|
||||
settings.dfaState = dfaState;
|
||||
|
@ -690,7 +689,7 @@ namespace Antlr4.Runtime.Atn
|
|||
public virtual string GetText(ICharStream input)
|
||||
{
|
||||
// index is first lookahead char, don't include.
|
||||
return input.GetText(Interval.Of(startIndex, input.Index() - 1));
|
||||
return input.GetText(Interval.Of(startIndex, input.Index - 1));
|
||||
}
|
||||
|
||||
public virtual int GetLine()
|
||||
|
|
|
@ -39,9 +39,12 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return NotSet;
|
||||
get
|
||||
{
|
||||
return NotSet;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -343,7 +343,7 @@ namespace Antlr4.Runtime.Atn
|
|||
//dump(dfa);
|
||||
// start with the DFA
|
||||
int m = input.Mark();
|
||||
int index = input.Index();
|
||||
int index = input.Index;
|
||||
try
|
||||
{
|
||||
int alt = ExecDFA(dfa, input, index, state);
|
||||
|
@ -371,17 +371,17 @@ namespace Antlr4.Runtime.Atn
|
|||
ParserRuleContext remainingContext = outerContext;
|
||||
System.Diagnostics.Debug.Assert(outerContext != null);
|
||||
DFAState s0 = dfa.s0full.Get();
|
||||
while (remainingContext != null && s0 != null && s0.IsContextSensitive())
|
||||
while (remainingContext != null && s0 != null && s0.IsContextSensitive)
|
||||
{
|
||||
remainingContext = SkipTailCalls(remainingContext);
|
||||
s0 = s0.GetContextTarget(GetReturnState(remainingContext));
|
||||
if (remainingContext.IsEmpty())
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(s0 == null || !s0.IsContextSensitive());
|
||||
System.Diagnostics.Debug.Assert(s0 == null || !s0.IsContextSensitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingContext = ((ParserRuleContext)remainingContext.GetParent());
|
||||
remainingContext = ((ParserRuleContext)remainingContext.Parent);
|
||||
}
|
||||
}
|
||||
if (s0 == null)
|
||||
|
@ -400,7 +400,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
int alt = 0;
|
||||
int m = input.Mark();
|
||||
int index = input.Index();
|
||||
int index = input.Index;
|
||||
try
|
||||
{
|
||||
SimulatorState state = ComputeStartState(dfa, outerContext, useContext);
|
||||
|
@ -452,7 +452,7 @@ namespace Antlr4.Runtime.Atn
|
|||
, remainingOuterContext);
|
||||
return ExecATN(dfa, input, startIndex, initialState);
|
||||
}
|
||||
remainingOuterContext = ((ParserRuleContext)remainingOuterContext.GetParent());
|
||||
remainingOuterContext = ((ParserRuleContext)remainingOuterContext.Parent);
|
||||
s = next;
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ namespace Antlr4.Runtime.Atn
|
|||
if (dfa.atnStartState is DecisionState)
|
||||
{
|
||||
if (!userWantsCtxSensitive || !acceptState.configs.GetDipsIntoOuterContext() || (
|
||||
treat_sllk1_conflict_as_ambiguity && input.Index() == startIndex))
|
||||
treat_sllk1_conflict_as_ambiguity && input.Index == startIndex))
|
||||
{
|
||||
}
|
||||
else
|
||||
|
@ -538,7 +538,7 @@ namespace Antlr4.Runtime.Atn
|
|||
// immediate decision
|
||||
if (acceptState.predicates != null)
|
||||
{
|
||||
int conflictIndex = input.Index();
|
||||
int conflictIndex = input.Index;
|
||||
if (conflictIndex != startIndex)
|
||||
{
|
||||
input.Seek(startIndex);
|
||||
|
@ -558,7 +558,7 @@ namespace Antlr4.Runtime.Atn
|
|||
if (reportAmbiguities)
|
||||
{
|
||||
SimulatorState fullContextState = ComputeStartState(dfa, outerContext, true);
|
||||
ReportAttemptingFullContext(dfa, fullContextState, startIndex, input.Index());
|
||||
ReportAttemptingFullContext(dfa, fullContextState, startIndex, input.Index);
|
||||
}
|
||||
input.Seek(startIndex);
|
||||
return AdaptivePredict(input, dfa.decision, outerContext, true);
|
||||
|
@ -569,7 +569,7 @@ namespace Antlr4.Runtime.Atn
|
|||
// disambiguating or validating predicates to evaluate
|
||||
if (s.predicates != null)
|
||||
{
|
||||
int stopIndex = input.Index();
|
||||
int stopIndex = input.Index;
|
||||
if (startIndex != stopIndex)
|
||||
{
|
||||
input.Seek(startIndex);
|
||||
|
@ -679,7 +679,7 @@ namespace Antlr4.Runtime.Atn
|
|||
.InvalidAltNumber;
|
||||
if (predictedAlt != ATN.InvalidAltNumber)
|
||||
{
|
||||
if (optimize_ll1 && input.Index() == startIndex && nextState.outerContext == nextState
|
||||
if (optimize_ll1 && input.Index == startIndex && nextState.outerContext == nextState
|
||||
.remainingOuterContext && dfa.decision >= 0 && !D.configs.HasSemanticContext())
|
||||
{
|
||||
if (t >= 0 && t <= short.MaxValue)
|
||||
|
@ -690,7 +690,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
if (useContext && always_try_local_context)
|
||||
{
|
||||
ReportContextSensitivity(dfa, nextState, startIndex, input.Index());
|
||||
ReportContextSensitivity(dfa, nextState, startIndex, input.Index);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -701,12 +701,12 @@ namespace Antlr4.Runtime.Atn
|
|||
// int k = input.index() - startIndex + 1; // how much input we used
|
||||
// System.out.println("used k="+k);
|
||||
if (!userWantsCtxSensitive || !D.configs.GetDipsIntoOuterContext() || (treat_sllk1_conflict_as_ambiguity
|
||||
&& input.Index() == startIndex))
|
||||
&& input.Index == startIndex))
|
||||
{
|
||||
if (reportAmbiguities && !D.configs.HasSemanticContext())
|
||||
{
|
||||
ReportAmbiguity(dfa, D, startIndex, input.Index(), D.configs.GetConflictingAlts()
|
||||
, D.configs);
|
||||
ReportAmbiguity(dfa, D, startIndex, input.Index, D.configs.GetConflictingAlts(),
|
||||
D.configs);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -719,7 +719,7 @@ namespace Antlr4.Runtime.Atn
|
|||
DFAState.PredPrediction[] predPredictions = D.predicates;
|
||||
if (predPredictions != null)
|
||||
{
|
||||
int conflictIndex = input.Index();
|
||||
int conflictIndex = input.Index;
|
||||
if (conflictIndex != startIndex)
|
||||
{
|
||||
input.Seek(startIndex);
|
||||
|
@ -741,7 +741,7 @@ namespace Antlr4.Runtime.Atn
|
|||
SimulatorState fullContextState = ComputeStartState(dfa, outerContext, true);
|
||||
if (reportAmbiguities)
|
||||
{
|
||||
ReportAttemptingFullContext(dfa, fullContextState, startIndex, input.Index());
|
||||
ReportAttemptingFullContext(dfa, fullContextState, startIndex, input.Index);
|
||||
}
|
||||
input.Seek(startIndex);
|
||||
return ExecATN(dfa, input, startIndex, fullContextState);
|
||||
|
@ -750,7 +750,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
if (D.predicates != null)
|
||||
{
|
||||
int stopIndex = input.Index();
|
||||
int stopIndex = input.Index;
|
||||
if (startIndex != stopIndex)
|
||||
{
|
||||
input.Seek(startIndex);
|
||||
|
@ -836,7 +836,7 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
break;
|
||||
}
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.GetParent());
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.Parent);
|
||||
s = next;
|
||||
}
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
if (c.GetState() is RuleStopState)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(c.GetContext().IsEmpty());
|
||||
System.Diagnostics.Debug.Assert(c.GetContext().IsEmpty);
|
||||
if (useContext && !c.GetReachesIntoOuterContext() || t == IIntStream.Eof)
|
||||
{
|
||||
if (skippedStopStates == null)
|
||||
|
@ -932,7 +932,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
else
|
||||
{
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.GetParent());
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.Parent);
|
||||
}
|
||||
contextElements.Add(nextContextElement);
|
||||
if (nextContextElement != PredictionContext.EmptyFullStateKey)
|
||||
|
@ -1034,7 +1034,7 @@ namespace Antlr4.Runtime.Atn
|
|||
PredictionContextCache contextCache = new PredictionContextCache();
|
||||
if (useContext)
|
||||
{
|
||||
while (s0 != null && s0.IsContextSensitive() && remainingGlobalContext != null)
|
||||
while (s0 != null && s0.IsContextSensitive && remainingGlobalContext != null)
|
||||
{
|
||||
DFAState next;
|
||||
remainingGlobalContext = SkipTailCalls(remainingGlobalContext);
|
||||
|
@ -1049,7 +1049,7 @@ namespace Antlr4.Runtime.Atn
|
|||
previousContext = GetReturnState(remainingGlobalContext);
|
||||
next = s0.GetContextTarget(previousContext);
|
||||
initialContext = initialContext.AppendContext(previousContext, contextCache);
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.GetParent());
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.Parent);
|
||||
}
|
||||
if (next == null)
|
||||
{
|
||||
|
@ -1058,7 +1058,7 @@ namespace Antlr4.Runtime.Atn
|
|||
s0 = next;
|
||||
}
|
||||
}
|
||||
if (s0 != null && !s0.IsContextSensitive())
|
||||
if (s0 != null && !s0.IsContextSensitive)
|
||||
{
|
||||
return new SimulatorState(globalContext, s0, useContext, remainingGlobalContext);
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
else
|
||||
{
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.GetParent());
|
||||
remainingGlobalContext = ((ParserRuleContext)remainingGlobalContext.Parent);
|
||||
}
|
||||
if (nextContextElement != PredictionContext.EmptyFullStateKey)
|
||||
{
|
||||
|
@ -1313,10 +1313,10 @@ namespace Antlr4.Runtime.Atn
|
|||
if (config.GetState() is RuleStopState)
|
||||
{
|
||||
// We hit rule end. If we have context info, use it
|
||||
if (!config.GetContext().IsEmpty())
|
||||
if (!config.GetContext().IsEmpty)
|
||||
{
|
||||
bool hasEmpty = config.GetContext().HasEmpty();
|
||||
int nonEmptySize = config.GetContext().Size() - (hasEmpty ? 1 : 0);
|
||||
bool hasEmpty = config.GetContext().HasEmpty;
|
||||
int nonEmptySize = config.GetContext().Size - (hasEmpty ? 1 : 0);
|
||||
for (int i = 0; i < nonEmptySize; i++)
|
||||
{
|
||||
PredictionContext newContext = config.GetContext().GetParent(i);
|
||||
|
@ -1329,7 +1329,7 @@ namespace Antlr4.Runtime.Atn
|
|||
// Make sure we track that we are now out of context.
|
||||
c.SetOuterContextDepth(config.GetOuterContextDepth());
|
||||
System.Diagnostics.Debug.Assert(depth > int.MinValue);
|
||||
if (optimize_closure_busy && c.GetContext().IsEmpty() && !closureBusy.AddItem(c))
|
||||
if (optimize_closure_busy && c.GetContext().IsEmpty && !closureBusy.AddItem(c))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1403,7 +1403,7 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
case ATNState.RuleStop:
|
||||
{
|
||||
checkClosure = c.GetContext().IsEmpty();
|
||||
checkClosure = c.GetContext().IsEmpty;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ namespace Antlr4.Runtime.Atn
|
|||
public virtual ATNConfig GetEpsilonTarget(ATNConfig config, Transition t, bool collectPredicates
|
||||
, bool inContext, PredictionContextCache contextCache)
|
||||
{
|
||||
switch (t.GetSerializationType())
|
||||
switch (t.SerializationType)
|
||||
{
|
||||
case Transition.Rule:
|
||||
{
|
||||
|
@ -2167,14 +2167,14 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
ATNState state = atn.states[context.invokingState];
|
||||
System.Diagnostics.Debug.Assert(state.GetNumberOfTransitions() == 1 && state.Transition
|
||||
(0).GetSerializationType() == Transition.Rule);
|
||||
(0).SerializationType == Transition.Rule);
|
||||
Antlr4.Runtime.Atn.RuleTransition transition = (Antlr4.Runtime.Atn.RuleTransition
|
||||
)state.Transition(0);
|
||||
if (!transition.tailCall)
|
||||
{
|
||||
break;
|
||||
}
|
||||
context = ((ParserRuleContext)context.GetParent());
|
||||
context = ((ParserRuleContext)context.Parent);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
|
@ -43,14 +43,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.precedence = precedence;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Precedence;
|
||||
get
|
||||
{
|
||||
return Precedence;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEpsilon()
|
||||
public override bool IsEpsilon
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -61,14 +61,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.isCtxDependent = isCtxDependent;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Predicate;
|
||||
get
|
||||
{
|
||||
return Predicate;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEpsilon()
|
||||
public override bool IsEpsilon
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -134,7 +134,10 @@ namespace Antlr4.Runtime.Atn
|
|||
return (InitialHash * HashMultiplier ^ parentHashCode) * HashMultiplier ^ returnStateHashCode;
|
||||
}
|
||||
|
||||
public abstract int Size();
|
||||
public abstract int Size
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract int GetReturnState(int index);
|
||||
|
||||
|
@ -203,19 +206,19 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
return context0;
|
||||
}
|
||||
if (context0.IsEmpty())
|
||||
if (context0.IsEmpty)
|
||||
{
|
||||
return IsEmptyLocal(context0) ? context0 : AddEmptyContext(context1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context1.IsEmpty())
|
||||
if (context1.IsEmpty)
|
||||
{
|
||||
return IsEmptyLocal(context1) ? context1 : AddEmptyContext(context0);
|
||||
}
|
||||
}
|
||||
int context0size = context0.Size();
|
||||
int context1size = context1.Size();
|
||||
int context0size = context0.Size;
|
||||
int context1size = context1.Size;
|
||||
if (context0size == 1 && context1size == 1 && context0.GetReturnState(0) == context1
|
||||
.GetReturnState(0))
|
||||
{
|
||||
|
@ -339,7 +342,7 @@ namespace Antlr4.Runtime.Atn
|
|||
context, IConcurrentMap<Antlr4.Runtime.Atn.PredictionContext, Antlr4.Runtime.Atn.PredictionContext
|
||||
> contextCache, PredictionContext.IdentityHashMap visited)
|
||||
{
|
||||
if (context.IsEmpty())
|
||||
if (context.IsEmpty)
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
@ -356,7 +359,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
bool changed = false;
|
||||
Antlr4.Runtime.Atn.PredictionContext[] parents = new Antlr4.Runtime.Atn.PredictionContext
|
||||
[context.Size()];
|
||||
[context.Size];
|
||||
for (int i = 0; i < parents.Length; i++)
|
||||
{
|
||||
Antlr4.Runtime.Atn.PredictionContext parent = GetCachedContext(context.GetParent(
|
||||
|
@ -365,8 +368,8 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
if (!changed)
|
||||
{
|
||||
parents = new Antlr4.Runtime.Atn.PredictionContext[context.Size()];
|
||||
for (int j = 0; j < context.Size(); j++)
|
||||
parents = new Antlr4.Runtime.Atn.PredictionContext[context.Size];
|
||||
for (int j = 0; j < context.Size; j++)
|
||||
{
|
||||
parents[j] = context.GetParent(j);
|
||||
}
|
||||
|
@ -414,9 +417,15 @@ namespace Antlr4.Runtime.Atn
|
|||
return new SingletonPredictionContext(this, returnState);
|
||||
}
|
||||
|
||||
public abstract bool IsEmpty();
|
||||
public abstract bool IsEmpty
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract bool HasEmpty();
|
||||
public abstract bool HasEmpty
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public sealed override int GetHashCode()
|
||||
{
|
||||
|
@ -448,20 +457,20 @@ namespace Antlr4.Runtime.Atn
|
|||
int stateNumber = currentState;
|
||||
StringBuilder localBuffer = new StringBuilder();
|
||||
localBuffer.Append("[");
|
||||
while (!p.IsEmpty() && p != stop)
|
||||
while (!p.IsEmpty && p != stop)
|
||||
{
|
||||
int index = 0;
|
||||
if (p.Size() > 0)
|
||||
if (p.Size > 0)
|
||||
{
|
||||
int bits = 1;
|
||||
while ((1 << bits) < p.Size())
|
||||
while ((1 << bits) < p.Size)
|
||||
{
|
||||
bits++;
|
||||
}
|
||||
int mask = (1 << bits) - 1;
|
||||
index = (perm >> offset) & mask;
|
||||
last &= index >= p.Size() - 1;
|
||||
if (index >= p.Size())
|
||||
last &= index >= p.Size - 1;
|
||||
if (index >= p.Size)
|
||||
{
|
||||
goto outer_continue;
|
||||
}
|
||||
|
@ -483,7 +492,7 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
if (p.GetReturnState(index) != EmptyFullStateKey)
|
||||
{
|
||||
if (!p.IsEmpty())
|
||||
if (!p.IsEmpty)
|
||||
{
|
||||
if (localBuffer.Length > 1)
|
||||
{
|
||||
|
|
|
@ -174,14 +174,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.y = y;
|
||||
}
|
||||
|
||||
public PredictionContext GetX()
|
||||
public PredictionContext X
|
||||
{
|
||||
return x;
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
public PredictionContext GetY()
|
||||
public PredictionContext Y
|
||||
{
|
||||
return y;
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
|
|
|
@ -45,15 +45,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.to = to;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Range;
|
||||
get
|
||||
{
|
||||
return Range;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
public override IntervalSet Label()
|
||||
public override IntervalSet Label
|
||||
{
|
||||
return IntervalSet.Of(from, to);
|
||||
get
|
||||
{
|
||||
return IntervalSet.Of(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -57,14 +57,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.followState = followState;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Rule;
|
||||
get
|
||||
{
|
||||
return Rule;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEpsilon()
|
||||
public override bool IsEpsilon
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -51,15 +51,20 @@ namespace Antlr4.Runtime.Atn
|
|||
this.set = set;
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Set;
|
||||
get
|
||||
{
|
||||
return Set;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
public override IntervalSet Label()
|
||||
public override IntervalSet Label
|
||||
{
|
||||
return set;
|
||||
get
|
||||
{
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -67,19 +67,28 @@ namespace Antlr4.Runtime.Atn
|
|||
return this.returnState == returnState ? 0 : -1;
|
||||
}
|
||||
|
||||
public override int Size()
|
||||
public override int Size
|
||||
{
|
||||
return 1;
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEmpty()
|
||||
public override bool IsEmpty
|
||||
{
|
||||
return false;
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasEmpty()
|
||||
public override bool HasEmpty
|
||||
{
|
||||
return false;
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override PredictionContext AppendContext(PredictionContext suffix, PredictionContextCache
|
||||
|
|
|
@ -115,18 +115,26 @@ namespace Antlr4.Runtime.Atn
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
public abstract int GetSerializationType();
|
||||
|
||||
/// <summary>Are we epsilon, action, sempred?</summary>
|
||||
public virtual bool IsEpsilon()
|
||||
public abstract int SerializationType
|
||||
{
|
||||
return false;
|
||||
get;
|
||||
}
|
||||
|
||||
[Nullable]
|
||||
public virtual IntervalSet Label()
|
||||
/// <summary>Are we epsilon, action, sempred?</summary>
|
||||
public virtual bool IsEpsilon
|
||||
{
|
||||
return null;
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IntervalSet Label
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol);
|
||||
|
|
|
@ -39,9 +39,12 @@ namespace Antlr4.Runtime.Atn
|
|||
{
|
||||
}
|
||||
|
||||
public override int GetSerializationType()
|
||||
public override int SerializationType
|
||||
{
|
||||
return Wildcard;
|
||||
get
|
||||
{
|
||||
return Wildcard;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace Antlr4.Runtime
|
|||
public override void Recover(Parser recognizer, RecognitionException e)
|
||||
{
|
||||
for (ParserRuleContext context = recognizer.GetContext(); context != null; context
|
||||
= ((ParserRuleContext)context.GetParent()))
|
||||
= ((ParserRuleContext)context.Parent))
|
||||
{
|
||||
context.exception = e;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
InputMismatchException e = new InputMismatchException(recognizer);
|
||||
for (ParserRuleContext context = recognizer.GetContext(); context != null; context
|
||||
= ((ParserRuleContext)context.GetParent()))
|
||||
= ((ParserRuleContext)context.Parent))
|
||||
{
|
||||
context.exception = e;
|
||||
}
|
||||
|
|
|
@ -122,14 +122,20 @@ namespace Antlr4.Runtime
|
|||
this.tokenSource = tokenSource;
|
||||
}
|
||||
|
||||
public virtual ITokenSource GetTokenSource()
|
||||
public virtual ITokenSource TokenSource
|
||||
{
|
||||
return tokenSource;
|
||||
get
|
||||
{
|
||||
return tokenSource;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Index()
|
||||
public virtual int Index
|
||||
{
|
||||
return p;
|
||||
get
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// public int range() { return range; }
|
||||
|
@ -154,9 +160,12 @@ namespace Antlr4.Runtime
|
|||
p = AdjustSeekIndex(index);
|
||||
}
|
||||
|
||||
public virtual int Size()
|
||||
public virtual int Size
|
||||
{
|
||||
return tokens.Count;
|
||||
get
|
||||
{
|
||||
return tokens.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Consume()
|
||||
|
@ -217,10 +226,10 @@ namespace Antlr4.Runtime
|
|||
IToken t = tokenSource.NextToken();
|
||||
if (t is IWritableToken)
|
||||
{
|
||||
((IWritableToken)t).SetTokenIndex(tokens.Count);
|
||||
((IWritableToken)t).TokenIndex = tokens.Count;
|
||||
}
|
||||
tokens.AddItem(t);
|
||||
if (t.GetType() == IToken.Eof)
|
||||
if (t.Type == IToken.Eof)
|
||||
{
|
||||
fetchedEOF = true;
|
||||
return i + 1;
|
||||
|
@ -256,7 +265,7 @@ namespace Antlr4.Runtime
|
|||
for (int i = start; i <= stop; i++)
|
||||
{
|
||||
IToken t = tokens[i];
|
||||
if (t.GetType() == IToken.Eof)
|
||||
if (t.Type == IToken.Eof)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -267,7 +276,7 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual int La(int i)
|
||||
{
|
||||
return Lt(i).GetType();
|
||||
return Lt(i).Type;
|
||||
}
|
||||
|
||||
protected internal virtual IToken Lb(int k)
|
||||
|
@ -389,7 +398,7 @@ namespace Antlr4.Runtime
|
|||
for (int i = start; i <= stop; i++)
|
||||
{
|
||||
IToken t = tokens[i];
|
||||
if (types == null || types.Get(t.GetType()))
|
||||
if (types == null || types.Get(t.Type))
|
||||
{
|
||||
filteredTokens.AddItem(t);
|
||||
}
|
||||
|
@ -426,13 +435,13 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
Sync(i);
|
||||
IToken token = tokens[i];
|
||||
if (i >= Size())
|
||||
if (i >= Size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
while (token.GetChannel() != channel)
|
||||
while (token.Channel != channel)
|
||||
{
|
||||
if (token.GetType() == IToken.Eof)
|
||||
if (token.Type == IToken.Eof)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -462,7 +471,7 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
protected internal virtual int PreviousTokenOnChannel(int i, int channel)
|
||||
{
|
||||
while (i >= 0 && tokens[i].GetChannel() != channel)
|
||||
while (i >= 0 && tokens[i].Channel != channel)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
@ -494,7 +503,7 @@ namespace Antlr4.Runtime
|
|||
// if none onchannel to right, nextOnChannel=-1 so set to = last token
|
||||
if (nextOnChannel == -1)
|
||||
{
|
||||
to = Size() - 1;
|
||||
to = Size - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -565,14 +574,14 @@ namespace Antlr4.Runtime
|
|||
IToken t = tokens[i];
|
||||
if (channel == -1)
|
||||
{
|
||||
if (t.GetChannel() != Lexer.DefaultTokenChannel)
|
||||
if (t.Channel != Lexer.DefaultTokenChannel)
|
||||
{
|
||||
hidden.AddItem(t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t.GetChannel() == channel)
|
||||
if (t.Channel == channel)
|
||||
{
|
||||
hidden.AddItem(t);
|
||||
}
|
||||
|
@ -585,9 +594,12 @@ namespace Antlr4.Runtime
|
|||
return hidden;
|
||||
}
|
||||
|
||||
public virtual string GetSourceName()
|
||||
public virtual string SourceName
|
||||
{
|
||||
return tokenSource.GetSourceName();
|
||||
get
|
||||
{
|
||||
return tokenSource.SourceName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the text of all tokens in this buffer.</summary>
|
||||
|
@ -596,7 +608,7 @@ namespace Antlr4.Runtime
|
|||
public virtual string GetText()
|
||||
{
|
||||
Fill();
|
||||
return GetText(Interval.Of(0, Size() - 1));
|
||||
return GetText(Interval.Of(0, Size - 1));
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
|
@ -617,11 +629,11 @@ namespace Antlr4.Runtime
|
|||
for (int i = start; i <= stop; i++)
|
||||
{
|
||||
IToken t = tokens[i];
|
||||
if (t.GetType() == IToken.Eof)
|
||||
if (t.Type == IToken.Eof)
|
||||
{
|
||||
break;
|
||||
}
|
||||
buf.Append(t.GetText());
|
||||
buf.Append(t.Text);
|
||||
}
|
||||
return buf.ToString();
|
||||
}
|
||||
|
@ -629,7 +641,7 @@ namespace Antlr4.Runtime
|
|||
[NotNull]
|
||||
public virtual string GetText(RuleContext ctx)
|
||||
{
|
||||
return GetText(ctx.GetSourceInterval());
|
||||
return GetText(ctx.SourceInterval);
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
|
@ -637,7 +649,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
if (start != null && stop != null)
|
||||
{
|
||||
return GetText(Interval.Of(start.GetTokenIndex(), stop.GetTokenIndex()));
|
||||
return GetText(Interval.Of(start.TokenIndex, stop.TokenIndex));
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ namespace Antlr4.Runtime
|
|||
this.stop = stop;
|
||||
if (source.GetItem1() != null)
|
||||
{
|
||||
this.line = source.GetItem1().GetLine();
|
||||
this.charPositionInLine = source.GetItem1().GetCharPositionInLine();
|
||||
this.line = source.GetItem1().Line;
|
||||
this.charPositionInLine = source.GetItem1().Column;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,53 +98,47 @@ namespace Antlr4.Runtime
|
|||
|
||||
public CommonToken(IToken oldToken)
|
||||
{
|
||||
text = oldToken.GetText();
|
||||
type = oldToken.GetType();
|
||||
line = oldToken.GetLine();
|
||||
index = oldToken.GetTokenIndex();
|
||||
charPositionInLine = oldToken.GetCharPositionInLine();
|
||||
channel = oldToken.GetChannel();
|
||||
start = oldToken.GetStartIndex();
|
||||
stop = oldToken.GetStopIndex();
|
||||
text = oldToken.Text;
|
||||
type = oldToken.Type;
|
||||
line = oldToken.Line;
|
||||
index = oldToken.TokenIndex;
|
||||
charPositionInLine = oldToken.Column;
|
||||
channel = oldToken.Channel;
|
||||
start = oldToken.StartIndex;
|
||||
stop = oldToken.StopIndex;
|
||||
if (oldToken is Antlr4.Runtime.CommonToken)
|
||||
{
|
||||
source = ((Antlr4.Runtime.CommonToken)oldToken).source;
|
||||
}
|
||||
else
|
||||
{
|
||||
source = Tuple.Create(oldToken.GetTokenSource(), oldToken.GetInputStream());
|
||||
source = Tuple.Create(oldToken.TokenSource, oldToken.InputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int GetType()
|
||||
public virtual int Type
|
||||
{
|
||||
return type;
|
||||
get
|
||||
{
|
||||
return type;
|
||||
}
|
||||
set
|
||||
{
|
||||
int type = value;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetLine(int line)
|
||||
public virtual int Line
|
||||
{
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public virtual string GetText()
|
||||
{
|
||||
if (text != null)
|
||||
get
|
||||
{
|
||||
return text;
|
||||
return line;
|
||||
}
|
||||
ICharStream input = GetInputStream();
|
||||
if (input == null)
|
||||
set
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int n = input.Size();
|
||||
if (start < n && stop < n)
|
||||
{
|
||||
return input.GetText(Interval.Of(start, stop));
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<EOF>";
|
||||
int line = value;
|
||||
this.line = line;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,44 +149,68 @@ namespace Antlr4.Runtime
|
|||
/// that start/stop indexes are not valid. It means that that input
|
||||
/// was converted to a new string in the token object.
|
||||
/// </remarks>
|
||||
public virtual void SetText(string text)
|
||||
public virtual string Text
|
||||
{
|
||||
this.text = text;
|
||||
get
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
ICharStream input = InputStream;
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int n = input.Size;
|
||||
if (start < n && stop < n)
|
||||
{
|
||||
return input.GetText(Interval.Of(start, stop));
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<EOF>";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
string text = value;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int GetLine()
|
||||
public virtual int Column
|
||||
{
|
||||
return line;
|
||||
get
|
||||
{
|
||||
return charPositionInLine;
|
||||
}
|
||||
set
|
||||
{
|
||||
int charPositionInLine = value;
|
||||
this.charPositionInLine = charPositionInLine;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int GetCharPositionInLine()
|
||||
public virtual int Channel
|
||||
{
|
||||
return charPositionInLine;
|
||||
get
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
set
|
||||
{
|
||||
int channel = value;
|
||||
this.channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetCharPositionInLine(int charPositionInLine)
|
||||
public virtual int StartIndex
|
||||
{
|
||||
this.charPositionInLine = charPositionInLine;
|
||||
}
|
||||
|
||||
public virtual int GetChannel()
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
public virtual void SetChannel(int channel)
|
||||
{
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public virtual void SetType(int type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public virtual int GetStartIndex()
|
||||
{
|
||||
return start;
|
||||
get
|
||||
{
|
||||
return start;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetStartIndex(int start)
|
||||
|
@ -200,9 +218,12 @@ namespace Antlr4.Runtime
|
|||
this.start = start;
|
||||
}
|
||||
|
||||
public virtual int GetStopIndex()
|
||||
public virtual int StopIndex
|
||||
{
|
||||
return stop;
|
||||
get
|
||||
{
|
||||
return stop;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetStopIndex(int stop)
|
||||
|
@ -210,24 +231,33 @@ namespace Antlr4.Runtime
|
|||
this.stop = stop;
|
||||
}
|
||||
|
||||
public virtual int GetTokenIndex()
|
||||
public virtual int TokenIndex
|
||||
{
|
||||
return index;
|
||||
get
|
||||
{
|
||||
return index;
|
||||
}
|
||||
set
|
||||
{
|
||||
int index = value;
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetTokenIndex(int index)
|
||||
public virtual ITokenSource TokenSource
|
||||
{
|
||||
this.index = index;
|
||||
get
|
||||
{
|
||||
return source.GetItem1();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ITokenSource GetTokenSource()
|
||||
public virtual ICharStream InputStream
|
||||
{
|
||||
return source.GetItem1();
|
||||
}
|
||||
|
||||
public virtual ICharStream GetInputStream()
|
||||
{
|
||||
return source.GetItem2();
|
||||
get
|
||||
{
|
||||
return source.GetItem2();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -237,7 +267,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
channelStr = ",channel=" + channel;
|
||||
}
|
||||
string txt = GetText();
|
||||
string txt = Text;
|
||||
if (txt != null)
|
||||
{
|
||||
txt = txt.ReplaceAll("\n", "\\\\n");
|
||||
|
@ -248,8 +278,8 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
txt = "<no text>";
|
||||
}
|
||||
return "[@" + GetTokenIndex() + "," + start + ":" + stop + "='" + txt + "',<" + type
|
||||
+ ">" + channelStr + "," + line + ":" + GetCharPositionInLine() + "]";
|
||||
return "[@" + TokenIndex + "," + start + ":" + stop + "='" + txt + "',<" + type +
|
||||
">" + channelStr + "," + line + ":" + Column + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,17 +68,17 @@ namespace Antlr4.Runtime
|
|||
int channel, int start, int stop, int line, int charPositionInLine) where _T0:ITokenSource
|
||||
{
|
||||
CommonToken t = new CommonToken(source, type, channel, start, stop);
|
||||
t.SetLine(line);
|
||||
t.SetCharPositionInLine(charPositionInLine);
|
||||
t.Line = line;
|
||||
t.Column = charPositionInLine;
|
||||
if (text != null)
|
||||
{
|
||||
t.SetText(text);
|
||||
t.Text = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (copyText && source.GetItem2() != null)
|
||||
{
|
||||
t.SetText(source.GetItem2().GetText(Interval.Of(start, stop)));
|
||||
t.Text = source.GetItem2().GetText(Interval.Of(start, stop));
|
||||
}
|
||||
}
|
||||
return t;
|
||||
|
|
|
@ -141,11 +141,11 @@ namespace Antlr4.Runtime
|
|||
for (int i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
IToken t = tokens[i];
|
||||
if (t.GetChannel() == channel)
|
||||
if (t.Channel == channel)
|
||||
{
|
||||
n++;
|
||||
}
|
||||
if (t.GetType() == IToken.Eof)
|
||||
if (t.Type == IToken.Eof)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace Antlr4.Runtime
|
|||
// ", lastErrorIndex="+
|
||||
// lastErrorIndex+
|
||||
// ", states="+lastErrorStates);
|
||||
if (lastErrorIndex == ((ITokenStream)recognizer.GetInputStream()).Index() && lastErrorStates
|
||||
if (lastErrorIndex == ((ITokenStream)recognizer.GetInputStream()).Index && lastErrorStates
|
||||
!= null && lastErrorStates.Contains(recognizer.GetState()))
|
||||
{
|
||||
// uh oh, another error at same token index and previously-visited
|
||||
|
@ -157,7 +157,7 @@ namespace Antlr4.Runtime
|
|||
// System.err.println("FAILSAFE consumes "+recognizer.getTokenNames()[recognizer.getInputStream().LA(1)]);
|
||||
recognizer.Consume();
|
||||
}
|
||||
lastErrorIndex = ((ITokenStream)recognizer.GetInputStream()).Index();
|
||||
lastErrorIndex = ((ITokenStream)recognizer.GetInputStream()).Index;
|
||||
if (lastErrorStates == null)
|
||||
{
|
||||
lastErrorStates = new IntervalSet();
|
||||
|
@ -249,7 +249,7 @@ namespace Antlr4.Runtime
|
|||
string input;
|
||||
if (tokens != null)
|
||||
{
|
||||
if (e.GetStartToken().GetType() == IToken.Eof)
|
||||
if (e.GetStartToken().Type == IToken.Eof)
|
||||
{
|
||||
input = "<EOF>";
|
||||
}
|
||||
|
@ -437,21 +437,21 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
IToken current = currentSymbol;
|
||||
IToken lookback = ((ITokenStream)recognizer.GetInputStream()).Lt(-1);
|
||||
if (current.GetType() == IToken.Eof && lookback != null)
|
||||
if (current.Type == IToken.Eof && lookback != null)
|
||||
{
|
||||
current = lookback;
|
||||
}
|
||||
return ConstructToken(((ITokenStream)recognizer.GetInputStream()).GetTokenSource(
|
||||
), expectedTokenType, tokenText, current);
|
||||
return ConstructToken(((ITokenStream)recognizer.GetInputStream()).TokenSource, expectedTokenType
|
||||
, tokenText, current);
|
||||
}
|
||||
|
||||
protected internal virtual IToken ConstructToken(ITokenSource tokenSource, int expectedTokenType
|
||||
, string tokenText, IToken current)
|
||||
{
|
||||
ITokenFactory factory = tokenSource.GetTokenFactory();
|
||||
return factory.Create(Tuple.Create(tokenSource, current.GetTokenSource().GetInputStream
|
||||
()), expectedTokenType, tokenText, IToken.DefaultChannel, -1, -1, current.GetLine
|
||||
(), current.GetCharPositionInLine());
|
||||
ITokenFactory factory = tokenSource.TokenFactory;
|
||||
return factory.Create(Tuple.Create(tokenSource, current.TokenSource.InputStream),
|
||||
expectedTokenType, tokenText, IToken.DefaultChannel, -1, -1, current.Line, current
|
||||
.Column);
|
||||
}
|
||||
|
||||
public virtual IntervalSet GetExpectedTokens(Parser recognizer)
|
||||
|
@ -496,12 +496,12 @@ namespace Antlr4.Runtime
|
|||
|
||||
protected internal virtual string GetSymbolText(IToken symbol)
|
||||
{
|
||||
return symbol.GetText();
|
||||
return symbol.Text;
|
||||
}
|
||||
|
||||
protected internal virtual int GetSymbolType(IToken symbol)
|
||||
{
|
||||
return symbol.GetType();
|
||||
return symbol.Type;
|
||||
}
|
||||
|
||||
protected internal virtual string EscapeWSAndQuote(string s)
|
||||
|
|
|
@ -85,8 +85,8 @@ namespace Antlr4.Runtime.Dfa
|
|||
states.Sort(new _IComparer_85());
|
||||
foreach (DFAState s in states)
|
||||
{
|
||||
IDictionary<int, DFAState> edges = s.GetEdgeMap();
|
||||
IDictionary<int, DFAState> contextEdges = s.GetContextEdgeMap();
|
||||
IDictionary<int, DFAState> edges = s.EdgeMap;
|
||||
IDictionary<int, DFAState> contextEdges = s.ContextEdgeMap;
|
||||
foreach (KeyValuePair<int, DFAState> entry in edges.EntrySet())
|
||||
{
|
||||
if ((entry.Value == null || entry.Value == ATNSimulator.Error) && !s.IsContextSymbol
|
||||
|
@ -115,7 +115,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
}
|
||||
}
|
||||
}
|
||||
if (s.IsContextSensitive())
|
||||
if (s.IsContextSensitive)
|
||||
{
|
||||
foreach (KeyValuePair<int, DFAState> entry_1 in contextEdges.EntrySet())
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
stateStr = ":s" + n + "=>" + s.prediction;
|
||||
}
|
||||
}
|
||||
if (s.IsContextSensitive())
|
||||
if (s.IsContextSensitive)
|
||||
{
|
||||
stateStr += "*";
|
||||
foreach (ATNConfig config in s.configs)
|
||||
|
|
|
@ -154,14 +154,17 @@ namespace Antlr4.Runtime.Dfa
|
|||
this.maxSymbol = maxSymbol;
|
||||
}
|
||||
|
||||
public bool IsContextSensitive()
|
||||
public bool IsContextSensitive
|
||||
{
|
||||
return contextEdges != null;
|
||||
get
|
||||
{
|
||||
return contextEdges != null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsContextSymbol(int symbol)
|
||||
{
|
||||
if (!IsContextSensitive() || symbol < minSymbol)
|
||||
if (!IsContextSensitive || symbol < minSymbol)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -170,7 +173,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
|
||||
public void SetContextSymbol(int symbol)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(IsContextSensitive());
|
||||
System.Diagnostics.Debug.Assert(IsContextSensitive);
|
||||
if (symbol < minSymbol)
|
||||
{
|
||||
return;
|
||||
|
@ -183,7 +186,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
lock (this)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(!configs.IsOutermostConfigSet());
|
||||
if (IsContextSensitive())
|
||||
if (IsContextSensitive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -213,13 +216,16 @@ namespace Antlr4.Runtime.Dfa
|
|||
}
|
||||
}
|
||||
|
||||
public virtual IDictionary<int, DFAState> GetEdgeMap()
|
||||
public virtual IDictionary<int, DFAState> EdgeMap
|
||||
{
|
||||
if (edges == null)
|
||||
get
|
||||
{
|
||||
return Sharpen.Collections.EmptyMap();
|
||||
if (edges == null)
|
||||
{
|
||||
return Sharpen.Collections.EmptyMap();
|
||||
}
|
||||
return edges.ToMap();
|
||||
}
|
||||
return edges.ToMap();
|
||||
}
|
||||
|
||||
public virtual DFAState GetContextTarget(int invokingState)
|
||||
|
@ -251,35 +257,38 @@ namespace Antlr4.Runtime.Dfa
|
|||
}
|
||||
}
|
||||
|
||||
public virtual IDictionary<int, DFAState> GetContextEdgeMap()
|
||||
public virtual IDictionary<int, DFAState> ContextEdgeMap
|
||||
{
|
||||
if (contextEdges == null)
|
||||
get
|
||||
{
|
||||
return Sharpen.Collections.EmptyMap();
|
||||
}
|
||||
IDictionary<int, DFAState> map = contextEdges.ToMap();
|
||||
if (map.ContainsKey(-1))
|
||||
{
|
||||
if (map.Count == 1)
|
||||
if (contextEdges == null)
|
||||
{
|
||||
return Sharpen.Collections.SingletonMap(PredictionContext.EmptyFullStateKey, map.
|
||||
Get(-1));
|
||||
return Sharpen.Collections.EmptyMap();
|
||||
}
|
||||
else
|
||||
IDictionary<int, DFAState> map = contextEdges.ToMap();
|
||||
if (map.ContainsKey(-1))
|
||||
{
|
||||
try
|
||||
if (map.Count == 1)
|
||||
{
|
||||
map.Put(PredictionContext.EmptyFullStateKey, Sharpen.Collections.Remove(map, -1));
|
||||
return Sharpen.Collections.SingletonMap(PredictionContext.EmptyFullStateKey, map.
|
||||
Get(-1));
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
else
|
||||
{
|
||||
// handles read only, non-singleton maps
|
||||
map = new LinkedHashMap<int, DFAState>(map);
|
||||
map.Put(PredictionContext.EmptyFullStateKey, Sharpen.Collections.Remove(map, -1));
|
||||
try
|
||||
{
|
||||
map.Put(PredictionContext.EmptyFullStateKey, Sharpen.Collections.Remove(map, -1));
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
// handles read only, non-singleton maps
|
||||
map = new LinkedHashMap<int, DFAState>(map);
|
||||
map.Put(PredictionContext.EmptyFullStateKey, Sharpen.Collections.Remove(map, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using Antlr4.Runtime;
|
||||
using Antlr4.Runtime.Misc;
|
||||
using Sharpen;
|
||||
|
||||
namespace Antlr4.Runtime
|
||||
|
@ -69,7 +68,7 @@ namespace Antlr4.Runtime
|
|||
|
||||
/// <summary>
|
||||
/// The value returned by
|
||||
/// <see cref="GetSourceName()">GetSourceName()</see>
|
||||
/// <see cref="SourceName()">SourceName()</see>
|
||||
/// when the actual name of the
|
||||
/// underlying source is not known.
|
||||
/// </summary>
|
||||
|
@ -282,7 +281,10 @@ namespace Antlr4.Runtime
|
|||
/// has occurred after this stream was
|
||||
/// constructed.
|
||||
/// </summary>
|
||||
public abstract int Index();
|
||||
internal abstract int Index
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the input cursor to the position indicated by
|
||||
|
@ -346,7 +348,10 @@ namespace Antlr4.Runtime
|
|||
/// if the size of the stream is
|
||||
/// unknown.
|
||||
/// </exception>
|
||||
public abstract int Size();
|
||||
internal abstract int Size
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>Gets the name of the underlying symbol source.</summary>
|
||||
/// <remarks>
|
||||
|
@ -356,7 +361,9 @@ namespace Antlr4.Runtime
|
|||
/// <see cref="UnknownSourceName">UnknownSourceName</see>
|
||||
/// .
|
||||
/// </remarks>
|
||||
[NotNull]
|
||||
public abstract string GetSourceName();
|
||||
public abstract string SourceName
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,23 +81,37 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
public const int HiddenChannel = 1;
|
||||
|
||||
/// <summary>Get the text of the token</summary>
|
||||
public abstract string GetText();
|
||||
/// <summary>Get the text of the token.</summary>
|
||||
/// <remarks>Get the text of the token.</remarks>
|
||||
internal abstract string Text
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>Get the token type of the token</summary>
|
||||
public abstract int GetType();
|
||||
/// <summary>Get the token type of the token.</summary>
|
||||
/// <remarks>Get the token type of the token.</remarks>
|
||||
internal abstract int Type
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The line number on which the 1st character of this token was matched,
|
||||
/// line=1..n
|
||||
/// </summary>
|
||||
public abstract int GetLine();
|
||||
internal abstract int Line
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The index of the first character of this token relative to the
|
||||
/// beginning of the line at which it occurs, 0..n-1
|
||||
/// </summary>
|
||||
public abstract int GetCharPositionInLine();
|
||||
internal abstract int Column
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>Return the channel this token.</summary>
|
||||
/// <remarks>
|
||||
|
@ -105,7 +119,10 @@ namespace Antlr4.Runtime
|
|||
/// on a different channel, but the parser only "tunes" to a single channel.
|
||||
/// The parser ignores everything not on DEFAULT_CHANNEL.
|
||||
/// </remarks>
|
||||
public abstract int GetChannel();
|
||||
internal abstract int Channel
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>An index from 0..n-1 of the token object in the input stream.</summary>
|
||||
/// <remarks>
|
||||
|
@ -115,7 +132,10 @@ namespace Antlr4.Runtime
|
|||
/// Return -1 to indicate that this token was conjured up since
|
||||
/// it doesn't have a valid index.
|
||||
/// </remarks>
|
||||
public abstract int GetTokenIndex();
|
||||
internal abstract int TokenIndex
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The starting character index of the token
|
||||
|
@ -125,27 +145,39 @@ namespace Antlr4.Runtime
|
|||
/// The starting character index of the token
|
||||
/// This method is optional; return -1 if not implemented.
|
||||
/// </remarks>
|
||||
public abstract int GetStartIndex();
|
||||
internal abstract int StartIndex
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>The last character index of the token.</summary>
|
||||
/// <remarks>
|
||||
/// The last character index of the token.
|
||||
/// This method is optional; return -1 if not implemented.
|
||||
/// </remarks>
|
||||
public abstract int GetStopIndex();
|
||||
internal abstract int StopIndex
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the
|
||||
/// <see cref="ITokenSource">ITokenSource</see>
|
||||
/// which created this token.
|
||||
/// </summary>
|
||||
public abstract ITokenSource GetTokenSource();
|
||||
internal abstract ITokenSource TokenSource
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the
|
||||
/// <see cref="ICharStream">ICharStream</see>
|
||||
/// from which this token was derived.
|
||||
/// </summary>
|
||||
public abstract ICharStream GetInputStream();
|
||||
internal abstract ICharStream InputStream
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,9 +60,15 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
IToken NextToken();
|
||||
|
||||
int GetLine();
|
||||
int Line
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
int GetCharPositionInLine();
|
||||
int Column
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From what character stream was this token created? You don't have to
|
||||
|
@ -74,7 +80,10 @@ namespace Antlr4.Runtime
|
|||
/// implement but it's nice to know where a Token comes from if you have
|
||||
/// include files etc... on the input.
|
||||
/// </remarks>
|
||||
ICharStream GetInputStream();
|
||||
ICharStream InputStream
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where are you getting tokens from? normally the implication will simply
|
||||
|
@ -84,13 +93,18 @@ namespace Antlr4.Runtime
|
|||
/// Where are you getting tokens from? normally the implication will simply
|
||||
/// ask lexers input stream.
|
||||
/// </remarks>
|
||||
string GetSourceName();
|
||||
string SourceName
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>Gets the factory used for constructing tokens.</summary>
|
||||
/// <remarks>Gets the factory used for constructing tokens.</remarks>
|
||||
ITokenFactory GetTokenFactory();
|
||||
|
||||
/// <summary>Optional method that lets users set factory in lexer or other source</summary>
|
||||
void SetTokenFactory(ITokenFactory factory);
|
||||
ITokenFactory TokenFactory
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,8 +104,10 @@ namespace Antlr4.Runtime
|
|||
/// which provides tokens for this
|
||||
/// stream.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
ITokenSource GetTokenSource();
|
||||
ITokenSource TokenSource
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the text of all tokens within the specified
|
||||
|
@ -213,7 +215,7 @@ namespace Antlr4.Runtime
|
|||
/// token, the behavior is unspecified.
|
||||
/// <p/>
|
||||
/// For streams which ensure that the
|
||||
/// <see cref="IToken.GetTokenIndex()">IToken.GetTokenIndex()</see>
|
||||
/// <see cref="IToken.TokenIndex()">IToken.TokenIndex()</see>
|
||||
/// method is
|
||||
/// accurate for all of its provided tokens, this method behaves like the
|
||||
/// following code. Other streams may implement this method in other ways
|
||||
|
|
|
@ -34,16 +34,34 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
public interface IWritableToken : IToken
|
||||
{
|
||||
void SetText(string text);
|
||||
string Text
|
||||
{
|
||||
set;
|
||||
}
|
||||
|
||||
void SetType(int ttype);
|
||||
int Type
|
||||
{
|
||||
set;
|
||||
}
|
||||
|
||||
void SetLine(int line);
|
||||
int Line
|
||||
{
|
||||
set;
|
||||
}
|
||||
|
||||
void SetCharPositionInLine(int pos);
|
||||
int Column
|
||||
{
|
||||
set;
|
||||
}
|
||||
|
||||
void SetChannel(int channel);
|
||||
int Channel
|
||||
{
|
||||
set;
|
||||
}
|
||||
|
||||
void SetTokenIndex(int index);
|
||||
int TokenIndex
|
||||
{
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
_token = null;
|
||||
_channel = IToken.DefaultChannel;
|
||||
_tokenStartCharIndex = _input.Index();
|
||||
_tokenStartCharIndex = _input.Index;
|
||||
_tokenStartCharPositionInLine = GetInterpreter().GetCharPositionInLine();
|
||||
_tokenStartLine = GetInterpreter().GetLine();
|
||||
_text = null;
|
||||
|
@ -274,14 +274,17 @@ outer_break: ;
|
|||
return _mode;
|
||||
}
|
||||
|
||||
public virtual ITokenFactory GetTokenFactory()
|
||||
public virtual ITokenFactory TokenFactory
|
||||
{
|
||||
return _factory;
|
||||
}
|
||||
|
||||
public virtual void SetTokenFactory(ITokenFactory factory)
|
||||
{
|
||||
this._factory = factory;
|
||||
get
|
||||
{
|
||||
return _factory;
|
||||
}
|
||||
set
|
||||
{
|
||||
ITokenFactory factory = value;
|
||||
this._factory = factory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Set the char stream and reset the lexer</summary>
|
||||
|
@ -294,9 +297,12 @@ outer_break: ;
|
|||
this._tokenFactorySourcePair = Tuple.Create(this, _input);
|
||||
}
|
||||
|
||||
public virtual string GetSourceName()
|
||||
public virtual string SourceName
|
||||
{
|
||||
return _input.GetSourceName();
|
||||
get
|
||||
{
|
||||
return _input.SourceName;
|
||||
}
|
||||
}
|
||||
|
||||
public override IIntStream GetInputStream()
|
||||
|
@ -341,28 +347,34 @@ outer_break: ;
|
|||
|
||||
public virtual IToken EmitEOF()
|
||||
{
|
||||
int cpos = GetCharPositionInLine();
|
||||
int cpos = Column;
|
||||
// The character position for EOF is one beyond the position of
|
||||
// the previous token's last character
|
||||
if (_token != null)
|
||||
{
|
||||
int n = _token.GetStopIndex() - _token.GetStartIndex() + 1;
|
||||
cpos = _token.GetCharPositionInLine() + n;
|
||||
int n = _token.StopIndex - _token.StartIndex + 1;
|
||||
cpos = _token.Column + n;
|
||||
}
|
||||
IToken eof = _factory.Create(_tokenFactorySourcePair, IToken.Eof, null, IToken.DefaultChannel
|
||||
, _input.Index(), _input.Index() - 1, GetLine(), cpos);
|
||||
, _input.Index, _input.Index - 1, Line, cpos);
|
||||
Emit(eof);
|
||||
return eof;
|
||||
}
|
||||
|
||||
public virtual int GetLine()
|
||||
public virtual int Line
|
||||
{
|
||||
return GetInterpreter().GetLine();
|
||||
get
|
||||
{
|
||||
return GetInterpreter().GetLine();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int GetCharPositionInLine()
|
||||
public virtual int Column
|
||||
{
|
||||
return GetInterpreter().GetCharPositionInLine();
|
||||
get
|
||||
{
|
||||
return GetInterpreter().GetCharPositionInLine();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetLine(int line)
|
||||
|
@ -378,7 +390,7 @@ outer_break: ;
|
|||
/// <summary>What is the index of the current character of lookahead?</summary>
|
||||
public virtual int GetCharIndex()
|
||||
{
|
||||
return _input.Index();
|
||||
return _input.Index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -471,7 +483,7 @@ outer_break: ;
|
|||
{
|
||||
IList<IToken> tokens = new List<IToken>();
|
||||
IToken t = NextToken();
|
||||
while (t.GetType() != IToken.Eof)
|
||||
while (t.Type != IToken.Eof)
|
||||
{
|
||||
tokens.AddItem(t);
|
||||
t = NextToken();
|
||||
|
@ -490,7 +502,7 @@ outer_break: ;
|
|||
|
||||
public virtual void NotifyListeners(LexerNoViableAltException e)
|
||||
{
|
||||
string text = _input.GetText(Interval.Of(_tokenStartCharIndex, _input.Index()));
|
||||
string text = _input.GetText(Interval.Of(_tokenStartCharIndex, _input.Index));
|
||||
string msg = "token recognition error at: '" + GetErrorDisplay(text) + "'";
|
||||
IAntlrErrorListener<int> listener = GetErrorListenerDispatch();
|
||||
listener.SyntaxError(this, null, _tokenStartLine, _tokenStartCharPositionInLine,
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Antlr4.Runtime
|
|||
public override string ToString()
|
||||
{
|
||||
string symbol = string.Empty;
|
||||
if (startIndex >= 0 && startIndex < ((ICharStream)GetInputStream()).Size())
|
||||
if (startIndex >= 0 && startIndex < ((ICharStream)GetInputStream()).Size)
|
||||
{
|
||||
symbol = ((ICharStream)GetInputStream()).GetText(Interval.Of(startIndex, startIndex
|
||||
));
|
||||
|
|
|
@ -742,7 +742,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
foreach (Transition transition in state.GetTransitions())
|
||||
{
|
||||
if (transition.GetSerializationType() != Transition.Rule)
|
||||
if (transition.SerializationType != Transition.Rule)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ namespace Antlr4.Runtime
|
|||
public virtual void EnterEveryRule(ParserRuleContext ctx)
|
||||
{
|
||||
System.Console.Out.WriteLine("enter " + this._enclosing.GetRuleNames()[ctx.GetRuleIndex
|
||||
()] + ", LT(1)=" + this._enclosing._input.Lt(1).GetText());
|
||||
()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text);
|
||||
}
|
||||
|
||||
public virtual void ExitEveryRule(ParserRuleContext ctx)
|
||||
{
|
||||
System.Console.Out.WriteLine("exit " + this._enclosing.GetRuleNames()[ctx.GetRuleIndex
|
||||
()] + ", LT(1)=" + this._enclosing._input.Lt(1).GetText());
|
||||
()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text);
|
||||
}
|
||||
|
||||
public virtual void VisitErrorNode(IErrorNode node)
|
||||
|
@ -64,8 +64,8 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual void VisitTerminal(ITerminalNode node)
|
||||
{
|
||||
ParserRuleContext parent = (ParserRuleContext)node.GetParent().GetRuleContext();
|
||||
IToken token = node.GetSymbol();
|
||||
ParserRuleContext parent = (ParserRuleContext)((IRuleNode)node.Parent).RuleContext;
|
||||
IToken token = node.Symbol;
|
||||
System.Console.Out.WriteLine("consume " + token + " rule " + this._enclosing.GetRuleNames
|
||||
()[parent.GetRuleIndex()] + " alt=" + parent.altNum);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace Antlr4.Runtime
|
|||
public virtual IToken Match(int ttype)
|
||||
{
|
||||
IToken t = GetCurrentToken();
|
||||
if (t.GetType() == ttype)
|
||||
if (t.Type == ttype)
|
||||
{
|
||||
_errHandler.EndErrorCondition(this);
|
||||
Consume();
|
||||
|
@ -190,7 +190,7 @@ namespace Antlr4.Runtime
|
|||
else
|
||||
{
|
||||
t = _errHandler.RecoverInline(this);
|
||||
if (_buildParseTrees && t.GetTokenIndex() == -1)
|
||||
if (_buildParseTrees && t.TokenIndex == -1)
|
||||
{
|
||||
// we must have conjured up a new token during single token insertion
|
||||
// if it's not the current symbol
|
||||
|
@ -204,7 +204,7 @@ namespace Antlr4.Runtime
|
|||
public virtual IToken MatchWildcard()
|
||||
{
|
||||
IToken t = GetCurrentToken();
|
||||
if (t.GetType() > 0)
|
||||
if (t.Type > 0)
|
||||
{
|
||||
_errHandler.EndErrorCondition(this);
|
||||
Consume();
|
||||
|
@ -212,7 +212,7 @@ namespace Antlr4.Runtime
|
|||
else
|
||||
{
|
||||
t = _errHandler.RecoverInline(this);
|
||||
if (_buildParseTrees && t.GetTokenIndex() == -1)
|
||||
if (_buildParseTrees && t.TokenIndex == -1)
|
||||
{
|
||||
// we must have conjured up a new token during single token insertion
|
||||
// if it's not the current symbol
|
||||
|
@ -464,8 +464,8 @@ namespace Antlr4.Runtime
|
|||
int charPositionInLine = -1;
|
||||
if (offendingToken != null)
|
||||
{
|
||||
line = offendingToken.GetLine();
|
||||
charPositionInLine = offendingToken.GetCharPositionInLine();
|
||||
line = offendingToken.Line;
|
||||
charPositionInLine = offendingToken.Column;
|
||||
}
|
||||
IAntlrErrorListener<IToken> listener = ((IParserErrorListener)GetErrorListenerDispatch
|
||||
());
|
||||
|
@ -486,7 +486,7 @@ namespace Antlr4.Runtime
|
|||
public virtual IToken Consume()
|
||||
{
|
||||
IToken o = GetCurrentToken();
|
||||
if (o.GetType() != Eof)
|
||||
if (o.Type != Eof)
|
||||
{
|
||||
((ITokenStream)GetInputStream()).Consume();
|
||||
}
|
||||
|
@ -559,8 +559,8 @@ namespace Antlr4.Runtime
|
|||
SetState(state);
|
||||
if (_buildParseTrees)
|
||||
{
|
||||
ParserRuleContext factoredContext = (ParserRuleContext)_ctx.GetChild(_ctx.GetChildCount
|
||||
() - 1);
|
||||
ParserRuleContext factoredContext = (ParserRuleContext)_ctx.GetChild(_ctx.ChildCount
|
||||
- 1);
|
||||
_ctx.RemoveLastChild();
|
||||
factoredContext.parent = localctx;
|
||||
localctx.AddChild(factoredContext);
|
||||
|
@ -868,7 +868,7 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual string GetSourceName()
|
||||
{
|
||||
return _input.GetSourceName();
|
||||
return _input.SourceName;
|
||||
}
|
||||
|
||||
/// <summary>A convenience method for use most often with template rewrites.</summary>
|
||||
|
@ -885,7 +885,7 @@ namespace Antlr4.Runtime
|
|||
IList<string> strings = new List<string>(tokens.Count);
|
||||
for (int i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
strings.AddItem(tokens[i].GetText());
|
||||
strings.AddItem(tokens[i].Text);
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
|
|
@ -223,9 +223,12 @@ namespace Antlr4.Runtime
|
|||
return t;
|
||||
}
|
||||
|
||||
public override RuleContext GetParent()
|
||||
public override RuleContext Parent
|
||||
{
|
||||
return (Antlr4.Runtime.ParserRuleContext)base.GetParent();
|
||||
get
|
||||
{
|
||||
return (Antlr4.Runtime.ParserRuleContext)base.Parent;
|
||||
}
|
||||
}
|
||||
|
||||
public override IParseTree GetChild(int i)
|
||||
|
@ -269,8 +272,8 @@ namespace Antlr4.Runtime
|
|||
if (o is ITerminalNode)
|
||||
{
|
||||
ITerminalNode tnode = (ITerminalNode)o;
|
||||
IToken symbol = tnode.GetSymbol();
|
||||
if (symbol.GetType() == ttype)
|
||||
IToken symbol = tnode.Symbol;
|
||||
if (symbol.Type == ttype)
|
||||
{
|
||||
j++;
|
||||
if (j == i)
|
||||
|
@ -295,8 +298,8 @@ namespace Antlr4.Runtime
|
|||
if (o is ITerminalNode)
|
||||
{
|
||||
ITerminalNode tnode = (ITerminalNode)o;
|
||||
IToken symbol = tnode.GetSymbol();
|
||||
if (symbol.GetType() == ttype)
|
||||
IToken symbol = tnode.Symbol;
|
||||
if (symbol.Type == ttype)
|
||||
{
|
||||
if (tokens == null)
|
||||
{
|
||||
|
@ -345,18 +348,24 @@ namespace Antlr4.Runtime
|
|||
return contexts;
|
||||
}
|
||||
|
||||
public override int GetChildCount()
|
||||
public override int ChildCount
|
||||
{
|
||||
return children != null ? children.Count : 0;
|
||||
get
|
||||
{
|
||||
return children != null ? children.Count : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override Interval GetSourceInterval()
|
||||
public override Interval SourceInterval
|
||||
{
|
||||
if (start == null || stop == null)
|
||||
get
|
||||
{
|
||||
return Interval.Invalid;
|
||||
if (start == null || stop == null)
|
||||
{
|
||||
return Interval.Invalid;
|
||||
}
|
||||
return Interval.Of(start.TokenIndex, stop.TokenIndex);
|
||||
}
|
||||
return Interval.Of(start.GetTokenIndex(), stop.GetTokenIndex());
|
||||
}
|
||||
|
||||
public virtual IToken GetStart()
|
||||
|
|
|
@ -96,8 +96,8 @@ namespace Antlr4.Runtime
|
|||
/// <summary>What is the error header, normally line/character position information?</summary>
|
||||
public virtual string GetErrorHeader(RecognitionException e)
|
||||
{
|
||||
int line = e.GetOffendingToken().GetLine();
|
||||
int charPositionInLine = e.GetOffendingToken().GetCharPositionInLine();
|
||||
int line = e.GetOffendingToken().Line;
|
||||
int charPositionInLine = e.GetOffendingToken().Column;
|
||||
return "line " + line + ":" + charPositionInLine;
|
||||
}
|
||||
|
||||
|
@ -121,16 +121,16 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
return "<no token>";
|
||||
}
|
||||
string s = t.GetText();
|
||||
string s = t.Text;
|
||||
if (s == null)
|
||||
{
|
||||
if (t.GetType() == IToken.Eof)
|
||||
if (t.Type == IToken.Eof)
|
||||
{
|
||||
s = "<EOF>";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = "<" + t.GetType() + ">";
|
||||
s = "<" + t.Type + ">";
|
||||
}
|
||||
}
|
||||
s = s.ReplaceAll("\n", "\\\\n");
|
||||
|
|
|
@ -116,25 +116,37 @@ namespace Antlr4.Runtime
|
|||
return invokingState == -1;
|
||||
}
|
||||
|
||||
// satisfy the ParseTree / SyntaxTree interface
|
||||
public virtual Interval GetSourceInterval()
|
||||
public virtual Interval SourceInterval
|
||||
{
|
||||
return Interval.Invalid;
|
||||
get
|
||||
{
|
||||
// satisfy the ParseTree / SyntaxTree interface
|
||||
return Interval.Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Antlr4.Runtime.RuleContext GetRuleContext()
|
||||
public virtual Antlr4.Runtime.RuleContext RuleContext
|
||||
{
|
||||
return this;
|
||||
get
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Antlr4.Runtime.RuleContext GetParent()
|
||||
public virtual Antlr4.Runtime.RuleContext Parent
|
||||
{
|
||||
return parent;
|
||||
get
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Antlr4.Runtime.RuleContext GetPayload()
|
||||
public virtual Antlr4.Runtime.RuleContext Payload
|
||||
{
|
||||
return this;
|
||||
get
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Return the combined text of all child nodes.</summary>
|
||||
|
@ -148,12 +160,12 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
public virtual string GetText()
|
||||
{
|
||||
if (GetChildCount() == 0)
|
||||
if (ChildCount == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < GetChildCount(); i++)
|
||||
for (int i = 0; i < ChildCount; i++)
|
||||
{
|
||||
builder.Append(GetChild(i).GetText());
|
||||
}
|
||||
|
@ -170,9 +182,12 @@ namespace Antlr4.Runtime
|
|||
return null;
|
||||
}
|
||||
|
||||
public virtual int GetChildCount()
|
||||
public virtual int ChildCount
|
||||
{
|
||||
return 0;
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T Accept<T, _T1>(IParseTreeVisitor<_T1> visitor) where _T1:T
|
||||
|
|
|
@ -156,9 +156,9 @@ namespace Antlr4.Runtime
|
|||
public override int Execute(StringBuilder buf)
|
||||
{
|
||||
buf.Append(text);
|
||||
if (tokens.Get(index).GetType() != IToken.Eof)
|
||||
if (tokens.Get(index).Type != IToken.Eof)
|
||||
{
|
||||
buf.Append(tokens.Get(index).GetText());
|
||||
buf.Append(tokens.Get(index).Text);
|
||||
}
|
||||
return index + 1;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual void InsertAfter(string programName, IToken t, object text)
|
||||
{
|
||||
InsertAfter(programName, t.GetTokenIndex(), text);
|
||||
InsertAfter(programName, t.TokenIndex, text);
|
||||
}
|
||||
|
||||
public virtual void InsertAfter(string programName, int index, object text)
|
||||
|
@ -299,7 +299,7 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual void InsertBefore(string programName, IToken t, object text)
|
||||
{
|
||||
InsertBefore(programName, t.GetTokenIndex(), text);
|
||||
InsertBefore(programName, t.TokenIndex, text);
|
||||
}
|
||||
|
||||
public virtual void InsertBefore(string programName, int index, object text)
|
||||
|
@ -333,10 +333,10 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual void Replace(string programName, int from, int to, object text)
|
||||
{
|
||||
if (from > to || from < 0 || to < 0 || to >= tokens.Size())
|
||||
if (from > to || from < 0 || to < 0 || to >= tokens.Size)
|
||||
{
|
||||
throw new ArgumentException("replace: range invalid: " + from + ".." + to + "(size="
|
||||
+ tokens.Size() + ")");
|
||||
+ tokens.Size + ")");
|
||||
}
|
||||
TokenStreamRewriter.RewriteOperation op = new TokenStreamRewriter.ReplaceOp(tokens
|
||||
, from, to, text);
|
||||
|
@ -348,7 +348,7 @@ namespace Antlr4.Runtime
|
|||
public virtual void Replace(string programName, IToken from, IToken to, object text
|
||||
)
|
||||
{
|
||||
Replace(programName, from.GetTokenIndex(), to.GetTokenIndex(), text);
|
||||
Replace(programName, from.TokenIndex, to.TokenIndex, text);
|
||||
}
|
||||
|
||||
public virtual void Delete(int index)
|
||||
|
@ -432,7 +432,7 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
public virtual string GetText()
|
||||
{
|
||||
return GetText(DefaultProgramName, Interval.Of(0, tokens.Size() - 1));
|
||||
return GetText(DefaultProgramName, Interval.Of(0, tokens.Size - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -460,9 +460,9 @@ namespace Antlr4.Runtime
|
|||
int start = interval.a;
|
||||
int stop = interval.b;
|
||||
// ensure start/end are in range
|
||||
if (stop > tokens.Size() - 1)
|
||||
if (stop > tokens.Size - 1)
|
||||
{
|
||||
stop = tokens.Size() - 1;
|
||||
stop = tokens.Size - 1;
|
||||
}
|
||||
if (start < 0)
|
||||
{
|
||||
|
@ -479,7 +479,7 @@ namespace Antlr4.Runtime
|
|||
(rewrites);
|
||||
// Walk buffer, executing instructions and emitting tokens
|
||||
int i = start;
|
||||
while (i <= stop && i < tokens.Size())
|
||||
while (i <= stop && i < tokens.Size)
|
||||
{
|
||||
TokenStreamRewriter.RewriteOperation op = indexToOp.Get(i);
|
||||
Sharpen.Collections.Remove(indexToOp, i);
|
||||
|
@ -488,9 +488,9 @@ namespace Antlr4.Runtime
|
|||
if (op == null)
|
||||
{
|
||||
// no operation at that index, just dump token
|
||||
if (t.GetType() != IToken.Eof)
|
||||
if (t.Type != IToken.Eof)
|
||||
{
|
||||
buf.Append(t.GetText());
|
||||
buf.Append(t.Text);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -504,13 +504,13 @@ namespace Antlr4.Runtime
|
|||
// include stuff after end if it's last index in buffer
|
||||
// So, if they did an insertAfter(lastValidIndex, "foo"), include
|
||||
// foo if end==lastValidIndex.
|
||||
if (stop == tokens.Size() - 1)
|
||||
if (stop == tokens.Size - 1)
|
||||
{
|
||||
// Scan any remaining operations after last token
|
||||
// should be included (they will be inserts).
|
||||
foreach (TokenStreamRewriter.RewriteOperation op in indexToOp.Values)
|
||||
{
|
||||
if (op.index >= tokens.Size() - 1)
|
||||
if (op.index >= tokens.Size - 1)
|
||||
{
|
||||
buf.Append(op.text);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Antlr4.Runtime.Tree
|
|||
public virtual Result VisitChildren(IRuleNode node)
|
||||
{
|
||||
Result result = DefaultResult();
|
||||
int n = node.GetChildCount();
|
||||
int n = node.ChildCount;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (!ShouldVisitNextChild(node, result))
|
||||
|
|
|
@ -49,9 +49,12 @@ namespace Antlr4.Runtime.Tree
|
|||
/// </summary>
|
||||
public interface IParseTree : ISyntaxTree
|
||||
{
|
||||
// the following methods narrow the return type; they are not additional methods
|
||||
IParseTree GetParent();
|
||||
IParseTree Parent
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
// the following methods narrow the return type; they are not additional methods
|
||||
IParseTree GetChild(int i);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using Antlr4.Runtime;
|
||||
using Antlr4.Runtime.Tree;
|
||||
using Sharpen;
|
||||
|
||||
|
@ -35,8 +34,14 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
public interface IRuleNode : IParseTree
|
||||
{
|
||||
RuleContext GetRuleContext();
|
||||
Antlr4.Runtime.RuleContext RuleContext
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
IRuleNode GetParent();
|
||||
IRuleNode Parent
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,9 @@ namespace Antlr4.Runtime.Tree
|
|||
/// </see>
|
||||
/// .
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
Interval GetSourceInterval();
|
||||
Interval SourceInterval
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,14 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
public interface ITerminalNode : IParseTree
|
||||
{
|
||||
IToken GetSymbol();
|
||||
IToken Symbol
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
IRuleNode GetParent();
|
||||
IRuleNode Parent
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,10 @@ namespace Antlr4.Runtime.Tree
|
|||
/// The parent of this node. If the return value is null, then this
|
||||
/// node is the root of the tree.
|
||||
/// </remarks>
|
||||
ITree GetParent();
|
||||
ITree Parent
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>This method returns whatever object represents the data at this note.</summary>
|
||||
/// <remarks>
|
||||
|
@ -60,7 +63,10 @@ namespace Antlr4.Runtime.Tree
|
|||
/// <see cref="Antlr4.Runtime.IToken">Antlr4.Runtime.IToken</see>
|
||||
/// object.
|
||||
/// </remarks>
|
||||
object GetPayload();
|
||||
object Payload
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If there are children, get the
|
||||
|
@ -77,7 +83,10 @@ namespace Antlr4.Runtime.Tree
|
|||
/// How many children are there? If there is none, then this
|
||||
/// node represents a leaf node.
|
||||
/// </remarks>
|
||||
int GetChildCount();
|
||||
int ChildCount
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print out a whole tree, not just a node, in LISP format
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Antlr4.Runtime.Tree
|
|||
}
|
||||
IRuleNode r = (IRuleNode)t;
|
||||
EnterRule(listener, r);
|
||||
int n = r.GetChildCount();
|
||||
int n = r.ChildCount;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
Walk(listener, r.GetChild(i));
|
||||
|
@ -74,7 +74,7 @@ namespace Antlr4.Runtime.Tree
|
|||
protected internal virtual void EnterRule(IParseTreeListener listener, IRuleNode
|
||||
r)
|
||||
{
|
||||
ParserRuleContext ctx = (ParserRuleContext)r.GetRuleContext();
|
||||
ParserRuleContext ctx = (ParserRuleContext)r.RuleContext;
|
||||
listener.EnterEveryRule(ctx);
|
||||
ctx.EnterRule(listener);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace Antlr4.Runtime.Tree
|
|||
protected internal virtual void ExitRule(IParseTreeListener listener, IRuleNode r
|
||||
)
|
||||
{
|
||||
ParserRuleContext ctx = (ParserRuleContext)r.GetRuleContext();
|
||||
ParserRuleContext ctx = (ParserRuleContext)r.RuleContext;
|
||||
ctx.ExitRule(listener);
|
||||
listener.ExitEveryRule(ctx);
|
||||
}
|
||||
|
|
|
@ -50,34 +50,49 @@ namespace Antlr4.Runtime.Tree
|
|||
return null;
|
||||
}
|
||||
|
||||
public virtual IToken GetSymbol()
|
||||
public virtual IToken Symbol
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public virtual IRuleNode GetParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public virtual IToken GetPayload()
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public virtual Interval GetSourceInterval()
|
||||
{
|
||||
if (symbol != null)
|
||||
get
|
||||
{
|
||||
int tokenIndex = symbol.GetTokenIndex();
|
||||
return new Interval(tokenIndex, tokenIndex);
|
||||
return symbol;
|
||||
}
|
||||
return Interval.Invalid;
|
||||
}
|
||||
|
||||
public virtual int GetChildCount()
|
||||
public virtual IRuleNode Parent
|
||||
{
|
||||
return 0;
|
||||
get
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IToken Payload
|
||||
{
|
||||
get
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Interval SourceInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
if (symbol != null)
|
||||
{
|
||||
int tokenIndex = symbol.TokenIndex;
|
||||
return new Interval(tokenIndex, tokenIndex);
|
||||
}
|
||||
return Interval.Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int ChildCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T Accept<T, _T1>(IParseTreeVisitor<_T1> visitor) where _T1:T
|
||||
|
@ -89,7 +104,7 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
if (symbol != null)
|
||||
{
|
||||
return symbol.GetText();
|
||||
return symbol.Text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -103,11 +118,11 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
if (symbol != null)
|
||||
{
|
||||
if (symbol.GetType() == IToken.Eof)
|
||||
if (symbol.Type == IToken.Eof)
|
||||
{
|
||||
return "<EOF>";
|
||||
}
|
||||
return symbol.GetText();
|
||||
return symbol.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Antlr4.Runtime.Tree
|
|||
public static string ToStringTree(ITree t, IList<string> ruleNames)
|
||||
{
|
||||
string s = Utils.EscapeWhitespace(GetNodeText(t, ruleNames), false);
|
||||
if (t.GetChildCount() == 0)
|
||||
if (t.ChildCount == 0)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ namespace Antlr4.Runtime.Tree
|
|||
s = Utils.EscapeWhitespace(GetNodeText(t, ruleNames), false);
|
||||
buf.Append(s);
|
||||
buf.Append(' ');
|
||||
for (int i = 0; i < t.GetChildCount(); i++)
|
||||
for (int i = 0; i < t.ChildCount; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
if (t is IRuleNode)
|
||||
{
|
||||
int ruleIndex = ((IRuleNode)t).GetRuleContext().GetRuleIndex();
|
||||
int ruleIndex = ((IRuleNode)t).RuleContext.GetRuleIndex();
|
||||
string ruleName = ruleNames[ruleIndex];
|
||||
return ruleName;
|
||||
}
|
||||
|
@ -162,10 +162,10 @@ namespace Antlr4.Runtime.Tree
|
|||
{
|
||||
if (t is ITerminalNode)
|
||||
{
|
||||
object symbol = ((ITerminalNode)t).GetSymbol();
|
||||
object symbol = ((ITerminalNode)t).Symbol;
|
||||
if (symbol is IToken)
|
||||
{
|
||||
string s = ((IToken)symbol).GetText();
|
||||
string s = ((IToken)symbol).Text;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -173,12 +173,12 @@ namespace Antlr4.Runtime.Tree
|
|||
}
|
||||
}
|
||||
// no recog for rule names
|
||||
object payload = t.GetPayload();
|
||||
object payload = t.Payload;
|
||||
if (payload is IToken)
|
||||
{
|
||||
return ((IToken)payload).GetText();
|
||||
return ((IToken)payload).Text;
|
||||
}
|
||||
return t.GetPayload().ToString();
|
||||
return t.Payload.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Return a list of all ancestors of this node.</summary>
|
||||
|
@ -189,17 +189,17 @@ namespace Antlr4.Runtime.Tree
|
|||
[NotNull]
|
||||
public static IList<ITree> GetAncestors(ITree t)
|
||||
{
|
||||
if (t.GetParent() == null)
|
||||
if (t.Parent == null)
|
||||
{
|
||||
return Sharpen.Collections.EmptyList();
|
||||
}
|
||||
IList<ITree> ancestors = new List<ITree>();
|
||||
t = t.GetParent();
|
||||
t = t.Parent;
|
||||
while (t != null)
|
||||
{
|
||||
ancestors.Add(0, t);
|
||||
// insert at start
|
||||
t = t.GetParent();
|
||||
t = t.Parent;
|
||||
}
|
||||
return ancestors;
|
||||
}
|
||||
|
|
|
@ -342,9 +342,12 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int Index()
|
||||
public virtual int Index
|
||||
{
|
||||
return currentCharIndex;
|
||||
get
|
||||
{
|
||||
return currentCharIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -396,14 +399,20 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int Size()
|
||||
public virtual int Size
|
||||
{
|
||||
throw new NotSupportedException("Unbuffered stream cannot know its size");
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException("Unbuffered stream cannot know its size");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetSourceName()
|
||||
public virtual string SourceName
|
||||
{
|
||||
return name;
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetText(Interval interval)
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
if (index >= n)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(n > 0 && tokens[n - 1].GetType() == IToken.Eof);
|
||||
System.Diagnostics.Debug.Assert(n > 0 && tokens[n - 1].Type == IToken.Eof);
|
||||
return tokens[n - 1];
|
||||
}
|
||||
return tokens[index];
|
||||
|
@ -175,12 +175,15 @@ namespace Antlr4.Runtime
|
|||
|
||||
public virtual int La(int i)
|
||||
{
|
||||
return Lt(i).GetType();
|
||||
return Lt(i).Type;
|
||||
}
|
||||
|
||||
public virtual ITokenSource GetTokenSource()
|
||||
public virtual ITokenSource TokenSource
|
||||
{
|
||||
return tokenSource;
|
||||
get
|
||||
{
|
||||
return tokenSource;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
|
@ -192,7 +195,7 @@ namespace Antlr4.Runtime
|
|||
[NotNull]
|
||||
public virtual string GetText(RuleContext ctx)
|
||||
{
|
||||
return GetText(ctx.GetSourceInterval());
|
||||
return GetText(ctx.SourceInterval);
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
|
@ -200,7 +203,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
if (start != null && stop != null)
|
||||
{
|
||||
return GetText(Interval.Of(start.GetTokenIndex(), stop.GetTokenIndex()));
|
||||
return GetText(Interval.Of(start.TokenIndex, stop.TokenIndex));
|
||||
}
|
||||
throw new NotSupportedException("The specified start and stop symbols are not supported."
|
||||
);
|
||||
|
@ -269,7 +272,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (this.n > 0 && tokens[this.n - 1].GetType() == IToken.Eof)
|
||||
if (this.n > 0 && tokens[this.n - 1].Type == IToken.Eof)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
@ -287,7 +290,7 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
if (t is IWritableToken)
|
||||
{
|
||||
((IWritableToken)t).SetTokenIndex(GetBufferStartIndex() + n);
|
||||
((IWritableToken)t).TokenIndex = GetBufferStartIndex() + n;
|
||||
}
|
||||
tokens[n++] = t;
|
||||
}
|
||||
|
@ -338,9 +341,12 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int Index()
|
||||
public virtual int Index
|
||||
{
|
||||
return currentTokenIndex;
|
||||
get
|
||||
{
|
||||
return currentTokenIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Seek(int index)
|
||||
|
@ -381,14 +387,20 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int Size()
|
||||
public virtual int Size
|
||||
{
|
||||
throw new NotSupportedException("Unbuffered stream cannot know its size");
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException("Unbuffered stream cannot know its size");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetSourceName()
|
||||
public virtual string SourceName
|
||||
{
|
||||
return tokenSource.GetSourceName();
|
||||
get
|
||||
{
|
||||
return tokenSource.SourceName;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
|
@ -409,7 +421,7 @@ namespace Antlr4.Runtime
|
|||
for (int i = a; i <= b; i++)
|
||||
{
|
||||
IToken t = tokens[i];
|
||||
buf.Append(t.GetText());
|
||||
buf.Append(t.Text);
|
||||
}
|
||||
return buf.ToString();
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c7dc3828fc49781d3015565db387f37c38137ee6
|
||||
Subproject commit 88652241cf2c248a66307e5866be98e3910b6519
|
Loading…
Reference in New Issue