Eliminating left recursion grammar transformation. The transformed expression grammar

Size: px
Start display at page:

Download "Eliminating left recursion grammar transformation. The transformed expression grammar"

Transcription

1 Eliminting left recursion grmmr trnsformtion Originl! rnsformed! 0 0! 0 α β α α α α α α α α β he two grmmrs generte the sme lnguge, but the one on the right genertes the rst, nd then string of s, using rule tht is right recursive insted of left recursive opyright c1994 Ron K ytron ll rights reserved 37 SIGPLN 94 OMPILER ONSRUION UORIL he trnsformed expression grmmr E! E 0 E 0! +E 0 E 0! -E 0! 0 0! 0 0! / 0! E) Which rule to choose? nd wht bout? E E E *+* + ) opyright c1994 Ron K ytron ll rights reserved 38 SIGPLN 94 OMPILER ONSRUION UORIL

2 irst sets irst) = 8 >< >: irst 1 ::: L ) = f g if 2 S!! i )2P irst! i ) if 2 V f g if = [ 8,1 k=1 2irst k )) irst )! B EGH H B! b! c E! e! E G! g H! h! irst!) H f h; g G f g g f c; g B f b g E f e; g f c; e; g f b; e; c; g; h; g B f b g EGH f e; c; g g opyright c1994 Ron K ytron ll rights reserved 39 SIGPLN 94 OMPILER ONSRUION UORIL ollow sets 1 Initilly set ollown ) = ;; 8 N 2 V 2 Given production! B, set ollowb) = ollowb) [ irst),fg) 3 Given production! B, where 2 irst), set ollowb) = ollowb) [ ollow)! B EGH H B! b! c E! e! E G! g H! h N ollown) f g B irst) [ ollow) = f c g irstg) = f g g ollow) [ irste) [ ollow ) = f e; g g E irst ) [ irstg) = f c; e; g g G irsth) [ ollow) = f h g H ollow) = f g opyright c1994 Ron K ytron ll rights reserved 40 SIGPLN 94 OMPILER ONSRUION UORIL

3 Recursive descent prser genertion Procedure N on ermn if Lookhed) 2 irst! 1 ); where N!! 1 ) 2 P then /* Use! 1 to generte clls to Expect) nd other nonterminls */ if Lookhed) 2 ollown ) nd N! ) 2 P then return ) /* error */ opyright c1994 Ron K ytron ll rights reserved 41 SIGPLN 94 OMPILER ONSRUION UORIL Recursive descent Exmple S!! c! Bd BQ B! bb d Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g opyright c1994 Ron K ytron ll rights reserved 42 SIGPLN 94 OMPILER ONSRUION UORIL

4 he generted procedures S!! c! Bd BQ B! bb d Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g Procedure S) if Lookhed) 2 f ; b; d; c; g then cll ) cll ) cll Expect) /* error */ Procedure ) if Lookhed) 2 f c g then cll Expectc) if Lookhed) 62 f d; g then /* error */ opyright c1994 Ron K ytron ll rights reserved 43 SIGPLN 94 OMPILER ONSRUION UORIL he generted procedures cont d) S!! c! Bd BQ B! bb d Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g Procedure ) if Lookhed) 2 f g then cll Expect) cll B) cll ) cll Expectd) if Lookhed) 2 f b; d g then cll B) cll Q) if Lookhed) 2 f c; g then return ) /* error */ opyright c1994 Ron K ytron ll rights reserved 44 SIGPLN 94 OMPILER ONSRUION UORIL

5 he generted procedures cont d) S!! c! Bd BQ B! bb d Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g Procedure B) if Lookhed) 2 f b g then cll Expectb) cll B) if Lookhed) 2 f d g then cll Expectd) /* error */ Procedure Q) if Lookhed) 2 f q g then cll Expectq) /* error */ opyright c1994 Ron K ytron ll rights reserved 45 SIGPLN 94 OMPILER ONSRUION UORIL Recursive descent expression grmmr E! E 0 E 0! +E 0 E 0! -E 0! 0 0! 0 0! / 0! E) irst ollow E f ;g f ); g E 0 f +;,g f ); g f ;g f +;,; ); g 0 f; / g f +;,; ); g f ;g f; /; +;,; ); g Procedure E 0 if Lookhed+) then cll Expect+) cll cll E 0 if Lookhed,) then cll Expect,) cll cll E 0 if Lookhed; ) ) then return ) cll Error) opyright c1994 Ron K ytron ll rights reserved 46 SIGPLN 94 OMPILER ONSRUION UORIL

6 Mintining lookhed Procedure min) Ltok GetN ext oken) cll S) unction Lookhed) : token return Ltok) Procedure Expecttok) if Ltok = tok) then Ltok GetN ext oken) /* error */ lookhed of k tokens is mintined by ppropritely buffering the input echniclly, k lookhed is equivlent in power to single token of lookhed he proof is constructive: ech permuttion of k symbols is encoded s single token he Expecttok) procedure rst compres the incoming token ginst tok, nd then dvnces input into the lookhed buffer opyright c1994 Ron K ytron ll rights reserved 47 SIGPLN 94 OMPILER ONSRUION UORIL Recursive descent correctness nd properties When is our recursive descent prser construction successful? If the grmmr involves ny left-recursion, then our construction method will crete prser contining n innite loop So, we require tht the grmmr be free of leftrecursion he grmmr trnsformtion technique covered erlier cn help eliminte leftrecursion lso, we require tht the prser operte deterministiclly: ctions tken t ech step mke progress towrd completion, so tht bcktrcking is not necessry hus, given set of rules for nonterminl N N!! 1 we require 1 2 If =! ; 1 n, then we lso require [ i \ i! n irst! i ) = f g ollown ) \ irst! i )) = f g opyright c1994 Ron K ytron ll rights reserved 48 SIGPLN 94 OMPILER ONSRUION UORIL

7 Recursive descent nd leftmost derivtions Let s exmine how our recursive descent prser recognizes the string bbddc b S B d b B B d he procedure ctivtions trce leftmost derivtion of the string We cll this style of prsing LL,becuse it uses Leftmost scn of the input nd produces Left-most derivtion c 1 S! 2! c 3 4! Bd 5 BQ 6 7 B! bb 8 d 9 Q! q S ) ) B d ) b B d ) b b B d ) bb d d ) bbd d ) bbdd c In fct, the record of the prse is simply the order in which the grmmr rules re pplied: opyright c1994 Ron K ytron ll rights reserved 49 SIGPLN 94 OMPILER ONSRUION UORIL Error repir Good progrmming lnguges re designed with reltively lrge distnce between syntcticlly correct progrms, to increse the likelihood tht conceptul mistkes re cught s syntctic errors Error repir usully occurs t two levels: Locl: repirs mistkes with little globl import, such s missing semicolons nd undeclred vribles Scope: repirs the progrm text so tht scopes re correct Errors of this kind include unblnced prentheses nd begin/ blocks Repir ctions cn be divided into insertions nd deletions ypiclly the compiler will use some lookhed nd bcktrcking in ttempting to mke progress in the prse here is gret vrition mong compilers, though some lnguges PL/) crry trdition of good error repir Gols of error repir include: 1 No input should cuse the compiler to collpse 2 Illegl constructs re flgged 3 requently occurring errors re repired grcefully 4 Miniml stuttering or cscding of errors LL-style prsing ls itself well to error repir, since the compiler uses the grmmr s rules to predict wht should occur next in the input opyright c1994 Ron K ytron ll rights reserved 50 SIGPLN 94 OMPILER ONSRUION UORIL

8 ugmenting recursive descent prsers for error recovery Recursive nd LL prsers re often clled predictive, becuse they operte by predicting the next step in derivtion Suppose the prser is operting in procedure for some nonterminl If n error occurs, it seems resonble to recover by skipping to symbol tht could follow, nd then return E! E 0 E 0! +E 0 E 0! -E 0! 0 0! 0 0! / 0! E) irst ollow E f ;g f ); g E 0 f +;,g f ); g f ;g f +;,; ); g 0 f; / g f +;,; ); g f ;g f; /; +;,; ); g Procedure E 0 StopSet) if Lookhed+) then cll Expect+) cll f +;,g[stopset) cll E 0 StopSet) if Lookhed; ) ) then return ) cll ErrorRecoverStopSet) opyright c1994 Ron K ytron ll rights reserved 51 SIGPLN 94 OMPILER ONSRUION UORIL ble-driven LLk) prsing Our recursive descent prser contined procedure for ech nonterminl he genertion of these procedures could be utomted through the construction nd testing of irst nd ollow sets for ny grmmr free of left recursion nother eqully utomtble pproch is to use simple prsing engine tht is driven by tbles constructed by similr nlysis of the grmmr Grmmr Grmmr nlyzer LLk) Prsing Engine Input ble Stck he prsing engine begins by pushing the strt symbol S onto the stck subsequent ction is one of the following: Ech Mtch: pirs n input symbol n on top-of-stck pply: replces the nonterminl N with!, wheren!!) 2 P opyright c1994 Ron K ytron ll rights reserved 52 SIGPLN 94 OMPILER ONSRUION UORIL

9 Mtch If the top-of-stck contins the terminl symbol, then the prsing engine must nd n s the next input symbol; the stck is popped, nd the input is dvnced Before fter If mtch simultneously empties the stck nd exhusts the input strem, then the string is ccepted by the prser If mtch is ttempted, but the symbols disgree, then n error is declred opyright c1994 Ron K ytron ll rights reserved 53 SIGPLN 94 OMPILER ONSRUION UORIL pply If the top-of-stck contins nonterminl N, then the prsing engine must choose the pproprite rule for N, syn! he stck is popped of symbol N, nd the symbols,, nd re pushed onto the stck, such tht is the new top-of-stck N Before α β γ fter Since mtch is lwys required when terminl is exposed on top-of-stck, the only informtion tht must be coded in our tble is the rule tht should be pplied when nonterminl ppers on top-of-stck s with our recursive descent prser, this decision cn be bsed on k symbols of lookhed into the input strem opyright c1994 Ron K ytron ll rights reserved 54 SIGPLN 94 OMPILER ONSRUION UORIL

10 onstructing the tble 1 S! 2! c 3 4! Bd 5 BQ 6 7 B! bb 8 d 9 Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g Lookhed Nonerm b c d q S B 7 8 Q 9 he nonblnk entries in the bove tble indicte the number of the rule tht should be pplied, given nonterminl on top-of-stck nd n input symbol s lookhed opyright c1994 Ron K ytron ll rights reserved 55 SIGPLN 94 OMPILER ONSRUION UORIL Using the tble 1 S! 2! c 3 4! Bd 5 BQ 6 7 B! bb 8 d 9 Q! q Lookhed Nonerm b c d q S B 7 8 Q 9 Below is shown the stck ctivity in prsing the input string bbddc S 1 B d 4 b B d 7 b B d 7 d d 8 d 3 c 2 Input string b b d d c opyright c1994 Ron K ytron ll rights reserved 56 SIGPLN 94 OMPILER ONSRUION UORIL

11 Bottom-up prsing b S B d b B B d bottom-up prse is essentilly rightmost derivtion, run in reverse Insted of replcing nonterminl by string, we recognize the string s reducing to the nonterminl c 1 S! 2! c 3 4! Bd 5 BQ 6 7 B! bb 8 d 9 Q! q S ) ) c ) B d c ) B dc ) b B dc ) b b B dc ) bb d dc he prsing engine issues the following instructions: shift: symbol is moved from input to top-of-stck reduce r: the stck is modied by pplying rule r opyright c1994 Ron K ytron ll rights reserved 57 SIGPLN 94 OMPILER ONSRUION UORIL Shift Before fter Like the top-down prser, the bottom-up prser checks for errors on shift he prse tble we shll construct indictes when shift is error-free ctully, insted of pushing symbol onto the stck, we push stte, which indexes the prse tble nd represents the current possibilities of the prse opyright c1994 Ron K ytron ll rights reserved 58 SIGPLN 94 OMPILER ONSRUION UORIL

12 α β γ Before N fter If the rule pplied is N!!, where! hs m symbols, then m symbols re popped off the stck, nd symbol representing N is pushed It s importnt to remember tht cnonicl prse cn perform reductions only t the top-of-stck opyright c1994 Ron K ytron ll rights reserved 59 SIGPLN 94 OMPILER ONSRUION UORIL Rightmost derivtion in reverse slow motion Stck Input ctivity bbddc Shift bbddc Shift b bddc Shift bb ddc Shift bbd dc B! d bbb dc B! bb bb dc B! bb B dc! B dc Shift Bd c! Bd c Shift c! c Shift S! S ccept his is LR-style prsing: scn from the left tht produces rightmost derivtion We could hve tried to pply! t ny point during the prse, but most would not hve mde progress towrd n ccept Where prse tble construction is successful, the tble directs the prse towrds n ccept if one is possible opyright c1994 Ron K ytron ll rights reserved 60 SIGPLN 94 OMPILER ONSRUION UORIL

13 LR tble construction Ech stte of the prser represents prsing possibilities fter processing given prex of the input string o construct the cnonicl LR0) set of sttes: 1 Ech stte begins with kernel tht represents progress through certin rules of the grmmr: 3) X! y z W! xzy! By he dot ) shows the progress through the rule chieved by moving into this stte 2 When is next to nonterminl, we must dd into this stte the closure by expnding ll rules of the nonterminl: 3)! bcd! z We then lbel ech component of the stte with n ction, indicting trnsfer to some other stte, reduction by rule, or ccept: 3) X! y z W! xzy! By! bcd! z which my crete new stte: 17) X! yz! z! bcd! z Stte 17 by rule 5 Stte 2 Stte 17 by rule 10 Stte 1 Stte 2 Stte 18 opyright c1994 Ron K ytron ll rights reserved 61 SIGPLN 94 OMPILER ONSRUION UORIL ble construction 1) S!! Bd BQ B! bb d 2) S!! c Stte 2 Stte 3 Stte 4 by rule 6 Stte 7 Stte 8 by rule 3 3)! Bd B! bb d 4)! B Q Q! q Stte 9 Stte 10 Stte 11 5) B! b B B! bb d Stte 12 6) B! d by rule 8 7) S! Stte 13 8)! c by rule 2 9)! B d! c 10)! BQ 11) Q! q 12) B! bb 13) S! Stte 14 Stte 8 by rule 3 by rule 5 by rule 9 by rule 7 ^ 14)! B d Stte 15 15)! Bd by rule 4 opyright c1994 Ron K ytron ll rights reserved 62 SIGPLN 94 OMPILER ONSRUION UORIL

14 onflict resolution 1 S! 2! c 3 4! Bd 5 BQ 6 7 B! bb 8 d 9 Q! q irst ollow S f ; b; d; c; g f g f ; b; d; g f c; g B f b; d g f c; d; q g f c; g f d; g Q f q g f c; g Within stte, how do we resolve whether to shift or reduce when either ction seems pproprite? 1) S!! Bd BQ B! bb d Stte 2 Stte 3 Stte 4 by rule 6 Exmining the ollow informtion shows tht only those input symbols in f c; g cn follow n In stte 1) we therefore by rule 6 only when c or ppers next in the input Since these symbols re disoint from the input symbols tht cuse shifts into other sttes f ; b; d g), we cn resolve the pprent conflict In generl, stte might hve n pprent shift/reduce or reduce/reduce conflict he more expensive tble construction methods generlly provide better conflict resolution opyright c1994 Ron K ytron ll rights reserved 63 SIGPLN 94 OMPILER ONSRUION UORIL ble for our exmple Stte b c d q B Q 1 Stte 3 by rule 6 by rule 6 Stte 2 Stte 4 2 Stte 8 by rule 3 by rule 3 Stte 7 3 Stte 9 4 Stte 11 5 Stte 12 6 by rule 8 7 Stte 13 8 by rule 2 9 Stte 8 by rule 3 by rule 3 Stte by rule 5 11 by rule 9 12 by rule 7 13 ^ ^ 14 Stte by rule 4 Stte 10 by rule 8 by rule 2 by rule 5 by rule 9 by rule 7 by rule 4 opyright c1994 Ron K ytron ll rights reserved 64 SIGPLN 94 OMPILER ONSRUION UORIL

15 Using the tble Stte b c d q B Q ^ ^ b 5 bbddc b bbddc bddc 1 3 b b 5 b b 5 b 5 d b 5 b b 5 b 5 12 B 1 3 b b 5 12 B b d d B B bb B B bb B bddc ddc dc Bdc dc Bdc dc 1 3 Bdc opyright c1994 Ron K ytron ll rights reserved 65 SIGPLN 94 OMPILER ONSRUION UORIL Using the tble cont d) Stte b c d q B Q ^ ^ B B 9 14 B Bdc dc dc 1 3 B B 9 14 d c d Bd c c dc c c c ^ ^ opyright c1994 Ron K ytron ll rights reserved 66 SIGPLN 94 OMPILER ONSRUION UORIL

16 Set of items construction for our expression grmmr 1 S! E 2 E! E+ 3 4! 5 6! E) 7 1) S! E E! E+!! E) Stte 2 Stte 2 Stte 3 Stte 3 Stte 4 2) S! E E! E + Stte 7 Stte 8 irst ollow S f ;g f g E f ;g f +; ); g f ;g f; +; ); g f ;g f; +; ); g 3) E!! by rule 3 Stte 9 he bove shift/reduce conflict is resolved by noting tht 62 ollowe) 4)! by rule 5 5)! E) E! E+!! E) Stte 10 Stte 10 Stte 3 Stte 3 Stte 4 6)! by rule 7 opyright c1994 Ron K ytron ll rights reserved 67 SIGPLN 94 OMPILER ONSRUION UORIL Set of items construction for our expression grmmr 1 S! E 2 E! E+ 3 4! 5 6! E) 7 7) S! E ^ 8) E! E+!! E) Stte 11 Stte 11 Stte 4 irst ollow S f ;g f g E f ;g f +; ); g f ;g f; +; ); g f ;g f; +; ); g 10) E! E +! E ) 11) E! E+! Stte 8 Stte 13 by rule 2 Stte 9 he bove shift/reduce conflict is resolved by noting tht 62 ollowe) 12)! by rule 4 9)!! E) Stte 12 13)! E) by rule 6 opyright c1994 Ron K ytron ll rights reserved 68 SIGPLN 94 OMPILER ONSRUION UORIL

17 he resulting prse tble Stte + ) E 1 Stte 2 Stte 3 2 Stte 8 Stte 7 3 by rule 3 Stte 9 by rule 3 by rule 3 4 by rule 5 5 Stte 10 Stte 3 6 by rule 7 7 ^ ^ 8 Stte Stte 8 Stte by rule 2 Stte 9 by rule 2 by rule 2 12 by rule 4 13 by rule 6 Stte 4 by rule 5 Stte 4 by rule 7 Stte 4 Stte 12 by rule 4 by rule 6 opyright c1994 Ron K ytron ll rights reserved 69 SIGPLN 94 OMPILER ONSRUION UORIL Using the tble Stte + ) E ^ ^ ) + +) + +) E Ẹ + + +) + +) + +) +) +) +) +) +) opyright c1994 Ron K ytron ll rights reserved 70 SIGPLN 94 OMPILER ONSRUION UORIL

18 Using the tble Stte + ) E ^ ^ ) +) +) 1 2 E E E E E E E E E 10 5 E E E E E + +) +) +) +) ) ) ) ) opyright c1994 Ron K ytron ll rights reserved 71 SIGPLN 94 OMPILER ONSRUION UORIL Using the tble Stte + ) E ^ ^ E E 10 5 E 10 ) E+ Ẹ ) ) ) 1 E 2 1 E 2 E 7 5 E E ) 13 E E) E+ E E ^^ + * + ) opyright c1994 Ron K ytron ll rights reserved 72 SIGPLN 94 OMPILER ONSRUION UORIL

10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing

10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing Motivting Exmple Lexicl nd yntx Anlysis (2) In Text: Chpter 4 Consider the grmmr -> cad A -> b Input string: w = cd How to build prse tree top-down? 2 Initilly crete tree contining single node (the strt

More information

Problem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins.

Problem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins. Problem Set 2 Fll 16 Due: Wednesdy, September 21th, in clss, before clss begins. 1. LL Prsing For the following sub-problems, consider the following context-free grmmr: S T$ (1) T A (2) T bbb (3) A T (4)

More information

CS 321 Programming Languages and Compilers. Bottom Up Parsing

CS 321 Programming Languages and Compilers. Bottom Up Parsing CS 321 Progrmming nguges nd Compilers Bottom Up Prsing Bottom-up Prsing: Shift-reduce prsing Grmmr H: fi ; fi b Input: ;;b hs prse tree ; ; b 2 Dt for Shift-reduce Prser Input string: sequence of tokens

More information

CS 430 Spring Mike Lam, Professor. Parsing

CS 430 Spring Mike Lam, Professor. Parsing CS 430 Spring 2015 Mike Lm, Professor Prsing Syntx Anlysis We cn now formlly descrie lnguge's syntx Using regulr expressions nd BNF grmmrs How does tht help us? Syntx Anlysis We cn now formlly descrie

More information

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing Undergrdute Compilers Review nd Intro to MJC Announcements Miling list is in full swing Tody Some thoughts on grd school Finish prsing Semntic nlysis Visitor pttern for bstrct syntx trees Some Thoughts

More information

12 <= rm <digit> 2 <= rm <no> 2 <= rm <no> <digit> <= rm <no> <= rm <number>

12 <= rm <digit> 2 <= rm <no> 2 <= rm <no> <digit> <= rm <no> <= rm <number> DDD16 Compilers nd Interpreters DDB44 Compiler Construction R Prsing Prt 1 R prsing concept Using prser genertor Prse ree Genertion Wht is R-prsing? eft-to-right scnning R Rigthmost derivtion in reverse

More information

ECE 468/573 Midterm 1 September 28, 2012

ECE 468/573 Midterm 1 September 28, 2012 ECE 468/573 Midterm 1 September 28, 2012 Nme:! Purdue emil:! Plese sign the following: I ffirm tht the nswers given on this test re mine nd mine lone. I did not receive help from ny person or mteril (other

More information

Midterm I Solutions CS164, Spring 2006

Midterm I Solutions CS164, Spring 2006 Midterm I Solutions CS164, Spring 2006 Februry 23, 2006 Plese red ll instructions (including these) crefully. Write your nme, login, SID, nd circle the section time. There re 8 pges in this exm nd 4 questions,

More information

Fig.25: the Role of LEX

Fig.25: the Role of LEX The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing

More information

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011 CSCI 3130: Forml Lnguges nd utomt Theory Lecture 12 The Chinese University of Hong Kong, Fll 2011 ndrej Bogdnov In progrmming lnguges, uilding prse trees is significnt tsk ecuse prse trees tell us the

More information

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table TDDD55 Compilers nd Interpreters TDDB44 Compiler Construction LR Prsing, Prt 2 Constructing Prse Tles Prse tle construction Grmmr conflict hndling Ctegories of LR Grmmrs nd Prsers Peter Fritzson, Christoph

More information

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an Scnner Termintion A scnner reds input chrcters nd prtitions them into tokens. Wht hppens when the end of the input file is reched? It my be useful to crete n Eof pseudo-chrcter when this occurs. In Jv,

More information

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the LR() nlysis Drwcks of LR(). Look-hed symols s eplined efore, concerning LR(), it is possile to consult the net set to determine, in the reduction sttes, for which symols it would e possile to perform reductions.

More information

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2014 Dec 11 th /13 th Finl Exm Nme: Note: in ll questions, the specil symol ɛ (epsilon) is used to indicte the empty string. Question 1. [5 points] Consider the following regulr expression;

More information

CSE 401 Midterm Exam 11/5/10 Sample Solution

CSE 401 Midterm Exam 11/5/10 Sample Solution Question 1. egulr expressions (20 points) In the Ad Progrmming lnguge n integer constnt contins one or more digits, but it my lso contin embedded underscores. Any underscores must be preceded nd followed

More information

Scanner Termination. Multi Character Lookahead

Scanner Termination. Multi Character Lookahead If d.doublevlue() represents vlid integer, (int) d.doublevlue() will crete the pproprite integer vlue. If string representtion of n integer begins with ~ we cn strip the ~, convert to double nd then negte

More information

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08 CS412/413 Introduction to Compilers Tim Teitelum Lecture 4: Lexicl Anlyzers 28 Jn 08 Outline DFA stte minimiztion Lexicl nlyzers Automting lexicl nlysis Jlex lexicl nlyzer genertor CS 412/413 Spring 2008

More information

Definition of Regular Expression

Definition of Regular Expression Definition of Regulr Expression After the definition of the string nd lnguges, we re redy to descrie regulr expressions, the nottion we shll use to define the clss of lnguges known s regulr sets. Recll

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5 CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,

More information

2014 Haskell January Test Regular Expressions and Finite Automata

2014 Haskell January Test Regular Expressions and Finite Automata 0 Hskell Jnury Test Regulr Expressions nd Finite Automt This test comprises four prts nd the mximum mrk is 5. Prts I, II nd III re worth 3 of the 5 mrks vilble. The 0 Hskell Progrmming Prize will be wrded

More information

Compilers Spring 2013 PRACTICE Midterm Exam

Compilers Spring 2013 PRACTICE Midterm Exam Compilers Spring 2013 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs

More information

CMSC 331 First Midterm Exam

CMSC 331 First Midterm Exam 0 00/ 1 20/ 2 05/ 3 15/ 4 15/ 5 15/ 6 20/ 7 30/ 8 30/ 150/ 331 First Midterm Exm 7 October 2003 CMC 331 First Midterm Exm Nme: mple Answers tudent ID#: You will hve seventy-five (75) minutes to complete

More information

Top-down vs Bottom-up. Bottom up parsing. Sentential form. Handles. Handles in expression example

Top-down vs Bottom-up. Bottom up parsing. Sentential form. Handles. Handles in expression example Bottom up prsing Generl e LR0) LR LR1) LLR o est exploit JvCUP, should understnd the theoreticl sis LR prsing); op-down vs Bottom-up Bottom-up more powerful thn top-down; Cn process more powerful grmmr

More information

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22) Homework Context Free Lnguges III Prse Trees nd Homework #5 (due 10/22) From textbook 6.4,b 6.5b 6.9b,c 6.13 6.22 Pln for tody Context Free Lnguges Next clss of lnguges in our quest! Lnguges Recll. Wht

More information

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 21 Sndiwy Fong Tody's Topics Homework 8 Review Optionl Homework 9 (mke up on Homework 7) Homework 8 Review Question1: write Prolog regulr grmmr for the following lnguge:

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence

More information

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or Opertor Precedence Most progrmming lnguges hve opertor precedence rules tht stte the order in which opertors re pplied (in the sence of explicit prentheses). Thus in C nd Jv nd CSX, +*c mens compute *c,

More information

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis CS143 Hndout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexicl Anlysis In this first written ssignment, you'll get the chnce to ply round with the vrious constructions tht come up when doing lexicl

More information

Assignment 4. Due 09/18/17

Assignment 4. Due 09/18/17 Assignment 4. ue 09/18/17 1. ). Write regulr expressions tht define the strings recognized by the following finite utomt: b d b b b c c b) Write FA tht recognizes the tokens defined by the following regulr

More information

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata CS 432 Fll 2017 Mike Lm, Professor (c)* Regulr Expressions nd Finite Automt Compiltion Current focus "Bck end" Source code Tokens Syntx tree Mchine code chr dt[20]; int min() { flot x = 42.0; return 7;

More information

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

In the last lecture, we discussed how valid tokens may be specified by regular expressions. LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.

More information

stack of states and grammar symbols Stack-Bottom marker C. Kessler, IDA, Linköpings universitet. 1. <list> -> <list>, <element> 2.

stack of states and grammar symbols Stack-Bottom marker C. Kessler, IDA, Linköpings universitet. 1. <list> -> <list>, <element> 2. TDDB9 Compilers nd Interpreters TDDB44 Compiler Construction LR Prsing Updted/New slide mteril 007: Pushdown Automton for LR-Prsing Finite-stte pushdown utomton contins lterntingly sttes nd symols in NUΣ

More information

2 Computing all Intersections of a Set of Segments Line Segment Intersection

2 Computing all Intersections of a Set of Segments Line Segment Intersection 15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design

More information

acronyms possibly used in this test: CFG :acontext free grammar CFSM :acharacteristic finite state machine DFA :adeterministic finite automata

acronyms possibly used in this test: CFG :acontext free grammar CFSM :acharacteristic finite state machine DFA :adeterministic finite automata EE573 Fll 2002, Exm open book, if question seems mbiguous, sk me to clrify the question. If my nswer doesn t stisfy you, plese stte your ssumptions. cronyms possibly used in this test: CFG :context free

More information

CSCE 531, Spring 2017, Midterm Exam Answer Key

CSCE 531, Spring 2017, Midterm Exam Answer Key CCE 531, pring 2017, Midterm Exm Answer Key 1. (15 points) Using the method descried in the ook or in clss, convert the following regulr expression into n equivlent (nondeterministic) finite utomton: (

More information

INTRODUCTION TO SIMPLICIAL COMPLEXES

INTRODUCTION TO SIMPLICIAL COMPLEXES INTRODUCTION TO SIMPLICIAL COMPLEXES CASEY KELLEHER AND ALESSANDRA PANTANO 0.1. Introduction. In this ctivity set we re going to introduce notion from Algebric Topology clled simplicil homology. The min

More information

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2016 Sep 29th Exm 1 Nme: Note: in ll questions, the speil symol ɛ (epsilon) is used to indite the empty string. Question 1. [10 points] Speify regulr expression tht genertes the lnguge over

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop

More information

CSc 453 Compilers and Systems Software. 6 : Top-Down Parsing I

CSc 453 Compilers and Systems Software. 6 : Top-Down Parsing I C 45 Compilers n ystems oftwre 6 : op-down Prsing I Christin Collberg Deprtment of Computer iene University of rizon ollberg@gmil.om Copyright 2009 Christin Collberg eptember 14, 2009 1 Overview 2 Compiler

More information

Today. Search Problems. Uninformed Search Methods. Depth-First Search Breadth-First Search Uniform-Cost Search

Today. Search Problems. Uninformed Search Methods. Depth-First Search Breadth-First Search Uniform-Cost Search Uninformed Serch [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.] Tody Serch Problems Uninformed Serch Methods

More information

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona Implementing utomt Sc 5 ompilers nd Systems Softwre : Lexicl nlysis II Deprtment of omputer Science University of rizon collerg@gmil.com opyright c 009 hristin ollerg NFs nd DFs cn e hrd-coded using this

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grmmrs Descriing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions descrie precisely the strings in the lnguge.

More information

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) * Pln for Tody nd Beginning Next week Interpreter nd Compiler Structure, or Softwre Architecture Overview of Progrmming Assignments The MeggyJv compiler we will e uilding. Regulr Expressions Finite Stte

More information

Stack. A list whose end points are pointed by top and bottom

Stack. A list whose end points are pointed by top and bottom 4. Stck Stck A list whose end points re pointed by top nd bottom Insertion nd deletion tke plce t the top (cf: Wht is the difference between Stck nd Arry?) Bottom is constnt, but top grows nd shrinks!

More information

Topic 2: Lexing and Flexing

Topic 2: Lexing and Flexing Topic 2: Lexing nd Flexing COS 320 Compiling Techniques Princeton University Spring 2016 Lennrt Beringer 1 2 The Compiler Lexicl Anlysis Gol: rek strem of ASCII chrcters (source/input) into sequence of

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Tree Structured Symmetrical Systems of Linear Equations and their Graphical Solution

Tree Structured Symmetrical Systems of Linear Equations and their Graphical Solution Proceedings of the World Congress on Engineering nd Computer Science 4 Vol I WCECS 4, -4 October, 4, Sn Frncisco, USA Tree Structured Symmetricl Systems of Liner Equtions nd their Grphicl Solution Jime

More information

CSCI 446: Artificial Intelligence

CSCI 446: Artificial Intelligence CSCI 446: Artificil Intelligence Serch Instructor: Michele Vn Dyne [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.]

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grmmrs Descriing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions descrie precisely the strings in the lnguge.

More information

COMP 423 lecture 11 Jan. 28, 2008

COMP 423 lecture 11 Jan. 28, 2008 COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring

More information

CMPSC 470: Compiler Construction

CMPSC 470: Compiler Construction CMPSC 47: Compiler Construction Plese complete the following: Midterm (Type A) Nme Instruction: Mke sure you hve ll pges including this cover nd lnk pge t the end. Answer ech question in the spce provided.

More information

Stained Glass Design. Teaching Goals:

Stained Glass Design. Teaching Goals: Stined Glss Design Time required 45-90 minutes Teching Gols: 1. Students pply grphic methods to design vrious shpes on the plne.. Students pply geometric trnsformtions of grphs of functions in order to

More information

Java CUP. Java CUP Specifications. User Code Additions. Package and Import Specifications

Java CUP. Java CUP Specifications. User Code Additions. Package and Import Specifications Jv CUP Jv CUP is prser-genertion tool, similr to Ycc. CUP uilds Jv prser for LALR(1) grmmrs from production rules nd ssocited Jv code frgments. When prticulr production is recognized, its ssocited code

More information

ASTs, Regex, Parsing, and Pretty Printing

ASTs, Regex, Parsing, and Pretty Printing ASTs, Regex, Prsing, nd Pretty Printing CS 2112 Fll 2016 1 Algeric Expressions To strt, consider integer rithmetic. Suppose we hve the following 1. The lphet we will use is the digits {0, 1, 2, 3, 4, 5,

More information

CSEP 573 Artificial Intelligence Winter 2016

CSEP 573 Artificial Intelligence Winter 2016 CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch

More information

From Dependencies to Evaluation Strategies

From Dependencies to Evaluation Strategies From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grmmrs Describing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions describe precisely the strings in the lnguge.

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

CS 221: Artificial Intelligence Fall 2011

CS 221: Artificial Intelligence Fall 2011 CS 221: Artificil Intelligence Fll 2011 Lecture 2: Serch (Slides from Dn Klein, with help from Sturt Russell, Andrew Moore, Teg Grenger, Peter Norvig) Problem types! Fully observble, deterministic! single-belief-stte

More information

Data sharing in OpenMP

Data sharing in OpenMP Dt shring in OpenMP Polo Burgio polo.burgio@unimore.it Outline Expressing prllelism Understnding prllel threds Memory Dt mngement Dt cluses Synchroniztion Brriers, locks, criticl sections Work prtitioning

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information

12-B FRACTIONS AND DECIMALS

12-B FRACTIONS AND DECIMALS -B Frctions nd Decimls. () If ll four integers were negtive, their product would be positive, nd so could not equl one of them. If ll four integers were positive, their product would be much greter thn

More information

Lexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Lexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Lexicl Anlysis Amith Snyl (www.cse.iit.c.in/ s) Deprtment of Computer Science nd Engineering, Indin Institute of Technology, Bomy Septemer 27 College of Engineering, Pune Lexicl Anlysis: 2/6 Recp The input

More information

LEX5: Regexps to NFA. Lexical Analysis. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class

LEX5: Regexps to NFA. Lexical Analysis. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class LEX5: Regexps to NFA Lexicl Anlysis CMPT 379: Compilers Instructor: Anoop Srkr noopsrkr.github.io/compilers-clss Building Lexicl Anlyzer Token POern POern Regulr Expression Regulr Expression NFA NFA DFA

More information

CMSC 430, Practice Problems 1 (Solutions)

CMSC 430, Practice Problems 1 (Solutions) CMC 430, Prtie Problems 1 olutios) 1. Cosider the followig grmmr: d or ) true flse. Compute First sets for eh produtio d otermil FIRTtrue) = { true } FIRTflse) = { flse } FIRT ) ) = { } FIRT d ) = FIRT

More information

A Heuristic Approach for Discovering Reference Models by Mining Process Model Variants

A Heuristic Approach for Discovering Reference Models by Mining Process Model Variants A Heuristic Approch for Discovering Reference Models by Mining Process Model Vrints Chen Li 1, Mnfred Reichert 2, nd Andres Wombcher 3 1 Informtion System Group, University of Twente, The Netherlnds lic@cs.utwente.nl

More information

Alignment of Long Sequences. BMI/CS Spring 2012 Colin Dewey

Alignment of Long Sequences. BMI/CS Spring 2012 Colin Dewey Alignment of Long Sequences BMI/CS 776 www.biostt.wisc.edu/bmi776/ Spring 2012 Colin Dewey cdewey@biostt.wisc.edu Gols for Lecture the key concepts to understnd re the following how lrge-scle lignment

More information

Subtracting Fractions

Subtracting Fractions Lerning Enhncement Tem Model Answers: Adding nd Subtrcting Frctions Adding nd Subtrcting Frctions study guide. When the frctions both hve the sme denomintor (bottom) you cn do them using just simple dding

More information

Section 10.4 Hyperbolas

Section 10.4 Hyperbolas 66 Section 10.4 Hyperbols Objective : Definition of hyperbol & hyperbols centered t (0, 0). The third type of conic we will study is the hyperbol. It is defined in the sme mnner tht we defined the prbol

More information

Improper Integrals. October 4, 2017

Improper Integrals. October 4, 2017 Improper Integrls October 4, 7 Introduction We hve seen how to clculte definite integrl when the it is rel number. However, there re times when we re interested to compute the integrl sy for emple 3. Here

More information

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) Numbers nd Opertions, Algebr, nd Functions 45. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) In sequence of terms involving eponentil growth, which the testing service lso clls geometric

More information

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID: Fll term 2012 KAIST EE209 Progrmming Structures for EE Mid-term exm Thursdy Oct 25, 2012 Student's nme: Student ID: The exm is closed book nd notes. Red the questions crefully nd focus your nswers on wht

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

Geometric transformations

Geometric transformations Geometric trnsformtions Computer Grphics Some slides re bsed on Shy Shlom slides from TAU mn n n m m T A,,,,,, 2 1 2 22 12 1 21 11 Rows become columns nd columns become rows nm n n m m A,,,,,, 1 1 2 22

More information

Integration. September 28, 2017

Integration. September 28, 2017 Integrtion September 8, 7 Introduction We hve lerned in previous chpter on how to do the differentition. It is conventionl in mthemtics tht we re supposed to lern bout the integrtion s well. As you my

More information

1 Quad-Edge Construction Operators

1 Quad-Edge Construction Operators CS48: Computer Grphics Hndout # Geometric Modeling Originl Hndout #5 Stnford University Tuesdy, 8 December 99 Originl Lecture #5: 9 November 99 Topics: Mnipultions with Qud-Edge Dt Structures Scribe: Mike

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy RecogniNon of Tokens if expressions nd relnonl opertors if è if then è then else è else relop è

More information

What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers

What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers Wht do ll those bits men now? bits (...) Number Systems nd Arithmetic or Computers go to elementry school instruction R-formt I-formt... integer dt number text chrs... floting point signed unsigned single

More information

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona CSc 453 Compilers nd Systems Softwre 4 : Lexicl Anlysis II Deprtment of Computer Science University of Arizon collerg@gmil.com Copyright c 2009 Christin Collerg Implementing Automt NFAs nd DFAs cn e hrd-coded

More information

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls Redings for Next Two Lectures Text CPSC 213 Switch Sttements, Understnding Pointers - 2nd ed: 3.6.7, 3.10-1st ed: 3.6.6, 3.11 Introduction to Computer Systems Unit 1f Dynmic Control Flow Polymorphism nd

More information

Control-Flow Analysis and Loop Detection

Control-Flow Analysis and Loop Detection ! Control-Flow Anlysis nd Loop Detection!Lst time! PRE!Tody! Control-flow nlysis! Loops! Identifying loops using domintors! Reducibility! Using loop identifiction to identify induction vribles CS553 Lecture

More information

An Efficient Divide and Conquer Algorithm for Exact Hazard Free Logic Minimization

An Efficient Divide and Conquer Algorithm for Exact Hazard Free Logic Minimization An Efficient Divide nd Conquer Algorithm for Exct Hzrd Free Logic Minimiztion J.W.J.M. Rutten, M.R.C.M. Berkelr, C.A.J. vn Eijk, M.A.J. Kolsteren Eindhoven University of Technology Informtion nd Communiction

More information

Section 3.1: Sequences and Series

Section 3.1: Sequences and Series Section.: Sequences d Series Sequences Let s strt out with the definition of sequence: sequence: ordered list of numbers, often with definite pttern Recll tht in set, order doesn t mtter so this is one

More information

Compiler Construction D7011E

Compiler Construction D7011E Compiler Construction D7011E Lecture 3: Lexer genertors Viktor Leijon Slides lrgely y John Nordlnder with mteril generously provided y Mrk P. Jones. 1 Recp: Hndwritten Lexers: Don t require sophisticted

More information

MIPS I/O and Interrupt

MIPS I/O and Interrupt MIPS I/O nd Interrupt Review Floting point instructions re crried out on seprte chip clled coprocessor 1 You hve to move dt to/from coprocessor 1 to do most common opertions such s printing, clling functions,

More information

Epson Projector Content Manager Operation Guide

Epson Projector Content Manager Operation Guide Epson Projector Content Mnger Opertion Guide Contents 2 Introduction to the Epson Projector Content Mnger Softwre 3 Epson Projector Content Mnger Fetures... 4 Setting Up the Softwre for the First Time

More information

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork MA1008 Clculus nd Liner Algebr for Engineers Course Notes for Section B Stephen Wills Deprtment of Mthemtics University College Cork s.wills@ucc.ie http://euclid.ucc.ie/pges/stff/wills/teching/m1008/ma1008.html

More information

MTH 146 Conics Supplement

MTH 146 Conics Supplement 105- Review of Conics MTH 146 Conics Supplement In this section we review conics If ou ne more detils thn re present in the notes, r through section 105 of the ook Definition: A prol is the set of points

More information

Virtual Machine (Part I)

Virtual Machine (Part I) Hrvrd University CS Fll 2, Shimon Schocken Virtul Mchine (Prt I) Elements of Computing Systems Virtul Mchine I (Ch. 7) Motivtion clss clss Min Min sttic sttic x; x; function function void void min() min()

More information

Lists in Lisp and Scheme

Lists in Lisp and Scheme Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages CS 314 Principles of Progrmming Lnguges Lecure 10: Synx Direced Trnslion Zheng (Eddy) Zhng Rugers Universiy Februry 19, 2018 Clss Informion Homework 2 is sill being grded. Projec 1 nd homework 4 will be

More information

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards A Tutology Checker loosely relted to Stålmrck s Algorithm y Mrtin Richrds mr@cl.cm.c.uk http://www.cl.cm.c.uk/users/mr/ University Computer Lortory New Museum Site Pemroke Street Cmridge, CB2 3QG Mrtin

More information

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex Long Quiz2 45mins Nme: Personl Numer: Prolem. (20pts) Here is n Tle of Perl Regulr Ex Chrcter Description. single chrcter \s whitespce chrcter (spce, t, newline) \S non-whitespce chrcter \d digit (0-9)

More information

Lexical analysis, scanners. Construction of a scanner

Lexical analysis, scanners. Construction of a scanner Lexicl nlysis scnners (NB. Pges 4-5 re for those who need to refresh their knowledge of DFAs nd NFAs. These re not presented during the lectures) Construction of scnner Tools: stte utomt nd trnsition digrms.

More information

EECS 281: Homework #4 Due: Thursday, October 7, 2004

EECS 281: Homework #4 Due: Thursday, October 7, 2004 EECS 28: Homework #4 Due: Thursdy, October 7, 24 Nme: Emil:. Convert the 24-bit number x44243 to mime bse64: QUJD First, set is to brek 8-bit blocks into 6-bit blocks, nd then convert: x44243 b b 6 2 9

More information

Small Business Networking

Small Business Networking Why network is n essentil productivity tool for ny smll business Effective technology is essentil for smll businesses looking to increse the productivity of their people nd processes. Introducing technology

More information

Small Business Networking

Small Business Networking Why network is n essentil productivity tool for ny smll business Effective technology is essentil for smll businesses looking to increse the productivity of their people nd business. Introducing technology

More information

Digital Design. Chapter 6: Optimizations and Tradeoffs

Digital Design. Chapter 6: Optimizations and Tradeoffs Digitl Design Chpter 6: Optimiztions nd Trdeoffs Slides to ccompny the tetbook Digitl Design, with RTL Design, VHDL, nd Verilog, 2nd Edition, by Frnk Vhid, John Wiley nd Sons Publishers, 2. http://www.ddvhid.com

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS COMPUTATION & LOGIC Sturdy st April 7 : to : INSTRUCTIONS TO CANDIDATES This is tke-home exercise. It will not

More information