Permalink
Browse files

Revert "(MCO-817) Allow unquoted function arguments"

This reverts commit 999bd0f.
  • Loading branch information...
MikaelSmith committed Mar 28, 2018
1 parent d838bca commit 24750c071f52f62681e0c016e9210ec685515b61
Showing with 8 additions and 15 deletions.
  1. +2 −3 lib/mcollective/matcher/scanner.rb
  2. +6 −12 spec/unit/mcollective/matcher/scanner_spec.rb
@@ -188,9 +188,8 @@ def gen_statement
return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
else
if func
if current_token_value.match(/^.+?\((\s*'[^']*'\s*(,\s*'[^']*')*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/) ||
current_token_value.match(/^.+?\((\s*"[^"]*"\s*(,\s*"[^"]*")*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/) ||
current_token_value.match(/^.+?\((\s*[^'"]*\s*(,\s*[^'"]*)*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/)
if current_token_value.match(/^.+?\((\s*(')[^']*(')\s*(,\s*(')[^']*('))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/) ||
current_token_value.match(/^.+?\((\s*(")[^"]*(")\s*(,\s*(")[^"]*("))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/)
return "fstatement", current_token_value
else
return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
@@ -71,18 +71,6 @@ module Matcher
token.should == ["fstatement", "foo('bar')"]
end
it "should identify a function statement token with double quotes" do
scanner = Scanner.new('foo("bar")')
token = scanner.get_token
token.should == ["fstatement", 'foo("bar")']
end
it "should identify a function statement token with no quotes" do
scanner = Scanner.new("foo(bar)")
token = scanner.get_token
token.should == ["fstatement", "foo(bar)"]
end
it "should identify a function statement with multiple parameters" do
scanner = Scanner.new("foo('bar','baz')")
token = scanner.get_token
@@ -113,6 +101,12 @@ module Matcher
token.should == ["bad_token", [0,7]]
end
it "should identify a bad token where function parameters are not in single quotes" do
scanner = Scanner.new("foo(bar)")
token = scanner.get_token
token.should == ["bad_token", [0,7]]
end
it "should identify a bad token where there are non alphanumerical or underscore chars in the dot value" do
scanner = Scanner.new("foo('bar').val-ue")
token = scanner.get_token

0 comments on commit 24750c0

Please sign in to comment.