[parser] Decompose 'barestmt'

* 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 commit is contained in:
Branislav Zahradník 2025-10-01 08:51:14 +02:00 committed by Lukas Mai
parent 70a73bdabb
commit 6e421d713c

12
perly.y
View File

@ -343,9 +343,15 @@ labfullstmt: LABEL barestmt
}
;
/* A bare statement, lacking label and other aspects of state op */
barestmt: PLUGSTMT
{ $$ = $PLUGSTMT; }
/* A bare statement, lacking label and other aspects of state op
*
* Maintain rule as simple alternatives of single nonterminals,
* leveraging bison's default action: $$ = $1.
*
* Try to keep nonterminals alphabetically sorted.
*/
barestmt
: PLUGSTMT
| KW_FORMAT startformsub formname formblock
{
CV *fmtcv = PL_compcv;