12.01.2013 Views

Tutorial Lex/Yacc - capsl

Tutorial Lex/Yacc - capsl

Tutorial Lex/Yacc - capsl

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[0-9]+ {<br />

}<br />

[A-Za-z]+ {<br />

}<br />

Flex Example<br />

/*Code*/<br />

yylval.dval = atof(yytext);<br />

return NUMBER;<br />

Return the token type.<br />

Declared in the .y file.<br />

/*Code*/<br />

struct symtab *sp = symlook(yytext);<br />

yylval.symp = sp;<br />

return WORD;<br />

. { return yytext[0]; }<br />

2/17/2012<br />

CAPSL<br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!