Skip to content

Commit

Permalink
Properly handle floating point numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Dalén committed Apr 26, 2013
1 parent 88305cd commit ab2c793
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/puppetdb/lexer.l
Expand Up @@ -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] }
Expand Down
6 changes: 3 additions & 3 deletions lib/puppetdb/lexer.rb
Expand Up @@ -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)] }

Expand Down

0 comments on commit ab2c793

Please sign in to comment.