signed_number = my_number_parser exponent_end = (parcon.CharIn("Ee") + signed_number)["".join] scientific_number = (signed_number + Optional(exponent_end))["".join] term = ( scientific_number[create_number_expression] | "(" + expr + ")" | apply_expr | name_expr ) term = InfixExpr(term, [("^", make_power_expression)]) term = InfixExpr(term, [("*", make_times_expression), ("/", make_divide_expression)]) term = InfixExpr(term, [("+", make_plus_expression), ("-", make_minus_expression)]) expr.set(term(name="expr")) class VariableDeclaration(sbml_ast.VariableDeclaration): """A class to represent Bio-PEPA variable declarations""" def __init__(self, variable, expression): super(VariableDeclaration, self).__init__(variable, expression) def format_declaration(self): """A function to return a Bio-PEPA formatted string representation of this variable declaration """ return self.variable + " = " + self.expression.show_expr() + " ;" def create_variable_dec(parse_result): """The parse action for the variable_definition parser"""
return justErrors(value) @rule('(' + -(singleBlockParam + xsp + (',' + sp(1) + singleBlockParam)[...]) + ')') def blockParams(value): """Parameters to a block declaration.""" return justErrors(value) @rule('(^)' + xsp + blockParams) def blockSuffix(value): """A suffix that, when appended to a type, makes it a block type.""" return justErrors(value) objcType.set(Translate(separated(simpleType + -cppTemplateValues, '::') + -blockSuffix, justErrors)) @rule(Regex(r'\[[^]]*]')) def arrayCardinality(_): """Matches an array cardinality specification like [4]""" return None def namedVariable(nameType): """Creates a pattern for a named simple or block variable.""" return ( (objcType + xsp + nameType + -arrayCardinality) | (objcType + '(^' + xsp + nameType + xsp + ')' + xsp + blockParams))
return justErrors(value) @rule('(' + xsp + -(singleBlockParam + xsp + (',' + sp(1) + singleBlockParam)[...]) + ')') def blockParams(value): """Parameters to a block declaration.""" return justErrors(value) @rule('(^' + -(xsp + -anyIdentifier + xsp) + ')' + xsp + blockParams) def blockSuffix(value): """A suffix that, when appended to a type, makes it a block type.""" return justErrors(value) objcType.set(Translate(separated(simpleType + -cppTemplateValues, '::') + -blockSuffix, justErrors)) @rule(Regex(r'\[[^]]*]')) def arrayCardinality(_): """Matches an array cardinality specification like [4]""" return None def blockVariable(nameType): """Creates a pattern for a named block variable.""" return ( (compositeIdentifier + -(sp(1) + '(^' + -(xsp + nameType + xsp) + ')' + xsp + (blockParams))) | (objcType + '(^' + xsp + nameType + xsp + ')' + xsp + blockParams) ) def namedVariable(nameType):