Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

understanding debugfile states #65

Open
codykingham opened this issue Mar 11, 2021 · 1 comment
Open

understanding debugfile states #65

codykingham opened this issue Mar 11, 2021 · 1 comment

Comments

@codykingham
Copy link

Hi all. I'm a newbie to YACC parsing, so apologies if this is trivial.

I'm using the debugfile and need a little help understanding the structure of each state printout.

Here's an example from my file:

state 4
    (3) phrase -> quant .
    $end            reduce using rule 3 (phrase -> quant .)
    CONJ            reduce using rule 3 (phrase -> quant .)
    CARD            reduce using rule 3 (phrase -> quant .)
    ART             reduce using rule 3 (phrase -> quant .)

What I'm confused by:
In this particular state the terminals CONJ, CARD, and ART are not mentioned in the first line, but they are mentioned in the actions. Why is this? My impression was that the actions refer back to the position within the parse.

@codykingham
Copy link
Author

After doing my homework, I believe I now have a good understanding of what's going on. After the position marker quant ., we may encounter any of the 4 input tokens next (given the grammar), i.e. end of string, CONJ, CARD, or ART. So it doesn't matter that they aren't listed.

I'm not yet clear why the printout sometimes does and doesn't include the next input token in the position string. Maybe this is just for brevity in some cases?

If anyone else is also trying to grasp the parser output, I've found the YACC documentation very instructive (see section 4 of http://dinosaur.compilertools.net/yacc/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant