Compilers. Chapter 4: Syntactic Analyser. 3 er course Spring Term. Precedence grammars. Precedence grammars
|
|
- Lewis Davidson
- 5 years ago
- Views:
Transcription
1 Complers Chpter 4: yntt Anlyser er ourse prng erm Prt 4g: mple Preedene Grmmrs Alfonso Orteg: nrque Alfonse: Introduton A preedene grmmr ses the nlyss n the preedene reltonshps mong the symols n the lnguge. Usng those reltonshps, the prser wll try to dede whh s the symol wth the hghest preedene, to strt uldng the ottom-up prse. Prevous exmple he purpose s to uld the grmmr n suh wy tht some symols hve preedene over other symols. or nstne, the followng grmmr does not gve preedene of over : ::= ut the rule ::= hs preedene over the other two rules, euse they nnot pply f the s hven t een redued to s 4
2 Prevous exmple Prevous exmple 5 6 Prevous exmple Ide In the followng sldes we shll formlse some reltons of preedene etween the symols of the grmmr: Whh symols hve equl preedene. Whh prs of symols re suh tht the frst one hs more preedene thn the seond one. 7 8
3 HA reltonshp efnton HA reltonshp trx representton Σ Σ N Let G={Σ N,Σ,P,Α} e ontext-ndependent grmmr. If U s non-termnl symol n the grmmr, we shll ll hed(u) the set of symols tht n e t the egnnng of the strngs derved from U. If there s rule U ::= Vx x...x n, V hed(u) If V hed(u), nd, W hed(v), then W hed(u) ::= ::= ::= ::= ::= ::= () ( ) ( ) 9 AIL reltonshp efnton AIL reltonshp trx representton Σ Σ N Let G={Σ N,Σ,P,Α} e ontext-ndependent grmmr. If U s non-termnl symol n the grmmr, we shll ll tl(u) the set of symols tht n e t the end of the strngs derved from U. If there s rule U ::= x x...x n V, V tl(u) If V tl(u), nd, W tl(v), then W tl(u) ::= ::= ::= ::= ::= ::= () ( ) ( )
4 Preedene reltonshps wo symols R nd, n grmmr, hve equl preedene () f nd only f there s ny rule n the grmmr n whh they pper onseutve R f nd only f there s rule (U ::= xry) Preedene reltonshps A symol R hs less preedene thn symol (R ) f nd only f there s rule n the grmmr U ::= w Rw, where w,w (Σ N Σ ) nd Hed() U U... R R... Z 4 Preedene reltonshps A symol R hs more preedene thn symol (R ) f nd only f there s rule n the grmmr U ::= w Ww, where w,w (Σ N Σ ) R l() ther Hed(W), or =W. U U Preedene reltonshps A grmmr s smple preedene grmmr f, for every pr of symols, there s only one preedene reltonshp. If we hve sententl form, we n lulte the preedene reltonshps etween eh pr of onseutve symols: x x x x4 x5 x6 x7 x8 x W... A hndle wll lwys strt wth reltonshp, wll possly ontnue wth ny numer of reltonshps, nd wll lwys end wth reltonshp. We re gong to see now how to uld the preedene mtrx showng the reltonshps.... R... R
5 xmple: reltonshp xmple: HA reltonshp ::= ::= ::= ::= 7 8 xmple: AIL reltonshp xmple: reltonshp ::= ::= x = It n e lulted s the (Boolen) mtrl produt Hed ::= ::= 9
6 xmple: dentty reltonshp xmple: reltonshp ::= ::= x x = It n e lulted s the (Boolen) mtrl produt: (AIL) t (HA OR Identty) ::= ::= Preedene reltonshps Preedene reltonshps ::= ::= ::= ::= If we hve the word: the reltonshps re: wth the hndle mrked n red. 4
7 Preedene reltonshps Prsng lgorthm N ::= ::= AR he mtrx n e extended wth AR nd n N symol Prse. Intlse stk wth the AR symol.. Compre top(stk) wth the next element n the strng, X.. If top(stk) s not relted to X, notfy syntt error.. If top(stk) X, push(x). If top(stk) X, push(x) 4. If top(stk) X, pop from the stk untl we fnd the reltonshp. he symols extrted from the stk re the hndle. We look for the hndle n the rght-hnd-sdes of the grmmr rules, nd susttute t y the left-hnd-sde, whh wll e pushed n the stk. he reltonshps wll e: AR N wth the hndle mrked n red. 5 6 Prsng lgorthm Prsng lgorthm N N N N A R,< A R AR AR 7 8
8 9 N AR N Prsng lgorthm A R,<,< N AR N Prsng lgorthm A R,<,<,< N AR N Prsng lgorthm A R,<,< N AR N Prsng lgorthm A R,<,<,=
9 N AR N Prsng lgorthm,=,<,< A R, = 4 N AR N Prsng lgorthm A R,< 5 N AR N Prsng lgorthm A R,<,= 6 N AR N Prsng lgorthm A R,<,=,=
10 7 N AR N Prsng lgorthm A R 8 N AR N Prsng lgorthm A R,< ACCP 9 N AR N Prsng lgorthm A R 4 N AR N Prsng lgorthm A R,<
11 Prsng lgorthm mplfton wth preedene funtons N N AR,<,< A R RROR: ther s no preedene etween nd, so the word s rejeted. 4 he preedene mtrx hs sze of N y N. We n represent t wth less spe usng ouple of funtons, f nd g, lled preedene funtons. hey hve the followng propertes: f(x) = g(y) f nd only f x y f(x) < g(y) f nd only f x y f(x) > g(y) f nd only f x y xmple: N f g AR - N - AR 4 mplfton wth preedene funtons Proedure for lultng the preedene funtons Advntges: he reltons of preedene n e stored n mtrx of sze xn, rther thn NxN. sdvntges: We lose some nformton, suh s the empty ells n the orgnl mtrx. In some ses, t wll e mpossle to fnd suh funtons. or nstne, onsder the followng mtrx: he restrtons re: f() = g() f() > g() f() = g() f() = g(), whh re mpossle to stsfy. he preedene funtons n e lulted wth the followng proedure:. Represent n dgrm: unton f, ppled to ll the symols n the grmmr, n row. unton g, ppled to every symol, n row elow.. or every pr (x,y), rw n r from f(x) to g(y) f x y or x y rw n r from g(y) to f(x) y x y or x y. nlly, for every ell f(x) or g(x): We ount how mny ells re essle from t, n zero, one or severl steps. ht numer wll e the vlue of the funton for tht symol. 4 44
12 Proedure for lultng the preedene funtons Proedure for lultng the preedene funtons f() f() f() f() f() f() f() f() g() g() g() g() g() AR g() g() g() N 45. We strt from f(). here re two nodes esle (nludng tself): f() nd g(). herefore, we set f() =. rom f(), we n go to f() nd g(). herefore, we set, gn, f() =. rom f(), we n go to {f(), g(), f()} -> f() = 4. rom f(), we n go to {f(), g(), f()} -> f() = 5. rom g(), we n go to {g(), f()} -> g() = 6. rom g(), we n go to {g(), f(), g()} -> g() = 7. rom g(), we n go to {g(), f()} -> g() = 8. rom g(), we n go to {g(), f(), g()} -> g() = 46 Proedure for lultng the preedene funtons Proedure for lultng the preedene funtons If x y, then f(x) = g(y), euse every node essle from f(x) wll e essle from g(y). If x y, then here s n rrow from f(x) to g(y), ut there s not n nverse rrow. herefore, we nnot go k from g(y) to f(x). hs mens tht from f(x) we ll e le to ess every node essle from g(y), plus f(x), plus every other node essle from f(x). f(x) wll e strtly hgher thn g(y) nlly, f x y, then, here s n rrow from g(y) to f(x), ut not the nverse. herefore, the numer of nodes essle from g(y) wll e strtly hgher thn the numer essle from f(x) -> g(y) > f(x). We n utomte the proedure n the followng wy:. Buld the mtrx B: (<=) t >=. Clulte the mtrx B = B OR B OR B OR B OR.... f(x) wll e the ddton of eh row n the top hlf of the mtrx. 4. g(x) wll e the ddton of eh row n the lower hlf of the mtrx
13 49 Proedure for lultng the preedene funtons N trt >= <= 5 Proedure for lultng the preedene funtons >= <= B 5 Proedure for lultng the preedene funtons B 5 Proedure for lultng the preedene funtons B g() g() g() g() f() f() f() f() Σ Σ Σ Σ Σ Σ Σ Σ
14 Complete exmple xmple: HA reltonshp = Hed ::= ::= ::= ::= ::= ::= 5 54 xmple: AIL reltonshp xmple: reltonshp ::= ::= ::= l = H x = < Hed 55 56
15 xmple: dentty reltonshp xmple: reltonshp ::= ::= ::= Id t = H x x = > (AIL) t (HA OR Identty) Preedene reltonshps Prsng lgorthm ::= ::= N A R N t 59 6
16 6 N Prsng lgorthm A R,< t N 6 N Prsng lgorthm A R t N 6 N Prsng lgorthm A R,< t N 64 N Prsng lgorthm A R,<,= t N
17 65 N Prsng lgorthm A R,<,=,< t N 66 N Prsng lgorthm A R,<,= t N 67 N Prsng lgorthm A R,<,=,< t N 68 N Prsng lgorthm A R,<,= t N
18 69 N Prsng lgorthm A R,<,=,= t N 7 N I Prsng lgorthm A R t N 7 N Prsng lgorthm A R,< t N 7 N I Prsng lgorthm A R t N
19 7 N Prsng lgorthm A R,< t N 74 N Prsng lgorthm A R,<,= t N 75 N Prsng lgorthm A R,<,=,< t N 76 N Prsng lgorthm A R,<,= t N
20 77 N Prsng lgorthm A R,<,=,< t N 78 N Prsng lgorthm A R,<,= t N 79 N Prsng lgorthm A R,<,=,= t N 8 N Prsng lgorthm A R t N
21 Prsng lgorthm Complete exmple N N Note tht the followng versons of the sme grmmr re not smplepreedene grmmrs: A R ::= ::= ::= ACCP ::= ::= ::= t Why? (exerse) 8 8 Proedure for lultng the preedene funtons Complete exmple f() f() f() f() f() f() unton f() Aessle ells f(), g() unton vlue f() f(), g(), f() f() f(), g(), f(), g() 4 g() g() g() g() g() g() f() f() f(), g(), f() f(), g(), f() 8 f() g() g() g() g() g() g() f(), g(), g(), f(), f() g() g(), f(), f() g(), f(), f(), g() g(), f() g(), f(), g(), f() g(), f(), f(), g()
22 Prsng lgorthm unton f() unton vlue N f() f() f() 4 A R f() f() g() g() g() g() 5 4 XRCI: Repet the nlyss of the strng usng the preedene funtons g() 4 g() 4 f(ar)=g(n) 85
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 informationthis 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 informationCS 241 Week 4 Tutorial Solutions
CS 4 Week 4 Tutoril Solutions Writing n Assemler, Prt & Regulr Lnguges Prt Winter 8 Assemling instrutions utomtilly. slt $d, $s, $t. Solution: $d, $s, nd $t ll fit in -it signed integers sine they re 5-it
More informationLecture 12 : Topological Spaces
Leture 12 : Topologil Spes 1 Topologil Spes Topology generlizes notion of distne nd loseness et. Definition 1.1. A topology on set X is olletion T of susets of X hving the following properties. 1. nd X
More informationRecap: rigid motions. [L7] Robotics (ME671): Forward Kinematics. Recap: homogeneous transforms. Robot Kinematics Suril Shah IIT Jodhpur
--6 Rep: rgd motons [L7] Robots (ME67): Forwrd Knemts Rgd moton s ombnton of rotton nd trnslton It n be represented usng homogeneous trnsform R d H Surl Shh IIT Jodhpur Inverse trnsforms: T T R R d H Rep:
More informationDefinition 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 informationCompilers 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 informationCOMPUTATIONAL INTELLIGENCE
COMPUTATIONAL INTELLIGENCE LABORATORY CLASSES Immentton smplstc verson of the network for some nference resons Adrn Horzyk IMPLEMENTATION OF THE SIMPLISTIC OR AANG Imment the smplstc verson of n structure
More informationCMPUT101 Introduction to Computing - Summer 2002
CMPUT Introdution to Computing - Summer 22 %XLOGLQJ&RPSXWHU&LUFXLWV Chpter 4.4 3XUSRVH We hve looked t so fr how to uild logi gtes from trnsistors. Next we will look t how to uild iruits from logi gtes,
More information1.4 Circuit Theorems
. Crcut Theorems. v,? (C)V, 5 6 (D) V, 6 5. A smple equvlent crcut of the termnl 6 v, network shown n fg. P.. s Fg. P... (A)V, (B)V, v (C)V,5 (D)V,5 Fg. P....,? 5 V, v (A) (B) Fg. P... (A)A, 0 (B) 0 A,
More information12 <= 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 informationCOMP 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 informationCSc 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 informationIntroduction to Algebra
INTRODUCTORY ALGEBRA Mini-Leture 1.1 Introdution to Alger Evlute lgeri expressions y sustitution. Trnslte phrses to lgeri expressions. 1. Evlute the expressions when =, =, nd = 6. ) d) 5 10. Trnslte eh
More informationThe Fundamental Theorem of Calculus
MATH 6 The Fundmentl Theorem of Clculus The Fundmentl Theorem of Clculus (FTC) gives method of finding the signed re etween the grph of f nd the x-xis on the intervl [, ]. The theorem is: FTC: If f is
More informationECE 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 informationCOMPUTATIONAL INTELLIGENCE
COMPUTATIONAL INTELLIGENCE LABORATORY CLASSES Immentton smplstc verson of the or AANG network for some nference resons Adrn Horzyk IMPLEMENTATION OF THE SIMPLISTIC OR AANG Imment the smplstc verson of
More informationLR 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 informationFig.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 informationWorld Journal of Engineering Research and Technology WJERT
wjert 207 Vol. 3 Issue 5 284-293. Orgnl Artcle IN 2454-695X World Journl of ngneerng Reserch nd Technology hndrmouleeswrn et l. World Journl of ngneerng Reserch nd Technology WJRT www.wjert.org JIF Impct
More informationChapter 4 Fuzzy Graph and Relation
Chpter 4 Fuzzy Grph nd Reltion Grph nd Fuzzy Grph! Grph n G = (V, E) n V : Set of verties(node or element) n E : Set of edges An edge is pir (x, y) of verties in V.! Fuzzy Grph ~ n ( ~ G = V, E) n V :
More informationIf you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.
Lecture 5 Wlks, Trils, Pths nd Connectedness Reding: Some of the mteril in this lecture comes from Section 1.2 of Dieter Jungnickel (2008), Grphs, Networks nd Algorithms, 3rd edition, which is ville online
More informationLecture 8: Graph-theoretic problems (again)
COMP36111: Advned Algorithms I Leture 8: Grph-theoreti prolems (gin) In Prtt-Hrtmnn Room KB2.38: emil: iprtt@s.mn..uk 2017 18 Reding for this leture: Sipser: Chpter 7. A grph is pir G = (V, E), where V
More informationCS 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 informationCS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig
CS311H: Discrete Mthemtics Grph Theory IV Instructor: Işıl Dillig Instructor: Işıl Dillig, CS311H: Discrete Mthemtics Grph Theory IV 1/25 A Non-plnr Grph Regions of Plnr Grph The plnr representtion of
More information1.1. Interval Notation and Set Notation Essential Question When is it convenient to use set-builder notation to represent a set of numbers?
1.1 TEXAS ESSENTIAL KNOWLEDGE AND SKILLS Prepring for 2A.6.K, 2A.7.I Intervl Nottion nd Set Nottion Essentil Question When is it convenient to use set-uilder nottion to represent set of numers? A collection
More informationΕΠΛ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 informationCompilers. Lesson 6 part a: generation of intermediate code. Intermediate Representations. Intermediate Representations.
Complers Lesson 6 prt : generton of ntermedte ode 3 rd yer Sprng term Alfonso Orteg: lfonso.orteg@um.es Enrque Alfonse: enrque.lfonse@um.es Intermedte Representtons INDEX Intermedte Representtons Generl
More information1.5 Extrema and the Mean Value Theorem
.5 Extrem nd the Men Vlue Theorem.5. Mximum nd Minimum Vlues Definition.5. (Glol Mximum). Let f : D! R e function with domin D. Then f hs n glol mximum vlue t point c, iff(c) f(x) for ll x D. The vlue
More informationCS 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 informationLesson 4.4. Euler Circuits and Paths. Explore This
Lesson 4.4 Euler Ciruits nd Pths Now tht you re fmilir with some of the onepts of grphs nd the wy grphs onvey onnetions nd reltionships, it s time to egin exploring how they n e used to model mny different
More informationHomework. 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 informationSection 2.3 Functions. Definition: Let A and B be sets. A function (mapping, map) f from A to B, denoted f :A B, is a subset of A B such that
Setion 2.3 Funtions Definition: Let n e sets. funtion (mpping, mp) f from to, enote f :, is suset of suh tht x[x y[y < x, y > f ]] n [< x, y 1 > f < x, y 2 > f ] y 1 = y 2 Note: f ssoites with eh x in
More informationRecognition of Tokens
42 Recognton o Tokens The queston s how to recognze the tokens? Exmple: ssume the ollowng grmmr rgment to generte specc lnguge: stmt expr expr then stmt expr then stmt else stmt term relop term term term
More informationΕΠΛ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 informationChapter Spline Method of Interpolation More Examples Computer Engineering
Chpter. Splne Metho of Interpolton More Emples Computer Engneerng Emple A root rm wth rp lser snner s ong quk qulty hek on holes rlle n " " retngulr plte. The enters of the holes n the plte esre the pth
More informationbox Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:
Boxes nd Arrows There re two kinds of vriles in Jv: those tht store primitive vlues nd those tht store references. Primitive vlues re vlues of type long, int, short, chr, yte, oolen, doule, nd flot. References
More informationF. R. K. Chung y. University ofpennsylvania. Philadelphia, Pennsylvania R. L. Graham. AT&T Labs - Research. March 2,1997.
Forced convex n-gons in the plne F. R. K. Chung y University ofpennsylvni Phildelphi, Pennsylvni 19104 R. L. Grhm AT&T Ls - Reserch Murry Hill, New Jersey 07974 Mrch 2,1997 Astrct In seminl pper from 1935,
More informationCalculus Differentiation
//007 Clulus Differentition Jeffrey Seguritn person in rowot miles from the nerest point on strit shoreline wishes to reh house 6 miles frther down the shore. The person n row t rte of mi/hr nd wlk t rte
More informationCS321 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 information12-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 information2 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 informationCan Pythagoras Swim?
Overview Ativity ID: 8939 Mth Conepts Mterils Students will investigte reltionships etween sides of right tringles to understnd the Pythgoren theorem nd then use it to solve prolems. Students will simplify
More informationCS 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 informationCS201 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 informationAPPLICATIONS OF INTEGRATION
Chpter 3 DACS 1 Lok 004/05 CHAPTER 5 APPLICATIONS OF INTEGRATION 5.1 Geometricl Interprettion-Definite Integrl (pge 36) 5. Are of Region (pge 369) 5..1 Are of Region Under Grph (pge 369) Figure 5.7 shows
More information6.045J/18.400J: Automata, Computability and Complexity. Quiz 2: Solutions. Please write your name in the upper corner of each page.
6045J/18400J: Automt, Computbility nd Complexity Mrh 30, 2005 Quiz 2: Solutions Prof Nny Lynh Vinod Vikuntnthn Plese write your nme in the upper orner of eh pge Problem Sore 1 2 3 4 5 6 Totl Q2-1 Problem
More informationTop-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 informationArea & Volume. Chapter 6.1 & 6.2 September 25, y = 1! x 2. Back to Area:
Bck to Are: Are & Volume Chpter 6. & 6. Septemer 5, 6 We cn clculte the re etween the x-xis nd continuous function f on the intervl [,] using the definite integrl:! f x = lim$ f x * i )%x n i= Where fx
More informationAnswer Key Lesson 6: Workshop: Angles and Lines
nswer Key esson 6: tudent Guide ngles nd ines Questions 1 3 (G p. 406) 1. 120 ; 360 2. hey re the sme. 3. 360 Here re four different ptterns tht re used to mke quilts. Work with your group. se your Power
More informationASTs, 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 informationCS412/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 informationMesh and Node Equations: Circuits Containing Dependent Sources
Mesh nd Node Equtons: Crcuts Contnng Dependent Sources Introducton The crcuts n ths set of problems re smll crcuts tht contn sngle dependent source. These crcuts cn be nlyzed usng mesh equton or usng node
More informationDuality in linear interval equations
Aville online t http://ijim.sriu..ir Int. J. Industril Mthemtis Vol. 1, No. 1 (2009) 41-45 Dulity in liner intervl equtions M. Movhedin, S. Slhshour, S. Hji Ghsemi, S. Khezerloo, M. Khezerloo, S. M. Khorsny
More informationGraphing Conic Sections
Grphing Conic Sections Definition of Circle Set of ll points in plne tht re n equl distnce, clled the rdius, from fixed point in tht plne, clled the center. Grphing Circle (x h) 2 + (y k) 2 = r 2 where
More informationCOMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator.
COMMON FRACTIONS BASIC DEFINITIONS * A frtion is n inite ivision. or / * In the frtion is lle the numertor n is lle the enomintor. * The whole is seprte into "" equl prts n we re onsiering "" of those
More information10/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 informationGrade 7/8 Math Circles Geometric Arithmetic October 31, 2012
Fculty of Mthemtics Wterloo, Ontrio N2L 3G1 Grde 7/8 Mth Circles Geometric Arithmetic Octoer 31, 2012 Centre for Eduction in Mthemtics nd Computing Ancient Greece hs given irth to some of the most importnt
More informationP(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have
Rndom Numers nd Monte Crlo Methods Rndom Numer Methods The integrtion methods discussed so fr ll re sed upon mking polynomil pproximtions to the integrnd. Another clss of numericl methods relies upon using
More informationMidterm 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 informationV = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V)
Definitions G = (V, E) V = set of verties (vertex / noe) E = set of eges (v, w) (v, w in V) (v, w) orere => irete grph (igrph) (v, w) non-orere => unirete grph igrph: w is jent to v if there is n ege from
More informationPink Retro Kitchen and Refrigerator
Please retain this information for future reference To order replacement parts, please visit 1 31 3 4 5 6 7 38 13 12 37 33 32 17 x 4 18 19 22 23 34 25 20 21 35 36 27 26 UTON: dult ssembly Required. Hardware
More informationIntroducing fractions
Introduing frtions Nme Colour hlf of eh shpe: Show the following fr ons: out of out of out of Lel these fr ons: Shde these fr ons: 7 0 Represents ommon fr ons on different models Interprets the numertor
More informationParadigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms
Prdigm. Dt Struture Known exmples: link tble, hep, Our leture: suffix tree Will involve mortize method tht will be stressed shortly in this ourse Suffix trees Wht is suffix tree? Simple pplitions History
More informationProblem 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 informationPattern Matching. Pattern Matching. Pattern Matching. Review of Regular Expressions
Pttern Mthing Pttern Mthing Some of these leture slides hve een dpted from: lgorithms in C, Roert Sedgewik. Gol. Generlize string serhing to inompletely speified ptterns. pplitions. Test if string or its
More informationCS143 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 informationStained 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 informationLesson6: Modeling the Web as a graph Unit5: Linear Algebra for graphs
Lesson6: Modeling the We s grph Unit5: Liner Alger for grphs Rene Pikhrdt Introdution to We Siene Prt 2 Emerging We Properties Rene Pikhrdt Institute CC-BY-SA-3. for We Siene nd Tehnologies Modeling the
More information10.2 Graph Terminology and Special Types of Graphs
10.2 Grph Terminology n Speil Types of Grphs Definition 1. Two verties u n v in n unirete grph G re lle jent (or neighors) in G iff u n v re enpoints of n ege e of G. Suh n ege e is lle inient with the
More informationQuiz2 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 information1 The Definite Integral
The Definite Integrl Definition. Let f be function defined on the intervl [, b] where
More informationBefore We Begin. Introduction to Spatial Domain Filtering. Introduction to Digital Image Processing. Overview (1): Administrative Details (1):
Overview (): Before We Begin Administrtive detils Review some questions to consider Winter 2006 Imge Enhncement in the Sptil Domin: Bsics of Sptil Filtering, Smoothing Sptil Filters, Order Sttistics Filters
More informationLily Yen and Mogens Hansen
SKOLID / SKOLID No. 8 Lily Yen nd Mogens Hnsen Skolid hs joined Mthemticl Myhem which is eing reformtted s stnd-lone mthemtics journl for high school students. Solutions to prolems tht ppered in the lst
More information6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it.
6.3 Volumes Just s re is lwys positive, so is volume nd our ttitudes towrds finding it. Let s review how to find the volume of regulr geometric prism, tht is, 3-dimensionl oject with two regulr fces seprted
More informationError Numbers of the Standard Function Block
A.2.2 Numers of the Stndrd Funtion Blok evlution The result of the logi opertion RLO is set if n error ours while the stndrd funtion lok is eing proessed. This llows you to rnh to your own error evlution
More informationCSE 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 informationSection 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 informationCSCE 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 information5 ANGLES AND POLYGONS
5 GLES POLYGOS urling rige looks like onventionl rige when it is extene. However, it urls up to form n otgon to llow ots through. This Rolling rige is in Pington sin in Lonon, n urls up every Friy t miy.
More informationMath 227 Problem Set V Solutions. f ds =
Mth 7 Problem Set V Solutions If is urve with prmetriztion r(t), t b, then we define the line integrl f ds b f ( r(t) ) dr dt (t) dt. Evlute the line integrl f(x,y,z)ds for () f(x,y,z) xosz, the urve with
More informationArrays as functions. Types. Multidimensional Arrays (row major, column major form) Java arrays
Louden Chpters 6,9 Types Dt Types nd Abstrct Dt Types 1 Arrys s functons f: U -> V (f U s ordnl type) f() rry C rrys types cn be wthout szes rry vrbles must hve fxed sze rry_mx( [], sze) // prmeters re
More informationLossy Image Compression Methods. CSEP 590 Data Compression Autumn Barbara. JPEG Standard JPEG. DCT Compression JPEG
ossy Imge Compresson ethods CSEP 59 Dt Compresson Autumn 7 ossy Imge Compresson rnsform Codng DC Compresson Slr quntzton (SQ). Vetor quntzton (). Wvelet Compresson SPIH UWIC (Unversty of Wshngton Imge
More informationReducing a DFA to a Minimal DFA
Lexicl Anlysis - Prt 4 Reducing DFA to Miniml DFA Input: DFA IN Assume DFA IN never gets stuck (dd ded stte if necessry) Output: DFA MIN An equivlent DFA with the minimum numer of sttes. Hrry H. Porter,
More informationTopic 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 informationSuffix Tries. Slides adapted from the course by Ben Langmead
Suffix Tries Slides dpted from the course y Ben Lngmed en.lngmed@gmil.com Indexing with suffixes Until now, our indexes hve een sed on extrcting sustrings from T A very different pproch is to extrct suffixes
More information3.5.1 Single slit diffraction
3..1 Single slit diffrction ves pssing through single slit will lso diffrct nd produce n interference pttern. The reson for this is to do with the finite width of the slit. e will consider this lter. Tke
More informationLecture 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 informationFuzzy soft -ring. E Blok Esenler, Istanbul, Turkey 2 Department of Mathematics, Marmara University, Istanbul, Turkey
IJST (202) A4: 469-476 Irnn Journl of Scence & Technology http://wwwshrzucr/en Fuzzy soft -rng S Onr, B A Ersoy * nd U Tekr 2 Deprtment of Mthemtcs, Yıldız Techncl Unversty Dvutpş Kmpüsü E Blok 202 34220
More informationImplementing 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 informationRight Angled Trigonometry. Objective: To know and be able to use trigonometric ratios in rightangled
C2 Right Angled Trigonometry Ojetive: To know nd e le to use trigonometri rtios in rightngled tringles opposite C Definition Trigonometry ws developed s method of mesuring ngles without ngulr units suh
More informationCSCI 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 informationGraphs with at most two trees in a forest building process
Grphs with t most two trees in forest uilding process rxiv:802.0533v [mth.co] 4 Fe 208 Steve Butler Mis Hmnk Mrie Hrdt Astrct Given grph, we cn form spnning forest y first sorting the edges in some order,
More informationCMSC 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 informationPointwise convergence need not behave well with respect to standard properties such as continuity.
Chpter 3 Uniform Convergence Lecture 9 Sequences of functions re of gret importnce in mny res of pure nd pplied mthemtics, nd their properties cn often be studied in the context of metric spces, s in Exmples
More information8.2 Areas in the Plane
39 Chpter 8 Applictions of Definite Integrls 8. Ares in the Plne Wht ou will lern out... Are Between Curves Are Enclosed Intersecting Curves Boundries with Chnging Functions Integrting with Respect to
More informationacronyms 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 information4452 Mathematical Modeling Lecture 4: Lagrange Multipliers
Mth Modeling Lecture 4: Lgrnge Multipliers Pge 4452 Mthemticl Modeling Lecture 4: Lgrnge Multipliers Lgrnge multipliers re high powered mthemticl technique to find the mximum nd minimum of multidimensionl
More informationTight triangulations: a link between combinatorics and topology
Tight tringultions: link between ombintoris nd topology Jonthn Spreer Melbourne, August 15, 2016 Topologil mnifolds (Geometri) Topology is study of mnifolds (surfes) up to ontinuous deformtion Complited
More informationCOMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples
COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure
More information