loader can also load without checking conformance
This commit is contained in:
parent
4fe7e19714
commit
a91c7d2bdd
1 changed files with 11 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ from concrete_syntax.textual_od import parser
|
||||||
from transformation.rule import Rule
|
from transformation.rule import Rule
|
||||||
|
|
||||||
# parse model and check conformance
|
# parse model and check conformance
|
||||||
def parse_and_check(state, m_cs, mm, descr: str):
|
def parse_and_check(state, m_cs, mm, descr: str, check_conformance=True):
|
||||||
try:
|
try:
|
||||||
m = parser.parse_od(
|
m = parser.parse_od(
|
||||||
state,
|
state,
|
||||||
|
|
@ -15,10 +15,11 @@ def parse_and_check(state, m_cs, mm, descr: str):
|
||||||
e.add_note("While parsing model " + descr)
|
e.add_note("While parsing model " + descr)
|
||||||
raise
|
raise
|
||||||
try:
|
try:
|
||||||
conf = Conformance(state, m, mm)
|
if check_conformance:
|
||||||
errors = conf.check_nominal()
|
conf = Conformance(state, m, mm)
|
||||||
if len(errors) > 0:
|
errors = conf.check_nominal()
|
||||||
print(render_conformance_check_result(errors))
|
if len(errors) > 0:
|
||||||
|
print(render_conformance_check_result(errors))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
e.add_note("In model " + descr)
|
e.add_note("In model " + descr)
|
||||||
raise
|
raise
|
||||||
|
|
@ -32,7 +33,7 @@ def read_file(filename):
|
||||||
KINDS = ["nac", "lhs", "rhs"]
|
KINDS = ["nac", "lhs", "rhs"]
|
||||||
|
|
||||||
# load model transformation rules
|
# load model transformation rules
|
||||||
def load_rules(state, get_filename, rt_mm_ramified, rule_names):
|
def load_rules(state, get_filename, rt_mm_ramified, rule_names, check_conformance=True):
|
||||||
rules = {}
|
rules = {}
|
||||||
|
|
||||||
files_read = []
|
files_read = []
|
||||||
|
|
@ -50,7 +51,7 @@ def load_rules(state, get_filename, rt_mm_ramified, rule_names):
|
||||||
while True:
|
while True:
|
||||||
base, ext = os.path.splitext(filename)
|
base, ext = os.path.splitext(filename)
|
||||||
processed_filename = base+suffix+ext
|
processed_filename = base+suffix+ext
|
||||||
nac = parse_and_check(state, read_file(processed_filename), rt_mm_ramified, descr)
|
nac = parse_and_check(state, read_file(processed_filename), rt_mm_ramified, descr, check_conformance)
|
||||||
nacs.append(nac)
|
nacs.append(nac)
|
||||||
suffix = "2" if suffix == "" else str(int(suffix)+1)
|
suffix = "2" if suffix == "" else str(int(suffix)+1)
|
||||||
files_read.append(processed_filename)
|
files_read.append(processed_filename)
|
||||||
|
|
@ -60,7 +61,7 @@ def load_rules(state, get_filename, rt_mm_ramified, rule_names):
|
||||||
return nacs
|
return nacs
|
||||||
elif kind == "lhs" or kind == "rhs":
|
elif kind == "lhs" or kind == "rhs":
|
||||||
try:
|
try:
|
||||||
m = parse_and_check(state, read_file(filename), rt_mm_ramified, descr)
|
m = parse_and_check(state, read_file(filename), rt_mm_ramified, descr, check_conformance)
|
||||||
files_read.append(filename)
|
files_read.append(filename)
|
||||||
return m
|
return m
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
|
|
@ -70,7 +71,8 @@ def load_rules(state, get_filename, rt_mm_ramified, rule_names):
|
||||||
state,
|
state,
|
||||||
"",
|
"",
|
||||||
rt_mm_ramified,
|
rt_mm_ramified,
|
||||||
descr="'"+filename+"'")
|
descr="'"+filename+"'",
|
||||||
|
check_conformance=check_conformance)
|
||||||
|
|
||||||
rules[rule_name] = Rule(*(parse(kind) for kind in KINDS))
|
rules[rule_name] = Rule(*(parse(kind) for kind in KINDS))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue