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

parsing bug for lazy expressions #7512

Closed
vicuna opened this issue Mar 29, 2017 · 1 comment
Closed

parsing bug for lazy expressions #7512

vicuna opened this issue Mar 29, 2017 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Mar 29, 2017

Original bug ID: 7512
Reporter: reuben.rowe
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-03-29T18:30:28Z)
Resolution: not a bug
Priority: normal
Severity: minor
Platform: Linux
OS: Ubuntu
OS Version: 16.04
Version: 4.04.0
Category: lexing and parsing

Bug description

According to the language specification

https://caml.inria.fr/pub/docs/manual-ocaml/expr.html

I should be able to write something like the following:

# let v = lazy let s = "hello" in s ^ "world" ;;

However this is reported as a syntax error by the compiler.

On the other hand, the following is fine:

# let v = lazy (let s = "hello" in s ^ "world") ;;

Is this a bug, or have I missed something?

Steps to reproduce

Enter the following in an interactive session:

let v = lazy let s = "hello" in s ^ "world" ;;

@vicuna
Copy link
Author

vicuna commented Mar 29, 2017

Comment author: @gasche

The BNF grammar specifies the structure of the code, but it does not enforce the parenthesizing strategy -- this is specified by associativies and precedence rules that are not part of the more declarative BNF grammar. In this particular case, the current way grammar rules are organized in the parser rejects requires a bit more parenthesizing than what is strictly required for ambiguity rejection, but I believe that this should not be considered a bug -- at best, allowing the relaxed form could be a feature/tweak request. Given that the latter doesn't seem more readable for humans (and can easily be avoided in computer-generated code by adding parentheses around lazy), I marked this PR as "no change required".

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

2 participants