-
Notifications
You must be signed in to change notification settings - Fork 4
Bootstrap AST and parser #1
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
Conversation
Optional(Optional<Input>), | ||
|
||
/// Text. | ||
Text(Input), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deviates from the original grammar by missing the parameter
variant.
Need to discuss this on voice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyranron there is a Note:
section which says
While
parameter
is allowed to appear as part ofalternative
andoption
in the AST, such an AST is not a valid a Cucumber Expression.
Basically ARCHITECTURE.md
describes AST that tries to be wider than Cucumber Expression
for some reason (the only I can think of is to make parser implementation simpler and then error on conversion to real Cucumber Expression
).
But in reality it doesn't make much sense to me. Especially alternative
definition
alternative = optional | parameter | text
text = whitespace | ")" | "}" | .
This grammar suggests that alternative
may have unescaped whitespaces, which is not true: example. They have to be escaped at least to avoid ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not even EBNF, as I understand, as wikipedia says that repetition is described with {...}
and not with (...)*
. It looks more like regex, but still has ,
for concatenation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilslv would you be so kind to make a PR to upstream that adjusts the described grammar to be accurate and precise enough. Because it really bothers: having spec which doesn't reflect reality, while implementations don't follow the spec 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not even EBNF, as I understand, as wikipedia says that repetition is described with
{...}
and not with(...)*
. It looks more like regex, but still has,
for concatenation.
From your link: *
is a repetition, and ( ... )
is grouping. So we have a group repetion here. I don't see any mistakes in that. And in Markdown it has ```ebnf
notation 🤷♂️
src/parse.rs
Outdated
/// ```text | ||
/// parameter := '{' (name | '\' name_to_escape)* '}' | ||
/// name := ^name_to_escape | ||
/// name_to_escape := '{' | '}' | '(' | '/' | '\' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to preserve here the original EBNF grammar syntax, so it will match the architecture document, and preserve original naming asap.
Markdown can do EBNF pretty well, though:
parameter = "{" (name | "\" name_to_escape)* "}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described above, provided EBNF grammar tries to describe language that is wider than Cucumber Expression
, but has errors. Grammar in my PR describes exactly Cucumber Expression
.
ack @ilslv As I've re-created this PR and represent its author, GitHub refuses to let me review it. So, please, just ping me for the next review. |
@tyranron can you add me as collaborator in this repo, so I can push |
@ilslv here you go |
@tyranron for some reason i still can't push a new branch
|
@ilslv let's merge them separately. |
FCM
|
@tyranron ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilslv thanks! Quite a brilliant code! 💪
Moved from cucumber-rs/cucumber#153
Part of cucumber-rs/cucumber#124
Synopsis
This is the first
PR
in the story ofCucumber expressions
support.Solution
This
PR
implementsCucumber expressions
AST
and a parser for it. NextPR
s will be addingAST
into regex transformation and support inside proc-macros.Checklist
Draft:
prefixDraft:
prefix is removed