Skip to content
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

Cosmetic changes to PEG grammar. #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Cosmetic changes to PEG grammar. #2

wants to merge 11 commits into from

Conversation

alanpost
Copy link

This is a list of mostly cosmetic changes to the PEG grammar.

Alan Post added 11 commits January 26, 2011 00:09
This change is consistent with operand-start, which doesn't group
these rules together.

This change is consistent with all other rules in operand-3, which
don't try to share common-substructure.

This change moves an ordered choice from the inside one choice out
to the loop with the other choices.  Since ordered choice is
something that can be checked in parallel, this change allows more
simultaneous threads to try parsing operand-3 at once.
The two choices in statement-2 differ only by the final element in
the outermost optional clause.  The first choice does not have
statement-2, the second choice does.  This can be expressed by
another '?' operator, removing one ordered choice.

If this rule was constructed this way in order to avoid a bug in
the RATS! parser, please ignore this change.
This rule include one choice which is "a b c" and one choice which
is "a b"  That is the same as saying "a b c?", so combine these
two choices.
This is the only choice in sumti-6 separated into it's own
production.  I'm not sure why it is pulled out, it is only
referenced in sumti-6.

If you were doing this because you wanted the parse tree
shaped a particular way, please ignore this change.

Otherwise, this change is more consistent with the rest of
the grammar.
|b c / a b c| is the same as saying |a? b c|, except in conditions
that make |a b c| never match (i.e., if |b c| always matches the
same input as |a b c|).

That is not the case here, these two choices can be folded into one
by making the first clause optional.
space-interval contains the rule |a / b / a b|.  Since the first
matching choice is always taken, the last choice will never match,
since a substring of that match is contained in a previous choice.

reorder this rule to be |a b? / b|, which is equivalent to the
*intent* to match a, or b, or a b.
@alanpost
Copy link
Author

e326dff is a legitimate bug: the third choice in the ordered choice will never be matched. This probably needs to have a higher priority than the other stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant