summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-06-07 15:25:21 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitb5db33bc2a639984cda9a651abe57d044c14f23d (patch)
treed544538a30938209fa887c38d6e5c660f75a4c3b /lib
parent9ddee72e05af79ab7f453b37e9497dca33f7d5ba (diff)
downloadpuppet-b5db33bc2a639984cda9a651abe57d044c14f23d.tar.gz
puppet-b5db33bc2a639984cda9a651abe57d044c14f23d.tar.xz
puppet-b5db33bc2a639984cda9a651abe57d044c14f23d.zip
Fix for 3664: interpolating qualified variables.
"${myclass::var}" was lexed as a CLASSNAME instead of a VARIABLE token, giving an error while parsing because a rvalue can't be a bare CLASSNAME token. This commit (based of Brice's) fixes it by restricting the contexts in which the CLASSNAME and CLASSREF tokens are acceptable, analagous with the handling for NAME tokens.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/lexer.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index c3c53a528..7adb0b6d1 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -108,12 +108,6 @@ class Puppet::Parser::Lexer
end
TOKENS = TokenList.new
-
- TOKENS.add_token :VARIABLE, %r{(\w*::)*\w+}
- def (TOKENS[:VARIABLE]).acceptable?(context={})
- [:DQPRE,:DQMID].include? context[:after]
- end
-
TOKENS.add_tokens(
'[' => :LBRACK,
']' => :RBRACK,
@@ -183,9 +177,11 @@ class Puppet::Parser::Lexer
end
[string_token, value]
end
- def (TOKENS[:NAME]).acceptable?(context={})
- ![:DQPRE,:DQMID].include? context[:after]
- end
+ [:NAME,:CLASSNAME,:CLASSREF].each { |name_token|
+ def (TOKENS[name_token]).acceptable?(context={})
+ ![:DQPRE,:DQMID].include? context[:after]
+ end
+ }
TOKENS.add_token :COMMENT, %r{#.*}, :accumulate => true, :skip => true do |lexer,value|
value.sub!(/# ?/,'')
@@ -237,6 +233,10 @@ class Puppet::Parser::Lexer
[TOKENS[:VARIABLE],value[1..-1]]
end
+ TOKENS.add_token :VARIABLE, %r{(\w*::)*\w+}
+ def (TOKENS[:VARIABLE]).acceptable?(context={})
+ [:DQPRE,:DQMID].include? context[:after]
+ end
TOKENS.sort_tokens