Hi there,
Thanks for the bug reports!
The LPG parser generator and the LPG IDE use different parsers (even
slightly
different grammars), partly since the parser generator hand-rolls its
scanner,
while the IDE uses LPG itself to generate the scanner. This difference
shows
up particularly for the %options directives. In theory, they should be in
perfect agreement, but obviously they're not quite.
More details below...
Brian Payton wrote:
Hi,
I'm starting to use the IMP LPG source editor, and I noticed the
editor shows syntax errors on certain input that LPG accepts,
particularly in the %options declarations. Here's the lines showing
errors, plus the error messages.
Line:
%options action=("DB2ZQueryParser.java", "/.", "./")
Error:
Multiple messages: misplaced construct(s): "ERROR_TOKEN" {0} is
invalid: "%options action" {0}
expected after this token: "DISJOINTPREDECESSORSETS_KEY"
I'm looking into this.
Line:
%options ParseTable=%options ParseTable=lpg.lpgjavaruntime.ParseTable
(Note: this options line doesn't make much sense to me, so it might be
an error in the source file. However LPG doesn't complain about it.)
Error:
Multiple messages: {0} unexpected token(s) ignored: "ERROR_TOKEN"
{0} is invalid: "%options ParseTable=%options "
Such a line is really two ParseTable options specifications, the first
with a bogus empty value that gets overridden by the second, which has
the value "lpg.lpgjavaruntime.ParseTable". You can safely delete the
initial "%options ParseTable=" prefix.
I don't think it really makes much sense to change the IDE parser to
accept this (erroneous) options specification. If anything, I'd argue
that we should change the parser generator to flag it as an error.
Line:
%options var=nt,automatic_ast,visitor,parent_save
Error:
{0} is invalid: "%options var"
You're right - we missed the "var" option. I'll fix that.
Line:
%options or_marker='|'
Error:
{0} is invalid: "%options or_marker='"
In this case, the grammar used by the IDE doesn't seem to permit a
quoted character. As a workaround, removing the quotes should work.
Of course, I'll fix the IDE's grammar to allow the quoting.
I also noticed that the editor doesn't hilight as keywords the "no"
prefix on keywords such as "noserialize", "nogoto_default", and
"noerror-maps"
I'll have to look into this as well.