Hi,

I'm not sure the fix is 100% correct, but it looks like this fixes the issue.
I didn't test anything more complex than my failing test manifests, 
so it might break everything else :-)

Thanks,
Brice

Original commit msg:
"${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 patch fixes the issue by making VARIABLE lexing higher priority than
CLASSNAME.

Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com>
---
 lib/puppet/parser/lexer.rb |   10 ++++++----
 spec/unit/parser/lexer.rb  |    1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 2a1f88e..2b8a5dd 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -108,6 +108,12 @@ 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,
@@ -227,10 +233,6 @@ 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
diff --git a/spec/unit/parser/lexer.rb b/spec/unit/parser/lexer.rb
index 2e58ef4..bb41900 100755
--- a/spec/unit/parser/lexer.rb
+++ b/spec/unit/parser/lexer.rb
@@ -409,6 +409,7 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
         %q["string with an escaped '\\$'"]                              => 
[[:STRING,"string with an escaped '$'"]],
         %q["string with $v (but no braces)"]                            => 
[[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
         %q["string with ${v} in braces"]                                => 
[[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' in braces']],
+        %q["string with ${qualified::var} in braces"]                   => 
[[:DQPRE,"string with "],[:VARIABLE,'qualified::var'],[:DQPOST,' in braces']],
         %q["string with $v and $v (but no braces)"]                     => 
[[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and 
"],[:VARIABLE,"v"],[:DQPOST," (but no braces)"]],
         %q["string with ${v} and ${v} in braces"]                       => 
[[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and 
"],[:VARIABLE,"v"],[:DQPOST," in braces"]],
         %q["string with ${'a nested single quoted string'} inside it."] => 
[[:DQPRE,"string with "],[:STRING,'a nested single quoted string'],[:DQPOST,' 
inside it.']],
-- 
1.6.6.1

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

Reply via email to