From: NeilBrown Date: Sun, 16 Jun 2019 02:16:44 +0000 (+1000) Subject: oceani: convert declarations to new approach to newlines X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=712fec2bb9a25d6f196e2d3565f51234e9f8cfd0 oceani: convert declarations to new approach to newlines There are now no conflicts. Yay!! Signed-off-by: NeilBrown --- diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 5366bf9..8a5e747 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -793,7 +793,7 @@ various places that `type_err()` are called. ###### output: type_err_const1 .tmp.code:3:12: Syntax error in constant: : - .tmp.code:4:8: Syntax error in constant: bar + .tmp.code:4:12: Syntax error in constant: : ## Test erroneous command line args diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 4f00438..d3a4caf 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -2019,6 +2019,7 @@ function will be needed. f = f->prev; } } }$ + | DeclareStruct NEWLINE $void Open -> { @@ -2026,16 +2027,19 @@ function will be needed. Close -> } | NEWLINE Close $*fieldlist - FieldBlock -> Open FieldList Close ${ $0 = $<2; }$ + FieldBlock -> Open FieldList } ${ $0 = $<2; }$ | Open SimpleFieldList } ${ $0 = $<2; }$ - | : FieldList ${ $0 = $<2; }$ + | : FieldList $$NEWLINE ${ $0 = $<2; }$ - FieldList -> SimpleFieldList NEWLINE ${ $0 = $<1; }$ - | FieldList SimpleFieldList NEWLINE ${ + FieldList -> SimpleFieldListLine ${ $0 = $<1; }$ + | FieldList SimpleFieldListLine ${ $2->prev = $<1; $0 = $<2; }$ + SimpleFieldListLine -> SimpleFieldList NEWLINE ${ $0 = $<1; }$ + | SimpleFieldListLine NEWLINE ${ $0 = $<1; }$ + SimpleFieldList -> Field ${ $0 = $<1; }$ | SimpleFieldList ; Field ${ $3->prev = $<1; @@ -3932,14 +3936,15 @@ various declarations in the parse context. $void Ocean -> DeclarationList + | NEWLINE Ocean DeclarationList -> Declaration | DeclarationList Declaration - Declaration -> DeclareConstant + Declaration -> Declaration NEWLINE + | DeclareConstant | DeclareProgram | DeclareStruct - | NEWLINE | ERROR NEWLINE ${ tok_err(c, "error: unhandled parse error", &$1); @@ -3974,17 +3979,19 @@ searching through for the Nth constant for decreasing N. DeclareConstant -> const Open ConstList Close | const Open SimpleConstList } - | const : ConstList + | const : ConstList $$NEWLINE | const SimpleConstList NEWLINE - ConstList -> ComplexConsts + ConstList -> ConstLines | NEWLINE ConstList - ComplexConsts -> ComplexConst ComplexConsts - | ComplexConst - ComplexConst -> SimpleConstList NEWLINE + ConstLines -> ConstLines SimpleConstLine + | SimpleConstLine SimpleConstList -> SimpleConstList ; Const | Const | SimpleConstList ; + SimpleConstLine -> SimpleConstList NEWLINE + | SimpleConstLine NEWLINE + | ERROR NEWLINE ${ tok_err(c, "Syntax error in constant", &$1); }$ $*type CType -> Type ${ $0 = $<1; }$ @@ -4017,7 +4024,6 @@ searching through for the Nth constant for decreasing N. v->val = interp_exec($5); } } }$ - | ERROR NEWLINE ${ tok_err(c, "Syntax error in constant", &$1); }$ ###### print const decls {