CS 330 Lecture 27 – Goodbye, Generics and a Base Calculator
April 7, 2014 by Chris Johnson. Filed under cs330, lectures, spring 2014.
Agenda
- what ?s
- two kinds of polymorphism
- Java’s approach to generics
- our first grammar/interpreter
TODO
Code
Basecalc.g
grammar Basecalc;
line
: expression EOF
;
expression
: LEFT_PARENTHESIS expression RIGHT_PARENTHESIS
| expression MULTIPLICATIVE_OPERATOR expression
| expression ADDITIVE_OPERATOR expression
| DIGITS SEPARATOR DIGITS
| DIGITS
;
LEFT_PARENTHESIS: '(';
RIGHT_PARENTHESIS: ')';
MULTIPLICATIVE_OPERATOR: [*/%];
ADDITIVE_OPERATOR: [-+];
SEPARATOR: '_';
DIGITS: [0-9A-Za-z]+;
WHITESPACE: [ \r\n\t]+ -> skip;