language Indice { lexicon { reservadas indice | fim | do palavra [a-zA-Z]+ inteiro [0-9]+ separadores , | = ignore [\ \0x0A\0x0D\0x09] } attributes String *.output, *.inRef; rule Raiz { RAIZ ::= indice LST_REF fim do indice compute { RAIZ.output = "\nindice " + LST_REF.output + "\nfim do indice\n"; }; } rule LstRef { LST_REF ::= REF compute { LST_REF.output = REF.output; } | LST_REF REF compute { LST_REF[0].output = LST_REF[1].output + "\n" + REF.output; }; } rule Ref { REF ::= IDENT = LST_PAL compute { LST_PAL.inRef = IDENT.output; REF.output = LST_PAL.output; }; } rule Ident { IDENT ::= #inteiro compute { IDENT.output = #inteiro.value(); } | #palavra compute { IDENT.output = #palavra.value(); }; } rule LstPal { LST_PAL ::= #palavra compute { LST_PAL.output = LST_PAL.inRef + " - " + #palavra.value(); } | LST_PAL , #palavra compute { LST_PAL[1].inRef = LST_PAL[0].inRef; LST_PAL[0].output = LST_PAL[1].output + " , " + LST_PAL.inRef + " - " + #palavra.value(); }; } }