[antlr-interest] how to let parser control lexer state.
David Holroyd
dave at badgers-in-foil.co.uk
Sat Apr 28 05:14:45 PDT 2007
On Fri, Apr 27, 2007 at 11:31:45PM -0700, Loring Craymer wrote:
> You are correct; I hadn't been aware of heredoc. It
> is still not a problem that needs tieing parser and
> lexer together.
[...]
> Nasty problem. It is amazing how often really bad
> ideas are adopted.
And yet, there is more!
# syntax on the same line is not part of the here-doc yet,
func1(<<HERE).func2()
text blah
HERE
# multiple here-docs,
puts(<<HERE, <<THERE)
foo
HERE
bar
THERE
And-yet-and-yet, going back to the OP, Ruby also treats these two
examples as different syntax,
# a here-doc, because 'puts' is a method (predefined in Ruby runtime)
puts <<HERE
foo
HERE
and,
puts = 1
# now, a left-shift operator, because we've created a 'puts' local var
puts <<HERE
foo
HERE
# (gives error as 'HERE' is not defined, but that's not the point)
Naturally, the syntax is also sensitive to whitespace on either side of
the '<<' :-)
--
http://david.holroyd.me.uk/
More information about the antlr-interest
mailing list