CS 330 Lecture 9 – A Calculator
Agenda
- what ?s
- a grammar
- lexing to get a token stream
TODO
- 1/4 sheet: read chapter 1 in your book.
Code
Basecalc.g
grammar Basecalc;
line
: expr
| expr CAST DIGITS
;
expr
:
LEFT_PARENTHESIS: '(';
RIGHT_PARENTHESIS: ')';
POWER: '^^';
MULTIPLICATIVE_OPERATOR: [*/%];
ADDITIVE_OPERATOR: [-+];
NOT: '~';
SHIFT: '<<' | '>>';
AND: '&';
XOR: '^';
OR: '|';
ASSIGNMENT: ':=';
CAST: '->';
LESS: '<';
GREATER: '>';
IDENTIFIER: '$' [a-z]+ [a-z_]*;
DIGITS: [0-9a-zA-Z]+;
Haiku
on being a witness
Judge, the court grammar!
Not
Judge, the court grammar!
answer -> YES | NO
Not
KINDA SORTA