How to parse and enter actions
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mlb_java
Posted On:   Thursday, November 3, 2011 04:45 PM

I'm working on a DSL where I'd like be able to references methods hierarchically from a request object. I.e, given a request: Request r = new Request(); I'd like to pull off objects directly using a syntax like: r.a.b.c, which would invoke actions like: r.getA().getB().getC() I think I can do it using reflection and the java Method class, but I'd like to be able to embed the method calls directly in the parser. Can someone please advise? I'm a total newbie on this... element returns [Evaluator e] : | p1=parameter { ??? } ('.' parameter { ??? } )* ; parameter returns [String s] : 'a' { $s = "getA()"; } | 'b' { $s = "getB()"; } | 'c' { $s = "getC()&quo   More>>

I'm working on a DSL where I'd like be able to references methods hierarchically from a request object. I.e, given a request: Request r = new Request(); I'd like to pull off objects directly using a syntax like: r.a.b.c, which would invoke actions like: r.getA().getB().getC() I think I can do it using reflection and the java Method class, but I'd like to be able to embed the method calls directly in the parser. Can someone please advise? I'm a total newbie on this...

			
element returns [Evaluator e]
:
| p1=parameter { ??? } ('.' parameter { ??? } )*
;

parameter returns [String s]
: 'a' { $s = "getA()"; }
| 'b' { $s = "getB()"; }
| 'c' { $s = "getC()"; }
;
   <<Less
About | Sitemap | Contact