Example #1
0
    def make_identifier(self) -> Token:
        id_str = ""
        pos_start = self.pos.copy()

        while self.current_char and (self.current_char.isalnum()
                                     or self.current_char == "_"):
            id_str += self.current_char
            self.advance()

        tok_type = TT_KEYWORD if id_str in KEYWORDS.values() else TT_IDENTIFIER
        return StringToken(tok_type, pos_start, self.pos, id_str)
Example #2
0
preprocessor = {
    'line': '_LINE',
    'init': '_INIT',
    'require': '_REQUIRE',
    'pragma': '_PRAGMA',
    'push': '_PUSH',
    'pop': '_POP',
}

macros = (
    '__LINE__',
    '__FILE__',
)

tokens = _tokens + tuple(set(reserved.values())) + tuple(
    preprocessor.values()) + macros


def t_INITIAL_bin_comment_beginBlockComment(t):
    r"/'"
    global __COMMENT_LEVEL

    __COMMENT_LEVEL += 1
    t.lexer.push_state('comment')


def t_comment_endBlockComment(t):
    r"'/"
    global __COMMENT_LEVEL
Example #3
0
preprocessor = {
    'line' : '_LINE',
    'init' : '_INIT',
    'require' : '_REQUIRE',
    'pragma' : '_PRAGMA',
    'push' : '_PUSH',
    'pop' : '_POP',
    }

macros = (
    '__LINE__', '__FILE__',
    )



tokens = _tokens + tuple(set(reserved.values())) + tuple(preprocessor.values()) + macros


def t_INITIAL_bin_comment_beginBlockComment(t):
    r"/'"
    global __COMMENT_LEVEL

    __COMMENT_LEVEL += 1
    t.lexer.push_state('comment')


def t_comment_endBlockComment(t):
    r"'/"
    global __COMMENT_LEVEL

    __COMMENT_LEVEL -= 1
Example #4
0
preprocessor = {
    'line': '_LINE',
    'init': '_INIT',
    'require': '_REQUIRE',
    'pragma': '_PRAGMA',
    'push': '_PUSH',
    'pop': '_POP',
}

macros = (
    '__LINE__',
    '__FILE__',
)

tokens = sorted(_tokens + tuple(set(reserved.values())) +
                tuple(preprocessor.values()) + macros)


def t_INITIAL_bin_comment_beginBlockComment(t):
    r"/'"
    global __COMMENT_LEVEL

    __COMMENT_LEVEL += 1
    t.lexer.push_state('comment')


def t_comment_endBlockComment(t):
    r"'/"
    global __COMMENT_LEVEL