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