[antlr-interest] Filtering Java expressions

Junkman j at junkwallah.org
Sat Aug 7 12:10:12 PDT 2010


Hi Bill,

Just throwing up a suggestion here (haven't thought it through).  Lex
the input, ignore comments and parse the rest into statements (ending
with ';') and blocks (ending with  {} block) containing statements, and
then try to parse each statement as variable declarations.  Would you
need to determine the context of the variable (local, class, etc.)?

If you expect to target other Java phrases and/or their context, you
might be better off writing the full grammar first.

Hope others will chime in with better suggestions.

J

Bill Andersen wrote:
> Hi folks
> 
> I'm working on a DSL that allows insertion of Java code blocks.  The only information I really need to get from the Java are variable declarations - what vars declared to be what type.  The rest I don't care about.
> 
> Is there a good way to do a partial parse of Java code to pick out declarations (or any other structure).  If it helps, I'm limiting this to pretty vanilla Java assignment and declaration expressions - no class defs.
> 
> Thanks
> 
> 	.bill
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list