soml-parser/lib/parser/function_definition.rb

18 lines
533 B
Ruby
Raw Normal View History

2014-06-04 18:55:04 +02:00
module Parser
module FunctionDefinition
include Parslet
rule(:function_definition) {
keyword_def >> ((module_name|instance_variable|name).as(:receiver) >> str(".")).maybe >> #possibly qualified
2014-06-19 18:33:08 +02:00
name.as(:function_name) >> parameter_list.maybe >> newline >> expressions_end >> newline
2014-06-04 18:55:04 +02:00
}
2014-06-19 18:33:08 +02:00
rule(:parameter_list) {
2014-06-04 18:55:04 +02:00
left_parenthesis >>
2014-06-19 18:33:08 +02:00
((name.as(:parameter) >> (comma >> name.as(:parameter)).repeat(0)).repeat(0,1)).as(:parameter_list) >>
2014-06-04 18:55:04 +02:00
right_parenthesis
}
end
end