05-Lexical-Analysis - CS 421 Lecture 5: Lexical analysis s...

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: CS 421 Lecture 5: Lexical analysis s Lecture outline s Lexical analysis (lexing) s Deterministic Finite Automaton as Lexer 6/8/2009 1 Compiler outline s Front-end s Takes input source code s Returns Abstract Syntax Tree and symbol table s Back-end s Takes AST and symbol table s Returns machine-executable binary code, or virtual machine code, or just interprets the program 6/8/2009 2 Front-end structure s Lexer (a.k.a. scanner, tokenizer) s Transforms program into a list of tokens s Produces name table (usually hash table) s Parser s Transforms list of tokens to AST s Symbol table construction s Fills in name table with information about names in program type, location, e t c . 6/8/2009 3 Manual and automatic methods s We will study how to write lexers and parsers. For each, we will give a manual technique and an automatic one. s Lexing s Manual: Deterministic Finite Automata (DFA) s Automatic: Regular expressions ocamllex s Parsing s Manual: Top-down (recursive descent) parsing s Automatic: Bottom-up (LR(1)) ocamlyacc 6/8/2009 4 Lexer s Divide input into tokens s Tokens are smallest units that are useful for parsing.Tokens are smallest units that are useful for parsing....
View Full Document

Page1 / 22

05-Lexical-Analysis - CS 421 Lecture 5: Lexical analysis s...

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