[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: The pleasures of the wonderful ;
From: |
Joel E. Denny |
Subject: |
Re: FYI: The pleasures of the wonderful ; |
Date: |
Fri, 7 Nov 2008 17:03:40 -0500 (EST) |
On Fri, 7 Nov 2008, Akim Demaille wrote:
> I have failures here on Java.
>
> # -*- compilation -*-
> 197. java.at:385: testing ...
> ../../../tests/java.at:385: bison -o Calc.java Calc.y
> ../../../tests/java.at:385: test -n "$CONF_JAVA" || exit 77
> test -n "$CONF_JAVAC" || exit 77
> Not enabling shell tracing (command contains an embedded newline)
> ../../../tests/java.at:385: $SHELL ../../../javacomp.sh Calc.java
> stderr:
> Calc.java:391: unreachable statement
> { yyval = new Integer (0); return YYERROR; ;};
> ^
> Calc.java:400: unreachable statement
> { yyval = new Integer (0); return YYERROR; ;};
> ^
> 2 errors
> stdout:
> ../../../tests/java.at:385: exit code was 1, expected 0
> 197. java.at:385: 197. Calculator (java.at:385): FAILED (java.at:385)
>
> Gee, I hate this change :(
It seems I forgot to rerun make check fully.
I pushed these 2 patches to branch-2.4.1 and will push to master after
I've tested there. However, it's fine by me if people want to get rid of
this feature altogether for 2.5.
>From 4b1ebc495bd39572b60640bc469b0852e9f71447 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Fri, 7 Nov 2008 16:48:31 -0500
Subject: [PATCH] Clean up %skeleton and %language priority implementation.
* src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
remove static qualifier because others will soon need to see it.
(language_prio): Likewise.
(getargs): Use command_line_prio rather than 0.
* src/getargs.h (command_line_prio, grammar_prio, default_prio): New
enum fields.
(skeleton_prio): Extern it.
(language_prio): Extern it.
* src/parse-gram.y: Use grammar_prio rather than 1.
diff --git a/src/getargs.c b/src/getargs.c
index c9fc9bf..f36f25b 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -70,9 +70,9 @@ static struct bison_language const valid_languages[] = {
{ "", "", "", "", false }
};
-static int skeleton_prio = 2;
+int skeleton_prio = default_prio;
const char *skeleton = NULL;
-static int language_prio = 2;
+int language_prio = default_prio;
struct bison_language const *language = &valid_languages[0];
const char *include = NULL;
@@ -520,11 +520,11 @@ getargs (int argc, char *argv[])
break;
case 'L':
- language_argmatch (optarg, 0, NULL);
+ language_argmatch (optarg, command_line_prio, NULL);
break;
case 'S':
- skeleton_arg (AS_FILE_NAME (optarg), 0, NULL);
+ skeleton_arg (AS_FILE_NAME (optarg), command_line_prio, NULL);
break;
case 'T':
diff --git a/src/getargs.h b/src/getargs.h
index 8449626..eb7f448 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -1,7 +1,7 @@
/* Parse command line arguments for bison.
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -24,11 +24,13 @@
#include "location.h"
extern char *program_name;
+enum { command_line_prio, grammar_prio, default_prio };
/* flags set by % directives */
/* for -S */
extern char const *skeleton;
+extern int skeleton_prio;
/* for -I */
extern char const *include;
@@ -68,6 +70,7 @@ struct bison_language
bool add_tab;
};
+extern int language_prio;
extern struct bison_language const *language;
/*-----------.
diff --git a/src/parse-gram.y b/src/parse-gram.y
index fa74d8d..a8526b2 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -254,7 +254,7 @@ prologue_declaration:
muscle_code_grow ("initial_action", action.code, @2);
code_scanner_last_string_free ();
}
-| "%language" STRING { language_argmatch ($2, 1, &@1); }
+| "%language" STRING { language_argmatch ($2, grammar_prio, &@1); }
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
| "%locations" { locations_flag = true; }
| "%name-prefix" STRING { spec_name_prefix = $2; }
@@ -300,7 +300,7 @@ prologue_declaration:
skeleton_user = uniqstr_new (skeleton_build);
free (skeleton_build);
}
- skeleton_arg (skeleton_user, 1, &@1);
+ skeleton_arg (skeleton_user, grammar_prio, &@1);
}
| "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag |= report_states; }
--
1.5.4.3
>From 7ed73f82ad0d54be945b9d5146e343c8e89bf81f Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Fri, 7 Nov 2008 16:48:57 -0500
Subject: [PATCH] Don't add a semicolon to actions for %skeleton or %language.
It breaks Java test cases as reported by Akim Demaille.
* src/scan-code.l: Implement.
diff --git a/src/scan-code.l b/src/scan-code.l
index 71c9076..13a78c2 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -175,7 +175,9 @@ splice (\\[ \f\t\v]*\n)*
/* As an undocumented Bison extension, append `;' before the last
brace in braced code, so that the user code can omit trailing
`;'. But do not append `;' if emulating Yacc, since Yacc does
- not append one.
+ not append one. Also, some output languages (like Java) do not
+ accept an extra semicolon, so don't append if the user specified
+ a skeleton or language.
FIXME: Bison should warn if a semicolon seems to be necessary
here, and should omit the semicolon if it seems unnecessary
@@ -186,7 +188,8 @@ splice (\\[ \f\t\v]*\n)*
should also diagnose other Bison extensions like %yacc.
Perhaps there should also be a GCC-style --pedantic-errors
option, so that such warnings are diagnosed as errors. */
- if (outer_brace && ! yacc_flag)
+ if (outer_brace && !yacc_flag && language_prio == default_prio
+ && skeleton_prio == default_prio)
obstack_1grow (&obstack_for_string, ';');
STRING_GROW;
--
1.5.4.3