summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-11-15 13:10:55 +0100
committerJames Turnbull <james@lovedthanlost.net>2008-11-17 21:05:36 +1100
commit064fb006a350e9555abe766c5cb4aeb803fd623a (patch)
treee9dd550404cb84a4a9c11d08560c9408bbba6f40 /lib/puppet/parser/ast
parent724a6f672308ab6f52d738caf20c5994e6225071 (diff)
downloadpuppet-064fb006a350e9555abe766c5cb4aeb803fd623a.tar.gz
puppet-064fb006a350e9555abe766c5cb4aeb803fd623a.tar.xz
puppet-064fb006a350e9555abe766c5cb4aeb803fd623a.zip
Add a doc attribute to AST nodes and fill it with the last seen comments
The lexer maintains a stack of last seen comments. On blank lines the lexer flush the comments. On each opening brace the lexer enters a new stack level. On each block AST nodes, the stack is popped. Each AST nodes has a doc property that is filled with the last seen comments on node creation (in fact only on important node creation representing statements). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/casestatement.rb2
-rw-r--r--lib/puppet/parser/ast/collection.rb2
-rw-r--r--lib/puppet/parser/ast/definition.rb2
-rw-r--r--lib/puppet/parser/ast/else.rb3
-rw-r--r--lib/puppet/parser/ast/function.rb3
-rw-r--r--lib/puppet/parser/ast/hostclass.rb3
-rw-r--r--lib/puppet/parser/ast/ifstatement.rb3
-rw-r--r--lib/puppet/parser/ast/node.rb3
-rw-r--r--lib/puppet/parser/ast/resource.rb3
-rw-r--r--lib/puppet/parser/ast/resource_defaults.rb2
-rw-r--r--lib/puppet/parser/ast/resource_override.rb3
-rw-r--r--lib/puppet/parser/ast/vardef.rb3
12 files changed, 32 insertions, 0 deletions
diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb
index aa03090de..73fbdcf1e 100644
--- a/lib/puppet/parser/ast/casestatement.rb
+++ b/lib/puppet/parser/ast/casestatement.rb
@@ -6,6 +6,8 @@ class Puppet::Parser::AST
class CaseStatement < AST::Branch
attr_accessor :test, :options, :default
+ associates_doc
+
# Short-curcuit evaluation. Return the value of the statements for
# the first option that matches.
def evaluate(scope)
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index 9e795a33c..a51b9b4d2 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -8,6 +8,8 @@ class Puppet::Parser::AST
class Collection < AST::Branch
attr_accessor :type, :query, :form
+ associates_doc
+
# We return an object that does a late-binding evaluation.
def evaluate(scope)
if self.query
diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb
index 0c65c702c..3cd8e79c7 100644
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@ -10,6 +10,8 @@ class Puppet::Parser::AST::Definition < Puppet::Parser::AST::Branch
attr_accessor :name
end
+ associates_doc
+
# The class name
@name = :definition
diff --git a/lib/puppet/parser/ast/else.rb b/lib/puppet/parser/ast/else.rb
index affac625d..70e80b4ee 100644
--- a/lib/puppet/parser/ast/else.rb
+++ b/lib/puppet/parser/ast/else.rb
@@ -4,6 +4,9 @@ class Puppet::Parser::AST
# A separate ElseIf statement; can function as an 'else' if there's no
# test.
class Else < AST::Branch
+
+ associates_doc
+
attr_accessor :statements
def each
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index eb36fa906..192940a7a 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -3,6 +3,9 @@ require 'puppet/parser/ast/branch'
class Puppet::Parser::AST
# An AST object to call a function.
class Function < AST::Branch
+
+ associates_doc
+
attr_accessor :name, :arguments
@settor = true
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 4f5c4797c..23d9a00e5 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -4,6 +4,9 @@ require 'puppet/parser/ast/definition'
# in that each class is a singleton -- only one will exist for a given
# node.
class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition
+
+ associates_doc
+
@name = :class
# Are we a child of the passed class? Do a recursive search up our
diff --git a/lib/puppet/parser/ast/ifstatement.rb b/lib/puppet/parser/ast/ifstatement.rb
index afa2cd572..d216b7c65 100644
--- a/lib/puppet/parser/ast/ifstatement.rb
+++ b/lib/puppet/parser/ast/ifstatement.rb
@@ -3,6 +3,9 @@ require 'puppet/parser/ast/branch'
class Puppet::Parser::AST
# A basic 'if/elsif/else' statement.
class IfStatement < AST::Branch
+
+ associates_doc
+
attr_accessor :test, :else, :statements
def each
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb
index 2bf6c1882..442518f44 100644
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@ -3,6 +3,9 @@ require 'puppet/parser/ast/hostclass'
# The specific code associated with a host. Nodes are annoyingly unlike
# other objects. That's just the way it is, at least for now.
class Puppet::Parser::AST::Node < Puppet::Parser::AST::HostClass
+
+ associates_doc
+
@name = :node
def initialize(options)
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb
index 8a60522a3..1a07fc585 100644
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@ -4,6 +4,9 @@ require 'puppet/parser/ast/resource_reference'
# builtin type.
class Puppet::Parser::AST
class Resource < AST::ResourceReference
+
+ associates_doc
+
attr_accessor :title, :type, :exported, :virtual
attr_reader :params
diff --git a/lib/puppet/parser/ast/resource_defaults.rb b/lib/puppet/parser/ast/resource_defaults.rb
index 4856f0594..4919817fb 100644
--- a/lib/puppet/parser/ast/resource_defaults.rb
+++ b/lib/puppet/parser/ast/resource_defaults.rb
@@ -6,6 +6,8 @@ class Puppet::Parser::AST
class ResourceDefaults < AST::Branch
attr_accessor :type, :params
+ associates_doc
+
# As opposed to ResourceDef, this stores each default for the given
# object type.
def evaluate(scope)
diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb
index 8380dcd00..5c4a2410f 100644
--- a/lib/puppet/parser/ast/resource_override.rb
+++ b/lib/puppet/parser/ast/resource_override.rb
@@ -4,6 +4,9 @@ class Puppet::Parser::AST
# Set a parameter on a resource specification created somewhere else in the
# configuration. The object is responsible for verifying that this is allowed.
class ResourceOverride < Resource
+
+ associates_doc
+
attr_accessor :object
attr_reader :params
diff --git a/lib/puppet/parser/ast/vardef.rb b/lib/puppet/parser/ast/vardef.rb
index a3094ac6e..2d5f623f7 100644
--- a/lib/puppet/parser/ast/vardef.rb
+++ b/lib/puppet/parser/ast/vardef.rb
@@ -3,6 +3,9 @@ require 'puppet/parser/ast/branch'
class Puppet::Parser::AST
# Define a variable. Stores the value in the current scope.
class VarDef < AST::Branch
+
+ associates_doc
+
attr_accessor :name, :value, :append
@settor = true