<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">Hi.<br>
<br>
Let me introduce myself, i'm Feriaman, coding for a long time, but using AnTLR for a short time.<br>AnTLR is great and really easier to use than things like Spirit (which i'm familiar with).<br>
<br>
Unfortunately, the documentation i could find is not as great as the tool himself.<br>
That's why i try to get help here.<br>I really apologise if this isn't the right place to ask help.<br><br>My question is : is there a way to factorise thoses grammar rules (maybe some template rule) : <br>---------------<br>singleA returns [A value]:<br> TOKENA<br> i1=ID {$value = Factory.CreateA($i1.text);}<br> ;<br>singleB returns [B value]:<br>
TOKENB<br> i1=ID {$value = Factory.CreateB($i1.text);}<br>
;<br><br>objectAList returns [List<A> value]:<br> first=singleA <br> {<br> $value = new List<A>();<br> $value.addValue($first.value);<br> }<br> (<br> ','<br> next=singleA {$value.addValue($next.value);}<br> )*<br> ;<br><br>
objectBList returns [List<B> value]:<br>
first=singleB <br>
{<br>
$value = new List<B>();<br>
$value.addValue($first.value);<br>
}<br>
(<br>
','<br>
next=singleB {$value.addValue($next.value);}<br>
)*<br>
;<br>---------------<br><br>Of course, generated function objectAList and objectBList should be different, because one returns a List<A> and the orther returnes a List<B>, so i understand i can't have a single rule (or am i wrong ?), but i suppose there is a way to write thoses two rules as a template rule, isn't it ?<br><br>Thanks alot ! </div><br /><hr />Discutez sur Messenger oł que vous soyez ! <a href='http://www.messengersurvotremobile.com/' target='_new'>Mettez Messenger sur votre mobile !</a></body>
</html>