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

Loring Craymer lgcraymer at yahoo.com
Sat Apr 28 16:04:03 PDT 2007


So, basically:  where Java uses jar archives for
packaging, Ruby uses a crippled version of shar and
embeds it in the language?

Amazing!  I thought the industry had learned something
since the days of lexing FORTRAN!

--Loring

--- David Holroyd <dave at badgers-in-foil.co.uk> 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!
> 
>   # 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/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around 
http://mail.yahoo.com 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list