improved interpreter
This commit is contained in:
@@ -30,7 +30,7 @@ class NassiShneidermanDiagram:
|
||||
if debug:
|
||||
logLevel = logging.DEBUG
|
||||
|
||||
logging.basicConfig(level=logLevel)
|
||||
logging.basicConfig(force=True, level=logLevel)
|
||||
|
||||
@staticmethod
|
||||
def set_font(font_filepath: str):
|
||||
@@ -38,11 +38,11 @@ class NassiShneidermanDiagram:
|
||||
|
||||
@staticmethod
|
||||
def _save_scope(scope: Function_scope, output_path: str):
|
||||
image_y_sz = scope.get_height()
|
||||
y_size = scope.get_height()
|
||||
x_size = scope.get_width()
|
||||
with NSD_writer(output_path, x_size, image_y_sz):
|
||||
with NSD_writer(output_path, x_size, y_size):
|
||||
x, y = 0, 0
|
||||
for instruction in scope.contents:
|
||||
for instruction in scope:
|
||||
x, y = instruction.to_image(x, y, x_size)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -13,6 +13,7 @@ logging.warning("""Because the Interpreter is still WIP, some Java language feat
|
||||
*foreach loops (will throw JavaSyntaxError)
|
||||
*constructors (will be ignored)
|
||||
*switch statements
|
||||
*Generics
|
||||
Please remove these features from the source code as they will result in incorrect behaviour""")
|
||||
|
||||
class Function_scope(Iterable):
|
||||
@@ -29,10 +30,10 @@ class Function_scope(Iterable):
|
||||
return int(h)
|
||||
|
||||
def get_width(self) -> int:
|
||||
w = 0.0
|
||||
w = 200.0
|
||||
for inst in self.contents:
|
||||
w = max(w, inst.getblkwidth())
|
||||
return int(max(200, w))
|
||||
return int(w)
|
||||
|
||||
def __iter__(self):
|
||||
return self.contents.__iter__()
|
||||
@@ -43,16 +44,15 @@ class JavaInterpreter:
|
||||
with open(filepath) as file:
|
||||
if not file.readable():
|
||||
raise InterpreterException(f"Unable to read input file {filepath}")
|
||||
self._src = file.read()
|
||||
self._src = file.read() #WARNING: throws if file is too large
|
||||
self._lines = [] # to be filled in later
|
||||
self._init_regex()
|
||||
self._recompile_regex()
|
||||
self.reset_tags()
|
||||
|
||||
def reset_tags(self, additional_tags: Dict[str, List[str]]=None):
|
||||
"""Reset the Interpreters internal tags to include the new tags given in {additional_tags}
|
||||
the key for comment tags is "comments"
|
||||
the key for tags that should be ignored is "ignore"
|
||||
the key for additional type tags is "types"
|
||||
"""Reset the Interpreters internal tags to include the new tags given in {additional_tags} or default.
|
||||
The key for comment tags is "comments"
|
||||
The key for tags that should be ignored is "ignore"
|
||||
The key for additional type tags is "types"
|
||||
"""
|
||||
|
||||
if additional_tags:
|
||||
|
||||
Reference in New Issue
Block a user