Hi Etienne, I'm having another problem while building my instruction. I've
defined the possibility of declaring a function (called unit in my
language).
What I do is this:
public void outAUnitInstr( AUnitInstr node){
System.out.println("Function: " + node.getId().getText());
Translation prova = new Translation();
node.getUnitphrase().apply(prova);
}
It works quite well because I'm able to store the instruction inside the
unit to create something similar to a symbols table but when the Adapter
goes on, it still traverses the Unitphrase() which I've already "explored"
applying the switch. Is there a way to jump to the next rule on the same
function level?
Here's an example:
unit ciao{
font ( (v) AND (NOT v.label == "Roma") AND v.degree >= 3 )
}
font ( (e) AND (NOT v.label == "Roma") AND v.degree >= 3 )
I'm in the UNIT node, my getUnitphrase gets what is inside the brackets and
creates its list of instructions(in this case FONT( (V...) ), then I want to
skip to FONT ( (E....).
2011/5/16 Etienne M. Gagnon <[email protected]>
> Hi Emanuele,
>
> Your solution seems excellent! The solution I suggested was relatively
> similar, but without the need for a list. It would have looked something
> like:
>
> public void caseATermAndTerm(...) { // caseXXX instead of outXXX
>
> BinaryQuery q = new BinaryQuery();
> q.setOperator("AND");
> q.setQ1(computeQuerty(node.getTerm()));
> q.setQ2(computeQuerty(node.getFactor()));
> this.computedQuery = q;
> }
>
> Note that I didn't need to reverse the order of Q1 and Q2.
>
> Have fun!
>
> Etienne
>
>
> On 2011-05-15 19:21, Emanuele Ianni wrote:
>
>> Hi Etienne. I actually solved my problem this morning at 4AM :)
>> I recently had my AI final exam so I was fresh of Prolog.
>> So I though about recursion and about using an accumulator like when you
>> reverse a list in Prolog. First I tried with the currentQuery but it wasn't
>> working, instead I've used a LinkedList so when I end up in a query node I
>> do something like:
>>
>> public void outATermAndTerm( ATermAndTerm node) {
>> BinaryQuery q = new BinaryQuery();
>> q.setOperator("AND");
>> q.setQ2(queryBuffer.pollLast());
>> q.setQ1(queryBuffer.pollLast());
>> queryBuffer.add(q);
>> }
>>
>> Thanks for the code, I'll read that.
>>
>
> --
> Etienne M. Gagnon, Ph.D.
> SableCC:http://sablecc.org
>
>
> _______________________________________________
> SableCC-Discussion mailing list
> [email protected]
> http://lists.sablecc.org/listinfo/sablecc-discussion
>
--
Distinti Saluti
Emanuele Ianni
_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion