Separate ? and - into special tokens

This commit is contained in:
Justin Li
2014-10-17 13:30:54 -04:00
parent 7843bcca8d
commit b4ea483c4e
4 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -31,8 +31,8 @@ class LexerUnitTest < Minitest::Test
end
def test_fancy_identifiers
tokens = Lexer.new('hi! five?').tokenize
assert_equal [[:id,'hi!'], [:id, 'five?'], [:end_of_string]], tokens
tokens = Lexer.new('hi five?').tokenize
assert_equal [[:id,'hi'], [:id, 'five'], [:question, '?'], [:end_of_string]], tokens
end
def test_whitespace
+2 -2
View File
@@ -44,9 +44,9 @@ class ParserUnitTest < Minitest::Test
end
def test_expressions
p = Parser.new("hi.there hi[5].! hi.there.bob")
p = Parser.new("hi.there hi?[5].there? hi.there.bob")
assert_equal 'hi.there', p.expression
assert_equal 'hi[5].!', p.expression
assert_equal 'hi?[5].there?', p.expression
assert_equal 'hi.there.bob', p.expression
p = Parser.new("567 6.0 'lol' \"wut\"")