/[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.52 by akim, Wed Feb 19 14:33:27 2003 UTC revision 1.53 by akim, Thu Feb 20 08:14:27 2003 UTC
# Line 66  static int global_count = 0; Line 66  static int global_count = 0;
66    
67  %{  %{
68  static int power (int base, int exponent);  static int power (int base, int exponent);
69    ]AT_LALR1_CC_IF([], [
70  /* yyerror receives the location if:  /* yyerror receives the location if:
71     - %location & %pure & %glr     - %location & %pure & %glr
72     - %location & %pure & %yacc & %parse-param. */     - %location & %pure & %yacc & %parse-param. */
73  static void yyerror (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])[  static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
74                       ]AT_PARAM_IF([value *result, int *count, ])[                       AT_PARAM_IF([value *result, int *count, ])
75                       const char *s                       const char *s
76                       );                       );])[
77  static int yylex (]AT_LEX_FORMALS[);  static int yylex (]AT_LEX_FORMALS[);
78  static int yygetc (]AT_LEX_FORMALS[);  static int yygetc (]AT_LEX_FORMALS[);
79  static void yyungetc (]AT_LEX_PRE_FORMALS[ int c);  static void yyungetc (]AT_LEX_PRE_FORMALS[ int c);
# Line 128  static FILE *yyin; Line 129  static FILE *yyin;
129  void  void
130  yy::Parser::print_ ()  yy::Parser::print_ ()
131  {  {
132    std::cerr << location;  AT_LOCATION_IF([
133      std::cerr << location;])
134  }  }
135    
136  /* A C++ error reporting function. */  /* A C++ error reporting function. */
137  void  void
138  yy::Parser::error_ ()  yy::Parser::error_ ()
139  {  {
140    std::cerr << location << ": " << message << std::endl;    std::cerr << AT_LOCATION_IF([location << ": " << ])message << std::endl;
141  }  }
142    
143  int  int
# Line 253  yylex (]AT_LEX_FORMALS[) Line 255  yylex (]AT_LEX_FORMALS[)
255  ])])[  ])])[
256      }      }
257    
258  ]AT_LALR1_CC_IF(  ]AT_LOCATION_IF([AT_LALR1_CC_IF(
259  [ AT_LOC.begin = AT_LOC.end;],  [ AT_LOC.begin = AT_LOC.end;],
260  [AT_LOCATION_IF([  [ AT_LOC.first_column = AT_LOC.last_column;
   AT_LOC.first_column = AT_LOC.last_column;  
261    AT_LOC.first_line   = AT_LOC.last_line;    AT_LOC.first_line   = AT_LOC.last_line;
262  ])])[  ])])[
263    
264    /* Skip white space.  */    /* Skip white space.  */
265    while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t')    while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t')
266      {      {
267  ]AT_LALR1_CC_IF(  ]AT_LOCATION_IF([AT_LALR1_CC_IF(
268  [     AT_LOC.begin = AT_LOC.end;],  [     AT_LOC.begin = AT_LOC.end;],
269  [AT_LOCATION_IF([  [     AT_LOC.first_column = AT_LOC.last_column;
       AT_LOC.first_column = AT_LOC.last_column;  
270        AT_LOC.first_line   = AT_LOC.last_line;        AT_LOC.first_line   = AT_LOC.last_line;
271  ])])[  ])])[
272      }      }
# Line 317  main (int argc, const char **argv) Line 317  main (int argc, const char **argv)
317        exit (1);        exit (1);
318      }      }
319    
320  #if YYDEBUG  ]AT_LALR1_CC_IF([], [m4_bmatch([$4], [%debug],
321    yydebug = 1;  [  yydebug = 1;])])[
 #endif  
322    status = yyparse (]AT_PARAM_IF([&result, &count])[);    status = yyparse (]AT_PARAM_IF([&result, &count])[);
323    if (global_result != result)    if (global_result != result)
324      abort ();      abort ();
# Line 439  m4_pushdef([AT_LALR1_CC_IF], Line 438  m4_pushdef([AT_LALR1_CC_IF],
438  [m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])  [m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])
439  m4_pushdef([AT_GLR_IF],  m4_pushdef([AT_GLR_IF],
440  [m4_bmatch([$3], [%glr-parser], [$1], [$2])])  [m4_bmatch([$3], [%glr-parser], [$1], [$2])])
441    # Using yacc.c?
442    m4_pushdef([AT_YACC_IF],
443    [m4_bmatch([$3], [%glr-parser\|%skeleton], [$2], [$1])])
444  m4_pushdef([AT_PARAM_IF],  m4_pushdef([AT_PARAM_IF],
445  [m4_bmatch([$3], [%parse-param], [$1], [$2])])  [m4_bmatch([$3], [%parse-param], [$1], [$2])])
446  m4_pushdef([AT_LOCATION_IF],  m4_pushdef([AT_LOCATION_IF],
# Line 455  m4_pushdef([AT_GLR_OR_PARAM_IF], Line 457  m4_pushdef([AT_GLR_OR_PARAM_IF],
457  m4_pushdef([AT_YYERROR_ARG_LOC_IF],  m4_pushdef([AT_YYERROR_ARG_LOC_IF],
458  [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],  [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
459                      [$2])])                      [$2])])
460  # yyerror cannot see the locations if !glr & pure & !param.  # yyerror always sees the locations (when activated), except if
461    # yacc & pure & !param.
462  m4_pushdef([AT_YYERROR_SEES_LOC_IF],  m4_pushdef([AT_YYERROR_SEES_LOC_IF],
463  [AT_LALR1_CC_IF([$1],  [AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
464                  [AT_LOCATION_IF([AT_GLR_IF([$1],                                          [$1])],
465                                             [AT_PURE_IF([AT_PARAM_IF([$1],                              [$1])],
466                                                                      [$2])],                  [$2])])
                                                        [$1])])],  
                                 [$2])])])  
467    
468  # The interface is pure: either because %pure-parser, or because we  # The interface is pure: either because %pure-parser, or because we
469  # are using the C++ parsers.  # are using the C++ parsers.
# Line 512  m4_popdef([AT_GLR_OR_PARAM_IF]) Line 513  m4_popdef([AT_GLR_OR_PARAM_IF])
513  m4_popdef([AT_PURE_AND_LOC_IF])  m4_popdef([AT_PURE_AND_LOC_IF])
514  m4_popdef([AT_LOCATION_IF])  m4_popdef([AT_LOCATION_IF])
515  m4_popdef([AT_PARAM_IF])  m4_popdef([AT_PARAM_IF])
516    m4_popdef([AT_YACC_IF])
517  m4_popdef([AT_GLR_IF])  m4_popdef([AT_GLR_IF])
518  m4_popdef([AT_LALR1_CC_IF])  m4_popdef([AT_LALR1_CC_IF])
519  ])  ])
# Line 696  m4_define([AT_CHECK_CALC_LALR1_CC], Line 698  m4_define([AT_CHECK_CALC_LALR1_CC],
698    
699  # AT_CHECK_CALC_LALR1_CC()  # AT_CHECK_CALC_LALR1_CC()
700    
701  AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])  AT_CHECK_CALC_LALR1_CC([%defines %locations])
702    
703  # AT_CHECK_CALC_LALR1_CC([%defines])  AT_CHECK_CALC_LALR1_CC([%defines])
704  # AT_CHECK_CALC_LALR1_CC([%locations])  # AT_CHECK_CALC_LALR1_CC([%locations])
705  # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])  # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])
706  # AT_CHECK_CALC_LALR1_CC([%verbose])  # AT_CHECK_CALC_LALR1_CC([%verbose])
# Line 707  AT_CHECK_CALC_LALR1_CC([%defines %pure-p Line 709  AT_CHECK_CALC_LALR1_CC([%defines %pure-p
709    
710  # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations])  # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations])
711    
712  # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])  AT_CHECK_CALC_LALR1_CC([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
713    
714  # AT_CHECK_CALC_LALR1_CC([%debug])  # AT_CHECK_CALC_LALR1_CC([%debug])
715  # AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])  AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
716    
717  # 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])
718    
719  # 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 {value *result} %parse-param {int *count}])

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

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