soml-parser/lib/parser/function_definition.rb

18 lines
530 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
name.as(:function_name) >> parmeter_list.maybe >> newline >> expressions_end >> newline
}
rule(:parmeter_list) {
left_parenthesis >>
((name.as(:parmeter) >> (comma >> name.as(:parmeter)).repeat(0)).repeat(0,1)).as(:parmeter_list) >>
right_parenthesis
}
end
end