On 8/11/08 9:25, David Schmitt wrote:
> Brice Figureau schrieb:
>> When the node/class (or any other block containing braces) is reduced we 
>> know that we just closed a brace block. It is the perfect time to pop 
>> the comment stack, and then associate the result with the AST node we're 
>> building.
>> It just requires to add some lexer.commentpop code to the grammar rules 
>> for the blocks statements (ie node, class, resources...), or 
>> modification of Parser.ast()
> 
> [without having looked at the code]
> 
> Couldn't the lexer collect the comments and add them to the _next_ 
> token, instead of storing them on a stack? Having the information on the 
> token should make it straightforward to process it in the grammar.

That's a solution but I don't think it'll work because:
  1) the next token after a comment is the RETURN token :-)

  2) if I solve 1), and I attribute the comment to let's say the CLASS 
token, the parser receives only the name of the tokens not a token object.

  3) Tokens are singletons. So even if I could get while inside the 
parser access to the token, I'm not sure I could grasp the right comment.

  4) And in the grammar rules, I'd have to unwind the parser stack, 
which I'm not sure is possible. I know that racc offers a _values array 
containing some of the predicates (but I'm not sure they map to lexed 
tokens).


I implemented the solution I proposed earlier, yesterday evening and it 
seems to work fine. The only drawbacks once again is that I had to 
modify slightly the grammar.

Anyway, thanks for helping me :-)
-- 
Brice Figureau
Days of Wonder
http://www.daysofwonder.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to