Implemented equality/pattern matching support.

Introduced a new event:

  match(pattern,groundterm)

This event can only be executed if pattern can be matched to groundterm.
Variable substitutions are persistent with respect to later events in
the same role.

Currently implemented as syntactic sugar, essentially unfolded in role R to:

  fresh x;
  send ( R,R, { groundterm }x );
  recv ( R,R, { pattern }x );

This work is not complete yet in the send that the output still contains
the unfolding. Ideally, the graph rendered detects this syntactic sugar
and renders a simplified event. This should be possible on the basis of
the label name prefix.

Conflicts:
	src/compiler.c
	src/parser.y
	src/scanner.l
	src/tac.h
This commit is contained in:
Cas Cremers
2012-11-21 11:28:40 +01:00
parent 9c9c6758f2
commit d4faeacd1e
6 changed files with 76 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ int yylex(void);
%token HASHFUNCTION
%token KNOWS
%token TRUSTED
%token MATCH
%type <tac> spdlcomplete
%type <tac> spdlrep
@@ -196,6 +197,15 @@ event : READT label '(' termlist ')' ';'
t->t2.tac = $4;
$$ = t;
}
| MATCH '(' term ',' term ')' ';'
{
/* first argument is pattern, second should be
* ground term */
Tac t= tacCreate(TAC_MATCH);
t->t1.tac = $3;
t->t2.tac = $5;
$$ = t;
}
| CLAIMT optlabel '(' termlist ')' ';'
/* TODO maybe claims should be in the syntax */
{ Tac t = tacCreate(TAC_CLAIM);