expressions are now statements
This commit is contained in:
parent
b424306156
commit
60746383ee
@ -1,18 +1,18 @@
|
|||||||
module Parser
|
module Parser
|
||||||
module Expression
|
module Statement
|
||||||
include Parslet
|
include Parslet
|
||||||
|
|
||||||
rule(:expression) { (simple_return | while_do | small_conditional | conditional |
|
rule(:statement) { (return_statement | while_statement | small_conditional | if_statement |
|
||||||
operator_expression | call_site | class_field | field |
|
assignment | class_field | field_def | call_site |
|
||||||
hash_constant | array_constant) }
|
hash_constant | array_constant) }
|
||||||
|
|
||||||
def delimited_expressions( delimit )
|
def delimited_statements( delimit )
|
||||||
( (delimit.absent? >> expression).repeat(1)).as(:expressions) >> delimit
|
( (delimit.absent? >> statement).repeat(1)).as(:statements) >> delimit
|
||||||
end
|
end
|
||||||
|
|
||||||
rule(:expressions_do) { delimited_expressions(keyword_do) }
|
rule(:statements_do) { delimited_statements(keyword_do) }
|
||||||
rule(:expressions_else) { delimited_expressions(keyword_else) }
|
rule(:statements_else) { delimited_statements(keyword_else) }
|
||||||
rule(:expressions_end) { delimited_expressions(keyword_end) }
|
rule(:statements_end) { delimited_statements(keyword_end) }
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
message.self
|
|
||||||
-- -- --
|
|
||||||
s(:expressions,
|
|
||||||
s(:field_access,
|
|
||||||
s(:receiver,
|
|
||||||
s(:name, :message)),
|
|
||||||
s(:field,
|
|
||||||
s(:name, :self))))
|
|
@ -1,5 +1,4 @@
|
|||||||
return 42
|
return 42
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:return,
|
||||||
s(:return,
|
s(:int, 42))
|
||||||
s(:int, 42)))
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
return "hello"
|
return "hello"
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:return,
|
||||||
s(:return,
|
s(:string, "hello"))
|
||||||
s(:string, "hello")))
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
return foo
|
return foo
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:return,
|
||||||
s(:return,
|
s(:name, :foo))
|
||||||
s(:name, :foo)))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user