> Started working on this m// thing and found a bug in the lexer: in
> find_regex_token, when we have several tokens matching, then only the
> first one will win which is the contrary of what we want.
>
> Why?
> Because in the if matched_length > length we scan the input string so we
> advance the string pointer and any other matching tokens will have
> difficulties to match again.
> It doesn't seem to me to be a feature (or I might be wrong).
>
> diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
> index 0db6c22..020963d 100644
> --- a/lib/puppet/parser/lexer.rb
> +++ b/lib/puppet/parser/lexer.rb
> @@ -297,12 +300,12 @@ class Puppet::Parser::Lexer
>
>              # We've found a longer match
>              if match_length > length
> -                value = @scanner.scan(token.regex)
>                  length = value.length
>                  matched_token = token
>              end
>          end
>
> +        value = @scanner.scan(matched_token.regex) unless
> matched_token.nil?
>          return matched_token, value
>      end
>

If you just move it out of the loop you'll always get the last-matching
because the length will always be set to 0 (value having been initialized up
top to '').

I agree it's a bug but I'm not buying the fix.  *smile*

-- Markus

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to