-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix a single weekday grammar callback #4357
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@oxidase I have a very hard time understanding this magic syntax. Given that these changes are not that obvious, do you think that we could add some commentary to make it easier to follow what is supposed to happen here?
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.
@MoKob i can explain what happened in this case: without parenthesis the semantic action
[_val = ph::construct<OpeningHours::WeekdayRange>(_a, _b)]
that constructs aWeekdayRange
was invoked only in a case if both the first and the second part of the rule succeed.In case
Mo-Fr
local rule variable_a
will beMo
and_b
will beFr
. So the actions will be called asph::construct<OpeningHours::WeekdayRange>(1, 5)
.If parsing of the second rule failed but the first part succeeded then both
_a
and_b
will be initialized to let saySa
, but construction of aph::construct<OpeningHours::WeekdayRange>(6, 6)
will not be called. SoWeekdayRange
will be a default initialized object with an empty range.Adding parenthesis around both rules makes invocation of
ph::construct<OpeningHours::WeekdayRange>(_a, _b)
in both cases:ph::construct<OpeningHours::WeekdayRange>(1,1)
ph::construct<OpeningHours::WeekdayRange>(2,5)
Idk if such lengthy comments would make sense, but I can make a step-by-step intro how to add semantic to unimplemented parts like
nth_entry
orday_offset
, For example, withnth_entry
it is possible to defineOct Su[1]
(the first Sunday in October) like in the Oktoberfest example.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.
@oxidase thank you for this explanation. This makes a lot more sense to me now.
I believe simply having a bit more context on what kind of format the grammar parses might already help here (
Parsing Mo-Fr into ph::construct<>(1,5)
orSa
intoph:construct<6,6>
). I agree that the longer explanation here might be a bit much, but it is already accessible now via git-blame, so I guess we are golden here.