help-bison
[Top][All Lists]
Advanced

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

Re: y.output format


From: Matthew P. Carter 98
Subject: Re: y.output format
Date: Fri, 21 Jun 2002 10:35:38 +0200

On 10 Jan 2002, Hans Aberg wrote:
>
> At 18:54 +0100 2002/01/09, Bernard Granier wrote:
> > Where can I find a  simple tutorial which explains the
y.output
> > file format ?
>
> It follows the standard format of bottom up parsing
(Bison uses
> LALR(1)), son one can look into standard books describing
that
> method. For example, Aho, Sethi & Ullman, "Compilers...".
>
> Bison generates code for a stack machine, which uses a
lookahead
> token to determine what action to take, and to find the
next
> state. For example, in
> state 11
>     command  ->  "rule" expression_list .   (rule 7)
>     expression_list  ->  expression_list . production
(rule 10)
>
>     "nonterminal"     shift, and go to state 12
>
>     $default  reduce using rule 7 (command)
>
>     production        go to state 13
>
> the dot "." on the RHS means that this is the point the
state
> machine has parsed so far, and the list below tells which
action to
> take, and which is the next state after that.

Hi Hans,

Thank you for your informative postings.

I have thoroughly reviewed the bison manual and the help-
bison archives.  I understand that, from any state, the
type of the look-ahead token is used to determine whether
to 1) shift that token onto the stack and go to another
state or 2) reduce some tokens or non-terminals on the top
of the stack to a single non-terminal on the top of the
stack.

What I don't understand is how a NON-terminal can ever be
the input to the finite state machine.  For example, your
example above indicates that the 'production' non-terminal
appearing on input causes the parser to go to state 13.
Shouldn't the input always only be the look-ahead token
(never a non-terminal)?  Is the line "production        go
to state 13" only there as extra information to remind the
human viewer that state 13 is the state to be used in the
situation of "expression_list  ->  expression_list
production ."?

Thank you very much for your time.





reply via email to

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