-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Uniform attributation: skip vs. fragment vs. hidden #27
Milestone
Comments
Closed
danieldietrich
modified the milestones:
1.1.0 M5 Additional Parser Features,
1.1.0 M1 - Parser Core
Sep 25, 2014
Consider adding attribution with annotations. It is more consistent to use a single syntactic element to augment grammar rules with meta information for processing parser input.
Notes:
Example:
For better readability braces may be used:
Tip: Use fragments when more attributes are needed:
|
danieldietrich
changed the title
[parser] Uniform attributation: skip vs. fragment vs. hidden
Uniform attributation: skip vs. fragment vs. hidden
Oct 3, 2014
Another idea is to write
because it is not so much noise. |
Closed
moved to javaslang-parser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Antlr parser has two phases: lexing and parsing.
We see that Antlr distinguishes the fact of hiding something from the result in a technical way. Parts of the grammar are attributed in different ways because the author of the grammar implicitly knows how the Altr framework works.
The Jslp (Javaslang Parser) has only one phase which combines lexing and parsing. The author of Jslp grammars should be able to attribute parts of the grammar in a uniform way. E.g. the Antlr lets us declare associativity of operators as
<assoc=right>
and<assoc=left>
. Additionally it attributes rules as prefixfragment
and it lets us declare (lexer?) rule alternatives as-> skip
. That are three different ways to attribute something, which is too diverse, imo.Therefore I suggest to simplify attributation, e.g. like this
Attributes are technically
<key=value>
pairs and semantically properties of the attributed element. In the case of a boolean property, value may be omitted if it is true, i.e.<hidden=true>
is the same as<hidden>
.Perhaps it is better for readability to add the rule attributes after
;
, like this:But on the other hand, Java's annotations are prefixed, so we may also do the same here:
The text was updated successfully, but these errors were encountered: