-
Notifications
You must be signed in to change notification settings - Fork 24
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
Allow comments in grammars #37
Comments
i don't think we'd have to look for |
now that i think of it, we should be able to confine comment parsing entirely within whitespace parsing, can you think of any exceptions? |
wait a second that's wrong, it's actually just |
i'm not sure if this should be closed yet, i found this out in the wild, it's VERY old but it's usage of comments really make sense, if newlines are allowable WS then any whitespace could have comments inside |
i might just have to bite the bullet on this one and replace all the simple WS parsing with a custom function that parses WS while transparently skipping comments |
one note here is that I don't think comments are actually allowed anywhere except at the end of a rule so rather than it's just From section 2.8 of the spec linked above:
|
which effectively means that anything that follows a |
also 🤔 I think we already handle |
|
I think we're talking about the same thing but just in case, here's the current behavior for bnf grammars
is equivalent to
i.e. but if we want to handle comments correctly, I believe we want
to be equivalent to
|
the problem is currently all WS could include newlines so all WS has to handle comments, take this example from the RFC u quoted foreinstance, it idiomatically puts a NL in the whitespace before a
|
oh, that's what ur talking about, yeah i thought that was a little weird, i've never seen that used out in the wild for that matter, not sure why anyone would want 2 production rules on 1 line |
hah brevity I guess, it's my fault 😆 to your previous point, I think that's okay! since we know that all comments will start with |
We need a way to allow incorporating comments into a grammar. It seems somewhat standard to
use the
;
to indicate the start of a comment and a\n
to close it. It'd be a good add I think to make that work.A couple initial questions:
;
all along the way?The text was updated successfully, but these errors were encountered: