@@ -1116,6 +1116,8 @@ void createParseFunction(ref CodeWriter code, LRGraph graph, size_t stateNr, con
1116
1116
foreach (i, s; node.backtrackStates)
1117
1117
{
1118
1118
prods ~= grammar.productionString(productions[i]);
1119
+ if (i == 0 )
1120
+ code.writeln(" lastError = null;" );
1119
1121
mixin (genCode(" code" , q{
1120
1122
// try $(s) $(grammar.productionString(productions[i]))
1121
1123
try
@@ -1125,25 +1127,30 @@ void createParseFunction(ref CodeWriter code, LRGraph graph, size_t stateNr, con
1125
1127
gotoParent = $(parseFunctionName(graph, s))(r, rl);
1126
1128
if (gotoParent < 0 )
1127
1129
{
1128
- throw lastError;
1130
+ assert ( lastError ! is null ) ;
1129
1131
}
1130
- if ($(tokenSetCode(grammar, node.elements[0 ].lookahead, " lexer" , true )))
1132
+ else if ($(tokenSetCode(grammar, node.elements[0 ].lookahead, " lexer" , true )))
1131
1133
{
1132
- throw new SingleParseException! Location(text(" unexpected \" " , lexer.front.content, " \" \" " , lexer.tokenName(lexer.front.symbol), " \" " ), lexer.front.currentLocation, lexer.front.currentTokenEnd);
1134
+ lastError = new SingleParseException! Location(text(" unexpected \" " , lexer.front.content, " \" \" " , lexer.tokenName(lexer.front.symbol), " \" " ), lexer.front.currentLocation, lexer.front.currentTokenEnd);
1135
+ }
1136
+ else
1137
+ {
1138
+ result = r;
1139
+ resultLocation = rl;
1140
+ return gotoParent;
1133
1141
}
1134
- result = r;
1135
- resultLocation = rl;
1136
- return gotoParent;
1137
1142
}
1138
1143
catch (ParseException e)
1139
1144
{
1140
1145
if (! e.allowBacktrack())
1141
1146
throw e;
1142
- lastError = null ;
1143
- * lexer = savedLexer;
1144
- lastTokenEnd = savedLastTokenEnd;
1145
- exceptions[$(i)] = e;
1147
+ lastError = e;
1146
1148
}
1149
+ assert (lastError ! is null );
1150
+ * lexer = savedLexer;
1151
+ lastTokenEnd = savedLastTokenEnd;
1152
+ exceptions[$(i)] = lastError;
1153
+ lastError = null ;
1147
1154
}));
1148
1155
}
1149
1156
mixin (genCode(" code" , q{
0 commit comments