Hello antlr users,

I am a bit stuck to the problem of fuzzy parsing and filter option. I looked at 
the fuzzy example,
but I am not sure it helps me. 

How do you usually handle it ? How do you keep all the the host code without any
modification when you write a language you embed into Java (or any other
language) ? I thought I could create a node containing a "big string" of host
code in my tree, but it does not seem to to be so obvious/easy. The parser has
difficulties to "recognize unknown constructs" (all but my specific
constructs == host code). Have you ever had this problem ?

Thanks in advance,

JC


* Jean-Christophe Bach <[email protected]> [11.08.2010. @16:54:30 
+0200]:
> I have a combined grammar and I would like to do fuzzy parsing. I know that 
> the
> filter option is designed for the lexer part, but is there any way to use this
> option by keeping my combined grammar ?
> In our old  parser (antlr2), we used this option like this (in a combined
> grammar) :
> 
> class HostParser extends Parser;
> ...
> // returns the current goal language code
> private String getCode() {
>   String result = targetlexer.target.toString();
>   targetlexer.clearTarget();
>   return result;
> }
> ...
> and parser rules
> 
> ...
> class HostLexer extends Lexer;
> options {
>   ...
>   filter=TARGET;
>   ...
>  }
> 
> public StringBuilder target = new StringBuilder("");
> // clear the buffer
> public void clearTarget() { target.delete(0,target.length()); }
> 
> ...
> 
> protected
> TARGET : (.) { target.append($getText); } ;
> 
> 
> It was very easy to do fuzzy parsing and to use what was parsed : when needed,
> we only had to call getCode() function to get a HostBlock code and to put it 
> in
> a node of our tree.  But with antlr3, I'm not sure to understand how to 
> proceed.
> I tried to give the option 'filter=true;' directly to my fragment TARGET rule,
> but it does not seem to be a good idea (I obtain errors).
> Would someone have any idea ?
> 
> Regards,
> 
> JC
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
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.

Reply via email to