Commit 5ba1bf19 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Parse, generate code and print the result

parent 1fe01443
......@@ -29,22 +29,18 @@ import argparse
from ColorFormatter import ColorFormatter
import opengeode
# Set up the logging facilities
log = logging.getLogger(__name__)
terminal_formatter = logging.Formatter(
fmt="%(levelname)s - %(name)s: %(message)s")
handler_console = logging.StreamHandler()
# Make sure the gui can import modules in the current directory
sys.path.insert(0, '.')
console = logging.StreamHandler(sys.__stdout__)
def parse_input_files(pr_files, ppty_file):
''' Invoke opengeode to parse the SDL models and use the expression
parser to analyse the properties (stop conditions) '''
# Parse the SDL model
ast = opengeode.parse(pr_files)
process = ast[0].processes[0]
......@@ -52,18 +48,37 @@ def parse_input_files(pr_files, ppty_file):
raise IOError('SDL Parser failed - {}'.format(err))'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():
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))
# 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
# Generate Ada code for each stop condition
for each in stop_conditions:
stmts, string, local_decl = opengeode.AdaGenerator.expression(each)
def cli():
''' Application entry point, when used from the command line '''
version = 'Taste Properties version {}'.format(__version__)
# Set up the logging facilities
log = logging.getLogger("properties")
console = logging.StreamHandler(sys.__stdout__)
# Parse the command line
parser = argparse.ArgumentParser(version=version)
parser.add_argument('-g', '--verbose', action='store_true', default=False,
Supports Markdown
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