This repository has been archived by the owner on Jul 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a39eb8
commit aabd867
Showing
1 changed file
with
9 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
from lexing.lexer import Lexer | ||
from lexing.errors import LexerError | ||
from errors.errors import SeaError | ||
|
||
def interface(streams, debug, mode): | ||
try: | ||
data = "" | ||
symbol = streams.in_stream.read_symbol() | ||
lexer = None | ||
|
||
while symbol != "": | ||
data += symbol | ||
symbol = streams.in_stream.read_symbol() | ||
LexerError.lexer = lexer = Lexer(streams.in_stream) | ||
lexer.make_tokens() | ||
|
||
streams.out_stream.write(data) | ||
streams.out_stream.write("Done.\n") | ||
except SeaError as error: | ||
streams.error_stream.write(error) | ||
finally: | ||
print_debug_info(debug, streams.debug_stream) | ||
print_debug_info(debug, streams.debug_stream, lexer) | ||
|
||
def print_debug_info(debug, debug_stream): | ||
def print_debug_info(debug, debug_stream, lexer): | ||
if not debug: | ||
return | ||
|
||
debug_stream.write("\nDebug is enabled.\n") | ||
debug_stream.write(f"\nTokens:\n\t{None if lexer is None else lexer.tokens}\n") |