17.01.2015 Views

S - Intranet - Department of Computer Science: Login

S - Intranet - Department of Computer Science: Login

S - Intranet - Department of Computer Science: Login

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Calculator JavaCup Specification (calc.cup)<br />

terminal PLUS, MINUS, TIMES, DIVIDE, LPAREN, RPAREN;<br />

terminal Integer NUMBER;<br />

non terminal Integer expr;<br />

precedence left PLUS, MINUS;<br />

precedence left TIMES, DIVIDE;<br />

expr ::= expr PLUS expr<br />

| expr MINUS expr<br />

| expr TIMES expr<br />

| expr DIVIDE expr<br />

| LPAREN expr RPAREN<br />

| NUMBER<br />

;<br />

• Is the grammar ambiguous<br />

• How can we get PLUS, NUMBER, ...<br />

– They are the terminals returned by the scanner.<br />

• How to connect with the scanner<br />

62

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

Saved successfully!

Ooh no, something went wrong!