{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AST - Abstract Syntax Click to edit Master subtitle style...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style CS784(PM) Abstract Syntax
Background image of page 1

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

View Full Document Right Arrow Icon
CS784(PM) Different Levels of Syntax Lexical syntax Basic symbols (names, values, operators, etc.) Concrete syntax Rules for writing expressions, statements, programs Input to compilers/interpreters Abstract syntax “Internal” representation Captures semantics 22
Background image of page 2
CS784(PM) 33 Overview Parse-expression Unparse- expression Interpreter Concrete Syntax Abstract Syntax Results
Background image of page 3

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

View Full Document Right Arrow Icon
CS784(PM) Concrete vs. Abstract Syntax Expressions with common meaning (should) have the same abstract syntax . C: a+b*c Assumes certain operator precedence (why?) Forth: bc*a+ (reverse Polish) This expression tree represents the meaning of expression Not the same as parse tree (why?) Does the value depend on traversal order? abc*+ (or is this it?) 44
Background image of page 4
CS784(PM) 55 Parse tree vs. AST + exp r 1 2 + 3 exp r exp r ( ) ( ) exp r exp r 1 2 + 3 + exp r exp r
Background image of page 5

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

View Full Document Right Arrow Icon
CS784(PM) 66 Abstract Syntax Tree More useful representation of syntax tree Less clutter Actual level of detail depends on your design Basis for semantic analysis Later annotated with various information Type information Computed values
Background image of page 6
CS784(PM) 77 Compilation in a Nutshell Source code (character stream) Lexical analysis Parsing Token stream Abstract syntax tree (AST) Semantic Analysis if (b == 0) a = b; if ( b ) a = b ; 0 = = if = = b 0 = a b if = = int  b int  0 = int  a lvalue int b boolean Decorated AST int ; ;
Background image of page 7

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

View Full Document Right Arrow Icon
CS784(PM) λ -expressions <exp> ::= <identifier> | ( lambda (<identifier> ) <exp>) | (<exp> <exp>)   Compare with Scheme S-expressions.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}