def function(): return keyword("def"), symbol, parameterlist, block def mod(): return "module", symbol, "{", -1, [function, rawstring], "}"
def returnstatement(): return keyword("return"), expression # ifstatement <- k"if" "(" expression ")" block k"else" block; def ifstatement(): return keyword("if"), "(", expression, ")", block, keyword("else"), block
def external_var_declarations(): return (keyword('VAR_EXTERNAL'), 0, constant, -1, (external_declaration, ';'), keyword('END_VAR'), 0, ';') def external_declaration(): return (global_var_name, ':', [_simple_specification, subrange_specification, enumerated_specification, array_specification, structure_type_name, function_block_type_name])
def single_byte_string_spec(): return (keyword('STRING'), 0, [('[', [integer, simple_type_name], ']'), ('(', [integer, simple_type_name], ')')], 0, (':=', single_byte_character_string)) def double_byte_string_var_declaration(): return (_var1_list, ':', double_byte_string_spec)
def r_edge(): return keyword('R_EDGE') def f_edge(): return keyword('F_EDGE')
def input_output_declarations(): return (keyword('VAR_IN_OUT'), -1, (var_init_decl, ';'), keyword('END_VAR'), 0, ';') def var_declaration(): return [_temp_var_decl, fb_name_decl]
def unit_interface(): return keyword('interface'), 0, uses_clause, -1, _decl_section def _unit_implementation(): return keyword('implementation'), 0, uses_clause, -1, _decl_section
def wstring(): return keyword('WSTRING') def string_initialization(): return (':=', _character_string)
def DEFINITION(): return keyword(r"DEFINE"), \ re.compile(r"[\w]+"), \ re.compile(r"[^\r\n]*") def GRAMMAR(): return -1, [DEFINITION , pyPEG.ignore(r"[^\r\n]*[\r\n]")]
def unit_head(): return keyword('unit'), identifier, ';' def unit_interface(): return keyword('interface'), 0, uses_clause, -1, _decl_section
def wstring(): return keyword("WSTRING")
def string(): return keyword("STRING")
def incompl_location(): return (keyword("AT"), re.compile(r"\%(I|Q|M)\*"))
def function(): return keyword("function"), symbol, parameterlist, block # simpleLanguage <- function; def simpleLanguage(): return function
def _unit_implementation(): return keyword('implementation'), 0, uses_clause, -1, _decl_section def _unit_block(): return keyword('end')
def _structure_declaration(): return (keyword('STRUCT'), structure_element_declaration, ';', -1, (structure_element_declaration, ';'), keyword('END_STRUCT'), 0, ';') def structure_element_declaration(): return (structure_element_name, ':', [initialized_structure, array_spec_init, string_var_type, simple_spec_init, subrange_spec_init, enumerated_spec_init])
def _unit_block(): return keyword('end') def uses_clause(): return keyword('uses'), _ident_list, ';'
def non_retain(): return keyword('NON_RETAIN') def input_declarations(): return (keyword('VAR_INPUT'), 0, [retain, non_retain], -1, (_input_declaration, ';'), keyword('END_VAR'), 0, ';')
def uses_clause(): return keyword('uses'), _ident_list, ';' def _decl_section(): return [const_section, type_section]
def edge_declaration(): return (_var1_list, ':', keyword('BOOL'), [r_edge, f_edge]) def var_init_decl(): return [array_var_init_decl, structured_var_init_decl, string_var_declaration, _var1_init_decl, fb_name_decl]
def const_section(): return keyword('const'), -2, const_declaration def const_declaration(): return identifier, 0, (':', _type_decl), '=', _const_expression, ';'
def constant(): return keyword('CONSTANT') def located_var_declarations(): return (keyword('VAR'), 0, [constant, retain, non_retain], -1, (located_var_decl, ';'), keyword('END_VAR'), 0, ';')
def type_section(): return keyword('type'), -2, type_declaration def type_declaration(): return identifier, '=', _type_decl, ';'
def global_var_declarations(): return (keyword('VAR_GLOBAL'), 0, [constant, retain], 0, persistent, -1, ([var_init_decl, global_var_decl], ';'), keyword('END_VAR'), 0, ';') def global_var_decl(): return (global_var_spec, ':', 0, [located_var_spec_init, function_block_type_name])
def _type_decl(): return [_struc_type, pointer_type, _variant_type, _simple_type, (keyword('type'), type_id)] def _struc_type(): return 0, keyword('packed'), [array_type, set_type, record_decl]
def incompl_located_var_declarations(): return (keyword('VAR'), 0, [retain, non_retain], -1, (incompl_located_var_decl, ';'), keyword('END_VAR'), 0, ';') def incompl_located_var_decl(): return (variable_name, incompl_location, ':', var_spec)
def _struc_type(): return 0, keyword('packed'), [array_type, set_type, record_decl] def array_type(): return keyword('array'), 0, ('[', 0, array_index, -1, (',', array_index), ']'), keyword('of'), array_subtype
def message(): return 0, message_fixed, keyword('message'), symbol, 0, message_type, 0, message_id, block, ';'
def array_type(): return keyword('array'), 0, ('[', 0, array_index, -1, (',', array_index), ']'), keyword('of'), array_subtype def array_index(): return [identifier, (_const_expression, '..', _const_expression)]
def ifstatement(): return keyword("if"), "(", expression, ")", block, keyword("else"), block # statement <- (ifstatement | returnstatement) ";"; def statement(): return [ifstatement, returnstatement], ";"
def array_subtype(): return [keyword('const'), _type_decl] def set_type(): return keyword('set'), keyword('of'), _type_decl
def array_specification(): return (keyword('ARRAY'), '[', subrange, -1, (',', subrange), ']', keyword('OF'), [string_type, non_generic_type_name]) def array_initialization(): return [('[', array_initial_elements, -1, (',', array_initial_elements), ']'), (array_initial_elements, -1, (',', array_initial_elements))]
def set_type(): return keyword('set'), keyword('of'), _type_decl def pointer_type(): return '^', _type_decl
def string(): return keyword('STRING') def wstring(): return keyword('WSTRING')
def record_decl(): return keyword('record'), -1, record_field, -1, record_item, keyword('end') def record_item(): return [const_section, type_section, record_field]
def retain(): return keyword('RETAIN') def non_retain(): return keyword('NON_RETAIN')
def TRUESPEC(): return "--", keyword("specification"), re.compile(r".*(?=is)"), "is", keyword("true") def FALSESPEC(): return "--", keyword("specification"), re.compile(r".*(?=is)"), "is", keyword("false"), TRACE
def input_declarations(): return (keyword('VAR_INPUT'), 0, [retain, non_retain], -1, (_input_declaration, ';'), keyword('END_VAR'), 0, ';') def _input_declaration(): return [var_init_decl, edge_declaration]
def FALSESPEC(): return "--", keyword("specification"), re.compile(r".*(?=is)"), "is", keyword("false"), TRACE def TRACE(): return -1, ignore(r"(?!->|--\ Loop).*\n"), -1 , [STATE, STATELOOP]
def f_edge(): return keyword('F_EDGE') def edge_declaration(): return (_var1_list, ':', keyword('BOOL'), [r_edge, f_edge])
def module_declaration(): return keyword("module"), ID, list_of_port_declarations, ";", -1, non_port_module_item, keyword("endmodule")
def output_declarations(): return (keyword('VAR_OUTPUT'), 0, [retain, non_retain], -1, (var_init_decl, ';'), keyword('END_VAR'), 0, ';') def input_output_declarations(): return (keyword('VAR_IN_OUT'), -1, (var_init_decl, ';'), keyword('END_VAR'), 0, ';')
def hours(): return -1, half, number, -1, keyword("hours") def sign(): return [re.compile(r"to"), re.compile(r"past")]
def retentive_var_declarations(): return (keyword('VAR'), keyword('RETAIN'), -1, (var_init_decl, ';'), keyword('END_VAR'), 0, ';') def constant(): return keyword('CONSTANT')
def returnstatement(): return keyword("return"), expression def ifstatement(): return keyword("if"), "(", expression, ")", block, keyword("else"), block
def located_var_declarations(): return (keyword('VAR'), 0, [constant, retain, non_retain], -1, (located_var_decl, ';'), keyword('END_VAR'), 0, ';') def located_var_decl(): return (0, variable_name, location, ':', located_var_spec_init)
def ifstatement(): return keyword("if"), "(", expression, ")", block, keyword("else"), block def statement(): return [ifstatement, returnstatement], ";"
def persistent(): return keyword('PERSISTENT') def global_var_declarations(): return (keyword('VAR_GLOBAL'), 0, [constant, retain], 0, persistent, -1, ([var_init_decl, global_var_decl], ';'), keyword('END_VAR'), 0, ';')
def function(): return keyword("function"), symbol, parameterlist, block def simpleLanguage(): return function
def location(): return (keyword('AT'), direct_variable) def global_var_list(): return (global_var_name, -1, (',', global_var_name))
def namespace(): return keyword('namespace'), symbol, ';'
def double_byte_string_spec(): return (keyword('WSTRING'), 0, [('[', [integer, simple_type_name], ']'), ('(', [integer, simple_type_name], ')')], 0, (':=', double_byte_character_string)) def incompl_located_var_declarations(): return (keyword('VAR'), 0, [retain, non_retain], -1, (incompl_located_var_decl, ';'), keyword('END_VAR'), 0, ';')
def const(): return keyword('const'), symbol, '=', literal, ';'
def incompl_location(): return (keyword('AT'), re.compile(r"\%(I|Q|M)\*")) def string(): return keyword('STRING')
def hours(): return -1, half, number, -1, keyword("uur") def sign(): return [re.compile(r"voor"), re.compile(r"over")]