Objectives: parsing lectures. CSE401: Parsing. Parsing: two jobs. Parsing. CFG terminology. Context-free grammars (CFGs) Understand:
|
|
- Beverly Ada Newman
- 6 years ago
- Views:
Transcription
1 Objectives: parsig lectures CSE401: Parsig Larry Syder Sprig 2003 Slides by Chambers, Eggers, Notki, Ruzzo, Syder ad others L. Syder & UW CSE Uderstad: Theory ad practice of parsig Uderlyig laguage theory (CFGs,...) Top-dow parsig (ad be able to do it) Bottom-up parsig (time permittig) Today s focus: grammars ad ambiguity 2 Parsig Parsig: two jobs sequece of tokes Abstract Sytax Tree (AST) Captures hierarchical structure of the program Is the primary represetatio of the program used by the rest of the compiler Parser abstract sytax tree (AST) It gets augmeted ad aotated, but the basic structure of the AST is used throughout Is the program sytactically correct? a := 3 * (5 + 4) if x > y the m := x a := 3 * / 4 if x < y else m := x If so, build the correspodig AST := a * if > := x y m x 3 4 all laguages Cotext-free grammars (CFGs) Turig-computable laguages cotext-free laguages regular laguages For lexig, we used regular expressios as the uderlyig otatio For parsig, we use cotext-free grammars i much the same way Regular expressios are ot powerful eough Ituitively, ca t express balace/estig (a b, pares) More geeral grammars are more powerful tha we eed Well, we could use more power, but istead we delay some checkig to sematic aalysis istead of doig all the aalysis based o the (geeral, but slow) grammar 5 CFG termiology Termials: alphabet, or set of legal tokes Notermials: represet abstract sytax uits Productios: rules defiig otermials i terms of a fiite sequece of termials ad otermials Start symbol: root symbol defiig the laguage Program ::= Stmt Stmt ::= if Expr the Stmt else Stmt ed Stmt ::= while Expr do Stmt ed 6 CSE401, Sp '03, L. Syder ad UW CSE
2 EBNF descriptio of PL/0 Program ::= module Id Block Id. Block ::= DeclList begi StmtList ed DeclList ::= { Decl Decl ::= CostDecl ProcDecl VarDecl CostDecl ::= cost CostDeclItem {, CostDeclItem CostDeclItem ::= Id : Type = CostExpr CostExpr ::= Id Iteger VarDecl ::= var VarDeclItem {, VarDeclItem VarDeclItem ::= Id : Type EBNF descriptio of PL/0 ProcDecl ::= procedure Id ( [ FormalDecl {, FormalDecl ] ) Block Id FormalDecl ::= Id : Type Type ::= it StmtList ::= { Stmt Stmt ::= CallStmt AssigStmt OutStmt IfStmt WhileStmt CallStmt ::= Id ( [ Exprs ] ) AssigStmt ::= Lvalue := Expr Lvalue ::= Id 7 8 EBNF descriptio of PL/0 Exercise: produce a sytax tree for squares.0 OutStmt ::= output := Expr IfStmt ::= if Test the StmtList ed WhileStmt ::= while Test do StmtList ed Test ::= odd Sum Sum Relop Sum Relop ::= <= <> < >= > = Exprs ::= Expr {, Expr Expr ::= Sum Sum ::= Term { (+ -) Term Term ::= Factor { (* /) Factor Factor ::= - Factor LValue Iteger iput ( Expr ) 9 module mai var x:it, squareret:it procedure square(:it) begi squareret := * ed square begi x := iput while x <> 0 do square(x) output := squareret x := iput ed ed mai. 10 Derivatios ad parsig Derivatio A sequece of expasio steps, Begiig with the start symbol, Leadig to a strig of termials Parsig: iverse of derivatio Give a target strig of termials, Recover otermials/productios represetig structure Parse trees We represet derivatios ad parses as parse trees Cocrete sytax tree Exact reflectio of the grammar Abstract sytax tree Simplified versio, reflectig key structural iformatio E.g., omit superfluous puctuatio & keywords CSE401, Sp '03, L. Syder ad UW CSE
3 a := 3 *(4+5) Cocrete Sytax Tree AStmt Lval := Expr a (Id) Sum Term Fact * Fact ( Expr ) 3 (it) Sum Term + Term 4 (it) 5 (it) Abstract sytax trees Cocrete sytax tree Abstract sytax tree a := 3 *(4+5) AStmt Lval := Expr a (Id) Sum Term Fact 3 (it) * Fact Expr ( ) Sum := a * Term + Term 13 4 (it) 5 (it) 14 Ex: A expressio grammar Ambiguity E ::= E Op E - E ( E ) it Op ::= + - * / Usig this grammar, fid parse trees for: 3 * * 5 Some grammars are ambiguous Differet parse trees with the same fial strig (Some laguages are ambiguous, with o possible o-ambiguous grammar but we avoid them) The structure of the parse tree captures some of the meaig of a program Ambiguity is bad sice it implies multiple possible meaigs for the same program Cosider the example o the previous slide Aother famous ambiguity: daglig else Stmt ::= if Expr the Stmt if Expr the Stmt else Stmt if e1 the if e2 the s1 else s2 To which the does the else belog? The compiler is t goig to be cofused However, if the compiler chooses a meaig differet from what the programmer iteded, it could get ugly Ay ideas for overcomig this problem? Resolvig ambiguity: #1 Œ Add a meta-rule For istace, else associates with the closest previous umatched if This works ad keeps the origial grammar itact But it s ad hoc ad iformal CSE401, Sp '03, L. Syder ad UW CSE
4 Resolvig ambiguity: #2 Rewrite the grammar to resolve it explicitly Stmt ::= MatchedStmt UmatchedStmt MatchedStmt ::= if Expr the MatchedStmt else MatchedStmt UmatchedStmt ::= if Expr the Stmt if Expr the MatchStmt else UmatchedStmt Resolvig ambiguity: #2 (cot.) Stmt ::= MatchedStmt UmatchedStmt MatchedStmt ::= if Expr the MatchedStmt else MatchedStmt UmatchedStmt ::= if Expr the Stmt if Expr the MatchStmt else UmatchedStmt Œ Formal, o additioal meta-rules Somewhat more obscure grammar if e1 the if e2 the s1 else s Resolvig ambiguity: #3 Œ Redesig the programmig laguage to remove the ambiguity Stmt ::= if Expr the Stmt ed if Expr the Stmt else Stmt ed Formal, clear, elegat Allows StmtList i the ad else brach, without addig begi/ed Extra ed required for every if statemet What about that expressio grammar? How to resolve its ambiguity? Optio #1: add meta-rules for precedece ad associativity Optio #2: modify the grammar to explicitly resolve the ambiguity Optio #3: redefie the laguage Optio #1: add meta-rules Optio #2: ew BNF E ::= E+T T T ::= T*F F F ::= id (E) Add meta-rules for precedece ad associativity E ::= E+E E-E E*E E/E E^E (E) -E +,- < *,/ < uary - < ^ etc. +,-,*,/ left-associative ^ right associative Simple, ituitive Œ But ot all parsers ca support this yacc does 23 Create a otermial for each precedece level Expr is the lowest precedece otermial Each otermial ca be rewritte with higher precedece operator Highest precedece operator icludes atomic expressios At each precedece level use Left recursio for left-associative operators Right recursio for right-associative operators No recursio for o-associative operators 24 CSE401, Sp '03, L. Syder ad UW CSE
5 Optio #2: example E ::= E+T T T ::= T*F F F ::= id (E) Optio #3: New laguage Require pares E.g., i APL all exprs evaluated left-to-right uless parethesized Forbid pares E.g.: RPN calculators w + x + y * z Desigig a grammar: o what basis? Parsig algorithms Accuracy Readability, clarity Uambiguity Limitatios of CFGs Similarity to desired AST structure Ability to be parsed by a particular parsig algorithm Top-dow parser => LL(k) grammar Bottom-up parser => LR(k) grammar Give iput (sequece of tokes) ad grammar, how do we fid a AST that represets the structure of the iput with respect to that grammar? Two basic kids of algorithms Top-dow: expad from grammar s start symbol util a legal program is produced Bottom-up: create sub-trees that are merged ito larger sub-trees, fially leadig to the start symbol Top-dow parsig Predictive parser Build AST from top (start symbol) to leaves (termials) Represets a leftmost derivatio (e.g., always expad leftmost otermial) Basic issue: whe replacig a o-termial with a right-had side (rhs), which rhs should you use? Basic solutio: Look at ext iput tokes Stmt ::= Call Assig If Call ::= Id Assig::= Id := Expr If ::= if Test the Stmts ed If ::= if Test the Stmts else Stmts ed 29 A top-dow parser that ca select the correct rhs lookig at the ext k tokes (lookahead) Efficiet No backtrackig is eeded Liear time to parse Implemetatio Table-drive: pushdow automato (PDA) like table-drive FSA plus stack for recursive FSA calls Recursive-descet parser [used i PL/0] Each o-termial parsed by a procedure Call other procedures to parse sub-o-termials, recursively 30 CSE401, Sp '03, L. Syder ad UW CSE
6 LL(k), LR(k),? These parsers have geerally sazzy ames The simpler oes look like the oes i the title of this slide The first L meas process tokes left to right The secod letter meas produce a (Right / Left)most derivatio Leftmost => top-dow Rightmost => bottom-up The k meas k tokes of lookahead We wo t discuss LALR(k), SLR, ad lots more parsig algorithms 31 LL(k) grammars It s easy to costruct a predictive parser if a grammar is LL(k) Left-to-right sca o iput, Leftmost derivatio, k tokes of lookahead Restrictios iclude Uambiguous No commo prefixes of legth k No left recursio (more details later) Collectively, the restrictios guaratee that, give k iput tokes, oe ca always select the correct rhs to expad Commo prefix S ::= if Test the Stmts ed if Test the Stmts else Stmts ed Left recursio E ::= E op E 32 Elimiatig commo prefixes Elimiatig left recursio: Œ Left factor them, creatig a ew o-termial for the commo prefix ad/or differet suffixes Before If ::= if Test the Stmts ed if Test the Stmts else Stmts ed After If ::= if Test the Stmts IfCot IfCot ::= ed else Stmts ed Grammar is a bit uglier Easy to do maually i a recursive-descet parser Before E ::= E + T T T ::= T * F F F ::= id ( E ) After E ::= T ECot ECot ::= + T ECot T ::= F TCot TCot ::= * F TCot F ::= id ( E ) Just add sugar Œ E ::= T { + T T ::= F { * F F ::= id ( E ) Sugared form is still pretty readable Easy to implemet i had-writte recursive descet parser Cocrete sytax tree is ot as close to abstract sytax tree LL(1) Parsig Theory Goal: Formal, rigorous descriptio of those grammars for which I ca figure out how to do a top-dow parse by lookig ahead just oe toke, plus correspodig algorithms. Notatio: T = Set of Termials (Tokes) N = Set of Notermials $ = Ed-of-file character (T-like, but ot i N T) CSE401, Sp '03, L. Syder ad UW CSE
7 Table-drive predictive parser Example 1 Automatically compute PREDICT table from grammar PREDICT(otermial,iput-symbol) Ł actio, e.g. which rhs or error Stmt ::= if expr the Stmt else Stmt while Expr do Stmt begi Stmts ed Stmts ::= Stmt Stmts Expr ::= id if the else while do begi ed id $ Stmt Stmts Expr 37 empty = error 38 LL(1) Parsig Algorithm Costructig PREDICT: overview push S$ /* S is start symbol */ while Stack ot empty X := pop(stack) a := peek at ext toke /* assume EOF = $ */ if X is termial or $ If X==a, read toke a else abort else look at PREDICT(X, a) /* X is otermial */ Empty : abort rule X : push Compute FIRST set for each rhs All tokes that ca appear first i a derivatio from that rhs I case rhs ca be empty, compute FOLLOW set for each o-termial All tokes that ca appear right after that otermial i a derivatio Costructios of FIRST ad FOLLOW sets are iterdepedet PREDICT depeds o both If ot at ed of iput, abort Example 1 (cot.) FIRST() 1 st toke from S ::= if E the S else S while E do S FIRST FOLLOW Defiitio: For ay strig of termials ad otermials, FIRST() is the set of termials that begi strigs derived from, together with, if ca derive. More precisely: begi Ss ed Ss ::= S Ss E ::= id For ay (N T)*, FIRST() = { a T * a for some (N T)* {, if * CSE401, Sp '03, L. Syder ad UW CSE
8 Computig FIRST 4 cases 1. FIRST() = { 2. For all a T, FIRST(a) = {a 3. For all A N, repeat util o chage If there is a rule A, add() to FIRST(A) For all rules A Y 1 Y k add(first(y 1 ) - {) if FIRST(Y 1 ) the add(first(y 2 ) - {) if FIRST(Y 1 Y 2 ) the add(first(y 3 ) - {) if FIRST(Y 1 Y 2...Y k ) the add() 43 Computig FIRST (Cot.) 4. For all ay strig Y 1 Y k (N T)*, similar: add(first(y 1 ) - {) if FIRST(Y 1 ) the add(first(y 2 ) - {) if FIRST(Y 1 Y 2 ) the add(first(y 3 ) - {) if FIRST(Y 1 Y 2...Y k ) the add() [Note: defied for all strigs really oly care about FIRST(right had sides).] 44 FOLLOW(B) Next toke after B Defiitio: for ay o-termial B, FOLLOW(B) is the set of termials that ca appear immediately after B i some derivatio from the start symbol, together with $, if B ca be the ed of such a derivatio. ($ represets ed of iput.) More precisely: For all B N, FOLLOW(B) = { a (T {$) S$*B a for some, (N T {$)* (S is the Start symbol of the grammar.) 45 Computig FOLLOW(B) Add $ to FOLLOW(S) Repeat util o chage For all rules A B [i.e. all rules with a B i r.h.s], Add (FIRST( ) - {) to FOLLOW(B) If FIRST( ) [i particular, if is empty] the Add FOLLOW(A) to FOLLOW(B) Assume for all A that S * A for some, (N T)*, else A irrelevat 46 PREDICT Give lhs, which rhs? For all rules A For all a FIRST() - { Add(A ) to PREDICT(A,a) If FIRST() the For all b FOLLOW(A) Add(A ) to PREDICT(A,b) Def: G is LL(1) iff every cell has 1 etry 47 Properties of LL(1) Grammars Clearly, give a coflict-free PREDICT table ( 1 etry/cell), the parser will do somethig uique with every iput Key fact is, if the table is built as above, that somethig is the correct thig I.e., the PREDICT table will reliably guide the LL(1) parsig algorithm so that it will Fid a derivatio for every strig i the laguage Declare a error o every strig ot i the laguage 48 CSE401, Sp '03, L. Syder ad UW CSE
9 Exercises (1 st especially recommeded) Easy: Pick some grammar with commo prefixes, left recursio, ad/or ambiguity. Build PREDICT it will have coflicts Harder: prove that every grammar with 1 of those properties will have PREDICT coflicts Harder: Fid a grammar with oe of those features that evertheless gives coflicts. I.e., absece of those features is ecessary but ot sufficiet for a grammar to be LL(1). Harder, for theoryheads: if the table has coflicts, ad the parser chooses amog them odetermiistically, it will work correctly 49 Example 2 E ::= T { + T T ::= F { * F F ::= - F id ( E ) E ::= T E E ::= + T E T ::= F T T ::= * F T F ::= - F id ( E ) Sugared Usugared 50 Example 2 (cot.) Example 2: PREDICT E ::= T E FIRST FOLLOW id + - * / ( ) $ E ::= + T E T ::= F T E E T ::= * F T F ::= - F T T id ( E ) F PREDICT ad LL(1) Recursive descet parsers The PREDICT table has at most oe etry i each cell if ad oly if the grammar is LL(1) there is oly oe choice (it s predictive), makig it fast to parse ad easy to implemet Multiple etries i a cell Arise with left recursio, ambiguity, commo prefixes, etc. Ca patch by had, if you kow what to do Or use more powerful parser (LL(2), or LR(k), or?) Or chage the grammar Write procedure for each o-termial Each procedure selects the correct right-had side by peekig at the iput tokes The the r.h.s. is cosumed If it s a termial symbol, verify it is ext ad the advace through the toke stream If it s a o-termial, call correspodig procedure Build ad retur AST represetig the r.h.s CSE401, Sp '03, L. Syder ad UW CSE
10 Recursive descet example Stmt ::= if expr the Stmt else Stmt while Expr do Stmt begi Stmts ed Stmts ::= Stmt Stmts Expr ::= id ParseStmt() { switch (ext toke) { "begi": ParseStmts()read "ed" break "while": ParseExpr() read "do" ParseStmt() break "if": ParseExpr() read "the" ParseStmt() read "else" ParseStmt() break default: abort 55 LL(1) ad Recursive Descet If the grammar is LL(1), it s easy to build a recursive descet parser Oe otermial/row oe procedure Use 1 toke lookahead to decide which rhs Table-drive parser's stack recursive call stack Recursive descet ca hadle some o-ll(1) features, too. 56 Example LL(1) & recursive descet Stmt Stmts Expr if the else while do begi ed id $ Example o-ll(1) & recursive descet Stmt Stmts Expr if the else while do begi ed id $ Stmt ::= if expr the Stmt else Stmt while Expr do Stmt begi Stmts ed Stmts ::= Stmt Stmts Expr ::= id ParseStmt() { switch (ext toke) { "begi": ParseStmts()read "ed" break "while": ParseExpr() read "do" ParseStmt() break "if": ParseExpr() read "the" ParseStmt() read "else" ParseStmt() break default: abort 57 Stmt ::= if expr the Stmt if expr the Stmt else Stmt while Expr do Stmt begi Stmts ed Stmts ::= Expr ::= Stmt Stmts id The daglig else ambiguity & commo prefixes ParseStmt() { switch (ext toke) { "if": ParseExpr() read "the" ParseStmt() if(ext toke == "else") {read "else" ParseStmt() break "begi": It s demo time Let s look at some of the PL/0 code to see how the recursive descet parsig works i practice 59 Parser::ParseStmts() <stmt list> ::= { <stmt> <stmt> ::= <id stmt> <out stmt> <if stmt> <while stmt> StmtArray* Parser::ParseStmts() { StmtArray* stmts = ew StmtArray Stmt* stmt for () { Toke t = scaer->peek() switch (t->kid()) { case IDENT: stmt = ParseIdetStmt() break case OUTPUT: stmt = ParseOutputStmt() break case IF: stmt = ParseIfStmt() break case WHILE: stmt = ParseWhileStmt() break default: retur stmts // o more stmts stmts->add(stmt) scaer->read(semicolon) 60 CSE401, Sp '03, L. Syder ad UW CSE
11 Parser::ParseIfStmt() <if stmt> ::= if <test> the <stmt list> ed <while stmt> ::= while <test> do <stmt list> ed Parser::ParseWhileStmt() Stmt* Parser::ParseIfStmt() { scaer->read(if) Expr* test = ParseTest() scaer->read(then) StmtArray* stmts = ParseStmts() scaer->read(end) retur ew IfStmt(test, stmts) Stmt* Parser::ParseWhileStmt() { scaer->read(while) Expr* test = ParseTest() scaer->read(do) StmtArray* stmts = ParseStmts() scaer->read(end) retur ew WhileStmt(test, stmts) Parser:: ParseIdetStmt() <id stmt> ::= <call stmt> <assig stmt> <call stmt> ::= IDENT "(" [ <exprs> ] ")" <assig stmt>::= <lvalue> := <expr> <lvalue> ::= IDENT Parser::ParseSum() <sum> ::= <term> { (+ -) <term> Stmt* Parser:: ParseIdetStmt() { Toke* id = scaer->read(ident) if (scaer->codread(lparen)){ ExprArray* args if (scaer->codread(rparen)){ args = NULL else { args = ParseExprs() scaer->read(rparen) retur ew CallStmt(id->idet(), args) else { LValue* lvalue = ew VarRef(id->idet()) scaer->read(gets) retur ew AssigStmt(lvalue, ParseExpr()) 63 Expr* Parser::ParseSum() { Expr* expr = ParseTerm() for () { Toke* t = scaer->peek() if (t->kid() == PLUS t->kid() == MINUS) { scaer->get() // eat the toke Expr* expr2 = ParseTerm() expr = ew BiOp(t->kid(), expr, expr2) else { retur expr 64 <term> ::= <factor> { (* /) <factor> Parser::ParseTerm() Yacc A bottom-up-parser geerator Expr* Parser::ParseTerm() { Expr* expr = ParseFactor() for () { Toke* t = scaer->peek() if (t->kid() == MUL t->kid() == DIVIDE) { scaer->get() // eat the toke Expr* expr2 = ParseFactor() expr = ew BiOp(t->kid(), expr, expr2) else { retur expr 65 yet aother compiler-compiler Iput: grammar, possibly augmeted with actio code Output: C code to parse it ad perform actios LALR(1) parser geerator practical bottom-up parser more powerful tha LL(1) moder updates of yacc yacc++, biso, byacc, 66 CSE401, Sp '03, L. Syder ad UW CSE
12 Yacc iput grammar Example Yacc with actios assigstmt: IDENT GETS expr ifstmt: IF test THEN stmts END IF test THEN stmts ELSE stmts END expr: term expr '+' term expr '-' term factor: '-' factor IDENT INTEGER INPUT '(' expr ')' 67 assigstmt: IDENT GETS expr { $$ = ew AssigStmt($1, $3) ifstmt: IF be THEN stmts END { $$ = ew IfStmt($2,$4,NULL) IF be THEN stmts ELSE stmts END { $$ = ew IfStmt($2,$4,$6) expr: term { $$ = $1 expr '+' term { $$ = ew BiOp(PLUS, $1, $3) expr '-' term { $$ = ew BiOp(MINUS, $1, $3) factor: '-' factor { $$ = ew UOp(MINUS, $2) IDENT { $$ = ew VarRef($1) INTEGER { $$ = ew ItLiteral($1) INPUT { $$ = ew IputExpr '(' expr ')' { $$ = $2 68 Parsig summary Parsig summary Techical details you should kow Discover/impose a useful (hierarchical) structure o flat toke sequece Represeted by Abstract Sytax Tree Validity check sytax of iput Could build cocrete sytax tree (but do't) May methods available Top-dow: LL(1)/recursive descet commo for simple, by-had projects Bottom-up: LR(1)/LALR(1)/SLR(1) commo for more complex projects parser geerator (e.g., yacc) almost ecessary Cotext-free grammars Defiitios Maipulatios (algorithmic) Left factor commo prefixes Elimiatig left recursio Ambiguity & (semiheuristic) fixes meta-rules (code/ precedece tables) rewrite grammar chage laguage Buildig a table-drive predictive parser LL(1) grammar: defiitio & commo obstacles PREDICT(otermial, iput symbol) FIRST(RHS) FOLLOW(otermial) Buildig a recursive descet parser Icludig AST Objectives: today Ambiguity Issues i desigig a grammar AST extesios for the 401 project Overview of parsig algorithms Motivatio ad details of top-dow, predictive parsers Recursive descet parsig Today++: a walk through the PL/0 parser Objectives: today Recap ad clarify PREDICT table Describe computatio of FIRST ad FOLLOW Ad the relatioship to PREDICT Recursive descet parsig High-level issues ad (time-permittig) a walk through the PL/0 parser CSE401, Sp '03, L. Syder ad UW CSE
13 Program ::= module Id Block Id. Block ::= DeclList begi StmtList ed DeclList ::= { Decl Decl ::= CostDecl ProcDecl VarDecl CostDecl ::= cost CostDeclItem {, CostDeclItem CostDeclItem ::= Id : Type = CostExpr CostExpr ::= Id Iteger VarDecl ::= var VarDeclItem {, VarDeclItem VarDeclItem ::= Id : Type ProcDecl ::= procedure Id ( [ FormalDecl {, FormalDecl ] ) Block Id FormalDecl ::= Id : Type Type ::= it StmtList ::= { Stmt Stmt ::= CallStmt AssigStmt OutStmt IfStmt WhileStmt CallStmt ::= Id ( [ Exprs ] ) AssigStmt ::= Lvalue := Expr Lvalue ::= Id OutStmt ::= output := Expr IfStmt ::= if Test the StmtList ed WhileStmt ::= while Test do StmtList ed Test ::= odd Sum Sum Relop Sum Relop ::= <= <> < >= > = Exprs ::= Expr {, Expr Expr ::= Sum Sum ::= Term { (+ -) Term Term ::= Factor { (* /) Factor Factor ::= - Factor LValue Iteger iput ( Expr ) EBNF descriptio of PL/0 73 AST extesios i project Expressios true ad false costats array idex expressio (a lvalue) fuctio call expressio ad ad or operators tests are expressios costat expressios Statemets Declaratios procedures with result types var parameters Types bool array for break retur if with else 74 if id the begi ed else while id do begi ed ed Productio applied Stmt 1. if Expr the Stmt else Stmt ed 6. if id the Stmt else Stmt ed 3. if id the begi Stmts ed else Stmt ed 5. if id the begi ed else Stmt ed 2. if id the begi ed else while Expr do Stmt ed 6. if id the begi ed else while id do Stmt ed 3. if id the begi ed else while id do begi Stmts ed ed 5. if id the begi ed else while id do begi ed ed 75 CSE401, Sp '03, L. Syder ad UW CSE
n Theory and practice of parsing n Underlying language theory (CFGs,...) n Top-down parsing (and be able to do it)
Objectives: parsig lectures CSE401: Parsig Adrei Alexadrescu Autum 2002 Slides by Chambers, Eggers, Notki, Ruzzo, ad others W.L.Ruzzo & UW CSE 1994-2002 Uderstad: Theory ad practice of parsig Uderlyig
More informationSyntax Analysis/Parsing. Context-free grammars (CFG s) Context-free grammars vs. Regular Expressions. BNF description of PL/0 syntax
Susan Eggers 1 CSE 401 Syntax Analysis/Parsing Context-free grammars (CFG s) Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax
More informationContext-free grammars (CFG s)
Syntax Analysis/Parsing Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax tree (AST) AST: captures hierarchical structure of
More informationToday s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?
CSE401: Itroductio to Compiler Costructio Larry Ruzzo Sprig 2004 Today s objectives Admiistrative details Defie compilers ad why we study them Defie the high-level structure of compilers Associate specific
More informationSolutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer
Departmet of Computer ciece Columbia Uiversity olutios to Fial COM W45 Programmig Laguages ad Traslators Moday, May 4, 2009 4:0-5:25pm, 309 Havemeyer Closed book, o aids. Do questios 5. Each questio is
More informationRecursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames
Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of
More informationn Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis
Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig
More informationCS 11 C track: lecture 1
CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material
More informationHow do we evaluate algorithms?
F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:
More information10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output
File class i Java File Iput ad Output TOPICS File Iput Exceptio Hadlig File Output Programmers refer to iput/output as "I/O". The File class represets files as objects. The class is defied i the java.io
More informationChapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists
More informationn Bottom-up (LR) parsing n Handle n LR item n Characteristic Finite State Machine (CFSM) n SLR(1) parsing tables n Conflicts in SLR(1)
Aoucemets Quiz Hold o to paper, brig over at the ed HW due tomorrow (exteded 1 day) We have office hours -7pm today Dowload SWI Prolog! HW3 will be posted toight or tomorrow Prolog Due Fray, Sep 8 at pm
More informationtop() Applications of Stacks
CS22 Algorithms ad Data Structures MW :00 am - 2: pm, MSEC 0 Istructor: Xiao Qi Lecture 6: Stacks ad Queues Aoucemets Quiz results Homework 2 is available Due o September 29 th, 2004 www.cs.mt.edu~xqicoursescs22
More informationCS211 Fall 2003 Prelim 2 Solutions and Grading Guide
CS11 Fall 003 Prelim Solutios ad Gradig Guide Problem 1: (a) obj = obj1; ILLEGAL because type of referece must always be a supertype of type of object (b) obj3 = obj1; ILLEGAL because type of referece
More informationChapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4
More informationPseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance
Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured
More informationChapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4
More informationAnalysis of Algorithms
Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite
More informationLecture 1: Introduction and Strassen s Algorithm
5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access
More information9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence
_9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to
More informationCOSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1
COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programmig Laguages Fuctioal Programmig Prof. Robert va Egele Overview What is fuctioal programmig? Historical origis of fuctioal programmig Fuctioal programmig today Cocepts of fuctioal programmig
More informationthe beginning of the program in order for it to work correctly. Similarly, a Confirm
I our sytax, a Assume statemet will be used to record what must be true at the begiig of the program i order for it to work correctly. Similarly, a Cofirm statemet is used to record what should be true
More informationCS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions
CS 111: Program Desig I Lecture # 7: First Loop, Web Crawler, Fuctios Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago September 18, 2018 What will this prit? x = 5 if x == 3: prit("hi!")
More informationCOP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen
COP4020 mig Laguages Compilers ad Iterpreters Prof. Robert va Egele Overview Commo compiler ad iterpreter cofiguratios Virtual machies Itegrated developmet eviromets Compiler phases Lexical aalysis Sytax
More informationLecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming
Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis
More information1.2 Binomial Coefficients and Subsets
1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =
More informationOutline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis
Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis
More informationModule 8-7: Pascal s Triangle and the Binomial Theorem
Module 8-7: Pascal s Triagle ad the Biomial Theorem Gregory V. Bard April 5, 017 A Note about Notatio Just to recall, all of the followig mea the same thig: ( 7 7C 4 C4 7 7C4 5 4 ad they are (all proouced
More informationChapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to
More informationRunning Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments
Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The
More informationCYK Algorithm Adapted to the Penttonen Normal Form
http://excel.fit.vutbr.cz CYK Algorithm Adapted to the Pettoe Normal Form Domiika Klobučíková* Abstract This paper deals with the topic of cotext-sesitive grammars as special cases of urestricted grammars,
More informationWhat are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs
What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure
More informationRunning Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments
Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.
More informationAnalysis of Algorithms
Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The
More informationChapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,
More informationCIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19
CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.
More informationcondition w i B i S maximum u i
ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility
More informationCIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13
CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis
More informationChapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig
More informationData Structures and Algorithms. Analysis of Algorithms
Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output
More informationCSC 220: Computer Organization Unit 11 Basic Computer Organization and Design
College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:
More informationCSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)
CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a
More informationAbstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:
Chapter 4 Computatio Bjare Stroustrup www.stroustrup.com/programmig Abstract Today, I ll preset the basics of computatio. I particular, we ll discuss expressios, how to iterate over a series of values
More informationExceptions. Your computer takes exception. The Exception Class. Causes of Exceptions
Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:
More informationPolynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0
Polyomial Fuctios ad Models 1 Learig Objectives 1. Idetify polyomial fuctios ad their degree 2. Graph polyomial fuctios usig trasformatios 3. Idetify the real zeros of a polyomial fuctio ad their multiplicity
More informationLecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein
068.670 Subliear Time Algorithms November, 0 Lecture 6 Lecturer: Roitt Rubifeld Scribes: Che Ziv, Eliav Buchik, Ophir Arie, Joatha Gradstei Lesso overview. Usig the oracle reductio framework for approximatig
More informationRecursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:
Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical
More informationCOMP Parallel Computing. PRAM (1): The PRAM model and complexity measures
COMP 633 - Parallel Computig Lecture 2 August 24, 2017 : The PRAM model ad complexity measures 1 First class summary This course is about parallel computig to achieve high-er performace o idividual problems
More informationAssignment 5; Due Friday, February 10
Assigmet 5; Due Friday, February 10 17.9b The set X is just two circles joied at a poit, ad the set X is a grid i the plae, without the iteriors of the small squares. The picture below shows that the iteriors
More informationThe Magma Database file formats
The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,
More informationCMPT 125 Assignment 2 Solutions
CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address
More informationGE FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III
GE2112 - FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III PROBLEM SOLVING AND OFFICE APPLICATION SOFTWARE Plaig the Computer Program Purpose Algorithm Flow Charts Pseudocode -Applicatio Software Packages-
More informationComputational Geometry
Computatioal Geometry Chapter 4 Liear programmig Duality Smallest eclosig disk O the Ageda Liear Programmig Slides courtesy of Craig Gotsma 4. 4. Liear Programmig - Example Defie: (amout amout cosumed
More informationFrom last week. Lecture 5. Outline. Principles of programming languages
Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for
More informationAbstract Syntax Trees. AST Data Structure. Visitor Interface. Accept methods. Visitor Methodology for AST Traversal CS412/CS413
Abstract Syta Trees CS412/CS413 Itroductio to Copilers Ti Teitelbau Lecture 12: Visitors; Sybol Tables February 18, 2005 Separate AST costructio fro seatic checkig phase Traverse the AST ad perfor seatic
More informationCSE 417: Algorithms and Computational Complexity
Time CSE 47: Algorithms ad Computatioal Readig assigmet Read Chapter of The ALGORITHM Desig Maual Aalysis & Sortig Autum 00 Paul Beame aalysis Problem size Worst-case complexity: max # steps algorithm
More informationSyntactic Analysis. Syntactic analysis, or parsing, is the second phase of compilation: The token file is converted to an abstract syntax tree.
Syntactic Analysis Syntactic analysis, or parsing, is the second phase of compilation: The token file is converted to an abstract syntax tree. Compiler Passes Analysis of input program (front-end) character
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 19 Query Optimizatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Query optimizatio Coducted by a query optimizer i a DBMS Goal:
More informationSolution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:
CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed
More informationCOP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen
COP4020 Programmig Laguages Subrouties ad Parameter Passig Prof. Robert va Egele Overview Parameter passig modes Subroutie closures as parameters Special-purpose parameters Fuctio returs COP4020 Fall 2016
More informationIntroduction to Sigma Notation
Itroductio to Siga Notatio Steph de Silva //207 What is siga otatio? is the capital Greek letter for the soud s I this case, it s just shorthad for su Siga otatio is what we use whe we have a series of
More informationCHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs
CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics
More informationParsing. Roadmap. > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing
Roadmap > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing The role of the parser > performs context-free syntax analysis > guides
More informationClasses and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1
Classes ad Objects jvo@ualg.pt José Valete de Oliveira 4-1 Agai: Distace betwee poits withi the first quadrat Sample iput Sample output 1 1 3 4 2 jvo@ualg.pt José Valete de Oliveira 4-2 1 The simplest
More informationLecture 5. Counting Sort / Radix Sort
Lecture 5. Coutig Sort / Radix Sort T. H. Corme, C. E. Leiserso ad R. L. Rivest Itroductio to Algorithms, 3rd Editio, MIT Press, 2009 Sugkyukwa Uiversity Hyuseug Choo choo@skku.edu Copyright 2000-2018
More informationParabolic Path to a Best Best-Fit Line:
Studet Activity : Fidig the Least Squares Regressio Lie By Explorig the Relatioship betwee Slope ad Residuals Objective: How does oe determie a best best-fit lie for a set of data? Eyeballig it may be
More informationChapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 2 C++ Basics Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 2.1 Variables ad Assigmets 2.2 Iput ad Output 2.3 Data Types ad Expressios 2.4 Simple Flow of Cotrol 2.5 Program
More informationMonday, September 13, Parsers
Parsers Agenda Terminology LL(1) Parsers Overview of LR Parsing Terminology Grammar G = (Vt, Vn, S, P) Vt is the set of terminals Vn is the set of non-terminals S is the start symbol P is the set of productions
More informationOnes Assignment Method for Solving Traveling Salesman Problem
Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:
More informationHash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Hash Tables xkcd. http://xkcd.com/221/. Radom Number. Used with permissio uder Creative
More informationA SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON
A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON Roberto Lopez ad Eugeio Oñate Iteratioal Ceter for Numerical Methods i Egieerig (CIMNE) Edificio C1, Gra Capitá s/, 08034 Barceloa, Spai ABSTRACT I this work
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies
More informationAdministrative UNSUPERVISED LEARNING. Unsupervised learning. Supervised learning 11/25/13. Final project. No office hours today
Admiistrative Fial project No office hours today UNSUPERVISED LEARNING David Kauchak CS 451 Fall 2013 Supervised learig Usupervised learig label label 1 label 3 model/ predictor label 4 label 5 Supervised
More informationComputers and Scientific Thinking
Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput
More informationBig-O Analysis. Asymptotics
Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses
More information15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015
15-859E: Advaced Algorithms CMU, Sprig 2015 Lecture #2: Radomized MST ad MST Verificatio Jauary 14, 2015 Lecturer: Aupam Gupta Scribe: Yu Zhao 1 Prelimiaries I this lecture we are talkig about two cotets:
More informationA graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n))
ca see that time required to search/sort grows with size of We How do space/time eeds of program grow with iput size? iput. time: cout umber of operatios as fuctio of iput Executio size operatio Assigmet:
More informationAppendix D. Controller Implementation
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);
More informationTask scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation
6-0-0 Kowledge Trasformatio from Task Scearios to View-based Desig Diagrams Nima Dezhkam Kamra Sartipi {dezhka, sartipi}@mcmaster.ca Departmet of Computig ad Software McMaster Uiversity CANADA SEKE 08
More informationprerequisites: 6.046, 6.041/2, ability to do proofs Randomized algorithms: make random choices during run. Main benefits:
Itro Admiistrivia. Sigup sheet. prerequisites: 6.046, 6.041/2, ability to do proofs homework weekly (first ext week) collaboratio idepedet homeworks gradig requiremet term project books. questio: scribig?
More informationCompiler Passes. Syntactic Analysis. Context-free Grammars. Syntactic Analysis / Parsing. EBNF Syntax of initial MiniJava.
Syntactic Analysis Syntactic analysis, or parsing, is the second phase of compilation: The token file is converted to an abstract syntax tree. Compiler Passes Analysis of input program (front-end) character
More informationElementary Educational Computer
Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified
More informationExamples and Applications of Binary Search
Toy Gog ITEE Uiersity of Queeslad I the secod lecture last week we studied the biary search algorithm that soles the problem of determiig if a particular alue appears i a sorted list of iteger or ot. We
More informationThe number n of subintervals times the length h of subintervals gives length of interval (b-a).
Simulator with MadMath Kit: Riema Sums (Teacher s pages) I your kit: 1. GeoGebra file: Ready-to-use projector sized simulator: RiemaSumMM.ggb 2. RiemaSumMM.pdf (this file) ad RiemaSumMMEd.pdf (educator's
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 20 Itroductio to Trasactio Processig Cocepts ad Theory Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Trasactio Describes local
More informationCS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June
CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that
More informationThompson s Group F (p + 1) is not Minimally Almost Convex
Thompso s Group F (p + ) is ot Miimally Almost Covex Claire Wladis Thompso s Group F (p + ). A Descriptio of F (p + ) Thompso s group F (p + ) ca be defied as the group of piecewiseliear orietatio-preservig
More information. Written in factored form it is easy to see that the roots are 2, 2, i,
CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or
More informationTerm Project Report. This component works to detect gesture from the patient as a sign of emergency message and send it to the emergency manager.
CS2310 Fial Project Loghao Li Term Project Report Itroductio I this project, I worked o expadig exercise 4. What I focused o is makig the real gesture recogizig sesor ad desig proper gestures ad recogizig
More informationOverview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup
Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates
More informationOne advantage that SONAR has over any other music-sequencing product I ve worked
*gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig
More informationn Maurice Wilkes, 1949 n Organize software to minimize errors. n Eliminate most of the errors we made anyway.
Bjare Stroustrup www.stroustrup.com/programmig Chapter 5 Errors Abstract Whe we program, we have to deal with errors. Our most basic aim is correctess, but we must deal with icomplete problem specificatios,
More informationAPPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS
APPLICATION NOTE PACE175AE BUILT-IN UNCTIONS About This Note This applicatio brief is iteded to explai ad demostrate the use of the special fuctios that are built ito the PACE175AE processor. These powerful
More informationRecursive Procedures. How can you model the relationship between consecutive terms of a sequence?
6. Recursive Procedures I Sectio 6.1, you used fuctio otatio to write a explicit formula to determie the value of ay term i a Sometimes it is easier to calculate oe term i a sequece usig the previous terms.
More informationWednesday, September 9, 15. Parsers
Parsers What is a parser A parser has two jobs: 1) Determine whether a string (program) is valid (think: grammatically correct) 2) Determine the structure of a program (think: diagramming a sentence) Agenda
More informationParsers. What is a parser. Languages. Agenda. Terminology. Languages. A parser has two jobs:
What is a parser Parsers A parser has two jobs: 1) Determine whether a string (program) is valid (think: grammatically correct) 2) Determine the structure of a program (think: diagramming a sentence) Agenda
More informationAnalysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis
Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems
More information