#! /usr/bin/perl -w
-# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008-2012 Free Software Foundation, Inc.
#
# This file is part of Bison, the GNU Compiler Compiler.
#
or die;
print $out <<EOF;
%error-verbose
-%debug
%{
#include <stdio.h>
#include <stdlib.h>
{
use Text::Wrap;
print $out wrap ("| ", " ",
- (map { "\"$_\"" } (1 .. $size)),
- " END \n"),
+ (map { "\"$_\"" } (1 .. $size)),
+ " END \n"),
" { \$\$ = $size; }\n";
};
print $out ";\n";
int
main (void)
{
+#if YYDEBUG
yydebug = !!getenv ("YYDEBUG");
+#endif
return yyparse ();
}
EOF
or die;
print $out <<EOF;
%{
+#include <assert.h>
#include <stdio.h>
-
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
static int
power (int base, int exponent)
{
+ assert (0 <= exponent);
int res = 1;
- if (exponent < 0)
- exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
int count = 0;
int status;
+#if YYDEBUG
+ yydebug = !!getenv ("YYDEBUG");
+#endif
+
input = fopen ("calc.input", "r");
if (!input)
{
%%
result:
- text { /* Throw away the result. */ }
+ text { /* Throw away the result. */ }
;
text:
- /* nothing */ { /* This will generate an empty string */ }
-| text TEXT { std::swap ($$, $2); }
-| text NUMBER { $$ = string_cast($2); }
+ /* nothing */ { /* This will generate an empty string */ }
+| text TEXT { std::swap ($$, $2); }
+| text NUMBER { $$ = string_cast($2); }
;
EOF
}
%%
result:
- text { delete $1; }
+ text { delete $1; }
;
text:
- /* nothing */ { $$ = new std::string; }
-| text TEXT { delete $1; $$ = $2; }
-| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
+ /* nothing */ { $$ = new std::string; }
+| text TEXT { delete $1; $$ = $2; }
+| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
;
EOF
}
if (stage == STAGE_MAX)
{
#if USE_LEX_SYMBOL
- return yy::parser::make_END_OF_FILE (yy::location());
+ return yy::parser::make_END_OF_FILE (location_type ());
#else
*yylloc = location_type ();
return token::END_OF_FILE;
else if (stage % 2)
{
#if USE_LEX_SYMBOL
- return yy::parser::make_NUMBER (stage, yy::location());
+ return yy::parser::make_NUMBER (stage, location_type ());
#else
# if defined ONE_STAGE_BUILD
yylval->build(stage);
else
{
#if USE_LEX_SYMBOL
- return yy::parser::make_TEXT ("A string.", yy::location());
+ return yy::parser::make_TEXT ("A string.", location_type ());
#else
# if defined ONE_STAGE_BUILD
yylval->build(std::string("A string."));
// Mandatory error function
void
-yy::parser::error(const yy::parser::location_type& yylloc,
- const std::string& message)
+yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
{
- std::cerr << yylloc << ": " << message << std::endl;
+ std::cerr << loc << ": " << msg << std::endl;
}
int main(int argc, char *argv[])
qw(
[ %d api.pure ]
&
- [ %d api.push_pull=both ]
+ [ %d api.push-pull=both ]
));
}