I have a project for which I would like to lex strings that have somewhat "Unix shell-like" quoting semantics. Unix shell strings are quite funky, but I'd be happy if I could express the following:
// Some straightforward stuff
somestring => [Token("somestring")]
"somestring" => [Token("somestring")]
two strings => [Token("two"), Token("strings")]
"one string" => [Token("one string")]
"error => parse error
// Here it gets a bit more subtle
one"string" => [Token("onestring")]
one"string"only => [Token("onestringonly")]
one\"string\"only => [Token("one\"string\"only")]
etc. At this point I don't need to replicate the differences between
' and ", though knowing how to would be interesting.
I'm sort of embarassed to show you my attempts, but I've attached the
closest I have. It doesn't work for the one\"string\" case though.
One thing I wanted to try but couldn't find much documentation on is
writing a essentially a totally custom lexer; I know how to parse
these strings in raw Java, but it wasn't completely clear to me which
methods to override, etc. Ideally of course I could express these
strings in the ANTLR lexer language, hopefully someone can point me
the right way there!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
shellLike.g
Description: Binary data
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
