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

Add support for "endless" rule #55

Merged
merged 1 commit into from
Mar 30, 2025
Merged

Conversation

eric1234
Copy link

This is similar to Ruby's "endless" method. The goal is to allow simple rules to be more compact (similar also to JavaScript's bracket-less arrow functions).

Being more compact (while still readable) allows more code to be seen at once and reduces keyword noise (lots of ends) and excess white space. These two things make it easier to scan and grok the grammar.

I've tested this in a project I am using Treetop for. It reduced the LOC for the Treetop files by 1/4 since a significant number of the rules were simple and could be expressed on a single line. This significantly reduced the scrolling to read the grammar.

This closes #54. See that issue for examples.

This is similar to Ruby's "endless" method. The goal is to allow simple rules
to be more compact (similar also to JavaScript's bracket-less arrow functions).

Being more compact (while still readable) allows more code to be seen at once
and reduces keyword noise (lots of `end`s) and excess white space. These two
things make it easier to scan and grok the grammar.

This closes cjheath#54. See that issue for examples.
@cjheath cjheath merged commit 7df506e into cjheath:master Mar 30, 2025
8 checks passed
@cjheath
Copy link
Owner

cjheath commented Mar 30, 2025

This was still problematic. The semantic predicate you added to ensure that the parsing_rule was all on one line actually looked at the text "rule", the first token, not the last one, which is the parsing rule.

It was a little ugly and I improved that. This change has been pushed to master. Please peruse it there before I publish the gem.

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.

Endless Rules?
2 participants