[antlr-interest] how to let parser control lexer state.

David Holroyd dave at badgers-in-foil.co.uk
Sat Apr 28 05:47:40 PDT 2007


On Sat, Apr 28, 2007 at 12:14:45PM +0000, David Holroyd wrote:
> 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!

Another knotty syntax example,

  ----8<----
  a=1
  [<<HERE, <<'THERE', <<-WHERE].each {|str| puts "value: #{str.inspect}"}
  foo #{a}
  HERE
  bar #{a}
  THERE
  foo
    and
      bar
        WHERE
  ---->8----

When run,

  value: "foo 1\n"
  value: "bar \#{a}\n"
  value: "foo\n  and\n    bar\n"


Makes the brain itch!


ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list