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

Re: ocamlyacc and $end #2823

Closed
vicuna opened this issue Jul 1, 2001 · 2 comments
Closed

Re: ocamlyacc and $end #2823

vicuna opened this issue Jul 1, 2001 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Jul 1, 2001

Original bug ID: 420
Reporter: administrator
Status: closed (set by @damiendoligez on 2005-12-15T14:49:26Z)
Resolution: won't fix
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Related to: #2327

Bug description

Full_Name: Ørjan Johansen
Version: ocaml-3.01-2
OS: linux
Submission from: fimfpc67.math.ntnu.no (129.241.15.112)

Dear Caml developers,

I have had certain problems using/understanding ocamlyacc, which I
now believe have to do with an inconsistency in whether a parsed
expression needs to be followed by EOF or not.

I noticed a similar bug report (id 4) by Prof. Courant, which,
although from December 1999, is still open.

I did some further investigations, which I hope may be of help in
correcting the bug.

The problem seems to occur when the parser is able to reduce an
expression to the goal %entry% without considering the lookahead.
This reduction causes a semantic action raising the YYexit exception,
and thus finishing parsing.

This is a slight difference from what the *.output file would imply,
which is that one should then pass to the final state, containing the
action

$end accept

I suspect that it is the lack of this final test for $end=EOF that is
the cause of the bug.

I have tried to think of a fix, but I have not been able to understand
the C code. My best guess would be to modify the automaton so that
the final state exists and tests for $end.

Otherwise, I would like to add my voice to those who would like
ocamlyacc to allow the passing of an extra argument to semantic
actions.

Yours sincerely,
Ørjan Johansen.

@vicuna
Copy link
Author

vicuna commented Jul 2, 2001

Comment author: administrator

I have had certain problems using/understanding ocamlyacc, which I
now believe have to do with an inconsistency in whether a parsed
expression needs to be followed by EOF or not.

I noticed a similar bug report (id 4) by Prof. Courant, which,
although from December 1999, is still open.

Yes -- I'm still puzzled about this aspect of ocamlyacc!
Empirically, the following solution works well:

  • always have the grammar entry point of the form

      entry:  somestuff EOF {...} ;
    
  • always have the lexer emit the EOF token when hitting the end of the
    input

This EOF token prevents the parser from "going too far". Still, I
agree that a better understanding of the $end pseudo-token could help.

Otherwise, I would like to add my voice to those who would like
ocamlyacc to allow the passing of an extra argument to semantic
actions.

You can sort of do it with having semantic actions return a functional
value. Built-in support for this would be nice, but it's not entirely
obvious.

Sincerely,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jul 2, 2001

Comment author: administrator

See #2327

@vicuna vicuna closed this as completed Dec 15, 2005
@vicuna vicuna added the wontfix label Mar 14, 2019
This was referenced Mar 14, 2019
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant