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

Parse properties in one shot

parent 5ba1bf19
......@@ -49,24 +49,24 @@ def parse_input_files(pr_files, ppty_file):
log.info('SDL parser OK')
# Parse the stop conditions (property file)
stop_conditions = []
with open(ppty_file, 'r') as ppties:
for line in ppties.readlines():
if not line.strip():
continue
expr, syntax, semantic, warnings, term = \
opengeode.ogParser.parseSingleElement('stop_if', line, process)
if syntax or semantic or warnings:
log.error('Error in expression: {}'.format(line))
else:
stop_conditions.append(expr)
with open(ppty_file, 'r') as pt:
stop_conditions, syntax, semantic, warnings, term = \
opengeode.ogParser.parseSingleElement('stop_if', pt.read(), process)
for each in syntax:
log.error(each)
for each in semantic:
log.error(each[0])
for each in warnings:
log.warning(each[0])
if syntax or semantic or warnings or not stop_conditions:
raise IOError('Error parsing stop conditions - Aborting')
# Set the context in the Ada generator
if stop_conditions:
opengeode.AdaGenerator.TYPES = process.dataview
opengeode.AdaGenerator.VARIABLES = process.variables
opengeode.AdaGenerator.PROCEDURES = process.procedures
opengeode.AdaGenerator.OUT_SIGNALS = process.output_signals
opengeode.AdaGenerator.TYPES = process.dataview
opengeode.AdaGenerator.VARIABLES = process.variables
opengeode.AdaGenerator.PROCEDURES = process.procedures
opengeode.AdaGenerator.OUT_SIGNALS = process.output_signals
# Generate Ada code for each stop condition
for each in stop_conditions:
......@@ -104,7 +104,10 @@ def cli():
log.debug('SDL files: {}'.format(', '.join(options.models)))
log.debug('Property file: {}'.format(options.spec))
parse_input_files(options.models, options.spec)
try:
parse_input_files(options.models, options.spec)
except IOError as err:
log.error(str(err))
return 0
......
stop if a = two
stop if state = timeout
stop if a = two;
stop if state = timeout;
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