grammar Gisele::Language::Syntax::Grammar ### Units rule unit_def (spacing task_def (spaces task_def)* spacing) end ### Task definitions rule task_def ('task' spaces task_name spaces (some_def spaces)* (explicit_statement spaces)? 'end') end rule some_def fluent_def | trackvar_def | task_def end ### Process statements rule process_statement implicit_seq_st | explicit_statement end rule implicit_seq_st (explicit_statement spaces st_list) end rule st_list (explicit_statement (spaces explicit_statement)*) end rule explicit_statement if_st | case_st | while_st | seq_st | par_st | task_call_st end rule case_st ('case' spaces (var_ref spaces)? (when_clause spaces)+ (else_clause spaces)? 'end') end rule when_clause ('when' spaces bool_expr spaces process_statement) end rule if_st ('if' spaces bool_expr spaces process_statement spaces (elsif_clause spaces)* (else_clause spaces)? 'end') end rule elsif_clause ('elsif' spaces bool_expr spaces process_statement) end rule else_clause ('else' spaces process_statement) end rule while_st ('while' spaces bool_expr spaces process_statement spaces 'end') end rule seq_st ('seq' spaces st_list spaces 'end') end rule par_st ('par' spaces st_list spaces 'end') end rule task_call_st (task_name) end ### Boolean expressions rule bool_expr (spacing theexpr:bool_or) end rule bool_or (left:bool_and spaces 'or' spaces right:bool_or) | bool_and end rule bool_and (left:bool_not spaces 'and' spaces right:bool_and) | bool_not end rule bool_not ('not' &([ \t\n] | '(') spacing expr:bool_not) | bool_term end rule bool_term bool_paren | bool_lit | var_ref end rule bool_paren ('(' spacing expr:bool_or spacing ')') end rule bool_lit (boolean_literal) end ### Variables rule variable_def trackvar_def | fluent_def end rule trackvar_def ('trackvar' spaces variable_name spacing event_set (spacing ',' spacing event_set)? initially_def?) end rule fluent_def ('fluent' spaces variable_name spacing event_set spacing ',' spacing event_set initially_def?) end rule initially_def (spaces 'initially' spaces lit:boolean_literal){ lit.value } end rule var_ref (variable_name) end ### Events rule event_set ('{' spacing (event (spacing ',' spacing event)*)? spacing '}') end rule event task_start_or_end | event_name end rule task_start_or_end task_name ':' ('start' | 'end') end ### Names rule task_name [A-Z] [A-Za-z0-9_]* end rule variable_name !(reserved_word spaces) [a-z] [A-Za-z0-9_]* end rule event_name !(reserved_word spaces) [a-z] [a-z0-9_]* end ### Literals rule boolean_literal ('true' | 'false'){ strip == "true" } end ### Spacing rule comment "#" (![\n] .)* end rule spaces (comment | [ \t\n])+ end rule spacing (comment | [ \t\n])* end ### Reserved Words rule reserved_word "if" | "else" | "elsif" | "when" | "while" | "seq" | "par" | "task" | "refinement" | "fluent" | "trackvar" | "initially" | "end" | "not" | "or" | "and" | "true" | "false" end end