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.

Bison: rules Section Example<br />

/*** Rules section ***/<br />

statement_list: statement '\n'<br />

| statement_list statement '\n'<br />

statement: NAME '=' expression { $1->value = $3; }<br />

| expression { printf("= %g\n", $1); }<br />

expression: NUMBER<br />

| NAME { $$ = $1->value; }<br />

This is the grammar for bison. It should<br />

look similar to the simple example<br />

grammar from before.<br />

2/17/2012<br />

CAPSL<br />

48

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

Saved successfully!

Ooh no, something went wrong!