コード例 #1
0
    def _command(self, CC_Type, Parameter):
        if self.column_count_per_chunk is None:

            if CC_Type == E_CharacterCountType.BAD:
                return [Op.GotoDoorId(self.door_id_on_bad_indentation)]
            elif CC_Type == E_CharacterCountType.COLUMN:
                return [
                    Op.ColumnCountAdd(Parameter),
                ]
            elif CC_Type == E_CharacterCountType.GRID:
                return [
                    Op.ColumnCountGridAdd(Parameter),
                ]
            elif CC_Type == E_CharacterCountType.LINE:
                return [
                    Op.LineCountAdd(Parameter),
                    Op.AssignConstant(E_R.Column, 1),
                ]
        else:

            if CC_Type == E_CharacterCountType.BAD:
                return [
                    Op.ColumnCountReferencePDeltaAdd(
                        E_R.InputP, self.column_count_per_chunk, False),
                    Op.ColumnCountReferencePSet(E_R.InputP),
                    Op.GotoDoorId(self.door_id_on_bad_indentation)
                ]
            elif CC_Type == E_CharacterCountType.COLUMN:
                return []
            elif CC_Type == E_CharacterCountType.GRID:
                return [
                    Op.ColumnCountReferencePDeltaAdd(
                        E_R.InputP, self.column_count_per_chunk, True),
                    Op.ColumnCountGridAdd(Parameter),
                    Op.ColumnCountReferencePSet(E_R.InputP)
                ]
            elif CC_Type == E_CharacterCountType.LINE:
                return [
                    Op.LineCountAdd(Parameter),
                    Op.AssignConstant(E_R.Column, 1),
                    Op.ColumnCountReferencePSet(E_R.InputP)
                ]
コード例 #2
0
ファイル: counter.py プロジェクト: smmckay/quex3
    "begin(newline)":            E_CharacterCountType.X_BEGIN_NEWLINE,
    "begin(comment to newline)": E_CharacterCountType.X_BEGIN_COMMENT_TO_NEWLINE,
    "end(newline)":              E_CharacterCountType.X_END_NEWLINE,
}

cc_type_name_db = dict((value, key) for key, value in cc_type_db.iteritems())

count_operation_db_without_reference = {
    E_CharacterCountType.BAD:    lambda Parameter, Dummy=None, Dummy2=None: [ 
        Op.GotoDoorId(Parameter)
    ],
    E_CharacterCountType.COLUMN: lambda Parameter, Dummy=None, Dummy2=None: [
        Op.ColumnCountAdd(Parameter)
    ],
    E_CharacterCountType.GRID:   lambda Parameter, Dummy=None, Dummy2=None: [
        Op.ColumnCountGridAdd(Parameter)
    ],
    E_CharacterCountType.LINE:   lambda Parameter, Dummy=None, Dummy2=None: [
        Op.LineCountAdd(Parameter),
        Op.AssignConstant(E_R.Column, 1),
    ],
    E_CharacterCountType.LOOP_ENTRY: lambda Parameter, Dummy=None, Dummy2=None: [ 
    ],
    E_CharacterCountType.LOOP_EXIT: lambda Parameter, Dummy=None, Dummy2=None: [ 
    ],
    E_CharacterCountType.COLUMN_BEFORE_APPENDIX_SM: lambda Parameter, ColumnNPerCodeUnit, ColumnAdd: [
        Op.ColumnCountAdd(ColumnAdd)
    ],
    E_CharacterCountType.BEFORE_RELOAD: lambda Parameter, Dummy=None, Dummy2=None: [ 
    ],
    E_CharacterCountType.AFTER_RELOAD: lambda Parameter, Dummy=None, Dummy2=None: [ 
コード例 #3
0
    "begin(newline)": E_CharacterCountType.BEGIN_NEWLINE,
    "begin(comment to newline)": E_CharacterCountType.BEGIN_COMMENT_TO_NEWLINE,
    "end(newline)": E_CharacterCountType.END_NEWLINE,
    "bad": E_CharacterCountType.BAD,
    "whitespace": E_CharacterCountType.WHITESPACE,
}

cc_type_name_db = dict((value, key) for key, value in cc_type_db.iteritems())

count_operation_db_without_reference = {
    E_CharacterCountType.BAD:
    lambda Parameter, Dummy=None: [Op.GotoDoorId(Parameter)],
    E_CharacterCountType.COLUMN:
    lambda Parameter, Dummy=None: [Op.ColumnCountAdd(Parameter)],
    E_CharacterCountType.GRID:
    lambda Parameter, Dummy=None: [Op.ColumnCountGridAdd(Parameter)],
    E_CharacterCountType.LINE:
    lambda Parameter, Dummy=None: [
        Op.LineCountAdd(Parameter),
        Op.AssignConstant(E_R.Column, 1),
    ],
    E_CharacterCountType.LOOP_ENTRY:
    lambda Parameter, Dummy=None: [],
    E_CharacterCountType.LOOP_EXIT:
    lambda Parameter, Dummy=None: [],
    E_CharacterCountType.BEFORE_RELOAD:
    lambda Parameter, Dummy=None: [],
    E_CharacterCountType.AFTER_RELOAD:
    lambda Parameter, Dummy=None: [],
}
コード例 #4
0
    def get_OpList(cls, LCCI, ModeName):
        """RETURN: [0] Verdict
                   [1] CounterCode

        Verdict == True  --> Run-time counter implementation required!!
                             Pattern's length cannot be determined beforehand.
                             
                   False --> No run-time counting is necessary!!
                             It was possible to determine the increments
                             based on the pattern's structure. 
                                 
        Default Character Counter is used when the increments and/or setting 
        cannot be derived from the pattern itself. 
        """
        if not (Setup.count_line_number_f or Setup.count_column_number_f):
            return False, []
        elif LCCI is None:
            return True, [Op.PasspartoutCounterCall(ModeName)]
        elif LCCI.run_time_counter_required_f:
            return True, [Op.PasspartoutCounterCall(ModeName)]

        # (*) Determine Line and Column Number Count ______________________________
        #
        #     Both, for line and column number considerations the same rules hold.
        #     Those rules are defined in 'get_offset()' as shown below.
        #
        def get_offset(Increment, IncrementByLexemeLength):
            if IncrementByLexemeLength == 0 or Increment == 0:
                return None, None
            elif Increment != E_Count.VOID:
                return Increment, 1
            else:
                return Lng.LEXEME_LENGTH(), IncrementByLexemeLength

        # Column and line counts must be shifted (begin=end) even if only
        # columns are counted. For example, even if only columns are modified
        # the old line_number_at_begin must be adapted to the current.
        cmd_list = [Op.ColumnCountShift(), Op.LineCountShift()]

        # -- Line Number Count
        offset, factor = get_offset(LCCI.line_n_increment,
                                    LCCI.line_n_increment_by_lexeme_length)
        if offset is not None:
            cmd_list.append(Op.LineCountAdd(offset, factor))

        # -- Column Number Count
        if LCCI.column_index != E_Count.VOID:
            cmd_list.append(Op.ColumnCountSet(LCCI.column_index + 1))

        elif LCCI.column_n_increment_by_lexeme_length != E_Count.VOID:
            offset, factor = get_offset(
                LCCI.column_n_increment,
                LCCI.column_n_increment_by_lexeme_length)
            if offset is not None:
                cmd_list.append(Op.ColumnCountAdd(offset, factor))

        else:
            # Following assert results from entry check against 'VOID'
            assert LCCI.grid_step_size_by_lexeme_length != E_Count.VOID

            if LCCI.grid_step_n == E_Count.VOID:
                grid_step_n = Lng.LEXEME_LENGTH()
            elif LCCI.grid_step_n != 0:
                grid_step_n = LCCI.grid_step_n
            else:
                grid_step_n = None

            if grid_step_n is not None:
                cmd_list.append(
                    Op.ColumnCountGridAdd(LCCI.grid_step_size_by_lexeme_length,
                                          grid_step_n))

        return False, cmd_list