Permalink
Browse files

Updated PEG rule for identifiers so they can contain a trailing quest…

…ion mark or exclamation point [issue 3]
  • Loading branch information...
1 parent 5d3ca10 commit 6968985345e08d48cade3a8cf00c807683f2b89d @aarongough committed Sep 2, 2010
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/parser/koi-reference-parser.treetop
  2. +15 −0 test/unit/identifier_test.rb
@@ -45,7 +45,7 @@ grammar KoiReferenceParser
end
rule identifier
- '$'? [a-zA-Z] [a-zA-Z0-9_]* <Identifier>
+ '$'? [a-zA-Z] [a-zA-Z0-9_]* ('?' / '!')? <Identifier>
end
##################
@@ -33,5 +33,20 @@ class FunctionCallTest < Test::Unit::TestCase
tree = Parser.parse('$test = "test"')
assert_identifier(tree)
end
+
+ test "should parse identifier with trailing underscores" do
+ tree = Parser.parse('test__ = "test"')
+ assert_identifier(tree)
+ end
+
+ test "should parse identifier with trailing ?" do
+ tree = Parser.parse('test? = "test"')
+ assert_identifier(tree)
+ end
+
+ test "should parse identifier with trailing !" do
+ tree = Parser.parse('test! = "test"')
+ assert_identifier(tree)
+ end
end

0 comments on commit 6968985

Please sign in to comment.