[stringtemplate-interest] Newbie Help
Terence Parr
parrt at cs.usfca.edu
Mon Aug 13 16:26:05 PDT 2007
On Aug 11, 2007, at 5:49 PM, Richard Wilburn wrote:
> Hi I am new to StringTemplate :)
>
> I am trying to use StringTemplate to generate source code. I
> realise that in order to use string template I need to think in a
> way similar to functional programming however its been along time
> since I have done any so I struggling a bit. I am trying to
> generate c# code. In particular a case statement.
>
> Here is the code that is in template.st
>
> switch(eventlist)
> {
> $events:{event|
> case $event$:
> $rulelist:{rule|
> $if(event == rule))$
ST won't let you do any attribute evaluations in the template. Pass
in as field or method of event. then do $if(event.isInECA1xpathquery)
$...$endif$.
> What the output is trying to do is to take an event that occurs (we
> don't know what it is until runtime) and try to work out (think c++
> style event loop/message pump) what it is with the case statement.
> Then I have a list of ECA rules (event condition action rules that
> I want to put in based on what their event. So event1 could be
> mouseclicked and event2 could be keypress. ECA rules 1,2,3,10 could
> apply to event1 and ECA rule 4 could apply to event 2. So what i
> need to do is a comparison to get the ECA rules in the correct case
> statement. If I haven't explained anything enough let me know.
> Ultimately I am after some sort of string value comparison operator.
Yep, must do that computation in model though :)
Ter
More information about the stringtemplate-interest
mailing list