[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: %nondeterministic-parser
From: |
Akim Demaille |
Subject: |
FYI: %nondeterministic-parser |
Date: |
Tue, 29 Apr 2003 14:54:16 +0200 |
User-agent: |
Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.3 (gnu/linux) |
Hi,
This change is needed for work in progress: the ability to generate
nondeterministic tables with other skeletons than just glr.c. It is
premature to document it.
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/gram.h, src/gram.c (pure_parser, glr_parser): Move to...
* src/getargs.c, src/getargs.h: here, as bool, not int.
(nondeterministic_parser): New.
* src/parse-gram.y, src/scan-gram.l: Support
%nondeterministic-parser.
* src/output.c (prepare): Use nondeterministic_parser instead
of glr_parser where appropriate.
* src/tables.c (conflict_row, action_row, save_row)
(token_actions, token_actions, pack_vector): Ditto.
2003-04-29 Akim Demaille <address@hidden>
Index: src/getargs.c
===================================================================
RCS file: /cvsroot/bison/bison/src/getargs.c,v
retrieving revision 1.55
diff -u -u -r1.55 getargs.c
--- src/getargs.c 11 Jan 2003 08:11:32 -0000 1.55
+++ src/getargs.c 29 Apr 2003 12:52:08 -0000
@@ -54,6 +54,10 @@
int graph_flag = 0;
int trace_flag = trace_none;
+bool nondeterministic_parser = false;
+bool glr_parser = false;
+bool pure_parser = false;
+
const char *skeleton = NULL;
const char *include = NULL;
Index: src/getargs.h
===================================================================
RCS file: /cvsroot/bison/bison/src/getargs.h,v
retrieving revision 1.23
diff -u -u -r1.23 getargs.h
--- src/getargs.h 11 Dec 2002 06:31:14 -0000 1.23
+++ src/getargs.h 29 Apr 2003 12:52:08 -0000
@@ -1,5 +1,5 @@
/* Parse command line arguments for bison.
- Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
+ Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -34,6 +34,23 @@
extern int token_table_flag; /* for -k */
extern int graph_flag; /* for -g */
extern int yacc_flag; /* for -y */
+
+/* GLR_PARSER is true if the input file says to use the GLR
+ (Generalized LR) parser, and to output some additional information
+ used by the GLR algorithm. */
+
+extern bool glr_parser;
+
+/* PURE_PARSER is true if should generate a parser that is all pure
+ and reentrant. */
+
+extern bool pure_parser;
+
+/* NONDETERMINISTIC_PARSER is true iff conflicts are accepted. This
+ is used by the GLR parser, and might be used in BackTracking
+ parsers too. */
+
+extern bool nondeterministic_parser;
/* --trace. */
enum trace
Index: src/gram.c
===================================================================
RCS file: /cvsroot/bison/bison/src/gram.c,v
retrieving revision 1.51
diff -u -u -r1.51 gram.c
--- src/gram.c 3 Feb 2003 15:35:56 -0000 1.51
+++ src/gram.c 29 Apr 2003 12:52:09 -0000
@@ -47,10 +47,6 @@
int max_user_token_number = 256;
-int glr_parser = 0;
-int pure_parser = 0;
-
-
/*--------------------------------------------------------------.
| Return true IFF the rule has a `number' smaller than NRULES. |
`--------------------------------------------------------------*/
Index: src/gram.h
===================================================================
RCS file: /cvsroot/bison/bison/src/gram.h,v
retrieving revision 1.53
diff -u -u -r1.53 gram.h
--- src/gram.h 3 Feb 2003 15:33:19 -0000 1.53
+++ src/gram.h 29 Apr 2003 12:52:09 -0000
@@ -231,17 +231,6 @@
-/* GLR_PARSER is nonzero if the input file says to use the GLR
- (Generalized LR) parser, and to output some additional
- information used by the GLR algorithm. */
-
-extern int glr_parser;
-
-/* PURE_PARSER is nonzero if should generate a parser that is all pure
- and reentrant. */
-
-extern int pure_parser;
-
/* Dump RITEM for traces. */
void ritem_print (FILE *out);
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.219
diff -u -u -r1.219 output.c
--- src/output.c 31 Mar 2003 09:17:40 -0000 1.219
+++ src/output.c 29 Apr 2003 12:52:09 -0000
@@ -614,7 +614,7 @@
/* Find the right skeleton file. */
if (!skeleton)
{
- if (glr_parser)
+ if (glr_parser || nondeterministic_parser)
skeleton = "glr.c";
else
skeleton = "yacc.c";
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.39
diff -u -u -r1.39 parse-gram.y
--- src/parse-gram.y 3 Feb 2003 15:35:56 -0000 1.39
+++ src/parse-gram.y 29 Apr 2003 12:52:10 -0000
@@ -120,6 +120,7 @@
PERCENT_LOCATIONS "%locations"
PERCENT_NAME_PREFIX "%name-prefix"
PERCENT_NO_LINES "%no-lines"
+ PERCENT_NONDETERMINISTIC_PARSER "%nondeterministic-parser"
PERCENT_OUTPUT "%output"
PERCENT_PARSE_PARAM "%parse-param {...}"
PERCENT_PURE_PARSER "%pure-parser"
@@ -180,14 +181,16 @@
| "%error-verbose" { error_verbose = 1; }
| "%expect" INT { expected_conflicts = $2; }
| "%file-prefix" "=" string_content { spec_file_prefix = $3; }
-| "%glr-parser" { glr_parser = 1; }
+| "%glr-parser" { nondeterministic_parser = true;
+ glr_parser = true; }
| "%lex-param {...}" { add_param ("lex_param", $1, @1); }
| "%locations" { locations_flag = 1; }
| "%name-prefix" "=" string_content { spec_name_prefix = $3; }
| "%no-lines" { no_lines_flag = 1; }
+| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" "=" string_content { spec_outfile = $3; }
| "%parse-param {...}" { add_param ("parse_param", $1, @1); }
-| "%pure-parser" { pure_parser = 1; }
+| "%pure-parser" { pure_parser = true; }
| "%skeleton" string_content { skeleton = $2; }
| "%token-table" { token_table_flag = 1; }
| "%verbose" { report_flag = report_states; }
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.59
diff -u -u -r1.59 scan-gram.l
--- src/scan-gram.l 18 Apr 2003 07:26:19 -0000 1.59
+++ src/scan-gram.l 29 Apr 2003 12:52:11 -0000
@@ -198,6 +198,7 @@
"%name"[-_]"prefix" return PERCENT_NAME_PREFIX;
"%no"[-_]"lines" return PERCENT_NO_LINES;
"%nonassoc" return PERCENT_NONASSOC;
+ "%nondeterministic-parser" return PERCENT_NONDETERMINISTIC_PARSER;
"%nterm" return PERCENT_NTERM;
"%output" return PERCENT_OUTPUT;
"%parse-param" token_type = PERCENT_PARSE_PARAM; BEGIN SC_PRE_CODE;
Index: src/tables.c
===================================================================
RCS file: /cvsroot/bison/bison/src/tables.c,v
retrieving revision 1.17
diff -u -u -r1.17 tables.c
--- src/tables.c 3 Feb 2003 15:35:57 -0000 1.17
+++ src/tables.c 29 Apr 2003 12:52:13 -0000
@@ -183,7 +183,7 @@
int i, j;
reductions *reds = s->reductions;
- if (! glr_parser)
+ if (!nondeterministic_parser)
return;
for (j = 0; j < ntokens; j += 1)
@@ -334,7 +334,7 @@
int j;
for (j = 0; j < ntokens; j++)
if (actrow[j] == rule_number_as_item_number
(default_rule->number)
- && ! (glr_parser && conflrow[j]))
+ && ! (nondeterministic_parser && conflrow[j]))
actrow[j] = 0;
}
}
@@ -381,7 +381,7 @@
/* Allocate non defaulted actions. */
froms[s] = sp = CALLOC (sp1, count);
tos[s] = CALLOC (sp2, count);
- conflict_tos[s] = glr_parser ? CALLOC (sp3, count) : NULL;
+ conflict_tos[s] = nondeterministic_parser ? CALLOC (sp3, count) : NULL;
/* Store non defaulted actions. */
for (i = 0; i < ntokens; i++)
@@ -389,7 +389,7 @@
{
*sp1++ = i;
*sp2++ = actrow[i];
- if (glr_parser)
+ if (nondeterministic_parser)
*sp3++ = conflrow[i];
}
@@ -413,7 +413,7 @@
symbol_number j;
rule_number r;
- int nconflict = glr_parser ? conflicts_total_count () : 0;
+ int nconflict = nondeterministic_parser ? conflicts_total_count () : 0;
CALLOC (yydefact, nstates);
@@ -425,7 +425,7 @@
conflict_list_cnt = 1;
/* Find the rules which are reduced. */
- if (!glr_parser)
+ if (!nondeterministic_parser)
for (r = 0; r < nrules; ++r)
rules[r].useful = false;
@@ -438,7 +438,7 @@
/* Now that the parser was computed, we can find which rules are
really reduced, and which are not because of SR or RR
conflicts. */
- if (!glr_parser)
+ if (!nondeterministic_parser)
{
for (j = 0; j < ntokens; ++j)
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
@@ -663,7 +663,7 @@
base_number *to = tos[i];
unsigned int *conflict_to = conflict_tos[i];
- if (! t)
+ if (!t)
abort ();
for (j = lowzero - from[0]; ; j++)
@@ -694,7 +694,7 @@
{
loc = j + from[k];
table[loc] = to[k];
- if (glr_parser && conflict_to != NULL)
+ if (nondeterministic_parser && conflict_to != NULL)
conflict_table[loc] = conflict_to[k];
check[loc] = from[k];
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: %nondeterministic-parser,
Akim Demaille <=