From b5db33bc2a639984cda9a651abe57d044c14f23d Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Mon, 7 Jun 2010 15:25:21 -0700 Subject: 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. --- lib/puppet/parser/lexer.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/puppet/parser') 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 -- cgit