[antlr-interest] How to have strings enclosed in " and/or "

matthew ford Matthew.Ford at forward.com.au
Thu Dec 9 11:36:27 PST 2004


Hi Ter,
What ambiguity do you see that I don't? Both  tokens mean the same  " = =
"
Perhaps I am too close the problem
matthew
----- Original Message ----- 
From: "Terence Parr" <parrt at cs.usfca.edu>
To: <antlr-interest at yahoogroups.com>
Sent: Friday, December 10, 2004 4:32 AM
Subject: Re: [antlr-interest] How to have strings enclosed in " and/or
&quot;


>
>
> On Dec 8, 2004, at 12:47 PM, matthew ford wrote:
> > Hi all,
> > I am having trouble in the lexer handling strings that start and end
> > with "
> > or &quot;
> > (might start with " and end with &quot;)
> > Some html editors kindly replace " with &quot; when you load the file.
> >
> > I would like to be able to handle something like
> >  "str is &quot;"here&quot;"&quot;"
> > to return
> >  str is "here&quot;
> >  due to the (STRING_PART)*  below and dropping the final quote of each
> > STRING_PART
> > "" inside a string just escapes a single "
> >
> > Any ideas on how to make this work?
>
> Hi Matthew,
>
> I'm thinking that this is a language ambiguity.  I can easily give you
> two input sentences that could be interpreted either way.
> Consequently, you're going to have trouble with with generalized LR
> (only diff is that GLR would give you back both interpretations).  You
> might have some luck with a semantic predicate that tracked what you
> start with or something, but I guess what you start with is
> meaningless.  Yep, seems like a language ambiguity leading to a problem
> for any grammar.
>
> To get around it, you might try a special char input stream that did
> the replacement, but even then it won't help you I think; don't know
> when to flip and when not to. :(
>
> Ter
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list