ln030 - Defining Language THREE We a d d th e fo l l o w i...

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

View Full Document Right Arrow Icon
Defining Language THREE We add the following to Language TWO ML-style function values ML-style function application
Background image of page 1

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

View Full DocumentRight Arrow Icon
THREE: Syntax A subset of ML expressions This grammar is unambiguous Function application has highest precedence A sample Language Three expression: (fn x => x * x) 3 THREE: < exp >* ::= fn < variable > => < exp > | < addexp > < addexp > ::= < addexp > + < mulexp > | < mulexp > < mulexp > ::= < mulexp > * < funexp > | < funexp > < funexp > ::= < funexp > < rootexp > | < rootexp > < rootexp > ::= let val < variable > = < exp > in < exp > end | ( < exp > ) | < variable > | < constant >
Background image of page 2
THREE: Abstract Syntax Two more kinds of AST nodes: apply(Function,Actual) applies the Function to the Actual parameter fn(Formal,Body) for an fn expression with the given Formal parameter and Body So for the Language Three program (fn x => x * x) 3 we have this AST: apply(fn(x,times(var(x,var(x)),const(3))
Background image of page 3

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

View Full DocumentRight Arrow Icon
Representing Functions A representation for functions:
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

Page1 / 7

ln030 - Defining Language THREE We a d d th e fo l l o w i...

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

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