[antlr-interest] Resolving a First/Follow Conflict in Logo.

Ron Burk ronburk at gmail.com
Tue Nov 2 13:08:12 PDT 2010


>
>
>
Hmmm. Seems like Logo (like Forth) was specifically designed
to not need much in the way of a parser at all (or as a friend used to
say, "Forth uses the programmer as its parser!").  Ignoring practicality,
if I were going to aim the giant cannon of a parser generator like ANTLR
at the gnat of parsing some Logo dialect (what the heck, probably
somebody out there is using it to parse Lisp :-), with what little I
know of Logo I might maintain my own stack for the trivial task of
parsing the part of  the language that isn't proc definition or
control flow.

Side note: presumably need/count in your proposed solution
need to be stackable to work correctly, since you're using
them in a recursive rule...

For processing the basic actions of LOGO, I might just
have the grammar look for any number of operators/operands
and in the action code put those on a stack. Seems like it
would be very easy (it's all prefix operator syntax AFAICT
in a typical LOGO dialect) to just stack'em up, popping whenever
the most recent operator has acquired its requisite number
of operands. This would likely put you in a position to give
better error messages as well,  given how little structure is
in the grammar of this language.

IMHO, which could be completely wrong. :-)


More information about the antlr-interest mailing list