V2EX  ›  英汉词典

Lexical Analysis

Definition / 定义

lexical analysis(词法分析):编译器或解释器处理源代码的早期阶段之一,把一串字符(character stream)分割并归类为有意义的词法单元(tokens),例如关键字、标识符、数字、运算符与分隔符等。常由lexer/scanner(词法分析器/扫描器)完成。
(在更广义语境中,也可指对文本词汇层面的分析,但在计算机科学里最常用的是“编译原理”的含义。)

Pronunciation / 发音

/ˈlɛksɪkəl əˈnæləsɪs/

Examples / 例句

The compiler performs lexical analysis before parsing.
编译器在进行语法分析之前会先做词法分析。

During lexical analysis, comments and whitespace are often ignored, while identifiers and keywords become tokens for the parser to read.
在词法分析过程中,注释和空白通常会被忽略,而标识符与关键字会被转换成词法单元,供语法分析器读取。

Etymology / 词源

lexical 来自 lexicon(“词汇、词典”),源于希腊语 lexikon(与“词语/表达”相关);analysis 源于希腊语 analysis(“分解、拆解”)。合在一起字面义为“对词汇层面的拆解与分析”,在编译领域即“把字符流拆成 token 并分类”。

Related Words / 相关词

Literary Works / 文学作品

  • Compilers: Principles, Techniques, and Tools(Aho, Lam, Sethi, Ullman,“龙书”)——在编译器前端章节系统讨论 lexical analysis。
  • Engineering a Compiler(Cooper & Torczon)——以工程实现视角讲解词法分析与 token 设计。
  • Modern Compiler Implementation(Andrew W. Appel)——在多语言实现框架中介绍词法分析器与自动机/正则的关系。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   711 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 19:43 · PVG 03:43 · LAX 11:43 · JFK 14:43
♥ Do have faith in what you're doing.