def add_function_to_stack(stack: AutomatonStack): arguments = [] if not stack.data_stack: raise ParsingError('Detected a closing parantheses without an opening one') stack_content = stack.pop_data() while not isinstance(stack_content, FunctionDeclaration): arguments.insert(0, stack_content) if not stack.data_stack: raise ParsingError('Detected a closing parantheses without an opening one') stack_content = stack.pop_data() stack.add_data(stack_content.create_function(arguments))
def add_constraint_to_stack(stack: AutomatonStack): value = stack.pop_data() variable = stack.pop_data() stack.add_data(Constraint(variable, value))
def perform_stack_action(self, stack: AutomatonStack, configuration: Configuration): variable = stack.pop_data() stack.add_data(FunctionDeclaration(variable.name))
def add_member_to_stack(stack: AutomatonStack): assert len(stack.data_stack) >= 2 member = stack.pop_data() variable = stack.pop_data() stack.add_data(MemberExpression(variable.name, member))