|
@@ -5,6 +5,7 @@ import sys
|
|
|
from grammar_compiler_visitor import GrammarCompilerVisitor
|
|
|
from hutnparser import Parser, Tree
|
|
|
from meta_grammar import Grammar
|
|
|
+from cached_exception import CachedException
|
|
|
|
|
|
global parsers
|
|
|
parsers = {}
|
|
@@ -159,10 +160,13 @@ def main(input_file, grammar_file, mode, args=[], symbols=None):
|
|
|
"M" : [ModelVisitor],
|
|
|
"MO" : [ModelObjectVisitor],
|
|
|
}
|
|
|
- visitors = [v(args) for v in modes[mode]]
|
|
|
- result = do_compile(input_file, grammar_file, visitors)
|
|
|
- if symbols is not None and getattr(visitors[-1], "object_symbols", None) is not None:
|
|
|
- symbols.update(visitors[-1].object_symbols)
|
|
|
+ try:
|
|
|
+ visitors = [v(args) for v in modes[mode]]
|
|
|
+ result = do_compile(input_file, grammar_file, visitors)
|
|
|
+ if symbols is not None and mode == "BS":
|
|
|
+ symbols.update(visitors[-1].object_symbols)
|
|
|
+ except CachedException:
|
|
|
+ return True
|
|
|
return result
|
|
|
|
|
|
if __name__ == "__main__":
|