Chapter-3 Syntax and Semantics
Chapter-3 Syntax and Semantics
Describing Syntax
and Semantics
ISBN 0-321-33025-0
Introduction
• A hierarchical representation of a
derivation <program>
<stmts>
<stmt>
<var> = <expr>
a <term> + <term>
<var> const
b
Copyright © 2006 Addison-Wesley. All rights reserved. 1-14
Ambiguity in Grammars
<expr> <expr>
<expr>
<expr> - <term>
const const
Copyright © 2006 Addison-Wesley. All rights reserved. 1-17
Associativity of Operators
<expr>
<expr>
<expr> + const
<expr> + const
const
Copyright © 2006 Addison-Wesley. All rights reserved. 1-18
Extended BNF