-
Notifications
You must be signed in to change notification settings - Fork 164
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
Optional Semicolons #447
Comments
This is clearly not a dealbreaker, I could go with mandatory semicolons or figure out a way to use layout even if that seems opinionated. But – the fact that the
…seems like a bug. Having the character I explicitly specified be accepted but treated as other characters, is definitely unexpected (or at least unintuitive) behavior. |
There is work in progress by @beataburreau on a new implementation of BNFC where one has a |
I think there is some bug about using semicolons somewhere... I'm trying to make a tinybasic grammar, but when i use a semicolon as a separator (like "PRINT A$;B$" ) it parses ok but the prettyprinter put every part on a different line. Changing the separator to a comma works fine... |
@praduca: There is same hard-writing in the |
Ah good to know it is something simple. Thanks for commenting so quickly |
Is it possible to create a syntax in LBNF in which, given a statement can have parts
<one>
and<two>
, the following are all legal syntax?Unlike layout, I do not have keywords at which open/close brackets can be inserted, and I do no necessarily want tab/alignment to be required for correct interpretation.
I simply want the parser to say, when it encounters a new line, something like:
(Similar to, say, JavaScript's "semicolon insertion" rule. Semicolons are generally required only where the beginning of a statement could also be interpreted as the continuation of the previous statement, or to write statements on one line. But Haskell's or Python's whitespace-based layout is not used. Just a rule that a line break can end a complete statement. Maybe similar to shell script?)
I tried this grammar:
Which successfully makes semicolons optional! BUT it doesn't require a newline in the absence of a semicolon. It acts as though I had written
""
instead of"\n"
. So e.g. this parses (which it should not, it should require a semicolon or a newline):And this:
…which should parse and then print back as this:
…does parse but instead prints back as this:
(If I were to, say, add a semicolon at the end of either of these examples, it would still parse and either would print
hello world hello world ;
– The semicolon seems to work fine when it is present.)I tried this modification (replacing the grammar line beginning with
Blank
):But the effect is that the semicolon is required.
The text was updated successfully, but these errors were encountered: