<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>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TOKENA<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i1=ID {$value = Factory.CreateA($i1.text);}<br>&nbsp;&nbsp;&nbsp; ;<br>singleB returns [B value]:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; TOKENB<br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; i1=ID {$value = Factory.CreateB($i1.text);}<br>
&nbsp;&nbsp;&nbsp; ;<br><br>objectAList returns [List&lt;A&gt; value]:<br>&nbsp;&nbsp;&nbsp; first=singleA <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $value = new List&lt;A&gt;();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $value.addValue($first.value);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ','<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; next=singleA {$value.addValue($next.value);}<br>&nbsp;&nbsp;&nbsp; )*<br>&nbsp;&nbsp;&nbsp; ;<br><br>
objectBList returns [List&lt;B&gt; value]:<br>
&nbsp;&nbsp;&nbsp; first=singleB <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $value = new List&lt;B&gt;();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $value.addValue($first.value);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; (<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ','<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; next=singleB {$value.addValue($next.value);}<br>
&nbsp;&nbsp;&nbsp; )*<br>
&nbsp;&nbsp;&nbsp; ;<br>---------------<br><br>Of course, generated function objectAList and objectBList should be different, because one returns a List&lt;A&gt; and the orther returnes a List&lt;B&gt;, 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>