lexical

lexical - Compiler Phases: Source program Lexical analyzer...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Machine-independent code improvement Target code generation Machine-specific code improvement Front End Backend Lexical Analysis Lexical analyzer: reads input characters and produces a sequence of tokens as output (nexttoken()). Trying to understand each element in a program. Token : a group of characters having a collective meaning. const pi = 3.14159; Token 1: (const, -) Token 2: (identifier, pi) Token 3: (=, -) Token 4: (realnumber, 3.14159) Token 5: (;, -) Interaction of Lexical analyzer with parser Lexical analyzer symbol table parser Source program token Nexttoken() Some terminology: Token : a group of characters having a collective meaning. A lexeme is a particular instant of a token. E.g. token: identifier, lexeme: pi, etc. pattern : the rule describing how a token can be formed . E.g: identifier: ([a-z]|[A-Z]) ([a-z]|[A-Z]|[0-9])* Lexical analyzer does not have to be an individual phase. But having a separate phase simplifies the design and improves the efficiency and portability . Two issues in lexical analysis....
View Full Document

Page1 / 13

lexical - Compiler Phases: Source program Lexical analyzer...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online