예제 #1
0
파일: member.py 프로젝트: zhiyin121/adviser
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     MemberState.check_stack(stack)
     stack.add_data(stack.get_current_content())
     MemberState.add_member_to_stack(stack)
     stack.remove_level()
     ExpressionEndState.add_function_to_stack(stack)
예제 #2
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     current_content = stack.get_current_content()
     if not current_content:
         raise ParsingError('A variable name was expected!')
     stack.add_data(Argument(current_content))
     stack.remove_level()
예제 #3
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     current_string = stack.get_current_content()
     stack.add_data(
         MessageComponent(MessageComponentType.STRING, current_string))
     stack.remove_level()
     stack.add_level()
예제 #4
0
 def perform_stack_action(self, stack: AutomatonStack, configuration: Configuration):
     current_content = stack.get_current_content()
     if not current_content:
         raise ParsingError('Empty function name is not allowed!')
     stack.add_data(FunctionDeclaration(current_content))
     stack.remove_level()
     stack.add_level()
예제 #5
0
 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))
예제 #6
0
파일: string.py 프로젝트: zhiyin121/adviser
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     current_string = stack.get_current_content()
     stack.add_data(ConstantExpression(current_string))
     stack.remove_level()
     stack.add_level()
예제 #7
0
    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))
예제 #8
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     variable = stack.pop_data()
     stack.add_data(FunctionDeclaration(variable.name))
예제 #9
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     current_content = stack.get_current_content()
     stack.add_data(VariableExpression(current_content))
     stack.remove_level()
     stack.add_level()
예제 #10
0
    def add_constraint_to_stack(stack: AutomatonStack):
        value = stack.pop_data()
        variable = stack.pop_data()

        stack.add_data(Constraint(variable, value))
예제 #11
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     stack.add_data(VariableExpression(stack.get_current_content()))
     stack.remove_level()
     AcceptState.check_stack(stack)
예제 #12
0
 def perform_stack_action(self, stack: AutomatonStack,
                          configuration: Configuration):
     stack.add_data(FunctionDeclaration(stack.get_current_content()))
     stack.remove_level()
     stack.add_level()