Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

plt 14

  • Loading branch information...
commit 11ce69ad0f768ca63f5023bb1524ad20cac373a2 1 parent 6335220
Nathan Hwang authored

Showing 2 changed files with 94 additions and 8 deletions. Show diff stats Hide diff stats

  1. +8 8 plt/13
  2. +86 0 plt/14
16 plt/13
@@ -83,10 +83,10 @@ grammar time:
83 83 jk it's ambiguous lol
84 84
85 85 stop, grammar time:
86   - E -> E_1 + T { E.n = Node('+', E_1.n, T.n); }
87   - | T { E.n = T.n; }
  86 + E -> E_1 + T { E.n = Node('+', E_1.n, T.n); }
  87 + | T { E.n = T.n; }
88 88 ;
89   - T -> (E) { T.n = E.n; }
  89 + T -> (E) { T.n = E.n; }
90 90 | num { T.n = Leaf(num, num.n); }
91 91 // Leaf: usually a pointer into a symbol table
92 92
@@ -111,16 +111,16 @@ Another example:
111 111 syntax: Node.i - inherited value, Node.s - synthesized value
112 112
113 113 grammar:
114   - E -> T A { E.n = A.s;
  114 + E -> T A { E.n = A.s;
115 115 A.i = T.n }
116 116 ;
117   - A -> + T A_1 { A_1.i = Node('+', A.i, T.n);
  117 + A -> + T A_1 { A_1.i = Node('+', A.i, T.n);
118 118 A.s = A_1.s }
119 119 ;
120   - A -> \epsilon { A.s = A.i }
  120 + A -> \epsilon { A.s = A.i }
121 121 ;
122   - T -> (E) { T.n = E.n }
123   - | num { T.n = Leaf(num, num.s) }
  122 + T -> (E) { T.n = E.n }
  123 + | num { T.n = Leaf(num, num.s) }
124 124 ;
125 125
126 126 AST: 1+2+3
86 plt/14
... ... @@ -0,0 +1,86 @@
  1 +PLT
  2 +2012/03/05
  3 +#14
  4 +================================================================================
  5 +
  6 +Got to class 20 minutes late (again) DAMN YOU PLT
  7 +
  8 +Talking about the assignment: talking about the infix to postfix problem
  9 +could've just printed it
  10 +
  11 +--------------------------------------------------------------------------------
  12 +Outline
  13 +
  14 +SDD's and SDT's
  15 +Intermediate Representations
  16 +Three-address code
  17 +Semantic analysis
  18 +
  19 +--------------------------------------------------------------------------------
  20 +Review SDDs
  21 +
  22 +talking about SDDs, zoning out
  23 +
  24 +I have no idea what he's doing
  25 +
  26 +Okay, we're talking about the last example in the last lecture
  27 + he said something about semantic action: hope he didn't hop to semantic
  28 + analysis
  29 +
  30 +if you want this, you can roll your own SDD parser
  31 +but you can also use yacc
  32 +
  33 +quote: "and now you know java!"
  34 +
  35 +--------------------------------------------------------------------------------
  36 +Intermediate representations (IR)
  37 +
  38 +talking about gcc suites: convert many source languages to many targets
  39 + need a flexible IR
  40 +
  41 +Optimization on IR:
  42 +Tree -> DAG (directed acyclic graph)
  43 +a+a*(b-c)+(b-c)*d
  44 +as a tree:
  45 +(+ (+ a (* a (- b c)))
  46 + (* (- b c) d))
  47 +we have two a's in the left branch:
  48 + instead of two copies, just point to a single a
  49 +also, we have (- b c) in two places
  50 + instead of two copies, just point to a single (- b c)
  51 +
  52 +generally: convert a tree to a DAG with shared objects
  53 +value-number method
  54 + idea: hash the component, see if it appears elsewhere
  55 + O(n): n length of AS
  56 +
  57 +--------------------------------------------------------------------------------
  58 +Three-address code
  59 +
  60 +wait wtf is this
  61 +I guess this is about things affecting 3 address things?
  62 + apparently, it's in the book
  63 +
  64 +1. x=y op z
  65 +2. x = op z
  66 +3. x = y // copy
  67 +4. goto L
  68 +5. if x goto L
  69 + if False x goto L
  70 +6. if x replop y goto L
  71 +7. procedure calls f(x,y)
  72 + stack code:
  73 + param x
  74 + param y
  75 + call f, z
  76 + return f
  77 +8. x[i] = y
  78 + x = y[i]
  79 +9. x = &y
  80 + x = *y
  81 + *x = y
  82 +
  83 +
  84 +he's talking about stack and heaps??? wat
  85 +
  86 +derp

0 comments on commit 11ce69a

Please sign in to comment.
Something went wrong with that request. Please try again.