Merge pull request #2382 from edirgarcia/master

Properly build decisionToDFA
This commit is contained in:
Terence Parr 2019-06-23 15:45:21 -07:00 committed by GitHub
commit a770ff26cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -203,6 +203,8 @@ YYYY/MM/DD, github id, Full name, email
2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com 2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com
2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com 2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com
2018/07/27, Maksim Novikov, mnovikov.work@gmail.com 2018/07/27, Maksim Novikov, mnovikov.work@gmail.com
2018/08/03, ENDOH takanao, djmchl@gmail.com
2018/10/18, edirgarcia, Edir García Lazo, edirgl@hotmail.com
2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com 2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com
2018/08/03, ENDOH takanao, djmchl@gmail.com 2018/08/03, ENDOH takanao, djmchl@gmail.com
2018/10/29, chrisaycock, Christopher Aycock, chris[at]chrisaycock[dot]com 2018/10/29, chrisaycock, Christopher Aycock, chris[at]chrisaycock[dot]com

View File

@ -32,6 +32,8 @@ namespace Antlr4.Runtime
private readonly ATN _atn; private readonly ATN _atn;
private readonly Dfa.DFA[] _decisionToDFA;
protected internal readonly BitSet pushRecursionContextStates; protected internal readonly BitSet pushRecursionContextStates;
private readonly string[] _ruleNames; private readonly string[] _ruleNames;
@ -61,8 +63,17 @@ namespace Antlr4.Runtime
this.pushRecursionContextStates.Set(state.stateNumber); this.pushRecursionContextStates.Set(state.stateNumber);
} }
} }
//init decision DFA
int numberofDecisions = atn.NumberOfDecisions;
this._decisionToDFA = new Dfa.DFA[numberofDecisions];
for (int i = 0; i < numberofDecisions; i++)
{
DecisionState decisionState = atn.GetDecisionState(i);
_decisionToDFA[i] = new Dfa.DFA(decisionState, i);
}
// get atn simulator that knows how to do predictions // get atn simulator that knows how to do predictions
Interpreter = new ParserATNSimulator(this, atn, null, null); Interpreter = new ParserATNSimulator(this, atn, _decisionToDFA, null);
} }
public override ATN Atn public override ATN Atn