Add exception handling for date parsing in lexer
This commit is contained in:
parent
3ae6068215
commit
cb4c194420
|
@ -76,7 +76,11 @@ def t_STRING(t):
|
|||
|
||||
def t_DATE_LITERAL(t):
|
||||
r'\d{4}-\d{2}-\d{2}'
|
||||
try:
|
||||
t.value = datetime.date.fromisoformat(t.value)
|
||||
except:
|
||||
print(f'Invalid date \'{t.value}\' at line {t.lexer.lineno}')
|
||||
raise SystemExit
|
||||
return t
|
||||
|
||||
def t_INT_LITERAL(t):
|
||||
|
|
Loading…
Reference in New Issue