Add "drop" grammar keyword to drop patterns

This commit is contained in:
josh committed 2021-06-09 22:48:30 -04:00
1 parent f67dd62b20
commit db70f8b94d
2 files changed
+16

No files matched your search

+3
View File
@@ -40,6 +40,9 @@ module Imbecile
end
@tokens << Token.new(name, pattern, @tokens.size)
token_names << name
elsif line =~ /^\s*drop\s+(\S+)$/
pattern = $1
@tokens << Token.new(nil, pattern, @tokens.size)
else
raise Error.new("Unexpected input on line #{line_number}: #{line}")
end
+13
View File
@@ -103,6 +103,19 @@ EOF
token foo
token bar
token WS \\s+
EOF
end
it "allows dropping a matched pattern" do
expected = [
["foo", "foo"],
[nil, " \t"],
["bar", "bar"],
]
expect(run(<<EOF, "foo \tbar")).to eq expected
token foo
token bar
drop \\s+
EOF
end
end