help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

about parse-gram of bison itself


From: tys lefering
Subject: about parse-gram of bison itself
Date: Sun, 6 Jun 2010 19:39:01 +0200
User-agent: SquirrelMail/1.4.18

Hi,
In parse-gram.y from GNU bison-2.5 branch.

The grammar_declaration rule is in 2 parts:

1)

grammar_declaration:
  precedence_declaration
| symbol_declaration
| "%start" symbol
| "%destructor" "{...}" generic_symlist
| "%printer" "{...}" generic_symlist
| "%default-prec"
| "%no-default-prec"
| "%code" braceless
| "%code" ID braceless
;

and 2)

grammar_declaration:
  "%union" union_name braceless
;

This is possible according to the manual, but what is
the reason to do this in this parser ? why not joined?

Also there is a '%token PERCENT_UNION "%union"' statement
in the grammar rules section, why not in the declarations
section? is this a bison feature or general for yacc grammars?

The manual does not say it is possible to have declarations
in the grammar rules section.

Worked with the bison parse-gram.y and did not find bugs
only some notes:
a FIXME comment in scan-gram.l in convert_ucn_to_byte()
/* FIXME: Currently we assume Unicode-compatible unibyte characters
     on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes).  On
     non-ASCII hosts we support only the portable C character set.
     These limitations should be removed once we add support for
     multibyte characters.  */
and no error check for errno at the strtoul().

in the <INITIAL> section in scan-gram.l most keywords allow
mixture of '-' and '_' example %pure[-_]parser but not for
all, like %file-prefix, is there a reason for this ?

the %term and %token return PERCENT_TOKEN in scan-gram.l
but nowhere this %term is documented. maybe bison can warn
about %term usage which only is found in very old grammars.

there is a %token GRAM_EOF in parser but not used and
not in lexer, does it have a function?

in grammar is at:
prologue_declaration:
 | /*FIXME: Err?  What is this horror doing here? */ ";"
 ;

is it so bad to have a extra ';' floating around ?

in the parser is another FIXME
/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
   FIXME: depends on the undocumented availability of YYLLOC.  */
#undef  yyerror
#define yyerror(Msg) \
        gram_error (&yylloc, Msg)
what is this about ?

and because of obstack bison allows unlimited string length
everywhere, right ? that can be a problem with graph output
which has a string length max. of 20000 chars for vcg and
possibly other formats have also limitations and maybe somehow
it could be a problem in the xml output and xstl, not tested
and checked yet.


pasted from the manual:

Bison declarations

%%
Grammar rules
%%

The Bison declarations declare the names of the terminal
and nonterminal symbols, and may also describe operator
precedence and the data types of semantic values of various symbols.

The grammar rules define how to construct each nonterminal
symbol from its parts.

http://www.gnu.org/software/bison/manual/bison.html#Grammar-Layout

http://www.gnu.org/software/bison/manual/bison.html#Rules

Multiple rules for the same result can be written separately
or can be joined with the vertical-bar character ‘|’ as follows:

result: rule1-components...
 | rule2-components...
 ...
 ;

They are still considered distinct rules even when joined in this way.

Thanks,







reply via email to

[Prev in Thread] Current Thread [Next in Thread]