help-bison
[Top][All Lists]
Advanced

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

Re: Help in understanding *.output file


From: Hans Aberg
Subject: Re: Help in understanding *.output file
Date: Sun, 19 Jan 2003 20:32:16 +0100

At 20:25 +0530 2003/01/19, Rajasankar K wrote:
[Reply to: "Bison Help" <address@hidden>]
>My understanding:
>============
>
>state 0 and state 1:
>-------------------
>Bison starts with state 0. On getting a NUMBER token, bison shifts that
>terminal to the stack and goes to state 1.
>When entering state1 the stack top *will* contain a NUMBER. No sooner than
>bison enters state 1, it does a reduction, since only $default is the event
>specified. So, NUMBER is popped from the stack and expr is pushed into the
>stack. On reduction bison *will always* go back to the state from which it
>entered the current state.

The correct version of how this so called push-down automaton works is
described in books on compilers, for example Aho, Sethi & Ullman,
"Compilers...", fig. 4.30, p.219. There is an online Parsing Techniques
book available, which might also have such descriptions:
    http://www.cs.vu.nl/~dick/PTAPG.html

Actually, with every token or grammar variable also a state is pushed (and
they are always popped in pairs, so one can have a stack which uses grammar
variable-state pairs if one so wants); the stack top state value is the
current state. A reduction reduces to a grammar variable; one then computes
the new current state pushed onto the top of the stack from the old top
value after the reduction on the stack and this grammar variable.

Studying such a book will also explain most of the stuff in the .output file.

  Hans Aberg






reply via email to

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