Can the LineContinuationTerminal be a grammar symbol?

Nov 3, 2014 at 7:23 PM
I have a grammar in which the LineContinuationTerminal is "-". But I also have a unary operator "-". After the "-" it expects a NewLine.

Can this be done? I've tried setting Priority...
Coordinator
Nov 5, 2014 at 4:36 AM
I don't understand - given the following:

a -
b

what it should be parsed as? As 'a-b' split on two lines, or as 'a b' ?
Any way does not seem like reasonable/logical outcome...
Nov 5, 2014 at 10:16 AM
Maybe it's more clear with the following test grammar:
var line_continuation = new LineContinuationTerminal("<line-continuation>", "-");
NonGrammarTerminals.Add(line_continuation);

var program = new NonTerminal("<program>");
var stmt = new NonTerminal("<stmt>");
var sign = new NonTerminal("<sign>");
program.Rule = MakeStarRule(program, NewLine, stmt);
stmt.Rule = ToTerm("x") + "=" + sign + ToTerm("y");
sign.Rule = ToTerm("+") | ToTerm("-") | Empty;
this.Root = program;
If the source is
x = y
x = +y
x = -y
the parser expects a new line symbol after the minus at the third line.
Coordinator
Nov 12, 2014 at 7:32 PM
it does not make any more clear, and I'm not sure if this can work at all. In pure human terms, how these arrangements can work, meaning what would be the rules for the programmer that writes these statements. As for Irony's parsing, I'm not sure how it might work at all, but it all begins with human-readable definition, which you then express in Irony's BNF expressions.
One thing I see - I wouldn't use the 'sign' definition this way; you should defined 'unary expr', just like in SampleExpressionGrammar, and then use it as one of expression sub-types in arithm expressions.
Nov 14, 2014 at 2:05 PM
I just made this sample grammar to show my point. With a human-readable definition (using unary expr) it also doesn't work.

When i make an new LineContinuationTerminal class that overrides the TryMatch method, it works very nice!
Coordinator
Nov 20, 2014 at 7:00 AM
well, good for you, probably default implementation of LineContinuation term works a bit differently than you expect