This chapter describes the first phase of a compiler, namely lexical analysis (scanning). It shows how a source program is transformed into a token stream that is then passed on to the next compiler phase (syntax analysis). Using regular grammars to specify the structure of the lexical symbols, it explains how a scanner works as an automaton that transforms a character stream into a token stream. It finally shows how to write a scanner for MicroJava.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Lexical Analysis

  • Hanspeter Mössenböck

摘要

This chapter describes the first phase of a compiler, namely lexical analysis (scanning). It shows how a source program is transformed into a token stream that is then passed on to the next compiler phase (syntax analysis). Using regular grammars to specify the structure of the lexical symbols, it explains how a scanner works as an automaton that transforms a character stream into a token stream. It finally shows how to write a scanner for MicroJava.