From ca00beb39b9d02578c1f0b556a2c2f70f28cf6e7 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 23 Jun 2019 09:00:06 +1000 Subject: [PATCH] parsergen: allow $$OUT as well as $$NEWLINE Both of these mean the same thing: the product must end in a 2-d visible way Signed-off-by: NeilBrown --- csrc/indent_test.mdc | 2 +- csrc/parsergen.mdc | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/csrc/indent_test.mdc b/csrc/indent_test.mdc index 6ba2479..88e9391 100644 --- a/csrc/indent_test.mdc +++ b/csrc/indent_test.mdc @@ -162,7 +162,7 @@ $*statement | Open SimpleStatements } ${ $0 = $<2; }$ | : SimpleStatements $$NEWLINE ${ $0 = $<2; }$ | : StatementBlock ${ $0 = $<2; }$ - StatementBlock -> Statementlist $$NEWLINE ${ $0 = $<1; }$ + StatementBlock -> Statementlist $$OUT ${ $0 = $<1; }$ SimpleStatements -> SimpleStatements ; SimpleStatement ${ { diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 679fab6..76fec3a 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -499,6 +499,8 @@ Now we have all the bits we need to parse a full production. vs = sym_find(g, tk.txt); if (vs->num == TK_newline) p.line_like = 1; + else if (vs->num == TK_out) + p.line_like = 2; else if (vs->precedence == 0) { err = "symbol after $$ must have precedence"; goto abort; @@ -1651,8 +1653,10 @@ it up a bit. First the items, with production number and associativity. printf(" [%d%s]", s->precedence, assoc_names[s->assoc]); } - if (pr->line_like) + if (pr->line_like == 1) printf(" $$NEWLINE"); + else if (pr->line_like) + printf(" $$OUT"); printf("\n"); } -- 2.43.0