mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* doc/bison.texinfo (Debugging): Split into...
(Tracing): this new section, its former contents, and... (Understanding): this new section. * src/getargs.h, src/getargs.c (verbose_flag): Remove, replaced by... (report_flag): this. Adjust all dependencies. (report_args, report_types, report_argmatch): New. (usage, getargs): Report/support -r, --report. * src/options.h (struct option_table_struct): Rename as.., (struct option_table_s): this. Rename the `set_flag' member to `flag' to match with getopt_long's struct. * src/options.c (option_table): Split verbose into an entry for %verbose, and another for --verbose. Support --report/-r, so remove -r from the obsolete --raw. * src/print.c: Attach full item sets and lookaheads reports to report_flag instead of trace_flag. * lib/argmatch.h, lib/argmatch.c: New, from Fileutils 4.1.
This commit is contained in:
23
ChangeLog
23
ChangeLog
@@ -1,3 +1,26 @@
|
||||
2002-05-25 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* doc/bison.texinfo (Debugging): Split into...
|
||||
(Tracing): this new section, its former contents, and...
|
||||
(Understanding): this new section.
|
||||
* src/getargs.h, src/getargs.c (verbose_flag): Remove, replaced
|
||||
by...
|
||||
(report_flag): this.
|
||||
Adjust all dependencies.
|
||||
(report_args, report_types, report_argmatch): New.
|
||||
(usage, getargs): Report/support -r, --report.
|
||||
* src/options.h
|
||||
(struct option_table_struct): Rename as..,
|
||||
(struct option_table_s): this.
|
||||
Rename the `set_flag' member to `flag' to match with getopt_long's
|
||||
struct.
|
||||
* src/options.c (option_table): Split verbose into an entry for
|
||||
%verbose, and another for --verbose.
|
||||
Support --report/-r, so remove -r from the obsolete --raw.
|
||||
* src/print.c: Attach full item sets and lookaheads reports to
|
||||
report_flag instead of trace_flag.
|
||||
* lib/argmatch.h, lib/argmatch.c: New, from Fileutils 4.1.
|
||||
|
||||
2002-05-24 Paul Hilfinger <Hilfinger@CS.Berkeley.EDU>
|
||||
and Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
|
||||
7
NEWS
7
NEWS
@@ -81,6 +81,13 @@ Changes in version 1.49b:
|
||||
the compiler supports ANSI C or is a C++ compiler, as enums.
|
||||
This helps debuggers producing symbols instead of values.
|
||||
|
||||
* Reports
|
||||
In addition to --verbose, bison supports --report=THINGS, which
|
||||
produces additional information:
|
||||
|
||||
`itemset' complete the core item sets with their closure
|
||||
`lookahead' explicitly associate lookaheads to items
|
||||
|
||||
|
||||
Changes in version 1.35, 2002-03-25:
|
||||
|
||||
|
||||
148
TODO
148
TODO
@@ -1,5 +1,20 @@
|
||||
-*- outline -*-
|
||||
|
||||
* documentation
|
||||
Explain $axiom (and maybe change its name: BTYacc names it goal).
|
||||
Complete the glossary (item, axiom, ?).
|
||||
|
||||
* report documentation
|
||||
Extend with error. The hard part will probably be finding the right
|
||||
rule so that a single state does not exhibit to many yet undocumented
|
||||
``features''. Maybe an empty action ought to be presented too. Shall
|
||||
we try to make a single grammar with all these features, or should we
|
||||
have several very small grammars?
|
||||
|
||||
* documentation
|
||||
Some history of Bison and some bibliography would be most welcome.
|
||||
Are there any Texinfo standards for bibliography?
|
||||
|
||||
* Several %unions
|
||||
I think this is a pleasant (but useless currently) feature, but in the
|
||||
future, I want a means to %include other bits of grammars, and _then_
|
||||
@@ -21,130 +36,25 @@ When implementing multiple-%union support, bare the following in mind:
|
||||
char *sval;
|
||||
}
|
||||
|
||||
* Experimental report features
|
||||
Decide whether they should be enabled, or optional. For instance, on:
|
||||
* --report=conflict-path
|
||||
Provide better assistance for understanding the conflicts by providing
|
||||
a sample text exhibiting the (LALR) ambiguity.
|
||||
|
||||
input:
|
||||
exp
|
||||
| input exp
|
||||
;
|
||||
* report
|
||||
Solved conflicts should not be reported in the beginning of the file.
|
||||
Rather they should be reported within each state description. Also,
|
||||
now that the symbol providing the precedence of a rule is kept, it is
|
||||
possible to explain why a conflict was solved this way. E.g., instead
|
||||
of
|
||||
|
||||
exp:
|
||||
token1 "1"
|
||||
| token2 "2"
|
||||
| token3 "3"
|
||||
;
|
||||
Conflict in state 8 between rule 2 and token '+' resolved as reduce.
|
||||
|
||||
token1: token;
|
||||
token2: token;
|
||||
token3: token;
|
||||
we can (in state 8) report something like
|
||||
|
||||
the traditional Bison reports:
|
||||
|
||||
state 0
|
||||
|
||||
$axiom -> . input $ (rule 0)
|
||||
|
||||
token shift, and go to state 1
|
||||
|
||||
input go to state 2
|
||||
exp go to state 3
|
||||
token1 go to state 4
|
||||
token2 go to state 5
|
||||
token3 go to state 6
|
||||
|
||||
state 1
|
||||
|
||||
token1 -> token . (rule 6)
|
||||
token2 -> token . (rule 7)
|
||||
token3 -> token . (rule 8)
|
||||
|
||||
"2" reduce using rule 7 (token2)
|
||||
"3" reduce using rule 8 (token3)
|
||||
$default reduce using rule 6 (token1)
|
||||
|
||||
while with --trace, i.e., when enabling both the display of non-core
|
||||
item sets and the display of lookaheads, Bison now displays:
|
||||
|
||||
state 0
|
||||
|
||||
$axiom -> . input $ (rule 0)
|
||||
input -> . exp (rule 1)
|
||||
input -> . input exp (rule 2)
|
||||
exp -> . token1 "1" (rule 3)
|
||||
exp -> . token2 "2" (rule 4)
|
||||
exp -> . token3 "3" (rule 5)
|
||||
token1 -> . token (rule 6)
|
||||
token2 -> . token (rule 7)
|
||||
token3 -> . token (rule 8)
|
||||
|
||||
token shift, and go to state 1
|
||||
|
||||
input go to state 2
|
||||
exp go to state 3
|
||||
token1 go to state 4
|
||||
token2 go to state 5
|
||||
token3 go to state 6
|
||||
|
||||
state 1
|
||||
|
||||
token1 -> token . ["1"] (rule 6)
|
||||
token2 -> token . ["2"] (rule 7)
|
||||
token3 -> token . ["3"] (rule 8)
|
||||
|
||||
"2" reduce using rule 7 (token2)
|
||||
"3" reduce using rule 8 (token3)
|
||||
$default reduce using rule 6 (token1)
|
||||
|
||||
so decide whether this should be an option, or always enabled. I'm in
|
||||
favor of making it the default, but maybe we should tune the output to
|
||||
distinguish core item sets from non core:
|
||||
|
||||
state 0
|
||||
Core:
|
||||
$axiom -> . input $ (rule 0)
|
||||
|
||||
Derived:
|
||||
input -> . exp (rule 1)
|
||||
input -> . input exp (rule 2)
|
||||
exp -> . token1 "1" (rule 3)
|
||||
exp -> . token2 "2" (rule 4)
|
||||
exp -> . token3 "3" (rule 5)
|
||||
token1 -> . token (rule 6)
|
||||
token2 -> . token (rule 7)
|
||||
token3 -> . token (rule 8)
|
||||
|
||||
token shift, and go to state 1
|
||||
|
||||
input go to state 2
|
||||
exp go to state 3
|
||||
token1 go to state 4
|
||||
token2 go to state 5
|
||||
token3 go to state 6
|
||||
|
||||
|
||||
> So, it seems clear that it has to be an additional option :)
|
||||
|
||||
Paul:
|
||||
|
||||
There will be further such options in the future, so I'd make
|
||||
them all operands of the --report option. E.g., you could do
|
||||
something like this:
|
||||
|
||||
--report=state --report=lookahead --report=itemset
|
||||
--report=conflict-path
|
||||
|
||||
where "--verbose" is equivalent to "--report=state", and where
|
||||
"--report=conflict-path" reports each path to a conflict
|
||||
state.
|
||||
|
||||
(As a minor point, I prefer avoiding plurals in option names.
|
||||
It's partly for brevity, and partly to avoid wearing out the
|
||||
's' keys in our keyboards. :-)
|
||||
|
||||
To implement this, see in the Fileutils the latest versions of
|
||||
argmatch and so forth.
|
||||
Conflict between rule 2 and token '+' resolved as reduce
|
||||
because '*' < '+'.
|
||||
|
||||
or something like that.
|
||||
|
||||
* Coding system independence
|
||||
Paul notes:
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
@settitle Bison @value{VERSION}
|
||||
@setchapternewpage odd
|
||||
|
||||
@iftex
|
||||
@finalout
|
||||
@end iftex
|
||||
|
||||
@c SMALL BOOK version
|
||||
@c This edition has been formatted so that you can format and print it in
|
||||
@@ -23,6 +21,7 @@
|
||||
@c Check COPYRIGHT dates. should be updated in the titlepage, ifinfo
|
||||
@c titlepage; should NOT be changed in the GPL. --mew
|
||||
|
||||
@c FIXME: I don't understand this `iftex'. Obsolete? --akim.
|
||||
@iftex
|
||||
@syncodeindex fn cp
|
||||
@syncodeindex vr cp
|
||||
@@ -154,7 +153,7 @@ Reference sections:
|
||||
* Error Recovery:: Writing rules for error recovery.
|
||||
* Context Dependency:: What to do if your language syntax is too
|
||||
messy for Bison to handle straightforwardly.
|
||||
* Debugging:: Debugging Bison parsers that parse wrong.
|
||||
* Debugging:: Understanding or debugging Bison parsers.
|
||||
* Invocation:: How to run Bison (to produce the parser source file).
|
||||
* Table of Symbols:: All the keywords of the Bison language are explained.
|
||||
* Glossary:: Basic concepts are explained.
|
||||
@@ -299,6 +298,11 @@ Handling Context Dependencies
|
||||
* Tie-in Recovery:: Lexical tie-ins have implications for how
|
||||
error recovery rules must be written.
|
||||
|
||||
Understanding or Debugging Your Parser
|
||||
|
||||
* Understanding:: Understanding the structure of your parser.
|
||||
* Tracing:: Tracing the execution of your parser.
|
||||
|
||||
Invoking Bison
|
||||
|
||||
* Bison Options:: All the options described in detail,
|
||||
@@ -707,9 +711,9 @@ In some cases the Bison parser file includes system headers, and in
|
||||
those cases your code should respect the identifiers reserved by those
|
||||
headers. On some non-@sc{gnu} hosts, @code{<alloca.h>},
|
||||
@code{<stddef.h>}, and @code{<stdlib.h>} are included as needed to
|
||||
declare memory allocators and related types.
|
||||
Other system headers may be included if you define @code{YYDEBUG} to a
|
||||
nonzero value (@pxref{Debugging, ,Debugging Your Parser}).
|
||||
declare memory allocators and related types. Other system headers may
|
||||
be included if you define @code{YYDEBUG} to a nonzero value
|
||||
(@pxref{Tracing, ,Tracing Your Parser}).
|
||||
|
||||
@node Stages
|
||||
@section Stages in Using Bison
|
||||
@@ -2351,14 +2355,14 @@ expseq1: exp
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
Any kind of sequence can be defined using either left recursion or
|
||||
right recursion, but you should always use left recursion, because it
|
||||
can parse a sequence of any number of elements with bounded stack
|
||||
space. Right recursion uses up space on the Bison stack in proportion
|
||||
to the number of elements in the sequence, because all the elements
|
||||
must be shifted onto the stack before the rule can be applied even
|
||||
once. @xref{Algorithm, ,The Bison Parser Algorithm }, for
|
||||
further explanation of this.
|
||||
Any kind of sequence can be defined using either left recursion or right
|
||||
recursion, but you should always use left recursion, because it can
|
||||
parse a sequence of any number of elements with bounded stack space.
|
||||
Right recursion uses up space on the Bison stack in proportion to the
|
||||
number of elements in the sequence, because all the elements must be
|
||||
shifted onto the stack before the rule can be applied even once.
|
||||
@xref{Algorithm, ,The Bison Parser Algorithm}, for further explanation
|
||||
of this.
|
||||
|
||||
@cindex mutual recursion
|
||||
@dfn{Indirect} or @dfn{mutual} recursion occurs when the result of the
|
||||
@@ -3276,7 +3280,7 @@ directives:
|
||||
@item %debug
|
||||
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not
|
||||
already defined, so that the debugging facilities are compiled.
|
||||
@xref{Debugging, ,Debugging Your Parser}.
|
||||
@xref{Tracing, ,Tracing Your Parser}.
|
||||
|
||||
@item %defines
|
||||
Write an extra output file containing macro definitions for the token
|
||||
@@ -3386,17 +3390,10 @@ The number of parser states (@pxref{Parser States}).
|
||||
@item %verbose
|
||||
Write an extra output file containing verbose descriptions of the
|
||||
parser states and what is done for each type of look-ahead token in
|
||||
that state.
|
||||
that state. @xref{Understanding, , Understanding Your Parser}, for more
|
||||
information.
|
||||
|
||||
This file also describes all the conflicts, both those resolved by
|
||||
operator precedence and the unresolved ones.
|
||||
|
||||
The file's name is made by removing @samp{.tab.c} or @samp{.c} from
|
||||
the parser output file name, and adding @samp{.output} instead.
|
||||
|
||||
Therefore, if the input file is @file{foo.y}, then the parser file is
|
||||
called @file{foo.tab.c} by default. As a consequence, the verbose
|
||||
output file is called @file{foo.output}.
|
||||
|
||||
@item %yacc
|
||||
Pretend the option @option{--yacc} was given, i.e., imitate Yacc,
|
||||
@@ -4954,8 +4951,414 @@ make sure your error recovery rules are not of this kind. Each rule must
|
||||
be such that you can be sure that it always will, or always won't, have to
|
||||
clear the flag.
|
||||
|
||||
@c ================================================== Debugging Your Parser
|
||||
|
||||
@node Debugging
|
||||
@chapter Debugging Your Parser
|
||||
|
||||
Developing a parser can be a challenge, especially if you don't
|
||||
understand the algorithm (@pxref{Algorithm, ,The Bison Parser
|
||||
Algorithm}). Even so, sometimes a detailed description of the automaton
|
||||
can help (@pxref{Understanding, , Understanding Your Parser}), or
|
||||
tracing the execution of the parser can give some insight on why it
|
||||
behaves improperly (@pxref{Tracing, , Tracing Your Parser}).
|
||||
|
||||
@menu
|
||||
* Understanding:: Understanding the structure of your parser.
|
||||
* Tracing:: Tracing the execution of your parser.
|
||||
@end menu
|
||||
|
||||
@node Understanding
|
||||
@section Understanding Your Parser
|
||||
|
||||
As documented elsewhere (@pxref{Algorithm, ,The Bison Parser Algorithm})
|
||||
Bison parsers are @dfn{shift/reduce automata}. In some cases (much more
|
||||
frequent than one would hope), looking at this automaton is required to
|
||||
tune or simply fix a parser. Bison provides two different
|
||||
representation of it, either textually or graphically (as a @sc{vcg}
|
||||
file).
|
||||
|
||||
The textual file is generated when the options @option{--report} or
|
||||
@option{--verbose} are specified, see @xref{Invocation, , Invoking
|
||||
Bison}. Its name is made by removing @samp{.tab.c} or @samp{.c} from
|
||||
the parser output file name, and adding @samp{.output} instead.
|
||||
Therefore, if the input file is @file{foo.y}, then the parser file is
|
||||
called @file{foo.tab.c} by default. As a consequence, the verbose
|
||||
output file is called @file{foo.output}.
|
||||
|
||||
The following grammar file, @file{calc.y}, will be used in the sequel:
|
||||
|
||||
@example
|
||||
%token NUM STR
|
||||
%left '+' '-'
|
||||
%left '*'
|
||||
%%
|
||||
exp: exp '+' exp
|
||||
| exp '-' exp
|
||||
| exp '*' exp
|
||||
| exp '/' exp
|
||||
| NUM
|
||||
;
|
||||
useless: STR;
|
||||
%%
|
||||
@end example
|
||||
|
||||
@command{bison} reports that @samp{calc.y contains 1 useless nonterminal
|
||||
and 1 useless rule} and that @samp{calc.y contains 7 shift/reduce
|
||||
conflicts}. When given @option{--report=state}, in addition to
|
||||
@file{calc.tab.c}, it creates a file @file{calc.output} with contents
|
||||
detailed below. The order of the output and the exact presentation
|
||||
might vary, but the interpretation is the same.
|
||||
|
||||
The first section includes details on conflicts that were solved thanks
|
||||
to precedence and/or associativity:
|
||||
|
||||
@example
|
||||
Conflict in state 8 between rule 2 and token '+' resolved as reduce.
|
||||
Conflict in state 8 between rule 2 and token '-' resolved as reduce.
|
||||
Conflict in state 8 between rule 2 and token '*' resolved as shift.
|
||||
@exdent @dots{}
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The next section lists states that still have conflicts.
|
||||
|
||||
@example
|
||||
State 8 contains 1 shift/reduce conflict.
|
||||
State 9 contains 1 shift/reduce conflict.
|
||||
State 10 contains 1 shift/reduce conflict.
|
||||
State 11 contains 4 shift/reduce conflicts.
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@cindex token, useless
|
||||
@cindex useless token
|
||||
@cindex nonterminal, useless
|
||||
@cindex useless nonterminal
|
||||
@cindex rule, useless
|
||||
@cindex useless rule
|
||||
The next section reports useless tokens, nonterminal and rules. Useless
|
||||
nonterminals and rules are removed in order to produce a smaller parser,
|
||||
but useless tokens are preserved, since they might be used by the
|
||||
scanner (note the difference between ``useless'' and ``not used''
|
||||
below):
|
||||
|
||||
@example
|
||||
Useless nonterminals:
|
||||
useless
|
||||
|
||||
Terminals which are not used:
|
||||
STR
|
||||
|
||||
Useless rules:
|
||||
#6 useless: STR;
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The next section reproduces the exact grammar that Bison used:
|
||||
|
||||
@example
|
||||
Grammar
|
||||
|
||||
Number, Line, Rule
|
||||
0 5 $axiom -> exp $
|
||||
1 5 exp -> exp '+' exp
|
||||
2 6 exp -> exp '-' exp
|
||||
3 7 exp -> exp '*' exp
|
||||
4 8 exp -> exp '/' exp
|
||||
5 9 exp -> NUM
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
and reports the uses of the symbols:
|
||||
|
||||
@example
|
||||
Terminals, with rules where they appear
|
||||
|
||||
$ (0) 0
|
||||
'*' (42) 3
|
||||
'+' (43) 1
|
||||
'-' (45) 2
|
||||
'/' (47) 4
|
||||
error (256)
|
||||
NUM (258) 5
|
||||
|
||||
Nonterminals, with rules where they appear
|
||||
|
||||
$axiom (8)
|
||||
on left: 0
|
||||
exp (9)
|
||||
on left: 1 2 3 4 5, on right: 0 1 2 3 4
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@cindex item
|
||||
@cindex pointed rule
|
||||
@cindex rule, pointed
|
||||
Bison then proceeds onto the automaton itself, describing each state
|
||||
with it set of @dfn{items}, also known as @dfn{pointed rules}. Each
|
||||
item is a production rule together with a point (marked by @samp{.})
|
||||
that the input cursor.
|
||||
|
||||
@example
|
||||
state 0
|
||||
|
||||
$axiom -> . exp $ (rule 0)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 2
|
||||
@end example
|
||||
|
||||
This reads as follows: ``state 0 corresponds to being at the very
|
||||
beginning of the parsing, in the initial rule, right before the start
|
||||
symbol (here, @code{exp}). When the parser returns to this state right
|
||||
after having reduced a rule that produced an @code{exp}, the control
|
||||
flow jumps to state 2. If there is no such transition on a nonterminal
|
||||
symbol, and the lookahead is a @code{NUM}, then this token is shifted on
|
||||
the parse stack, and the control flow jumps to state 1. Any other
|
||||
lookahead triggers a parse error.''
|
||||
|
||||
@cindex core, item set
|
||||
@cindex item set core
|
||||
@cindex kernel, item set
|
||||
@cindex item set core
|
||||
Even though the only active rule in state 0 seems to be rule 0, the
|
||||
report lists @code{NUM} as a lookahead symbol because @code{NUM} can be
|
||||
at the beginning of any rule deriving an @code{exp}. By default Bison
|
||||
reports the so-called @dfn{core} or @dfn{kernel} of the item set, but if
|
||||
you want to see more detail you can invoke @command{bison} with
|
||||
@option{--report=itemset} to list all the items, include those that can
|
||||
be derived:
|
||||
|
||||
@example
|
||||
state 0
|
||||
|
||||
$axiom -> . exp $ (rule 0)
|
||||
exp -> . exp '+' exp (rule 1)
|
||||
exp -> . exp '-' exp (rule 2)
|
||||
exp -> . exp '*' exp (rule 3)
|
||||
exp -> . exp '/' exp (rule 4)
|
||||
exp -> . NUM (rule 5)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 2
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
In the state 1...
|
||||
|
||||
@example
|
||||
state 1
|
||||
|
||||
exp -> NUM . (rule 5)
|
||||
|
||||
$default reduce using rule 5 (exp)
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
the rule 5, @samp{exp: NUM;}, is completed. Whatever the lookahead
|
||||
(@samp{$default}), the parser will reduce it. If it was coming from
|
||||
state 0, then, after this reduction it will return to state 0, and will
|
||||
jump to state 2 (@samp{exp: go to state 2}).
|
||||
|
||||
@example
|
||||
state 2
|
||||
|
||||
$axiom -> exp . $ (rule 0)
|
||||
exp -> exp . '+' exp (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
|
||||
$ shift, and go to state 3
|
||||
'+' shift, and go to state 4
|
||||
'-' shift, and go to state 5
|
||||
'*' shift, and go to state 6
|
||||
'/' shift, and go to state 7
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
In state 2, the automaton can only shift a symbol. For instance,
|
||||
because of the item @samp{exp -> exp . '+' exp}, if the lookahead if
|
||||
@samp{+}, it will be shifted on the parse stack, and the automaton
|
||||
control will jump to state 4, corresponding to the item @samp{exp -> exp
|
||||
'+' . exp}. Since there is no default action, any other token than
|
||||
those listed above will trigger a parse error.
|
||||
|
||||
The state 3 is named the @dfn{final state}, or the @dfn{accepting
|
||||
state}:
|
||||
|
||||
@example
|
||||
state 3
|
||||
|
||||
$axiom -> exp $ . (rule 0)
|
||||
|
||||
$default accept
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
the initial rule is completed (the start symbol and the end
|
||||
of input were read), the parsing exits successfully.
|
||||
|
||||
The interpretation of states 4 to 7 is straightforward, and is left to
|
||||
the reader.
|
||||
|
||||
@example
|
||||
state 4
|
||||
|
||||
exp -> exp '+' . exp (rule 1)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 8
|
||||
|
||||
state 5
|
||||
|
||||
exp -> exp '-' . exp (rule 2)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 9
|
||||
|
||||
state 6
|
||||
|
||||
exp -> exp '*' . exp (rule 3)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 10
|
||||
|
||||
state 7
|
||||
|
||||
exp -> exp '/' . exp (rule 4)
|
||||
|
||||
NUM shift, and go to state 1
|
||||
|
||||
exp go to state 11
|
||||
@end example
|
||||
|
||||
As was announced in beginning of the report, @samp{State 8 contains 1
|
||||
shift/reduce conflict}:
|
||||
|
||||
@example
|
||||
state 8
|
||||
|
||||
exp -> exp . '+' exp (rule 1)
|
||||
exp -> exp '+' exp . (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
|
||||
'*' shift, and go to state 6
|
||||
'/' shift, and go to state 7
|
||||
|
||||
'/' [reduce using rule 1 (exp)]
|
||||
$default reduce using rule 1 (exp)
|
||||
@end example
|
||||
|
||||
Indeed, there are two actions associated to the lookahead @samp{/}:
|
||||
either shifting (and going to state 7), or reducing rule 1. The
|
||||
conflict means that either the grammar is ambiguous, or the parser lacks
|
||||
information to make the right decision. Indeed the grammar is
|
||||
ambiguous, as, since we did not specify the precedence of @samp{/}, the
|
||||
sentence @samp{NUM + NUM / NUM} can be parsed as @samp{NUM + (NUM /
|
||||
NUM)}, which corresponds to shifting @samp{/}, or as @samp{(NUM + NUM) /
|
||||
NUM}, which corresponds to reducing rule 1.
|
||||
|
||||
Because in LALR(1) parsing a single decision can be made, Bison
|
||||
arbitrarily chose to disable the reduction, see @ref{Shift/Reduce, ,
|
||||
Shift/Reduce Conflicts}. Discarded actions are reported in between
|
||||
square brackets.
|
||||
|
||||
Note that all the previous states had a single possible action: either
|
||||
shifting the next token and going to the corresponding state, or
|
||||
reducing a single rule. In the other cases, i.e., when shifting
|
||||
@emph{and} reducing is possible or when @emph{several} reductions are
|
||||
possible, the lookahead is required to select the action. State 8 is
|
||||
one such state: if the lookahead is @samp{*} or @samp{/} then the action
|
||||
is shifting, otherwise the action is reducing rule 1. In other words,
|
||||
the first two items, corresponding to rule 1, are not eligible when the
|
||||
lookahead is @samp{*}, since we specified that @samp{*} has higher
|
||||
precedence that @samp{+}. More generally, some items are eligible only
|
||||
with some set of possible lookaheads. When run with
|
||||
@option{--report=lookahead}, Bison specifies these lookaheads:
|
||||
|
||||
@example
|
||||
state 8
|
||||
|
||||
exp -> exp . '+' exp [$, '+', '-', '/'] (rule 1)
|
||||
exp -> exp '+' exp . [$, '+', '-', '/'] (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
|
||||
'*' shift, and go to state 6
|
||||
'/' shift, and go to state 7
|
||||
|
||||
'/' [reduce using rule 1 (exp)]
|
||||
$default reduce using rule 1 (exp)
|
||||
@end example
|
||||
|
||||
The remaining states are similar:
|
||||
|
||||
@example
|
||||
state 9
|
||||
|
||||
exp -> exp . '+' exp (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp '-' exp . (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
|
||||
'*' shift, and go to state 6
|
||||
'/' shift, and go to state 7
|
||||
|
||||
'/' [reduce using rule 2 (exp)]
|
||||
$default reduce using rule 2 (exp)
|
||||
|
||||
state 10
|
||||
|
||||
exp -> exp . '+' exp (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp '*' exp . (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
|
||||
'/' shift, and go to state 7
|
||||
|
||||
'/' [reduce using rule 3 (exp)]
|
||||
$default reduce using rule 3 (exp)
|
||||
|
||||
state 11
|
||||
|
||||
exp -> exp . '+' exp (rule 1)
|
||||
exp -> exp . '-' exp (rule 2)
|
||||
exp -> exp . '*' exp (rule 3)
|
||||
exp -> exp . '/' exp (rule 4)
|
||||
exp -> exp '/' exp . (rule 4)
|
||||
|
||||
'+' shift, and go to state 4
|
||||
'-' shift, and go to state 5
|
||||
'*' shift, and go to state 6
|
||||
'/' shift, and go to state 7
|
||||
|
||||
'+' [reduce using rule 4 (exp)]
|
||||
'-' [reduce using rule 4 (exp)]
|
||||
'*' [reduce using rule 4 (exp)]
|
||||
'/' [reduce using rule 4 (exp)]
|
||||
$default reduce using rule 4 (exp)
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
Observe that state 11 contains conflicts due to the lack of precedence
|
||||
of @samp{/} wrt @samp{+}, @samp{-}, and @samp{*}, but also because the
|
||||
associativity of @samp{/} is not specified.
|
||||
|
||||
|
||||
@node Tracing
|
||||
@section Tracing Your Parser
|
||||
@findex yydebug
|
||||
@cindex debugging
|
||||
@cindex tracing the parser
|
||||
@@ -5059,6 +5462,8 @@ yyprint (FILE *file, int type, YYSTYPE value)
|
||||
@}
|
||||
@end smallexample
|
||||
|
||||
@c ================================================= Invoking Bison
|
||||
|
||||
@node Invocation
|
||||
@chapter Invoking Bison
|
||||
@cindex invoking Bison
|
||||
@@ -5158,7 +5563,7 @@ you are developing Bison.
|
||||
@itemx --debug
|
||||
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not
|
||||
already defined, so that the debugging facilities are compiled.
|
||||
@xref{Debugging, ,Debugging Your Parser}.
|
||||
@xref{Tracing, ,Tracing Your Parser}.
|
||||
|
||||
@item --locations
|
||||
Pretend that @code{%locations} was specified. @xref{Decl Summary}.
|
||||
@@ -5204,6 +5609,27 @@ Same as above, but save in the file @var{defines-file}.
|
||||
Pretend that @code{%verbose} was specified, i.e, specify prefix to use
|
||||
for all Bison output file names. @xref{Decl Summary}.
|
||||
|
||||
@item -r @var{things}
|
||||
@itemx --report=@var{things}
|
||||
Write an extra output file containing verbose description of the comma
|
||||
separated list of @var{things} among:
|
||||
|
||||
@table @code
|
||||
@item state
|
||||
Description of the grammar, conflicts (resolved and unresolved), and
|
||||
LALR automaton.
|
||||
|
||||
@item lookahead
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
each rule's lookahead set.
|
||||
|
||||
@item itemset
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
the full set of items for each state, instead of its core only.
|
||||
@end table
|
||||
|
||||
For instance, on the following grammar
|
||||
|
||||
@item -v
|
||||
@itemx --verbose
|
||||
Pretend that @code{%verbose} was specified, i.e, write an extra output
|
||||
@@ -5365,8 +5791,8 @@ Macro to discard a value from the parser stack and fake a look-ahead
|
||||
token. @xref{Action Features, ,Special Features for Use in Actions}.
|
||||
|
||||
@item YYDEBUG
|
||||
Macro to define to equip the parser with tracing code. @xref{Debugging,
|
||||
,Debugging Your Parser}.
|
||||
Macro to define to equip the parser with tracing code. @xref{Tracing,
|
||||
,Tracing Your Parser}.
|
||||
|
||||
@item YYERROR
|
||||
Macro to pretend that a syntax error has just been detected: call
|
||||
@@ -5430,7 +5856,7 @@ look-ahead token. @xref{Error Recovery}.
|
||||
@item yydebug
|
||||
External integer variable set to zero by default. If @code{yydebug}
|
||||
is given a nonzero value, the parser will output information on input
|
||||
symbols and parser action. @xref{Debugging, ,Debugging Your Parser}.
|
||||
symbols and parser action. @xref{Tracing, ,Tracing Your Parser}.
|
||||
|
||||
@item yyerrok
|
||||
Macro to cause parser to recover immediately to its normal mode
|
||||
|
||||
@@ -35,6 +35,7 @@ INCLUDES = -I$(top_builddir)/intl \
|
||||
EXTRA_DIST = malloc.c realloc.c strnlen.c
|
||||
|
||||
libbison_a_SOURCES = \
|
||||
argmatch.h argmatch.c \
|
||||
gettext.h \
|
||||
basename.c dirname.h dirname.c \
|
||||
getopt.h getopt.c getopt1.c \
|
||||
|
||||
20
po/de.po
20
po/de.po
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.35\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-04-26 11:58:57+0200\n"
|
||||
"Last-Translator: Michael Piefel <piefel@informatik.hu-berlin.de>\n"
|
||||
"Language-Team: German <de@li.org>\n"
|
||||
@@ -86,7 +86,7 @@ msgstr " %d Schiebe/Reduziere"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d Reduziere/Reduziere"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s enthält "
|
||||
@@ -608,44 +608,44 @@ msgstr "das Startsymbol %s ist undefiniert"
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "das Startsymbol %s ist ein Token"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Nutzlose Nicht-Terminale:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Nicht genutzte Terminale:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Ungenutzte Regeln:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d Regel wurde niemals reduziert\n"
|
||||
msgstr[1] "%d Regeln wurden niemals reduziert\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d nutzloses Nicht-Terminal"
|
||||
msgstr[1] "%d nutzlose Nicht-Terminale"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " und "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d nutzlose Regel"
|
||||
msgstr[1] "%d nutzlose Regeln"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "es lassen sich keine Sätze vom Startsymbol %s ableiten"
|
||||
|
||||
20
po/es.po
20
po/es.po
@@ -29,7 +29,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: GNU bison 1.35\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-04-03 10:19+0200\n"
|
||||
"Last-Translator: Nicolás García-Pedrajas <ngarcia-pedrajas@acm.org>\n"
|
||||
"Language-Team: Spanish <es@li.org>\n"
|
||||
@@ -142,7 +142,7 @@ msgstr " %d desplazamiento(s)/reducci
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d reducción(ones)/reducción(ones)"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s contiene "
|
||||
@@ -684,44 +684,44 @@ msgstr "el s
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "el símbolo de inicio (axioma) %s es un terminal"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "No terminales sin uso:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Terminales que no se usan:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Reglas sin uso:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d regla que nunca se ha reducido\n"
|
||||
msgstr[1] "%d reglas que nunca se han reducido\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d no terminal sin uso"
|
||||
msgstr[1] "%d no terminales sin uso"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " y "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d regla sin uso"
|
||||
msgstr[1] "%d reglas sin uso"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "El símbolo de inicio (axioma) %s no deriva ninguna sentencia"
|
||||
|
||||
20
po/et.po
20
po/et.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.33b\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-03-05 16:27+0200\n"
|
||||
"Last-Translator: Toomas Soome <tsoome@ut.ee>\n"
|
||||
"Language-Team: Estonian <et@li.org>\n"
|
||||
@@ -85,7 +85,7 @@ msgstr " %d nihutamine/redutseerimine"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d redutseerimine/redutseerimine"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s sisaldab "
|
||||
@@ -597,44 +597,44 @@ msgstr "stardis
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "stardisümbol %s on märk"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Kasutamata mitteterminalid:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Terminalid, mida ei kasutatud:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Kasutamata reeglid:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d reegel ei redutseeru\n"
|
||||
msgstr[1] "%d reeglit ei redutseeru\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d kasutamata mitteterminal"
|
||||
msgstr[1] "%d kasutamata mitteterminali"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " ja "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d kasutamata reegel"
|
||||
msgstr[1] "%d kasutamata reeglit"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Stardisümbolist %s ei tuletata ühtegi lauset"
|
||||
|
||||
20
po/fr.po
20
po/fr.po
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: GNU bison 1.34a\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-03-21 15:00-0500\n"
|
||||
"Last-Translator: Michel Robitaille <robitail@IRO.UMontreal.CA>\n"
|
||||
"Language-Team: French <traduc@traduc.org>\n"
|
||||
@@ -87,7 +87,7 @@ msgstr " %d d
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d réduction/réduction"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s contient "
|
||||
@@ -605,44 +605,44 @@ msgstr "le symbole de d
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "le symbole de départ %s est un terminal"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Non-terminaux inutiles:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Terminaux non utilisés:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Règles inutiles:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d règle n'a jamais été réduite\n"
|
||||
msgstr[1] "%d règles n'ont jamais été réduites\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d nonterminal inutilisable"
|
||||
msgstr[1] "%d nonterminals inutilisables"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " et "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d règle inutilisable"
|
||||
msgstr[1] "%d règles inutilisables"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Aucune phrase ne peut être dérivée du symbole de départ %s"
|
||||
|
||||
20
po/hr.po
20
po/hr.po
@@ -7,7 +7,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.34a\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-04-10 22:20+01\n"
|
||||
"Last-Translator: Denis Lackovic <delacko@fly.srk.fer.hr>\n"
|
||||
"Language-Team: Croatian <lokalizacija@linux.hr>\n"
|
||||
@@ -87,7 +87,7 @@ msgstr " %d pomakni/reduciraj"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d reduviraj/reduciraj"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s sadr¾i"
|
||||
@@ -598,44 +598,44 @@ msgstr "po
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "poèetni simbol %s je znak"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Beskorisni nezavr¹ni znakovi:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Zavr¹ni znakovi koji nisu kori¹teni:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Beskorisna pravila:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d pravilo nije nikad reducirano\n"
|
||||
msgstr[1] "%d pravila nisu nikad reducirana\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d beskorisan nezavr¹ni znak"
|
||||
msgstr[1] "%d beskorisnih nezavr¹nih znakova"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " i"
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d beskorisno pravilo"
|
||||
msgstr[1] "%d beskorisnih pravila"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Poèetni simbol %s ne daje niti jednu reèenicu"
|
||||
|
||||
20
po/it.po
20
po/it.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.31\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-01-18 12:40 CET\n"
|
||||
"Last-Translator: Paolo Bonzini <bonzini@gnu.org>\n"
|
||||
"Language-Team: Italian <it@li.org>\n"
|
||||
@@ -86,7 +86,7 @@ msgstr " %d shift/riduzione"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d riduzione/riduzione"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s contiene "
|
||||
@@ -597,44 +597,44 @@ msgstr "simbolo iniziale %s non definito"
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "specificato il token %s come simbolo iniziale"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Simboli nonterminali inutili:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Simboli terminali inutilizzati:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Regole inutili:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d regola non applicata\n"
|
||||
msgstr[1] "%d regole non applicate\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d simbolo nonterminale inutilizzato"
|
||||
msgstr[1] "%d simboli nonterminali inutilizzati"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " e "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d regola inutile"
|
||||
msgstr[1] "%d regole inutili"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "dal simbolo iniziale %s non deriva alcuna frase"
|
||||
|
||||
20
po/ja.po
20
po/ja.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: GNU bison 1.30f\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2001-12-10 15:59+0900\n"
|
||||
"Last-Translator: Daisuke Yamashita <yamad@mb.infoweb.ne.jp>\n"
|
||||
"Language-Team: Japanese <ja@li.org>\n"
|
||||
@@ -83,7 +83,7 @@ msgstr " %d
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d 還元/還元"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s の中身は"
|
||||
@@ -596,41 +596,41 @@ msgstr "
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "開始シンボル %s はトークンです"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "無意味な非終端子:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "利用されない終端子:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "無意味な規則:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d 個の規則は決して還元されません\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d 個の無意味な非終端子"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr "および"
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d 個の無意味な規則"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "開始シンボル %s はどの文にも由来しません"
|
||||
|
||||
20
po/nl.po
20
po/nl.po
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.34a\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-03-20 12:54+0100\n"
|
||||
"Last-Translator: Tim Van Holder <tim.van.holder@pandora.be>\n"
|
||||
"Language-Team: Dutch <vertaling@nl.linux.org>\n"
|
||||
@@ -87,7 +87,7 @@ msgstr " %d vershuif/reductie"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d reductie/reductie"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s bevat"
|
||||
@@ -614,37 +614,37 @@ msgstr "het startsymbool %s is niet gedefinieerd"
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "het startsymbool %s is een token"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Nutteloze niet-eindsymbolen:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Eindsymbolen die niet gebruikt worden:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Nutteloze regels:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d regel wordt nooit gereduceerd\n"
|
||||
msgstr[1] "%d regels worden nooit gereduceerd\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d nutteloos niet-eindsymbool"
|
||||
msgstr[1] "%d nutteloze niet-eindsymbolen"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " en "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
@@ -652,7 +652,7 @@ msgstr[0] "%d nutteloze regel"
|
||||
msgstr[1] "%d nutteloze regels"
|
||||
|
||||
# Ik _denk_ dat dit correct weergeeft wat er bedoeld wordt (m.a.w. er is geen regel voor het startsymbool)
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Startsymbool %s wordt vanuit geen enkele zin bereikt"
|
||||
|
||||
20
po/ru.po
20
po/ru.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.32\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-01-25 12:19+0300\n"
|
||||
"Last-Translator: Dmitry S. Sivachenko <dima@Chg.RU>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
@@ -89,7 +89,7 @@ msgstr " %d
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d ×Ù×ÏÄ/×Ù×ÏÄ"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s ÓÏÄÅÒÖÉÔ "
|
||||
@@ -606,19 +606,19 @@ msgstr "
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "ÎÁÞÁÌØÎÙÊ ÓÉÍ×ÏÌ %s Ñ×ÌÑÅÔÓÑ ÌÅËÓÅÍÏÊ"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "âÅÓÐÏÌÅÚÎÙÅ ÎÅÔÅÒÍÉÎÁÌÙ:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "îÅÉÓÐÏÌØÚÏ×ÁÎÎÙÅ ÔÅÒÍÉÎÁÌÙ:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "âÅÓÐÏÌÅÚÎÙÅ ÐÒÁ×ÉÌÁ:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
@@ -626,7 +626,7 @@ msgstr[0] "%d
|
||||
msgstr[1] "%d ÐÒÁ×ÉÌÁ ÎÅ Ó×ÅÄÅÎÏ\n"
|
||||
msgstr[2] "%d ÐÒÁ×ÉÌ ÎÅ Ó×ÅÄÅÎÏ\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
@@ -634,11 +634,11 @@ msgstr[0] "%d
|
||||
msgstr[1] "%d ÂÅÓÐÏÌÅÚÎÙÈ ÎÅÔÅÒÍÉÎÁÌÁ"
|
||||
msgstr[2] "%d ÂÅÓÐÏÌÅÚÎÙÈ ÎÅÔÅÒÍÉÎÁÌÏ×"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " É "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
@@ -646,7 +646,7 @@ msgstr[0] "%d
|
||||
msgstr[1] "%d ÂÅÓÐÏÌÅÚÎÙÈ ÐÒÁ×ÉÌÁ"
|
||||
msgstr[2] "%d ÂÅÓÐÏÌÅÚÎÙÈ ÐÒÁ×ÉÌ"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "îÁÞÁÌØÎÙÊ ÓÉÍ×ÏÌ %s ÎÅ ×Ù×ÏÄÉÔ ÎÉ ÏÄÎÏÇÏ ÐÒÅÄÌÏÖÅÎÉÑ"
|
||||
|
||||
20
po/sv.po
20
po/sv.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.33b\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-03-05 10:18+0100\n"
|
||||
"Last-Translator: Göran Uddeborg <goeran@uddeborg.pp.se>\n"
|
||||
"Language-Team: Swedish <sv@li.org>\n"
|
||||
@@ -86,7 +86,7 @@ msgstr " %d skifta/reducera"
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d reducera/reducera"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s innehåller "
|
||||
@@ -602,44 +602,44 @@ msgstr "startsymbolen %s
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "startsymbolen %s är ett element"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Oanvändbara icketerminaler:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Terminaler som inte används:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Oanvändbara regler:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d regel reduceras aldrig\n"
|
||||
msgstr[1] "%d regler reduceras aldrig\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d oanvändbar icketerminal"
|
||||
msgstr[1] "%d oanvändbara icketerminaler"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " och "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d oanvändbar regel"
|
||||
msgstr[1] "%d oanvändbara regler"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Startsymbolen %s genererar inga meningar"
|
||||
|
||||
20
po/tr.po
20
po/tr.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.34\n"
|
||||
"POT-Creation-Date: 2002-05-06 10:24+0200\n"
|
||||
"POT-Creation-Date: 2002-05-21 19:56+0200\n"
|
||||
"PO-Revision-Date: 2002-03-14 11:03GMT +02:00\n"
|
||||
"Last-Translator: Altuð Bayram <altugbayram_2000@yahoo.com>\n"
|
||||
"Language-Team: Turkish <gnu-tr-u12a@lists.sourceforge.net>\n"
|
||||
@@ -88,7 +88,7 @@ msgstr " %d
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d indirgeme/indirgeme"
|
||||
|
||||
#: src/conflicts.c:380 src/reduce.c:391
|
||||
#: src/conflicts.c:380 src/reduce.c:397
|
||||
#, c-format
|
||||
msgid "%s contains "
|
||||
msgstr "%s içerir"
|
||||
@@ -605,44 +605,44 @@ msgstr "ba
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "baþlangýç simgesi %s bir andaçtýr"
|
||||
|
||||
#: src/reduce.c:332
|
||||
#: src/reduce.c:338
|
||||
msgid "Useless nonterminals:"
|
||||
msgstr "Yararsýz deðiþken simgeler:"
|
||||
|
||||
#: src/reduce.c:346
|
||||
#: src/reduce.c:352
|
||||
msgid "Terminals which are not used:"
|
||||
msgstr "Kullanýlmayan sabit simgeler:"
|
||||
|
||||
#: src/reduce.c:358
|
||||
#: src/reduce.c:364
|
||||
msgid "Useless rules:"
|
||||
msgstr "Yararsýz kurallar:"
|
||||
|
||||
#: src/reduce.c:386
|
||||
#: src/reduce.c:392
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d kural asla indirgenmedi\n"
|
||||
msgstr[1] "%d kural asla indirgenmedi\n"
|
||||
|
||||
#: src/reduce.c:394
|
||||
#: src/reduce.c:400
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d yararsýz deðiþken simge"
|
||||
msgstr[1] "%d yararsýz deðiþken simge"
|
||||
|
||||
#: src/reduce.c:400
|
||||
#: src/reduce.c:406
|
||||
msgid " and "
|
||||
msgstr " ve "
|
||||
|
||||
#: src/reduce.c:403
|
||||
#: src/reduce.c:409
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d yararsýz kural"
|
||||
msgstr[1] "%d yararsýz kural"
|
||||
|
||||
#: src/reduce.c:433
|
||||
#: src/reduce.c:439
|
||||
#, c-format
|
||||
msgid "Start symbol %s does not derive any sentence"
|
||||
msgstr "Baþlangýç simgesi %s herhangi bir cümleden türemez"
|
||||
|
||||
@@ -43,7 +43,7 @@ static bitset lookaheadset;
|
||||
static inline void
|
||||
log_resolution (state_t *state, int LAno, int token, const char *resolution)
|
||||
{
|
||||
if (verbose_flag)
|
||||
if (report_flag & report_states)
|
||||
obstack_fgrow4 (&output_obstack,
|
||||
_("\
|
||||
Conflict in state %d between rule %d and token %s resolved as %s.\n"),
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "getopt.h"
|
||||
#include "system.h"
|
||||
#include "files.h"
|
||||
#include "getopt.h"
|
||||
#include "argmatch.h"
|
||||
#include "complain.h"
|
||||
#include "getargs.h"
|
||||
#include "xalloc.h"
|
||||
#include "options.h"
|
||||
#include "files.h"
|
||||
|
||||
int debug_flag = 0;
|
||||
int defines_flag = 0;
|
||||
int locations_flag = 0;
|
||||
int no_lines_flag = 0;
|
||||
int no_parser_flag = 0;
|
||||
int report_flag = 0;
|
||||
int token_table_flag = 0;
|
||||
int verbose_flag = 0;
|
||||
int yacc_flag = 0; /* for -y */
|
||||
int graph_flag = 0;
|
||||
int trace_flag = 0;
|
||||
@@ -44,6 +43,48 @@ const char *include = NULL;
|
||||
|
||||
extern char *program_name;
|
||||
|
||||
/*----------------------.
|
||||
| --report's handling. |
|
||||
`----------------------*/
|
||||
|
||||
static const char * const report_args[] =
|
||||
{
|
||||
/* In a series of synonyms, present the most meaningful first, so
|
||||
that argmatch_valid be more readable. */
|
||||
"none",
|
||||
"state", "states",
|
||||
"itemset", "itemsets",
|
||||
"lookahead", "lookaheads",
|
||||
"all",
|
||||
0
|
||||
};
|
||||
|
||||
static const int report_types[] =
|
||||
{
|
||||
report_none,
|
||||
report_states, report_states,
|
||||
report_states | report_itemsets, report_states | report_itemsets,
|
||||
report_states | report_lookaheads, report_states | report_lookaheads,
|
||||
report_all
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
report_argmatch (char *args)
|
||||
{
|
||||
ARGMATCH_ASSERT (report_args, report_types);
|
||||
do
|
||||
{
|
||||
int report = XARGMATCH ("--report", args,
|
||||
report_args, report_types);
|
||||
if (report == report_none)
|
||||
report_flag = report_none;
|
||||
else
|
||||
report_flag |= report;
|
||||
}
|
||||
while ((args = strtok (NULL, ",")));
|
||||
}
|
||||
|
||||
/*---------------------------.
|
||||
| Display the help message. |
|
||||
`---------------------------*/
|
||||
@@ -89,10 +130,18 @@ Parser:\n\
|
||||
fputs (_("\
|
||||
Output:\n\
|
||||
-d, --defines also produce a header file\n\
|
||||
-v, --verbose also produce an explanation of the automaton\n\
|
||||
-r, --report=THINGS also produce details on the automaton\n\
|
||||
-v, --verbose same as `--report=state'\n\
|
||||
-b, --file-prefix=PREFIX specify a PREFIX for output files\n\
|
||||
-o, --output=FILE leave output to FILE\n\
|
||||
-g, --graph also produce a VCG description of the automaton\n\
|
||||
\n\
|
||||
THINGS is a list of comma separated words that can include:\n\
|
||||
`state' describe the states\n\
|
||||
`itemset' complete the core item sets with their closure\n\
|
||||
`lookahead' explicitly associate lookaheads to items\n\
|
||||
`all' include all the above information\n\
|
||||
`none' disable the report\n\
|
||||
"), stream);
|
||||
putc ('\n', stream);
|
||||
|
||||
@@ -170,7 +219,7 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose_flag = 1;
|
||||
report_flag |= report_states;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
@@ -196,10 +245,6 @@ getargs (int argc, char *argv[])
|
||||
token_table_flag = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
fatal (_("`%s' is no longer supported"), "--raw");
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
no_parser_flag = 1;
|
||||
break;
|
||||
@@ -220,6 +265,10 @@ getargs (int argc, char *argv[])
|
||||
spec_name_prefix = optarg;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
report_argmatch (optarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Parse command line arguments for bison.
|
||||
Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc.
|
||||
Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -31,11 +32,22 @@ extern int locations_flag;
|
||||
extern int no_lines_flag; /* for -l */
|
||||
extern int no_parser_flag; /* for -n */
|
||||
extern int token_table_flag; /* for -k */
|
||||
extern int verbose_flag; /* for -v */
|
||||
extern int graph_flag; /* for -g */
|
||||
extern int yacc_flag; /* for -y */
|
||||
extern int trace_flag;
|
||||
|
||||
/* --report. */
|
||||
enum
|
||||
{
|
||||
report_none = 0,
|
||||
report_states = 1 << 0,
|
||||
report_itemsets = 1 << 1,
|
||||
report_lookaheads = 1 << 2,
|
||||
report_all = ~0
|
||||
};
|
||||
|
||||
extern int report_flag;
|
||||
|
||||
void getargs PARAMS ((int argc, char *argv[]));
|
||||
|
||||
#endif /* !GETARGS_H_ */
|
||||
|
||||
13
src/lex.c
13
src/lex.c
@@ -484,7 +484,7 @@ option_strcmp (const char *left, const char *right)
|
||||
token_t
|
||||
parse_percent_token (void)
|
||||
{
|
||||
const struct option_table_struct *tx = NULL;
|
||||
const struct option_table_s *tx = NULL;
|
||||
const char *arg = NULL;
|
||||
/* Where the ARG was found in token_buffer. */
|
||||
size_t arg_offset = 0;
|
||||
@@ -578,15 +578,16 @@ parse_percent_token (void)
|
||||
switch (tx->ret_val)
|
||||
{
|
||||
case tok_stropt:
|
||||
assert (tx->set_flag);
|
||||
assert (tx->flag);
|
||||
if (arg)
|
||||
{
|
||||
char **flag = (char **) tx->flag;
|
||||
/* Keep only the first assignment: command line options have
|
||||
already been processed, and we want them to have
|
||||
precedence. Side effect: if this %-option is used
|
||||
several times, only the first is honored. Bah. */
|
||||
if (!*((char **) (tx->set_flag)))
|
||||
*((char **) (tx->set_flag)) = xstrdup (arg);
|
||||
if (!*flag)
|
||||
*flag = xstrdup (arg);
|
||||
}
|
||||
else
|
||||
fatal (_("`%s' requires an argument"), token_buffer);
|
||||
@@ -594,8 +595,8 @@ parse_percent_token (void)
|
||||
break;
|
||||
|
||||
case tok_intopt:
|
||||
assert (tx->set_flag);
|
||||
*((int *) (tx->set_flag)) = 1;
|
||||
assert (tx->flag);
|
||||
*((int *) (tx->flag)) = 1;
|
||||
return tok_noop;
|
||||
break;
|
||||
|
||||
|
||||
@@ -50,7 +50,10 @@ typedef enum token_e
|
||||
tok_define,
|
||||
tok_skel,
|
||||
tok_noop,
|
||||
/* A directive that sets to true its associated variable. */
|
||||
tok_intopt,
|
||||
/* A directive that sets its associated variable to the string
|
||||
argument. */
|
||||
tok_stropt,
|
||||
tok_illegal,
|
||||
tok_obsolete
|
||||
|
||||
@@ -91,7 +91,7 @@ main (int argc, char *argv[])
|
||||
compute_output_file_names ();
|
||||
|
||||
/* Output the detailed report on the grammar. */
|
||||
if (verbose_flag)
|
||||
if (report_flag)
|
||||
print_results ();
|
||||
|
||||
/* Stop if there were errors, to avoid trashing previous output
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "options.h"
|
||||
|
||||
/* Shorts options. */
|
||||
const char *shortopts = "yvegdhrltknVo:b:p:S:";
|
||||
const char *shortopts = "yvegdhr:ltknVo:b:p:S:";
|
||||
|
||||
/* A CLI option only.
|
||||
Arguments is the policy: `no', `optional', `required'.
|
||||
@@ -52,7 +52,7 @@ const char *shortopts = "yvegdhrltknVo:b:p:S:";
|
||||
(String), (Arguments##_argument), (Var), (Token), (OptionChar) },
|
||||
|
||||
|
||||
const struct option_table_struct option_table[] =
|
||||
const struct option_table_s option_table[] =
|
||||
{
|
||||
/*
|
||||
* Command line.
|
||||
@@ -71,6 +71,8 @@ const struct option_table_struct option_table[] =
|
||||
OPTN ("output", required, 0, 0, 'o')
|
||||
OPTN ("output-file", required, 0, 0, 'o')
|
||||
OPTN ("graph", optional, 0, 0, 'g')
|
||||
OPTN ("report", required, 0, 0, 'r')
|
||||
OPTN ("verbose", no, 0, 0, 'v')
|
||||
|
||||
/* Hidden. */
|
||||
OPTN ("trace", no, &trace_flag, 0, 1)
|
||||
@@ -92,6 +94,7 @@ const struct option_table_struct option_table[] =
|
||||
DRTV ("nonassoc", no, NULL, tok_nonassoc)
|
||||
DRTV ("binary", no, NULL, tok_nonassoc)
|
||||
DRTV ("prec", no, NULL, tok_prec)
|
||||
DRTV ("verbose", no, &report_flag, tok_intopt)
|
||||
DRTV ("error-verbose",no, &error_verbose, tok_intopt)
|
||||
|
||||
/* FIXME: semantic parsers will output an `include' of an
|
||||
@@ -111,7 +114,6 @@ const struct option_table_struct option_table[] =
|
||||
|
||||
/* Output. */
|
||||
BOTH ("defines", optional, &defines_flag, tok_intopt, 'd')
|
||||
BOTH ("verbose", no, &verbose_flag, tok_intopt, 'v')
|
||||
|
||||
/* Operation modes. */
|
||||
BOTH ("fixed-output-files", no, &yacc_flag, tok_intopt, 'y')
|
||||
@@ -122,7 +124,7 @@ const struct option_table_struct option_table[] =
|
||||
BOTH ("locations", no, &locations_flag, tok_intopt, 1)
|
||||
BOTH ("no-lines", no, &no_lines_flag, tok_intopt, 'l')
|
||||
BOTH ("no-parser", no, &no_parser_flag, tok_intopt, 'n')
|
||||
BOTH ("raw", no, 0, tok_obsolete, 'r')
|
||||
BOTH ("raw", no, 0, tok_obsolete, 0)
|
||||
BOTH ("skeleton", required, 0, tok_skel, 'S')
|
||||
BOTH ("token-table", no, &token_table_flag, tok_intopt, 'k')
|
||||
|
||||
@@ -153,17 +155,16 @@ long_option_table_new ()
|
||||
if (option_table[i].access == opt_cmd_line
|
||||
|| option_table[i].access == opt_both)
|
||||
{
|
||||
/* Copy the struct information in the longoptions. */
|
||||
res[j].name = option_table[i].name;
|
||||
res[j].has_arg = option_table[i].has_arg;
|
||||
/* When an options is declared having 'optional_argument' and
|
||||
a flag is specified to be set, the option is skipped on
|
||||
command line. So we never use a flag when a command line
|
||||
option is declared 'optional_argument. */
|
||||
/* When a getopt_long option has an associated variable
|
||||
(member FLAG), then it is set of the VAL member value. In
|
||||
other words, we cannot expect getopt_long to store the
|
||||
argument if we also want a short option. */
|
||||
if (res[j].has_arg == optional_argument)
|
||||
res[j].flag = NULL;
|
||||
else
|
||||
res[j].flag = option_table[i].set_flag;
|
||||
res[j].flag = option_table[i].flag;
|
||||
res[j++].val = option_table[i].val;
|
||||
}
|
||||
res[number_options].name = NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Concentrate all options use in bison,
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef enum opt_access_e
|
||||
|
||||
/* This is the general struct, which contains user's options from
|
||||
command line or in grammar with percent flag. */
|
||||
struct option_table_struct
|
||||
struct option_table_s
|
||||
{
|
||||
/* Set the accessibility. */
|
||||
opt_access_t access;
|
||||
@@ -42,8 +42,8 @@ struct option_table_struct
|
||||
const char *name;
|
||||
/* Use for command line. */
|
||||
int has_arg;
|
||||
/* A set_flag value causes the named flag to be set. */
|
||||
void *set_flag;
|
||||
/* An optional lvalue to be set. */
|
||||
void *flag;
|
||||
/* A retval action returns the code. */
|
||||
int ret_val;
|
||||
/* The short option value, frequently a letter. */
|
||||
@@ -53,9 +53,9 @@ struct option_table_struct
|
||||
extern const char *shortopts;
|
||||
|
||||
/* Table which contain all options. */
|
||||
extern const struct option_table_struct option_table[];
|
||||
extern const struct option_table_s option_table[];
|
||||
|
||||
/* Set the longopts variable from option_table. */
|
||||
/* Return a malloc'd list of the options for getopt_long. */
|
||||
struct option *long_option_table_new PARAMS ((void));
|
||||
|
||||
#endif /* !OPTIONS_H_ */
|
||||
|
||||
18
src/print.c
18
src/print.c
@@ -72,9 +72,8 @@ print_core (FILE *out, state_t *state)
|
||||
item_number_t *sitems = state->items;
|
||||
int snritems = state->nitems;
|
||||
|
||||
/* New experimental feature: if TRACE_FLAGS output all the items of
|
||||
a state, not only its kernel. */
|
||||
if (trace_flag)
|
||||
/* Output all the items of a state, not only its kernel. */
|
||||
if (report_flag & report_itemsets)
|
||||
{
|
||||
closure (sitems, snritems);
|
||||
sitems = itemset;
|
||||
@@ -105,8 +104,8 @@ print_core (FILE *out, state_t *state)
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
fprintf (out, " %s", escape (symbols[*sp]->tag));
|
||||
|
||||
/* Experimental feature: display the lookaheads. */
|
||||
if (trace_flag && state->nlookaheads)
|
||||
/* Display the lookaheads? */
|
||||
if (report_flag & report_lookaheads)
|
||||
{
|
||||
int j, k;
|
||||
int nlookaheads = 0;
|
||||
@@ -513,10 +512,9 @@ print_results (void)
|
||||
|
||||
print_grammar (out);
|
||||
|
||||
/* New experimental feature: output all the items of a state, not
|
||||
only its kernel. Requires to run closure, which need memory
|
||||
allocation/deallocation. */
|
||||
if (trace_flag)
|
||||
/* If the whole state item sets, not only the kernels, are wanted,
|
||||
`closure' will be run, which needs memory allocation/deallocation. */
|
||||
if (report_flag & report_itemsets)
|
||||
new_closure (nritems);
|
||||
/* Storage for print_reductions. */
|
||||
shiftset = bitset_create (ntokens, BITSET_FIXED);
|
||||
@@ -525,7 +523,7 @@ print_results (void)
|
||||
print_state (out, states[i]);
|
||||
bitset_free (shiftset);
|
||||
bitset_free (lookaheadset);
|
||||
if (trace_flag)
|
||||
if (report_flag & report_itemsets)
|
||||
free_closure ();
|
||||
|
||||
xfclose (out);
|
||||
|
||||
Reference in New Issue
Block a user