Parsing and Symbol Table

1 / 6

# Parsing and Symbol Table - PowerPoint PPT Presentation

Parsing and Symbol Table. if (sym==constsym) { getsym(); do { constdeclaration(lev,&amp;tx,&amp;dx); while(sym==comma) { getsym(); constdeclaration(lev,&amp;tx,&amp;dx); } if(sym==semicolon)getsym(); else error(5); } while (sym==ident); }

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Parsing and Symbol Table' - genera

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Parsing and Symbol Table

if (sym==constsym) {

getsym();

do {

constdeclaration(lev,&tx,&dx);

while(sym==comma) {

getsym(); constdeclaration(lev,&tx,&dx);

}

if(sym==semicolon)getsym(); else error(5);

} while (sym==ident);

}

if (sym==varsym) {

getsym();

do { vardeclaration(lev,&tx,&dx);

while (sym==comma) {

getsym(); vardeclaration(lev,&tx,&dx);

}

if(sym==semicolon) getsym(); else error(5);

} while(sym==ident);

}

const N = 100, k = 6;

M = 20;

var a,b;

c;

constdeclaration(lev,ptx,pdx)

int lev,*ptx,*pdx;

{

if (sym==ident) {

getsym();

if ((sym==eql) || (sym==becomes)) {

if (sym==becomes) error(1);

getsym();

if (sym==number) {enter(constant,ptx,pdx,lev); getsym();}

}

}

}

const N = 100, k = 6;

M = 20;

while(sym==procsym) {

getsym();

if(sym==ident){ enter(procedure,&tx,&dx,lev); getsym(); }

else error(4);

if (sym==semicolon) getsym();

else if (sym==lparen);

else error(5);

block(lev+1, tx);

if(sym==semicolon) { getsym(); }

else error(5); }

vardeclaration(lev,ptx,pdx)

int *ptx,*pdx,lev;

{

if (sym==ident) {enter(variable, ptx,pdx,lev); getsym();}

else error(4);

}

var a,b;

c;

struct namerecord{

int kind;

char name[10];

int val;

int level; int adr; int indirect; };

enter(k,ptx,pdx,lev)

int k; int *ptx; int *pdx;int lev;

{

char *id1;

int ii,len;

(*ptx)++;

id1=id;

len=strlen(id);

for (ii=0;ii<=len;ii++){table[*ptx].name[ii]=*id1; id1++;}

table[*ptx].kind=k;

if (k==constant) table[*ptx].val=num;

else if (k==variable)

{