CAP/TP02/ariteval/Arit.g4
Emma Nardino ff5f2319ec Add TPO2
2024-09-23 11:04:28 +02:00

28 lines
410 B
ANTLR

grammar Arit;
// MIF08@Lyon1 and CAP@ENSL, arit evaluator
@header {
# header - mettre les déclarations globales
import sys
idTab = {};
class UnknownIdentifier(Exception):
pass
class DivByZero(Exception):
pass
}
prog: ID {print("prog = "+str($ID.text));} ;
COMMENT
: '//' ~[\r\n]* -> skip
;
ID : ('a'..'z'|'A'..'Z')+;
INT: '0'..'9'+;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines