/[bison]/bison/tests/calc.at
ViewVC logotype

Diff of /bison/tests/calc.at

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by akim, Thu Feb 6 10:04:29 2003 UTC revision 1.51 by akim, Wed Feb 19 13:40:53 2003 UTC
# Line 116  exp: Line 116  exp:
116  | '-' exp  %prec NEG { $$ = -$2;            }  | '-' exp  %prec NEG { $$ = -$2;            }
117  | exp '^' exp        { $$ = power ($1, $3); }  | exp '^' exp        { $$ = power ($1, $3); }
118  | '(' exp ')'        { $$ = $2;             }  | '(' exp ')'        { $$ = $2;             }
119  | '(' error ')'      { $$ = 0;              }  | '(' error ')'      { $$ = 1111;           }
120    | '!'                { YYERROR;             }
121  ;  ;
122  %%  %%
123  /* The input. */  /* The input. */
# Line 559  _AT_CHECK_CALC([$1], Line 560  _AT_CHECK_CALC([$1],
560  _AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],  _AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],
561                       [1.2: syntax error, unexpected "number"])                       [1.2: syntax error, unexpected "number"])
562  _AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],  _AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],
563                       [1.2: syntax error, unexpected '/', expecting "number" or '-' or '('])                       [1.2: syntax error, unexpected '/', expecting "number" or '-' or '(' or '!'])
564  _AT_CHECK_CALC_ERROR([$1], [1], [error], [4],  _AT_CHECK_CALC_ERROR([$1], [1], [error], [4],
565                       [1.0: syntax error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])                       [1.0: syntax error, unexpected $undefined])
566  _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],  _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],
567                       [1.6: syntax error, unexpected '='])                       [1.6: syntax error, unexpected '='])
568  _AT_CHECK_CALC_ERROR([$1], [1],  _AT_CHECK_CALC_ERROR([$1], [1],
# Line 571  _AT_CHECK_CALC_ERROR([$1], [1], Line 572  _AT_CHECK_CALC_ERROR([$1], [1],
572                       [2.0: syntax error, unexpected '+'])                       [2.0: syntax error, unexpected '+'])
573  # Exercise error messages with EOF: work on an empty file.  # Exercise error messages with EOF: work on an empty file.
574  _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],  _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
575                       [1.0: syntax error, unexpected "end of input", expecting "number" or '-' or '\n' or '('])                       [1.0: syntax error, unexpected "end of input"])
576    
577  # Exercise the error token: without it, we die at the first error,  # Exercise the error token: without it, we die at the first error,
578  # hence be sure i. to have several errors, ii. to test the action  # hence be sure to
579  # associated to `error'.  #
580  _AT_CHECK_CALC_ERROR([$1], [0], [(1 ++ 2) + (0 0) = 1], [82],  # - have several errors which exercise different shift/discardings
581  [1.4: syntax error, unexpected '+', expecting "number" or '-' or '('  #   - (): nothing to pop, nothing to discard
582  1.14: syntax error, unexpected "number"  #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
583  calc: error: 0 != 1])  #   - (* * *): nothing to pop, a lot to discard
584    #   - (1 + 2 * *): some to pop and discard
585    #
586    # - test the action associated to `error'
587    #
588    # - check the lookahead that triggers an error is not discarded
589    #   when we enter error recovery.  Below, the lookahead causing the
590    #   first error is ")", which is needed to recover from the error and
591    #   produce the "0" that triggers the "0 != 1" error.
592    #
593    _AT_CHECK_CALC_ERROR([$1], [0],
594                         [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
595                         [156],
596    [1.1: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
597    1.17: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
598    1.22: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
599    1.40: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
600    calc: error: 4444 != 1])
601    
602    # The same, but this time exercising explicitly triggered syntax errors.
603    # POSIX says the lookahead causing the error should not be discarded.
604    _AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [64],
605    [1.9: syntax error, unexpected "number"
606    calc: error: 2222 != 1])
607  AT_CHECK_POPDEFS  AT_CHECK_POPDEFS
608    
609  AT_CLEANUP  AT_CLEANUP
# Line 673  m4_define([AT_CHECK_CALC_LALR1_CC], Line 696  m4_define([AT_CHECK_CALC_LALR1_CC],
696    
697  # AT_CHECK_CALC_LALR1_CC()  # AT_CHECK_CALC_LALR1_CC()
698    
699  AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])  # FIXME: YYERROR is not supported
700    #   AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])
701    
702  # AT_CHECK_CALC_LALR1_CC([%defines])  # AT_CHECK_CALC_LALR1_CC([%defines])
703  # AT_CHECK_CALC_LALR1_CC([%locations])  # AT_CHECK_CALC_LALR1_CC([%locations])
704  # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])  # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26