From cb44ba3cf4ab55d364365e807bb0eac249c8186c Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 24 Oct 2002 18:14:19 +0000 Subject: [PATCH] input parser no longer ignores extra stuff at the end of accepted input --- ginac/input_lexer.ll | 5 ++++- ginac/input_parser.yy | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ginac/input_lexer.ll b/ginac/input_lexer.ll index 4a5a6501..139d6907 100644 --- a/ginac/input_lexer.ll +++ b/ginac/input_lexer.ll @@ -87,7 +87,7 @@ AN [0-9a-zA-Z_] */ %% -[ \t]+ /* skip whitespace */ +[ \t\n]+ /* skip whitespace */ /* special values */ Pi ginac_yylval = Pi; return T_LITERAL; @@ -123,6 +123,9 @@ Digits ginac_yylval = (long)Digits; return T_DIGITS; return T_SYMBOL; } + /* end of input */ +<> return T_EOF; + /* everything else */ . return *yytext; diff --git a/ginac/input_parser.yy b/ginac/input_parser.yy index c5c78d2d..43d7cc82 100644 --- a/ginac/input_parser.yy +++ b/ginac/input_parser.yy @@ -57,7 +57,7 @@ ex attach_index(const ex & base, ex i, bool covariant); /* Tokens (T_LITERAL means a literal value returned by the parser, but not of class numeric or symbol (e.g. a constant or the FAIL object)) */ -%token T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ +%token T_EOF T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ /* Operator precedence and associativity */ %right '=' @@ -78,7 +78,7 @@ ex attach_index(const ex & base, ex i, bool covariant); */ %% -input : exp { +input : exp T_EOF { try { parsed_ex = $1; YYACCEPT; @@ -87,7 +87,6 @@ input : exp { YYERROR; } } - | error {yyclearin; yyerrok;} ; exp : T_NUMBER {$$ = $1;} -- 2.45.1