From 95070280bac6f1a7fb6fa7af3f885ae3a01cd5e9 Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Mon, 18 Mar 2019 13:38:25 +0700 Subject: [PATCH] allow bracket in parameter name #25 --- src/NCalc/NCalcLexer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NCalc/NCalcLexer.cs b/src/NCalc/NCalcLexer.cs index ebdbb43..2d036fc 100644 --- a/src/NCalc/NCalcLexer.cs +++ b/src/NCalc/NCalcLexer.cs @@ -1804,18 +1804,25 @@ private void mNAME() DebugLocation(265, 39); // C:\\Users\\sebros\\My Projects\\NCalc\\Grammar\\NCalc.g:265:39: (~ ( ']' ) )* try { DebugEnterSubRule(10); + int opened = 0; while (true) { int alt10=2; try { DebugEnterDecision(10, decisionCanBacktrack[10]); int LA10_0 = input.LA(1); - if (((LA10_0>='\u0000' && LA10_0<='\\')||(LA10_0>='^' && LA10_0<='\uFFFF'))) + if (LA10_0 >= '\u0000' || LA10_0 <= '\uFFFF') + alt10 = 1; + + if(LA10_0 == '[') + opened++; + else if(LA10_0 == ']') { - alt10=1; + opened--; + if(opened < 0) + alt10=2; } - } finally { DebugExitDecision(10); } switch ( alt10 ) {