]> ocean-lang.org Git - ocean/commitdiff
parsergen: introuce $$NEWINE pseudo-precedence.
authorNeilBrown <neil@brown.name>
Sat, 15 Jun 2019 22:29:16 +0000 (08:29 +1000)
committerNeilBrown <neil@brown.name>
Sat, 15 Jun 2019 23:04:44 +0000 (09:04 +1000)
Sometimes we need a produce to be terminated by a newline, but we
don't want to consume the newline with a "shift".
Case in point is:
   Block -> : StatementList

Which can be used with
   Statement -> if Expression Block
   StatementList -> Statement

I want this to parse:

   if something: if otherthing: action

which might seem a little odd, but is syntactically sensible.
The NEWLINE at the end is requred, and must close both nested Statements.
The NEWLINE will already cause a REDUCE, but if we don't have
   Block -> : Statementlist NEWLINE
then something else could force a reduce, and we don't want that.
So introduce a marking "$$NEWLINE" which is similar to imposing a precedence
on a production.  Now

   Block -> : StatementList $$NEWLINE

means that a NEWLINE is required to end a Block, but it isn't
shifted.  If anything else if found here, it is an error.

We also allow $eof and OUT to reduce this production.

Signed-off-by: NeilBrown <neil@brown.name>

No differences found