/[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.55 by akim, Tue Apr 29 08:41:13 2003 UTC revision 1.56 by adl, Wed May 14 18:41:48 2003 UTC
# Line 50  AT_DATA_GRAMMAR([calc.y], Line 50  AT_DATA_GRAMMAR([calc.y],
50  extern void perror (const char *s);  extern void perror (const char *s);
51    
52  /* Exercise pre-prologue dependency to %union.  */  /* Exercise pre-prologue dependency to %union.  */
53  typedef int value;  typedef int semantic_value;
54    
55  static value global_result = 0;  static semantic_value global_result = 0;
56  static int global_count = 0;  static int global_count = 0;
57  %}  %}
58    
59  /* Exercise %union. */  /* Exercise %union. */
60  %union  %union
61  {  {
62    value ival;    semantic_value ival;
63  };  };
64    
65  %{  %{
# Line 69  static int power (int base, int exponent Line 69  static int power (int base, int exponent
69     - %location & %pure & %glr     - %location & %pure & %glr
70     - %location & %pure & %yacc & %parse-param. */     - %location & %pure & %yacc & %parse-param. */
71  static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])  static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
72                       AT_PARAM_IF([value *result, int *count, ])                       AT_PARAM_IF([semantic_value *result, int *count, ])
73                       const char *s                       const char *s
74                       );])[                       );])[
75  static int yylex (]AT_LEX_FORMALS[);  static int yylex (]AT_LEX_FORMALS[);
# Line 139  yy::Parser::error_ () Line 139  yy::Parser::error_ ()
139  }  }
140    
141  int  int
142  yyparse (void)  yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
143  {  {
144    yy::Parser parser (!!YYDEBUG[]AT_LOCATION_IF([, yy::Location::Location ()]));    yy::Parser parser (!!YYDEBUG[]AT_LOCATION_IF([, yy::Location::Location ()])AT_PARAM_IF([, result, count]));
145    return parser.parse ();    return parser.parse ();
146  }  }
147  ],  ],
148  [static void  [static void
149  yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])  yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
150           AT_PARAM_IF([value *result, int *count, ])           AT_PARAM_IF([semantic_value *result, int *count, ])
151           const char *s)           const char *s)
152  {  {
153  AT_PARAM_IF([(void) result; (void) count;])  AT_PARAM_IF([(void) result; (void) count;])
# Line 299  power (int base, int exponent) Line 299  power (int base, int exponent)
299  int  int
300  main (int argc, const char **argv)  main (int argc, const char **argv)
301  {  {
302    value result = 0;    semantic_value result = 0;
303    int count = 0;    int count = 0;
304    int status;    int status;
305    
# Line 546  AT_CHECK_CALC_LALR([%error-verbose %debu Line 546  AT_CHECK_CALC_LALR([%error-verbose %debu
546    
547  AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])  AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
548    
549  AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])  AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
550    
551    
552  # ----------------------- #  # ----------------------- #
# Line 582  AT_CHECK_CALC_GLR([%error-verbose %debug Line 582  AT_CHECK_CALC_GLR([%error-verbose %debug
582    
583  AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])  AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
584    
585  AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])  AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
586    
587    
588  # ----------------------------- #  # ----------------------------- #
# Line 594  AT_BANNER([[Simple LALR1 C++ Calculator. Line 594  AT_BANNER([[Simple LALR1 C++ Calculator.
594  # AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])  # AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])
595  # ---------------------------------------  # ---------------------------------------
596  # Start a testing chunk which compiles `calc' grammar with  # Start a testing chunk which compiles `calc' grammar with
597  # BISON-OPTIONS and %glr-parser, and performs several tests over the parser.  # the C++ skeleton, and performs several tests over the parser.
598  m4_define([AT_CHECK_CALC_LALR1_CC],  m4_define([AT_CHECK_CALC_LALR1_CC],
599  [AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)])  [AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)])
600    
# Line 619  AT_CHECK_CALC_LALR1_CC([%error-verbose % Line 619  AT_CHECK_CALC_LALR1_CC([%error-verbose %
619    
620  AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])  AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
621    
622  # AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])  AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.56

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