diff --git a/lib/puppetdb/lexer.l b/lib/puppetdb/lexer.l index ffacac7..b30a65c 100644 --- a/lib/puppetdb/lexer.l +++ b/lib/puppetdb/lexer.l @@ -21,8 +21,8 @@ rule or { [:OR, text] } true { [:BOOLEAN, true]} false { [:BOOLEAN, false]} + -?\d+\.\d+ { [:NUMBER, text.to_f] } -?\d+ { [:NUMBER, text.to_i] } - -?\d+\.?(\d+)? { [:NUMBER, text.to_f] } \"(\\.|[^\\"])*\" { [:STRING, JSON.load(text)] } [\w_:]+ { [:STRING, text] } @@ { [:EXPORTED, text] } diff --git a/lib/puppetdb/lexer.rb b/lib/puppetdb/lexer.rb index 11c7893..9565e33 100644 --- a/lib/puppetdb/lexer.rb +++ b/lib/puppetdb/lexer.rb @@ -108,12 +108,12 @@ def scan_evaluate( str ) when (text = ss.scan(/false/)) @rex_tokens.push action { [:BOOLEAN, false]} + when (text = ss.scan(/-?\d+\.\d+/)) + @rex_tokens.push action { [:NUMBER, text.to_f] } + when (text = ss.scan(/-?\d+/)) @rex_tokens.push action { [:NUMBER, text.to_i] } - when (text = ss.scan(/-?\d+\.?(\d+)?/)) - @rex_tokens.push action { [:NUMBER, text.to_f] } - when (text = ss.scan(/\"(\\.|[^\\"])*\"/)) @rex_tokens.push action { [:STRING, JSON.load(text)] }