Recovery when end of expression (EOL or `;`) is missing

The top of my grammar is defined as follows:

// expressionList is optional to handle code-less file that contains only EOL between blank lines and order comment // lines elixirFile ::= endOfExpression* (expressionList endOfExpression*)?

// Must have at least one EOL or SEMICOLON, but at most one SEMICOLON endOfExpression ::= EOL* SEMICOLON EOL* | EOL
private expressionList ::= expression (endOfExpression+ expression)*


The problem I have is that if two expressions are immediately next to each other such as `123 456` instead of `123; 456` or `123\n456`, then the parser enters DUMMY_BLOCK mode and won't try to parse the trailing lines of the file.  I know I can add recovery with pin and recoverWhile, but since pin works on a prefix I don't know how to recover when the `endOfExpression+` is missng since it's the start of the `endOfExpression+ expression` subrule.  I assume I need to change how I write expressionList so that `endOfExpression+` appears at the end of a subrule so I can pin on `expression` instead and let missing `endOfExpression+` to be skipped, but I haven't been able to figure out how to transform `expressionList` into such a format.  I'd like the recovery to continue until the next `endOfExpression`, so that only one line at time is messed up if possible.

Please sign in to leave a comment.