Commit b8955a03 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Dig syntax error detection

parent 502591de
...@@ -5260,6 +5260,10 @@ def add_to_ast(ast, filename=None, string=None): ...@@ -5260,6 +5260,10 @@ def add_to_ast(ast, filename=None, string=None):
LOG.error('Parser initialization error: ' + str(err)) LOG.error('Parser initialization error: ' + str(err))
raise raise
tree_rule_return_scope = parser.pr_file() tree_rule_return_scope = parser.pr_file()
for each in parser.error_list:
LOG.error(each)
for each in lexer.sdl92Lexer.error_list:
LOG.error(each)
# Root of the AST is of type antlr3.tree.CommonTree # Root of the AST is of type antlr3.tree.CommonTree
# Add it as a child of the common tree # Add it as a child of the common tree
subtree = tree_rule_return_scope.tree subtree = tree_rule_return_scope.tree
......
...@@ -51,6 +51,36 @@ endsystem; ...@@ -51,6 +51,36 @@ endsystem;
else: else:
assert False assert False
def test_system_with_error_2():
''' Detect the syntax error (missing SEMI after "procedure entry") '''
string='''system huuh;
block huuh;
process huuh;
/* CIF START (171, 77), (70, 35) */
START;
/* CIF NEXTSTATE (171, 132), (70, 35) */
NEXTSTATE a-;
/* CIF state (386, 90), (70, 35) */
state a;
endstate;
endprocess huuh;
endblock;
endsystem;
'''
test = parser_init(string=string)
# Parse and then check that the reported error is the expected one
#res = test.system_definition()
res = test.pr_file()
node = res.tree
try:
check_syntax(node, recursive=True, input_string=string)
except SyntaxError:
err = "\n".join(test.error_list)
raise SyntaxError(err)
else:
assert False
if __name__ == '__main__': if __name__ == '__main__':
for name, value in dict(globals()).viewitems(): for name, value in dict(globals()).viewitems():
if name.startswith('test_'): if name.startswith('test_'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment