adding tokens to basic types
This commit is contained in:
parent
ca8e63d8f3
commit
c538679c67
@ -37,6 +37,3 @@ DEPENDENCIES
|
|||||||
rake
|
rake
|
||||||
rubygems-tasks
|
rubygems-tasks
|
||||||
salama-reader!
|
salama-reader!
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.10.5
|
|
||||||
|
@ -42,19 +42,65 @@ grammar BasicTypes
|
|||||||
|
|
||||||
rule string_expression
|
rule string_expression
|
||||||
#"'" (/.*/ !"'") "'"
|
#"'" (/.*/ !"'") "'"
|
||||||
('"' str:(!'"' .)* '"') {Ast::StringExpression.new capture(:str).to_str }
|
('"' str:(!'"' .)* '"') {Ast::StringExpression.new(capture(:str).to_str) }
|
||||||
end
|
|
||||||
|
|
||||||
rule instance_variable
|
|
||||||
('@' ivar:name_expression) { Ast::VariableExpression.new (capture(:ivar).value).name }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rule basic_expression
|
rule basic_expression
|
||||||
name_expression | integer_expression | instance_variable |
|
name_expression | integer_expression |
|
||||||
module_name_expression | string_expression
|
module_name_expression | string_expression
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Tokens are single or double character combinations with "meaning"
|
||||||
|
# braces, comman, point, questionmark , quotes, that kind of thing
|
||||||
|
# operator symbols are separate in Opreators
|
||||||
|
|
||||||
|
rule left_parenthesis
|
||||||
|
'(' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule right_parenthesis
|
||||||
|
')' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule left_brace
|
||||||
|
'{' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule right_brace
|
||||||
|
'}' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule left_bracket
|
||||||
|
'[' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule right_bracket
|
||||||
|
']' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule association
|
||||||
|
"=>" space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule comma
|
||||||
|
',' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule colon
|
||||||
|
':' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule semicolon
|
||||||
|
';' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule question_mark
|
||||||
|
'?' space?
|
||||||
|
end
|
||||||
|
|
||||||
|
rule excamation_mark
|
||||||
|
'!' space?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -54,25 +54,12 @@ class TestBasic < MiniTest::Test
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instance_variable
|
|
||||||
@input = '@foo_bar '
|
|
||||||
@output = Ast::VariableExpression.new(:foo_bar)
|
|
||||||
check
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_module_name
|
def test_module_name
|
||||||
@input = 'FooBar '
|
@input = 'FooBar '
|
||||||
@output = Ast::ModuleName.new("FooBar")
|
@output = Ast::ModuleName.new("FooBar")
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def ttest_comment # maybe a non test at this point (higher up)
|
|
||||||
out = "# i am a comment \n"
|
|
||||||
@input = out.dup #NEEDS the return, which is what delimits the comment
|
|
||||||
@output = @output #dont transform
|
|
||||||
check
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_string
|
def test_string
|
||||||
@input = '"hello"'
|
@input = '"hello"'
|
||||||
@output = Ast::StringExpression.new('hello')
|
@output = Ast::StringExpression.new('hello')
|
||||||
|
Loading…
Reference in New Issue
Block a user