parsing and symbol table
Download
Skip this Video
Download Presentation
Parsing and Symbol Table

Loading in 2 Seconds...

play fullscreen
1 / 6

Parsing and Symbol Table - PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on

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); }

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

PowerPoint Slideshow about ' Parsing and Symbol Table' - genera


An Image/Link below is provided (as is) to download presentation

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
slide2

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;

slide3

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;

slide4

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); }

slide5

vardeclaration(lev,ptx,pdx)

int *ptx,*pdx,lev;

{

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

else error(4);

}

var a,b;

c;

slide6

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)

{

table[*ptx].level=lev; table[*ptx].adr=*pdx;

table[*ptx].indirect=flag; (*pdx)++;

} else /* procedure */ { table[*ptx].level=lev;}}

struct namerecord table[1000];

ad