On 3/11/08 9:36, Brice Figureau wrote:
> On Sun, 2008-11-02 at 21:56 -0600, Luke Kanies wrote:
>> On Oct 31, 2008, at 5:40 PM, Brice Figureau wrote:
>>> grammar.ra
>>> index 23c2934..d01ab61 100644
>>> --- a/lib/puppet/parser/grammar.ra
>>> +++ b/lib/puppet/parser/grammar.ra
>>> @@ -77,26 +77,28 @@ fstatement: NAME LPAREN funcvalues RPAREN {
>>> result = ast AST::Function,
>>> :name => val[0],
>>> :arguments => args,
>>> - :ftype => :statement
>>> + :ftype => :statement,
>>> + :doc => @lexer.getcomment
>>> }
>> Wouldn't it be easier to have the 'ast' method add the 'doc' attribute?
>
> That was my first implementation, but it doesn't work. In fact you want
> the documenation to be attached to the statement AST node (ie the
> resource, the class, the define...). If you let the doc to be attached
> on each AST creation, you end up with a class comment attached to the
> AST node of the name of the class and not the class itself :-(
>
> That's why I had to move the comment association to the specific
> upper-level nodes. I think I could have done it only in the statement:
> grammar rule but it would have need some logic code to scan the current
> _values stack to find the real proper node. I think the solution I chose
> is simpler and more clear this way.
> The only drawback is that whenever you have to add a statement to the
> language you need to provide the documentation association.
>
>> If you're not adding docs to every ast class, then you could have a
>> boolean on the AST classes that should add docs.
>
> I'm not sure I understand what you mean. Can you elaborate on this,
> please?
Never mind I figured it out.
The various AST node now defines if they want the doc to be attached,
and if true, the ast method attaches it on demand.
That's way cleaner now, and there is no more modification of the grammar.
Thanks for the idea,
--
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
-~----------~----~----~----~------~----~------~--~---