Well, I actually wanted to use it in production because basically what I
want to do is syntax highlight. If I only use the lexer I could not use
something like:

If it's a TId and a Parameter then color this way, if it's a TId and a
function signature color that way. Right now I use the Adapter and I color
it after a full instruction is completed so I can validate it and color it.
(while is not completed I just color the token using the lexer information).
Does it make sense to you?

2011/2/18 Etienne M. Gagnon <[email protected]>

> Hi Emanuele,
>
> You could always override the Parser.filter() method to tell you about all
> the reductions done by the parser. SableCC does construct the AST while
> parsing, but it does so the LR way: it builds partials ASTs, one per child
> of a production, and it attaches them to the node of the parent on REDUCE
> actions. So, there is a stack of partial ASTs already built at the time of
> the parse error, but making sense of such ASTs is not usually possible.
> Therefore, SableCC does not provide access to these partial ASTs other than
> in a limited fashion through the filter() method.
>
> I would not recommend using this information other than for debugging your
> grammar. I definitely advise you against using partial AST information in
> deployed software.
>
> Hoping this helps you,
>
> Etienne
>
>
> On 2011-02-18 07:59, Emanuele Ianni wrote:
>
>> Guys I have a question. I'm using sablecc 3.2. I was wondering something.
>> I've extended the lexer to print tokens. This is a typical output:
>>
>> TId, state : 0, text : [font]
>> ...
>>
>> TBlank, state : 0, text : [ ]
>> TRPar, state : 0, text : [)]
>> Parser Exception
>> [1,71] expecting: EOF
>>
>> As you can see the lexer prints every token and then, since there is
>> something that shouldn't be there, the parser generate an Exception, the
>> last line is a e.getMessage(). So far that's ok. But...since the
>> e.getMessage() is pretty specific I would guess that there's already a
>> partial AST. Is thare some way I could explore that partial AST with the
>> DepthFirstAdapter? Basically this is a part of the specific grammar:
>>
>>    par =
>>        {numero} number |
>>        {stringa} string |
>>        {idpar} id ;
>>
>> What I want to know is if is possible to know already if that TId or
>> TNumber are already parameters even if the AST is not complete.
>>
>
> --
> 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

Le informazioni e gli allegati contenuti in questa e-mail sono considerati
confidenziali e possono essere riservati. Qualora non foste il destinatario,
siete pregati di distruggere questo messaggio e notificarmi il problema
immediatamente. In ogni caso, non dovrete spedire a terze parti questa
e-mail. Vi ricordo che la diffusione, l'utilizzo e/o la conservazione dei
dati ricevuti per errore costituiscono violazione alle disposizioni del D.L.
n. 196/2003 denominato "Codice in materia di protezione dei dati personali"

The information in this e.mail and in any attachements is confidential and
may be privileged. If you are not the intended recipient, please destroy
this message and notify the sender immediately. You should not retain, copy
or use this e.mail for any purpose, nor disclose all or any part of its
contents to any other person according to the Italian Legislative Decree n.
196/2003.
_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion

Reply via email to