Array Dependence Analysis and Vectorization with the Chains ...

Array Dependence Analysis and Vectorization with the Chains ...

COP4020 Programming Languages Parsing Prof. Xin Yuan Overview Top-down and bottom-up parsing Recursive descent parsing Table driven LL(1) parsing 02/22/20 COP4020 Spring 2014 2 Parsing: The process to determine whether the start symbol can derive the program.

If successful, the program is a valid program. If failed, the program is invalid. Two approaches in general. Expanding from the start symbol to the whole program (top down) Reduction from the whole program to start symbol (bottom up). identifier * identifier + identifier

Top-down parsing build the parse tree from root to leave (using leftmost derivation, why?). Recursive descent parser LL parser First L left to right scan Second L left most derivation Recursive descent parsing associates a procedure with each nonterminal in the grammar, it may require backtracking of the input string. Example: -> | ^ id | array [] of ->integer | char | num dotdot num void type() { if (lookahead == INTEGER || lookahead == CHAR || lookahead==NUM) simple();

else if (lookahead == ^) { match (^); match(ID); } else if (lookahead == ARRAY) { match (ARRAY); match([); simple(); match (]); match (OF); type(); } else error(); } Example: -> | ^ id | array [] of ->integer | char | num dotdot num void simple() { if (lookahead == INTEGER) match (INTEGER); else if (lookahead == CHAR) match (CHAR); else if (lookahead == NUM) { match(NUM); match(DOTDOT); match(NUM); } else error(); } void match(token t) { if (lookahead == t) {lookahead = nexttoken();} else error();

} Recursive descent parsing may require backtracking of the input string try out all productions, backtrack if necessary. E.g S->cAd, A->ab | a input string cad A special case of recursive-descent parser that needs no backtracking is called a predictive parser. Look at the input string, must predict the right production every time to avoid backtracking LL(1) Needs to know what first symbols can be generated by the right side of a production only lookahead for one token

Non recursive predictive parsing (table driven LL(1) parsing) Predictive parser can be implemented by recursive-descent parsing Requirement: by looking at the first terminal symbol that a nonterminal symbol can derive, we should be able to choose the correct production to expand the nonterminal symbol. If the requirement is met, the parser easily be implemented using a non-recursive scheme by building a parsing table. A parsing table example (1) E->TE (2) E->+TE (3) E-> (4) T->FT (5) T->*FT (6) T-> (7) F->(E) (8) F->id

E E T T F id (1) + * ( (1) (2) (4) $ (3) (3) (6) (6)

(4) (6) (8) ) (5) (7) Using the parsing table, the predictive parsing program works like this: A stack of grammar symbols ($ on the bottom) A string of input tokens ($ at the end) A parsing table, M[NT, T] of productions Algorithm: put $ Start on the stack ($ is the end of input string). 1) if top == input == $ then accept 2) if top == input then

pop top of the stack; advance to next input symbol; goto 1; 3) If top is nonterminal if M[top, input] is a production then replace top with the production; goto 1 else error 4) else error Example: (1) E->TE (2) E->+TE (3) E-> (4) T->FT (5) T->*FT (6) T-> (7) F->(E) (8) F->id Stack $E $ET $ETF $ETid $ET ...

E E T T F id (1) + * ( (1) (2) (4) input id+id*id$ id+id*id$ id+id*id$ id+id*id$ +id*id$ $ (3)

(3) (6) (6) (4) (6) (8) ) (5) (7) production E->TE T->FT F->id This produces leftmost derivation: E=>TE=>FTE=>idTE=>.=>id+id*id

Recently Viewed Presentations

  • Hvað eru stjórnmál? - Kafli 15

    Hvað eru stjórnmál? - Kafli 15

    Herforingjastjórn sem kallar sig SLORC eða ráðið fyrir endurreisn laga og reglu í ríkinu hunsaði úrslitin og neitaði að gefa frá sér völdin. 13. kafli. Hvað eru stjórnmál * Burma (bls. 290) Aung San Suu Kyi hefur setið í stofufangelsi...
  • Powerpoint template guide (title)

    Powerpoint template guide (title)

    Survey Questions - Sections. Title presentation. Morcott as a place to live or work . This section looks to gain an understanding of how Morcott residents feel about Morcott as a place to live, what people feel about current services...
  • Oracle Solutions -

    Oracle Solutions -

    The training can be paced to the learning trajectory of your team. Public instructor-led training in our eCapital University training room: ... Oracle Financial Data Management, Enterprise Edition 9. Oracle BI Dashboards and Reports 10.
  • Connective tissue - جامعة الملك سعود

    Connective tissue - جامعة الملك سعود

    procollagen processed by enzymes outside cell. assemble into collagen fibers. ... Elastin is a protein in connective tissue that is elastic and allows many tissues in the body to resume their shape after stretching or contracting. Elastin helps skin to...
  • Las 9s de la Calidad - Ing. José Manuel Poveda

    Las 9s de la Calidad - Ing. José Manuel Poveda

    , a lo que se considera como bueno, noble y honesto; cuando una persona se apega al orden y al control de sus actos está acudiendo a la prudencia, y la inteligencia en su comportamiento se transforma en un generador...
  • Gestational Trophoblastic Neoplasms (GTN)

    Gestational Trophoblastic Neoplasms (GTN)

    The initial histologic features of any lesion identified as GTN are less important than the clinical data and hCG level. Complete Hydatidiform Mole Macroscopically : Edema and swelling of virtually Villi without identifiable fetal parts or amniotic membranes Microscopically: The...
  • SHC PowerPoint Template - Gigaset

    SHC PowerPoint Template - Gigaset

    Arial Wingdings Times New Roman Siemens Sans 新細明體 Template_Siemens_Gigaset_0806061 1_Template_Siemens_Gigaset_0806061 Gigaset DE380 IP R Corded VoIP phone with outstanding speech quality Features Packing First steps Configure the Router via Selfinstaller Tool Selfinstaller Selfinstaller Selfinstaller Configuration Wizard Settings ...
  • Chapter 7: Regions of the US Section 1 - The Northeast

    Chapter 7: Regions of the US Section 1 - The Northeast

    Chapter 7: Regions of the USSection 1 - The Northeast. Titan Blaster #1: List from memory the nine states that form the Northeast. ... The area from Boston to Washington DC is considered a megalopolis of over 40 million people....