Esempio n. 1
0
def _get_pre_context_epilog_definition(dial_db):
    backup_position = Lng.REGISTER_NAME(E_R.BackupStreamPositionOfLexemeStartP)

    txt = [
        Lng.LABEL(DoorID.global_end_of_pre_context_check(dial_db)),
        #-------------------
        Lng.IF(backup_position, "!=", "((QUEX_TYPE_STREAM_POSITION)-1)"),
            # "QUEX_NAME(Buffer_print_content)(&me->buffer);\n",
            # "std::cout << std::endl;\n",
            Lng.IF("false", "==", Lng.BUFFER_SEEK(backup_position)),
                Lng.RAISE_ERROR_FLAG("E_Error_File_SeekFailed"),
                Lng.RETURN,
            Lng.END_IF,
            Lng.LEXEME_START_SET(PositionStorage=None), # use '_read_p'
            # "std::cout << \"lexst \" << me->buffer._lexeme_start_p[0] << std::endl;",
            # "std::cout << \"readp \" << me->buffer._read_p[0] << std::endl;",
            # "QUEX_NAME(Buffer_print_content)(&me->buffer);\n",
            # "std::cout << std::endl;\n",
            Lng.ASSIGN(backup_position, "((QUEX_TYPE_STREAM_POSITION)-1)"),
        Lng.ELSE_FOLLOWS,
            #-----------------------
            # -- set the input stream back to the real current position.
            #    during backward lexing the analyzer went backwards, so it needs to be reset.
            Lng.INPUT_P_TO_LEXEME_START(),
        Lng.END_IF,
    ]

    return [ "%s\n" % line for line in txt ]
Esempio n. 2
0
 def unicode_to_output(self, CodeUnitN):
     txt = [
         Lng.ASSIGN(
             "unicode",
             "(uint32_t)(%s)" % Lng.OP("(int32_t)input", "+", "offset"))
     ]
     txt.extend(self.get_output_formatter(CodeUnitN))
     txt.append(Lng.PURE_RETURN)
     return ["    %s" % line for line in txt]
Esempio n. 3
0
 def get_offset_code(self, Info):
     """RETURNS: Code to implement code conversion to UNICODE by adding or
                 subtracting an offset.
     """
     offset = Info.codec_interval_begin_unicode - Info.codec_interval_begin
     return "%s" % Lng.ASSIGN("offset", "(int32_t)(%s)" % offset)