程序员达达

Tag Archive for Compiler

pycparser源码阅读笔记(2) – c_lexer.py

lexer

里面整个就定义了一个名为Clexer的类。调用类成员函数input,就能设置好输入的string stream。而每次调用token则可以得到不同的token。 def __init__(self, error_func, on_lbrace_func, on_rbrace_func, type_lookup_func): """ Create a new Lexer. error_func: An error function. Will be called with an error message, line and column as arguments, in case of an error during lexing.   on_lbrace_func, on_rbrace_func: Called when an LBRACE or RBRACE is encountered (likely to push/pop type_lookup_func’s scope)   type_lookup_func: A…