PLT: Lecture 3 - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

PLT: Lecture 3

Description:

Operator symbols with their arity, and fixity; Informal Structure ... Succinctly specifying arity and fixity: 0O1. 1O0. 1O1. 0On. nO0 ... – PowerPoint PPT presentation

Number of Views:143
Avg rating:3.0/5.0
Slides: 15
Provided by: deptSc7
Category:
Tags: plt | fixity | lecture

less

Transcript and Presenter's Notes

Title: PLT: Lecture 3


1
PLT Lecture 3
  • Mathematical Notation Continued

2
Last Lecture
  • Outlined the need for compilation
  • Outlined the requirements for compilation
  • Sought a domain where they have experience with
    these requirements
  • Started exploring this domain mathematical
    notation
  • Its parts
  • Their properties

3
Expression Trees
  • Advantages
  • Ease of reading
  • Spaced out
  • No need for decoding delimiters
  • Spacing means space for annotations
  • But they suffer from the word-processor
    1-dimension problem
  • Often addressed by using images to portray
    expressions.
  • This can lead to problems too

4
Maths as Images Problems
  • Searching problems
  • Re-use problems
  • Display Problems
  • Font size variations
  • Resolution, emphasized when printed
  • The halo effect (admittedly small)
  • Horizontal alignment with text
  • Bandwidth problems

5
1-D Notations
  • Demarking first and last symbols in a
    sub-expression
  • ( )
  • lt gt
  • Free to use which-ever you like in Mathematics
    but not so in computer languages (C for e.g.)
  • Meanings of ( ) 4
  • Meanings of 2
  • Meanings of 5.5

6
Communication Issues
  • In reading expressions in 1-D, identical
    delimiters can cause problems
  • ( ((bb)-((4a)c)))/(2a)
  • ( bb-lt4agtc)/(2a)
  • See how easy it is when using stretchable
    operators
  • (ab)/(cd)
  • ( (ab))/(cd)
  • ( ((ab)/(cd))
  • ( ((ab)/(cd)) (d(d1))

7
Reducing the number of delimiter expressions
  • The scoping issue
  • Stretchable operators
  • Piggy in the middle
  • Prefix and postfix unary operator
  • Binary infix operators
  • 243
  • What happens the 4
  • If its the right operand of then 24 is the
    left operand of 18
  • If its the left operand of then 43 is the
    right operant of 14
  • More formally
  • Priority
  • Associativity

8
Priority
  • If o1 has a greater priority than o2 then (for
    binary infix ops)
  • a o1 b o2 c (a o1 b) o2 c
  • a o2 b o1 c a o2 (b o1 c)
  • This can only help so much in our effort to
    minimize delimiters

9
Extending Priority for unary operators
  • Scenario
  • Unary prefix operator / unary postfix operator
  • Unary prefix operator / binary infix operator
  • Binary infix operator / unary prefix operator
  • Latter 2 assume the unary operators have higher
    precedence than binary ones
  • !altb (a1, b0)

10
Priorities / Associativity in C
  • Associativity (a16, b4, c2)
  • int a3
  • int a-b-3
  • (a5)(b8)(c2)
  • a / b / c
  • sizeof(sizeof(8))
  • Priority (w1, x0, y6, z5)
  • if(x!0)
  • --j // illegal
  • Data ptr
  • ty / z w
  • dataptry

11
Keywords in Programming Language Expressions
  • Delimiters
  • Algol 68 / Modula-2
  • if..fi
  • dood
  • case.esac
  • Operators
  • ADD X TO Y GIVING Z

12
A Scheme for Generating Definitions of
Expressions
  • Generic Rules
  • Starter Rule
  • Provide a starter set of expressions
  • Complex Rules
  • Build on the starter rules to provide a more
    complex set of expressions
  • Uses 3 sets
  • Literal symbols
  • Variable symbols
  • Punctuation symbols ( )
  • Operator symbols with their arity, and fixity

13
Informal Structure
  • Every literal symbol is an expression
  • Every variable symbol is an expression
  • Is E1 is an expression, then (E1) is an
    expression
  • If o is a unary prefix operator and E1 is an
    expression then oE1 is an expression
  • If o is a binary infix operator and E1, E2 are
    expressions then E1 o E2 is an expression
  • If o is a unary postfix operator and E1 is an
    expression then E1o is an expression
  • If o is a n-ary prefix operator and E1, E2En are
    expressions then o(E1, E2En) is an expression
  • If o is a n-ary postfix operator and E1, E2En
    are expressions then (E1, E2En)o is an
    expression

14
mOn Notation
  • Succinctly specifying arity and fixity
  • 0O1
  • 1O0
  • 1O1
  • 0On
  • nO0
  • Now we are in a better position to formalize the
    scheme
  • We will do this in the next lecture
Write a Comment
User Comments (0)
About PowerShow.com