soml-parser/lib/parser/function_definition.rb

17 lines
500 B
Ruby
Raw Normal View History

2014-06-04 18:55:04 +02:00
module Parser
module FunctionDefinition
include Parslet
2015-09-15 17:57:31 +02:00
2014-06-04 18:55:04 +02:00
rule(:function_definition) {
2015-09-17 23:02:52 +02:00
type >> ((module_name|name).as(:receiver) >> str(".")).maybe >> #possibly qualified
name.as(:function_name) >> left_parenthesis >>
parameter_list.maybe >> right_parenthesis >> expressions_end >> space?
2014-06-04 18:55:04 +02:00
}
2014-06-19 18:33:08 +02:00
rule(:parameter_list) {
2015-09-17 23:02:52 +02:00
((field.as(:parameter) >> (comma >> field.as(:parameter)).repeat(0)).repeat(0,1)).as(:parameter_list)
2014-06-04 18:55:04 +02:00
}
end
end