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)
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
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
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