120 likes | 283 Views
Tabular Parsing. Tabular Parsing. Tabular Parsing Primitive Item : X . for X V Phrase Item : A X . Y for some A XY P. Source string z = z 1 z 2 . . z n where z I Table T i,j contains any primitive item X .
E N D
Tabular Parsing Tabular Parsing Primitive Item : X . for X V Phrase Item : A X . Y for some A XY P. • Source string z = z1 z2 . . zn where zI • Table Ti,j contains any • primitive item X . • for which X zj . . zj+i-1 and any • phrase item A X . Y for which • X zj . . zj+i-1 .
Tabular Parsing Example N. dAn. dA.n d.An d.n d. A. a. . n.
Tabular Parsing Pseudo Code Initialize Table for j = 1 to n, add z1 . to Tij . Process Rest of Table for j = n down to 1 Process jth column for i = 1 to n+j-1 repeat for each completed phrase item A Z. in Ti,j add primitive item A. to Ti,j for each primitive item X. in Ti,j if A XY then add initial phrase item A X . Y to Ti,j for each partial phrase item A X.UY in TI,j , Process( i,j, A X.UY) until no change in Ti,j
Tabular Parsing Pseudo Code Process( i,j, A X.UY ) Let k = i+j Process kth column For p = 1 to n+k-1 for each primitive item U. in Tp,k add extended phrase item A XU.Y to TI+p,j
Tabular Parsing Example An attribute grammar for converting Infix to Postfix Note: Grammar is not LL(1)