Some code and documentation improvements.

* data/c.m4 (b4_table_value_equals): New macro to capture
some repeated code.
* data/glr.c (yyis_pact_ninf): Use it here.
(yyis_table_ninf): Likewise.
(yyreportSyntaxError): Improve internal comments.
* data/yacc.c (yyis_pact_ninf): New macro copied from glr.c.
Use it everywhere possible.
(yyis_table_ninf): Likewise.
(yysyntax_error): Improve internal comments.
* data/lalr1.cc (yysyntax_error_): Likewise.
* data/lalr1.java (yysyntax_error): Likewise.
* src/tables.h: Improve comments about yypact, yytable, etc.
(cherry picked from commit 8741288212)

Conflicts:

	data/lalr1.java
	data/yacc.c
This commit is contained in:
Joel E. Denny
2009-08-25 01:12:37 -04:00
parent 890ab17c84
commit 77373efad2
9 changed files with 216 additions and 168 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.4.1.86-ae09ec. */
/* A Bison parser, made by GNU Bison 2.4.1.120-890ab. */
/* Skeleton interface for Bison's Yacc-like parsers in C
@@ -161,7 +161,7 @@
typedef union YYSTYPE
{
/* Line 1677 of yacc.c */
/* Line 1684 of yacc.c */
#line 94 "parse-gram.y"
symbol *symbol;
@@ -176,8 +176,8 @@ typedef union YYSTYPE
/* Line 1677 of yacc.c */
#line 181 "../../branch-2.5/src/parse-gram.h"
/* Line 1684 of yacc.c */
#line 181 "parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@@ -54,8 +54,15 @@
something else to do.
YYPACT[S] = index in YYTABLE of the portion describing state S.
The lookahead token's type is used to index that portion to find
out what to do.
The lookahead token's number, I, is used to index that portion of
YYTABLE to find out what action to perform.
If YYPACT[S] == YYPACT_NINF, if YYPACT[S] + I is outside the bounds
of YYTABLE (from 0 to YYLAST), or if YYCHECK indicates that I is
outside the bounds of the portion for S, then the default action
(from YYDEFACT and YYDEFGOTO) should be used instead of YYTABLE.
Otherwise, the value YYTABLE[YYPACT[S] + I] should be used even if
YYPACT[S] < 0.
If the value in YYTABLE is positive, we shift the token and go to
that state.
@@ -64,6 +71,8 @@
If the value is zero, the default action from YYDEFACT[S] is used.
If the value is YYTABLE_NINF, it's a syntax error.
YYPGOTO[I] = the index in YYTABLE of the portion describing what to
do after reducing a rule that derives variable I + NTOKENS. This
portion is indexed by the parser state number, S, as of before the