Current grammar uses one stack frame per newline for leading
newlines as these productions are right-recursive. This is
unnecessary and inelegant. Change to use a left-recursive Newlines
production.
Signed-off-by: NeilBrown <neil@brown.name>
| DeclareStruct NEWLINE
$void
| DeclareStruct NEWLINE
$void
+ Newlines -> NEWLINE
+ | Newlines NEWLINE
$*fieldlist
FieldBlock -> Open FieldList } ${ $0 = $<2; }$
| Open SimpleFieldList } ${ $0 = $<2; }$
| : FieldList $$NEWLINE ${ $0 = $<2; }$
FieldList -> FieldLines ${ $0 = $<1; }$
$*fieldlist
FieldBlock -> Open FieldList } ${ $0 = $<2; }$
| Open SimpleFieldList } ${ $0 = $<2; }$
| : FieldList $$NEWLINE ${ $0 = $<2; }$
FieldList -> FieldLines ${ $0 = $<1; }$
- | NEWLINE FieldLines ${ $0 = $<2; }$
+ | Newlines FieldLines ${ $0 = $<2; }$
FieldLines -> SimpleFieldListLine ${ $0 = $<1; }$
| FieldLines SimpleFieldListLine ${
$2->prev = $<1;
FieldLines -> SimpleFieldListLine ${ $0 = $<1; }$
| FieldLines SimpleFieldListLine ${
$2->prev = $<1;
| : Statementlist $$NEWLINE ${ $0 = $<2; }$
Statementlist -> ComplexStatements ${ $0 = reorder_bilist($<1); }$
| : Statementlist $$NEWLINE ${ $0 = $<2; }$
Statementlist -> ComplexStatements ${ $0 = reorder_bilist($<1); }$
- | NEWLINE Statementlist ${ $0 = $<2; }$
+ | Newlines ComplexStatements ${ $0 = reorder_bilist($<2); }$
ComplexStatements -> ComplexStatements ComplexStatement ${
if ($2 == NULL) {
ComplexStatements -> ComplexStatements ComplexStatement ${
if ($2 == NULL) {
$void
Ocean -> DeclarationList
$void
Ocean -> DeclarationList
+ | Newlines DeclarationList
DeclarationList -> Declaration
| DeclarationList Declaration
DeclarationList -> Declaration
| DeclarationList Declaration
| const SimpleConstList NEWLINE
ConstList -> ConstLines
| const SimpleConstList NEWLINE
ConstList -> ConstLines
ConstLines -> ConstLines SimpleConstLine
| SimpleConstLine
SimpleConstList -> SimpleConstList ; Const
ConstLines -> ConstLines SimpleConstLine
| SimpleConstLine
SimpleConstList -> SimpleConstList ; Const