teaching machines

CS 330 Lecture 27 – Goodbye, Generics and a Base Calculator

April 7, 2014 by . Filed under cs330, lectures, spring 2014.

Agenda

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;