A lightweight lexical analyzer implemented in Python for tokenizing source code. 一个轻量级的 Python 词法分析器,用于源代码的分词。
This tool reads an input source file, identifies tokens based on predefined lexical rules (such as keywords, identifiers, operators, and delimiters), and outputs the recognized token sequence. 该工具读取输入源文件,根据预定义的词法规则(如关键字、标识符、运算符和分隔符)识别 Token,并输出识别到的 Token 序列。
Lexical-Analyzer-Lab
A lightweight lexical analyzer implemented in Python for tokenizing source code. 一个轻量级的 Python 词法分析器,用于源代码的分词。
compiler-construction, lexical-analysis, lexer, python, tokenization
-
Ensure you have Python installed. 确保你已安装 Python。
-
Place your test code in
input.txt. 将你的测试代码放入input.txt文件中。 -
Run the script: 运行脚本:
python lexer.py