Skip to content

Commit

Permalink
refactor Lexer to use errors instead of Exceptions to be more descritive
Browse files Browse the repository at this point in the history
  • Loading branch information
NiumXp committed Feb 11, 2024
1 parent af155ae commit 68d59a5
Show file tree
Hide file tree
Showing 22 changed files with 822 additions and 812 deletions.
6 changes: 3 additions & 3 deletions norminette/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import argparse
from norminette.errors import formatters
from norminette.file import File
from norminette.lexer import Lexer, TokenError
from norminette.lexer import Lexer
from norminette.exceptions import CParsingError
from norminette.registry import Registry
from norminette.context import Context
Expand Down Expand Up @@ -127,10 +127,10 @@ def main():
for file in files:
try:
lexer = Lexer(file)
tokens = lexer.get_tokens()
tokens = list(lexer)
context = Context(file, tokens, debug, args.R)
registry.run(context)
except (TokenError, CParsingError) as e:
except CParsingError as e:
print(file.path + f": Error!\n\t{colors(e.msg, 'red')}")
sys.exit(1)
except KeyboardInterrupt:
Expand Down
3 changes: 1 addition & 2 deletions norminette/lexer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from norminette.lexer.lexer import Lexer
from norminette.lexer.lexer import TokenError
from norminette.lexer.tokens import Token

__all__ = ["Lexer", "TokenError", "Token"]
__all__ = ["Lexer", "Token"]
1 change: 1 addition & 0 deletions norminette/lexer/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
">>": "RIGHT_SHIFT",
"<<": "LEFT_SHIFT",
"?": "TERN_CONDITION",
"#": "HASH",
}

brackets = {
Expand Down
Loading

0 comments on commit 68d59a5

Please sign in to comment.