From 0af96112158a0c05159d4de527dfebeb519131fe Mon Sep 17 00:00:00 2001 From: Edir Garcia Lazo Date: Thu, 18 Oct 2018 11:16:55 -0700 Subject: [PATCH 1/2] Properly build and pass in decisionToDFA --- contributors.txt | 3 ++- .../CSharp/Antlr4.Runtime/ParserInterpreter.cs | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/contributors.txt b/contributors.txt index 3a223169c..235746cd5 100644 --- a/contributors.txt +++ b/contributors.txt @@ -192,4 +192,5 @@ YYYY/MM/DD, github id, Full name, email 2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com 2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com 2018/07/27, Maksim Novikov, mnovikov.work@gmail.com -2018/08/03, ENDOH takanao, djmchl@gmail.com \ No newline at end of file +2018/08/03, ENDOH takanao, djmchl@gmail.com +2018/10/18, edirgarcia, Edir GarcĂ­a Lazo, edirgl@hotmail.com \ No newline at end of file diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs index ff50eafd7..6aeedf2e4 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs @@ -31,6 +31,8 @@ namespace Antlr4.Runtime private readonly string _grammarFileName; private readonly ATN _atn; + + private readonly Dfa.DFA[] _decisionToDFA; protected internal readonly BitSet pushRecursionContextStates; @@ -61,8 +63,17 @@ namespace Antlr4.Runtime this.pushRecursionContextStates.Set(state.stateNumber); } } - // get atn simulator that knows how to do predictions - Interpreter = new ParserATNSimulator(this, atn, null, null); + + //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 + Interpreter = new ParserATNSimulator(this, atn, _decisionToDFA, null); } public override ATN Atn From 9a42ff33f4d87eb16eaa742f1cf59d002028d7ca Mon Sep 17 00:00:00 2001 From: Edir Garcia Lazo Date: Thu, 18 Oct 2018 11:20:38 -0700 Subject: [PATCH 2/2] Use proper spacing formatting for this repo --- .../CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs index 6aeedf2e4..e7b0c701b 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs @@ -32,7 +32,7 @@ namespace Antlr4.Runtime private readonly ATN _atn; - private readonly Dfa.DFA[] _decisionToDFA; + private readonly Dfa.DFA[] _decisionToDFA; protected internal readonly BitSet pushRecursionContextStates;