Improve errors

This commit is contained in:
Bartłomiej Pluta
2019-06-30 20:05:23 +02:00
parent 65353a80f2
commit d0b3a8b3da
8 changed files with 105 additions and 94 deletions

View File

@@ -2,6 +2,7 @@ from enum import Enum
import time
import re
import sys
from Error import SyntaxException
class TokenType(Enum):
OPEN_PAREN = 1
@@ -19,10 +20,6 @@ class TokenType(Enum):
COMMENT = 13
PERCENT = 14
MINUS = 15
class TokenizerError(Exception):
pass
class Token:
def __init__(self, type, value, pos):
@@ -188,7 +185,7 @@ def doTokenize(lines):
break
if not tokenized:
raise TokenizerError(f"Line {lineNumber+1}, col {current+1}: unknown symbol '{line[current]}'")
raise SyntaxException((lineNumber, current), f"Unknown symbol '{line[current]}'")
return [token for token in tokens if token.type is not None]