[antlr-interest] Parsing Strings with placeholders

Joern Gebhardt joern.gebhardt at gmail.com
Wed Feb 25 05:37:07 PST 2009


Hi Johannes,

thanks for the quick response. However, I think that the island grammar
approach you pointed out might be a little bit overweight for my small
island grammer that has only one rule to match the variable placeholders
(i.e ${...})

Instead I might do this parsing manually in a lexer action and emit two or
more tokens in this lexer rule as described in
http://www.antlr.org/wiki/pages/viewpage.action?pageId=3604497

Regards,
Joe



On Wed, Feb 25, 2009 at 12:47 PM, Johannes Luber <JALuber at gmx.de> wrote:

> > Hi,
> >
> > my language is able to define and use some variables/placeholders similar
> > to
> > the UNIX shell scripts:
> >
> > a = "wonderful"
> > b = "The weather is ${a}."
> >
> > The usage of these placeholder variables is only allowed inside of STRING
> > expressions.
> >
> > My question is now, how do I define the lexer/parser rules in an
> > intelligent
> > way so that I can easily replace the placeholders by their content?
>
> I think using island-grammars may be the solution. See <
> http://www.antlr.org/wiki/display/ANTLR3/Island+Grammars+Under+Parser+Control>
> as well the mentioned example.
>
> Johannes
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090225/8c21200b/attachment.html 


More information about the antlr-interest mailing list