Skip to content

Conversation

@happy-barney
Copy link

@happy-barney happy-barney commented Oct 2, 2025

  • 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
  • This set of changes does not require a perldelta entry.

@happy-barney
Copy link
Author

I'm pushing changes from my GLR parser work, which are compatible with LALR(1) grammar,
so can rebase quickly.

@jkeenan
Copy link
Contributor

jkeenan commented Oct 2, 2025

I'm pushing changes from my GLR parser work, which are compatible with LALR(1) grammar, so can rebase quickly.

Please fix the porting test failures, get make test_porting && make test_harness to pass, then re-push. Thanks.

@happy-barney
Copy link
Author

@jkeenan done - during rebase I forgot to run regen perly at some point and relied on test result from before rebase

Branislav Zahradník added 25 commits October 7, 2025 14:09
* 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
@mauke mauke merged commit 412b9d4 into Perl:blead Oct 7, 2025
33 checks passed
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.

4 participants