-
Notifications
You must be signed in to change notification settings - Fork 601
[parser] Decompose rule barestmt
#23796
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
|
I'm pushing changes from my GLR parser work, which are compatible with LALR(1) grammar, |
Please fix the porting test failures, get |
44f7dea to
42421f7
Compare
|
@jkeenan done - during rebase I forgot to run regen perly at some point and relied on test result from before rebase |
* Concern separation
By extracting complex rules into standalone nonterminals code will become
easier to read and maintain.
Nonterminals can be easily ordered (e.g.: alphabetically) as well as reordered.
Leveraging bison's implicit rule such structure contain less noise.
Goal is to make `barestmt` to look like (simplificed):
```
barestmt
: PLUGSTMT
| bare_statement_class_declaration
| bare_statement_class_definition
| bare_statement_given
| bare_statement_null
| bare_statement_try
| bare_statement_yadayada
;
```
* Nonterminal readability
Extracted nonterminals will contain single sequence so for readability purpose
tabular format will be used:
```
bare_statement_class_declaration
: KW_CLASS
BAREWORD[version]
BAREWORD[package]
PERLY_SEMICOLON
{
... action
}
;
```
Single token per line limits number of required eye movements as well as
it provides indentation separation of terminals/nonterminals and actions:
- 1st tab indent: grammar operator
- 2nd tab indent: terminal/nonterminal
- 3rd+ tab indent: action code
42421f7 to
770d8c0
Compare
By extracting complex rules into standalone nonterminals code will become
easier to read and maintain.
Nonterminals can be easily ordered (e.g.: alphabetically) as well as reordered.
Leveraging bison's implicit rule such structure contain less noise.
Goal is to make
barestmtto look like (simplificed):Extracted nonterminals will contain single sequence so for readability purpose
tabular format will be used:
Single token per line limits number of required eye movements as well as
it provides indentation separation of terminals/nonterminals and actions: