]> www.ginac.de Git - ginac.git/commitdiff
input parser no longer ignores extra stuff at the end of accepted input
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 18:14:19 +0000 (18:14 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 18:14:19 +0000 (18:14 +0000)
ginac/input_lexer.ll
ginac/input_parser.yy

index 4a5a65015e31ac983b64a92a18b1e8fb7457f694..139d6907aa58b2a237922cbf247e33dbb59eb17b 100644 (file)
@@ -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;
 
                        /* special values */
 Pi                     ginac_yylval = Pi; return T_LITERAL;
@@ -123,6 +123,9 @@ Digits                      ginac_yylval = (long)Digits; return T_DIGITS;
                                return T_SYMBOL;
                        }
 
                                return T_SYMBOL;
                        }
 
+                       /* end of input */
+<<EOF>>                        return T_EOF;
+
                        /* everything else */
 .                      return *yytext;
 
                        /* everything else */
 .                      return *yytext;
 
index c5c78d2dd9cf4656e44d9825f851c1018c01fd7b..43d7cc826942124104e1faa55046349a2476bf5f 100644 (file)
@@ -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)) */
 
 /* 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 '='
 
 /* 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;
                try {
                        parsed_ex = $1;
                        YYACCEPT;
@@ -87,7 +87,6 @@ input : exp {
                        YYERROR;
                }
        }
                        YYERROR;
                }
        }
-       | error         {yyclearin; yyerrok;}
        ;
 
 exp    : T_NUMBER              {$$ = $1;}
        ;
 
 exp    : T_NUMBER              {$$ = $1;}