c05 - CS421 COMPILERS AND INTERPRETERS CS421 Compiler...

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

View Full Document Right Arrow Icon
CS421 COMPILERS AND INTERPRETERS Copyright 1994 - 2010 Zhong Shao, Yale University Abstract Syntax : Page 1 of 10 Compiler Front-End • Almost all compilers and interpreters contain the same front-end --- it consists of three components: 1. Lexical Analysis --- report lexical errors, output a list of tokens 2. Syntax Analysis --- report syntactic errors, output a parse tree 3. Semantic Analysis --- report semantic errors (e.g., type-errors, undefined identifiers, . ..) --- generate a clean and error-free abstract syntax tree token get next token lexical analyzer parser source program parse tree error-free abstract syntax semantic analysis CS421 COMPILERS AND INTERPRETERS Copyright 1994 - 2010 Zhong Shao, Yale University Abstract Syntax : Page 2 of 10 “Concrete” vs. “Abstract” Syntax • The grammar specified in “ tiger.grm ” (for Yacc) is mainly used for parsing only ---------- the key is to resolve all ambiguities. This grammar is called Concrete Syntax . Abstract Syntax ( Absyn ) is used to characterize the essential structure of the program ----------- the key is to be as simple as possible; Absyn may contain ambiguities. • The grammar for Abstract Syntax is defined using ML datatypes. • Traditional Compilers: do semantic analysis on Concrete Syntax --- implemented as “actions” in Section 3 of “ tiger.grm ” file (for Yacc) Modern Compilers : “ tiger.grm ” constructs the Abstract Syntax tree; the semantic analysis is performed on the Absyn later after parsing! CS421 COMPILERS AND INTERPRETERS
Background image of page 1

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

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

This document was uploaded on 01/06/2012.

Page1 / 3

c05 - CS421 COMPILERS AND INTERPRETERS CS421 Compiler...

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

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