- Added switch '--la-tupling' to enforce left-associative tupling
instead of the default right-associative tupling. Note that this only matters for full typeflaw matching. - Adapted multi-nsl test script to test for both association variants.
This commit is contained in:
@@ -39,6 +39,7 @@ switchesInit (int argc, char **argv)
|
||||
switches.engine = POR_ENGINE; // default is partial ordering engine
|
||||
switches.match = 0; // default matching
|
||||
switches.clp = 0;
|
||||
switches.la_tupling = false;
|
||||
|
||||
// Pruning and Bounding
|
||||
switches.prune = 2; // default pruning method
|
||||
@@ -377,6 +378,21 @@ switcher (const int process, int index)
|
||||
}
|
||||
}
|
||||
|
||||
if (detect (' ', "la-tupling", 0))
|
||||
{
|
||||
if (!process)
|
||||
{
|
||||
/* not very important
|
||||
helptext ("--la-tupling", "compile using left-associative tupling");
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
switches.la_tupling = true;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================
|
||||
* Modelchecker only
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ struct switchdata
|
||||
int engine; //!< Engine type (POR_ENGINE,ARACHNE_ENGINE)
|
||||
int match; //!< Matching type.
|
||||
int clp; //!< Do we use clp?
|
||||
int la_tupling; //!< Tupling is by default right-associative, optionally left-associative.
|
||||
|
||||
// Pruning and Bounding
|
||||
int prune; //!< Type of pruning.
|
||||
|
||||
76
src/tac.c
76
src/tac.c
@@ -1,31 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include "tac.h"
|
||||
#include "memory.h"
|
||||
#include "switches.h"
|
||||
|
||||
extern int yylineno;
|
||||
|
||||
static Tac allocatedTacs;
|
||||
|
||||
//! Init segment
|
||||
void
|
||||
tacInit (void)
|
||||
{
|
||||
allocatedTacs = NULL;
|
||||
}
|
||||
|
||||
//! Closing segment
|
||||
void
|
||||
tacDone (void)
|
||||
{
|
||||
Tac ts, tf;
|
||||
Tac ts;
|
||||
|
||||
ts = allocatedTacs;
|
||||
while (ts != NULL)
|
||||
{
|
||||
Tac tf;
|
||||
|
||||
tf = ts;
|
||||
ts = ts->allnext;
|
||||
memFree (tf, sizeof (struct tacnode));
|
||||
}
|
||||
}
|
||||
|
||||
//! Create a tac node of some type
|
||||
Tac
|
||||
tacCreate (int op)
|
||||
{
|
||||
@@ -90,13 +96,9 @@ tacCat (Tac t1, Tac t2)
|
||||
}
|
||||
}
|
||||
|
||||
/* in: a list. out: a tuple (for e.g. associativity)
|
||||
* Effectively, this defines how we interpret tuples with
|
||||
* more than two components.
|
||||
*/
|
||||
|
||||
//! List to right-associative tuple
|
||||
Tac
|
||||
tacTuple (Tac taclist)
|
||||
tacTupleRa (Tac taclist)
|
||||
{
|
||||
Tac tc;
|
||||
|
||||
@@ -120,6 +122,66 @@ tacTuple (Tac taclist)
|
||||
return tc;
|
||||
}
|
||||
|
||||
//! List to left-associative tuple
|
||||
Tac
|
||||
tacTupleLa (Tac taclist)
|
||||
{
|
||||
Tac tc;
|
||||
|
||||
/* initial node is simple the first item */
|
||||
tc = taclist;
|
||||
tc->prev = NULL;
|
||||
|
||||
/* add any other nodes (one is ensured) */
|
||||
do
|
||||
{
|
||||
Tac tcnew;
|
||||
|
||||
taclist = taclist->next;
|
||||
/* add a new node (taclist) to the existing thing by first making the old one into the left-hand side of a tuple */
|
||||
tcnew = tacCreate (TAC_TUPLE);
|
||||
tcnew->t1.tac = tc;
|
||||
tcnew->t2.tac = taclist;
|
||||
tc = tcnew;
|
||||
/* unlink */
|
||||
tc->t1.tac->next = NULL;
|
||||
tc->t2.tac->prev = NULL;
|
||||
}
|
||||
while (taclist->next != NULL);
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
//! Compile a list into a tuple
|
||||
/* in: a list. out: a tuple (for e.g. associativity)
|
||||
* Effectively, this defines how we interpret tuples with
|
||||
* more than two components.
|
||||
*/
|
||||
Tac
|
||||
tacTuple (Tac taclist)
|
||||
{
|
||||
if (taclist == NULL || taclist->next == NULL)
|
||||
{
|
||||
/* just return */
|
||||
return taclist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (switches.la_tupling)
|
||||
{
|
||||
/* switch --la-tupling */
|
||||
/* left-associative */
|
||||
return tacTupleLa (taclist);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* DEFAULT behaviour */
|
||||
/* right-associative */
|
||||
return tacTupleRa (taclist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* tacPrint
|
||||
* Print the tac. Only for debugging purposes.
|
||||
|
||||
Reference in New Issue
Block a user