2007-06-11 13:01:04 +01:00
|
|
|
/*
|
|
|
|
* Scyther : An automatic verifier for security protocols.
|
2012-04-24 12:56:51 +01:00
|
|
|
* Copyright (C) 2007-2012 Cas Cremers
|
2007-06-11 13:01:04 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
%{
|
|
|
|
#include "pheading.h"
|
|
|
|
#include "tac.h"
|
2007-01-06 14:45:29 +00:00
|
|
|
#include "error.h"
|
2012-11-22 11:30:00 +00:00
|
|
|
#include "list.h"
|
2012-12-14 22:53:04 +00:00
|
|
|
#include "string.h"
|
|
|
|
#include "switches.h"
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
struct tacnode* spdltac;
|
|
|
|
|
|
|
|
int yyerror(char *s);
|
|
|
|
int yylex(void);
|
|
|
|
|
2012-11-22 11:30:00 +00:00
|
|
|
List macrolist=NULL;
|
|
|
|
|
|
|
|
List findMacroDefinition(Symbol s)
|
|
|
|
{
|
|
|
|
List l;
|
|
|
|
|
|
|
|
if (s == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* Now check if it is in the list
|
|
|
|
* already */
|
|
|
|
for (l = list_rewind(macrolist); l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
Tac tmacro;
|
|
|
|
Symbol sl;
|
|
|
|
|
|
|
|
tmacro = (Tac) l->data;
|
|
|
|
sl = (tmacro->t1.tac)->t1.sym; // The symbol
|
|
|
|
if (strcmp (sl->text, s->text) == 0)
|
|
|
|
{
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
%}
|
|
|
|
|
|
|
|
%union{
|
|
|
|
char* str;
|
|
|
|
struct tacnode* tac;
|
|
|
|
Symbol symb;
|
2006-01-02 16:05:53 +00:00
|
|
|
int value;
|
2004-04-23 11:58:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
%token <symb> ID
|
2012-12-14 22:53:04 +00:00
|
|
|
%token <str> TEXT
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
%token PROTOCOL
|
|
|
|
%token ROLE
|
|
|
|
%token READT
|
2008-08-20 15:15:27 +01:00
|
|
|
%token RECVT
|
2004-04-23 11:58:43 +01:00
|
|
|
%token SENDT
|
|
|
|
%token CLAIMT
|
|
|
|
%token VAR
|
|
|
|
%token CONST
|
2010-01-05 12:45:19 +00:00
|
|
|
%token FRESH
|
2004-04-23 11:58:43 +01:00
|
|
|
%token RUN
|
|
|
|
%token SECRET
|
|
|
|
%token COMPROMISED
|
|
|
|
%token INVERSEKEYS
|
2013-04-26 10:36:41 +01:00
|
|
|
%token INVERSEKEYFUNCTIONS
|
2004-04-23 11:58:43 +01:00
|
|
|
%token UNTRUSTED
|
|
|
|
%token USERTYPE
|
2006-01-02 16:05:53 +00:00
|
|
|
%token SINGULAR
|
2006-01-09 09:38:17 +00:00
|
|
|
%token FUNCTION
|
|
|
|
%token HASHFUNCTION
|
|
|
|
%token KNOWS
|
|
|
|
%token TRUSTED
|
2012-12-14 22:53:04 +00:00
|
|
|
%token OPTION
|
|
|
|
%token MACRO
|
2012-11-21 10:28:40 +00:00
|
|
|
%token MATCH
|
2012-11-21 12:40:15 +00:00
|
|
|
%token NOT
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
%type <tac> spdlcomplete
|
|
|
|
%type <tac> spdlrep
|
|
|
|
%type <tac> spdl
|
|
|
|
%type <tac> roles
|
|
|
|
%type <tac> role
|
|
|
|
%type <tac> roledef
|
|
|
|
%type <tac> event
|
|
|
|
%type <tac> declaration
|
|
|
|
%type <tac> secretpref
|
|
|
|
%type <tac> typeinfo1
|
|
|
|
%type <tac> typeinfoN
|
|
|
|
%type <tac> term
|
2006-05-16 16:00:21 +01:00
|
|
|
%type <tac> basicterm
|
2012-11-22 11:30:00 +00:00
|
|
|
%type <tac> basicormacro
|
2004-04-23 11:58:43 +01:00
|
|
|
%type <tac> termlist
|
2006-05-16 16:00:21 +01:00
|
|
|
%type <tac> basictermlist
|
2004-04-23 11:58:43 +01:00
|
|
|
%type <tac> key
|
|
|
|
%type <tac> roleref
|
2006-07-27 11:44:12 +01:00
|
|
|
%type <tac> knowsdecl
|
2012-11-22 11:30:00 +00:00
|
|
|
%type <tac> macrodecl
|
2012-12-14 22:53:04 +00:00
|
|
|
%type <tac> options
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2006-01-02 16:05:53 +00:00
|
|
|
%type <value> singular
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
%type <symb> label
|
2005-12-28 11:50:17 +00:00
|
|
|
%type <symb> optlabel
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
%start spdlcomplete
|
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
spdlcomplete : spdlrep
|
|
|
|
{ spdltac = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
spdlrep : /* empty */
|
|
|
|
{ $$ = NULL; }
|
|
|
|
| spdl spdlrep
|
|
|
|
{ $$ = tacCat($1,$2); }
|
|
|
|
;
|
|
|
|
|
|
|
|
spdl : UNTRUSTED termlist ';'
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_UNTRUSTED);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| RUN roleref '(' termlist ')' ';'
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_RUN);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $2;
|
|
|
|
t->t2.tac = $4;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| PROTOCOL ID '(' termlist ')' '{' roles '}' optclosing
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_PROTOCOL);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $2;
|
|
|
|
t->t2.tac = $7;
|
|
|
|
t->t3.tac = $4;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| USERTYPE termlist ';'
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_USERTYPE);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2012-12-14 22:53:04 +00:00
|
|
|
| options
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
options : OPTION TEXT optclosing
|
|
|
|
{
|
|
|
|
// Process 'option' as command-line options.
|
|
|
|
process_switch_buffer($2);
|
|
|
|
$$ = NULL;
|
|
|
|
}
|
2004-04-23 11:58:43 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
roles : /* empty */
|
|
|
|
{ $$ = NULL; }
|
|
|
|
| role roles
|
|
|
|
{ $$ = tacCat($1,$2); }
|
|
|
|
| declaration roles
|
|
|
|
{ $$ = tacCat($1,$2); }
|
|
|
|
;
|
|
|
|
|
2006-01-02 16:05:53 +00:00
|
|
|
role : singular ROLE ID '{' roledef '}' optclosing
|
2004-04-23 11:58:43 +01:00
|
|
|
{
|
2006-01-02 16:05:53 +00:00
|
|
|
// TODO process singular (0/1)
|
2004-04-23 11:58:43 +01:00
|
|
|
Tac t = tacCreate(TAC_ROLE);
|
2006-01-02 16:05:53 +00:00
|
|
|
t->t1.sym = $3;
|
|
|
|
t->t2.tac = $5;
|
|
|
|
t->t3.value = $1;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2006-01-02 16:05:53 +00:00
|
|
|
singular : /* empty */
|
|
|
|
{ $$ = 0; }
|
|
|
|
| SINGULAR
|
|
|
|
{ $$ = 1; }
|
|
|
|
;
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
optclosing : /* empty */
|
|
|
|
{ }
|
|
|
|
| ';'
|
|
|
|
{ }
|
|
|
|
;
|
|
|
|
|
|
|
|
roledef : /* empty */
|
|
|
|
{ $$ = NULL; }
|
|
|
|
| event roledef
|
|
|
|
{ $$ = tacCat($1,$2); }
|
|
|
|
| declaration roledef
|
|
|
|
{ $$ = tacCat($1,$2); }
|
2006-07-27 11:44:12 +01:00
|
|
|
| knowsdecl roledef
|
|
|
|
{ $$ = tacCat($1,$2); }
|
2004-04-23 11:58:43 +01:00
|
|
|
;
|
|
|
|
|
2008-08-20 15:15:27 +01:00
|
|
|
/*
|
|
|
|
* For now, recv and read are synonyms, but have their own branch below. That's ugly duplication. Ultimately we want to deprecate read,
|
|
|
|
* but that will take a while I guess.
|
|
|
|
*/
|
2004-04-23 11:58:43 +01:00
|
|
|
event : READT label '(' termlist ')' ';'
|
2012-04-25 08:53:07 +01:00
|
|
|
{ Tac t = tacCreate(TAC_RECV);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
/* TODO test here: tac2 should have at least 3 elements */
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t2.tac = $4;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2008-08-20 15:15:27 +01:00
|
|
|
| RECVT label '(' termlist ')' ';'
|
2012-04-25 08:53:07 +01:00
|
|
|
{ Tac t = tacCreate(TAC_RECV);
|
2008-08-20 15:15:27 +01:00
|
|
|
t->t1.sym = $2;
|
|
|
|
/* TODO test here: tac2 should have at least 3 elements */
|
|
|
|
t->t2.tac = $4;
|
|
|
|
$$ = t;
|
|
|
|
}
|
2004-04-23 11:58:43 +01:00
|
|
|
| SENDT label '(' termlist ')' ';'
|
|
|
|
{ Tac t = tacCreate(TAC_SEND);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
/* TODO test here: tac2 should have at least 3 elements */
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t2.tac = $4;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2012-11-21 10:28:40 +00:00
|
|
|
| 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;
|
2012-11-21 12:40:15 +00:00
|
|
|
t->t3.value = true;
|
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| NOT MATCH '(' term ',' term ')' ';'
|
|
|
|
{
|
|
|
|
/* first argument is pattern, second should be
|
|
|
|
* ground term */
|
|
|
|
Tac t= tacCreate(TAC_MATCH);
|
|
|
|
t->t1.tac = $4;
|
|
|
|
t->t2.tac = $6;
|
|
|
|
t->t3.value = false;
|
2012-11-21 10:28:40 +00:00
|
|
|
$$ = t;
|
|
|
|
}
|
2005-12-28 11:50:17 +00:00
|
|
|
| CLAIMT optlabel '(' termlist ')' ';'
|
2004-04-23 11:58:43 +01:00
|
|
|
/* TODO maybe claims should be in the syntax */
|
|
|
|
{ Tac t = tacCreate(TAC_CLAIM);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $2;
|
|
|
|
t->t2.tac = $4;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
roleref : ID '.' ID
|
|
|
|
{ Tac t = tacCreate(TAC_ROLEREF);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $1;
|
|
|
|
t->t2.sym = $3;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2006-07-27 11:44:12 +01:00
|
|
|
knowsdecl : KNOWS termlist ';'
|
|
|
|
{ Tac t = tacCreate(TAC_KNOWS);
|
|
|
|
t->t1.tac = $2;
|
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2012-11-22 11:30:00 +00:00
|
|
|
macrodecl : MACRO basicterm '=' termlist ';'
|
|
|
|
{
|
|
|
|
List l;
|
2012-11-23 12:26:04 +00:00
|
|
|
Tac t;
|
2012-11-22 11:30:00 +00:00
|
|
|
|
|
|
|
l = findMacroDefinition($2->t1.sym);
|
2012-11-23 12:26:04 +00:00
|
|
|
if (l != NULL)
|
2012-11-22 11:30:00 +00:00
|
|
|
{
|
|
|
|
/* Already defined. We can consider this
|
|
|
|
* a bug or we can define it to
|
|
|
|
* overwrite.
|
2012-11-23 12:26:04 +00:00
|
|
|
*
|
|
|
|
* For now, we decide to overwrite. This
|
|
|
|
* will also aid in straightforward file
|
|
|
|
* composition, if both files contain
|
|
|
|
* macros.
|
2012-11-22 11:30:00 +00:00
|
|
|
*/
|
2012-11-23 12:26:04 +00:00
|
|
|
macrolist = list_delete(l);
|
|
|
|
// Alternative:
|
2012-11-22 11:30:00 +00:00
|
|
|
//yyerror("macro symbol already defined earlier.");
|
|
|
|
}
|
2012-11-23 12:26:04 +00:00
|
|
|
|
|
|
|
// Now we know that l does not occur in macrolist
|
|
|
|
/* Add to macro declaration list.
|
|
|
|
* TAC_MACRO doesn't show up in the compiler though. */
|
|
|
|
t = tacCreate(TAC_MACRO);
|
|
|
|
t->t1.tac = $2;
|
|
|
|
t->t2.tac = tacTuple($4);
|
|
|
|
macrolist = list_append(macrolist, t);
|
2012-11-22 11:30:00 +00:00
|
|
|
$$ = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2006-05-16 16:00:21 +01:00
|
|
|
declaration : secretpref CONST basictermlist typeinfo1 ';'
|
2004-04-23 11:58:43 +01:00
|
|
|
{ Tac t = tacCreate(TAC_CONST);
|
2010-01-05 12:45:19 +00:00
|
|
|
t->t1.tac = $3; // names
|
|
|
|
t->t2.tac = $4; // type
|
|
|
|
t->t3.tac = $1; // secret?
|
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| FRESH basictermlist typeinfo1 ';'
|
|
|
|
{ Tac t = tacCreate(TAC_FRESH);
|
|
|
|
t->t1.tac = $2; // names
|
|
|
|
t->t2.tac = $3; // type
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2006-05-16 16:00:21 +01:00
|
|
|
| secretpref VAR basictermlist typeinfoN ';'
|
2004-04-23 11:58:43 +01:00
|
|
|
{ Tac t = tacCreate(TAC_VAR);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $3;
|
|
|
|
t->t2.tac = $4;
|
2010-01-05 12:45:19 +00:00
|
|
|
t->t3.tac = $1; // obsolete: should not even occur at the global level
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2006-05-16 16:00:21 +01:00
|
|
|
| SECRET basictermlist typeinfo1 ';'
|
2004-04-23 11:58:43 +01:00
|
|
|
{ Tac t = tacCreate(TAC_SECRET);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $2;
|
|
|
|
t->t2.tac = $3;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
| INVERSEKEYS '(' term ',' term ')' ';'
|
|
|
|
{ Tac t = tacCreate(TAC_INVERSEKEYS);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac = $3;
|
|
|
|
t->t2.tac = $5;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2013-04-26 10:36:41 +01:00
|
|
|
| INVERSEKEYFUNCTIONS '(' term ',' term ')' ';'
|
|
|
|
{ Tac t = tacCreate(TAC_INVERSEKEYFUNCTIONS);
|
|
|
|
t->t1.tac = $3;
|
|
|
|
t->t2.tac = $5;
|
|
|
|
$$ = t;
|
|
|
|
}
|
2004-04-23 11:58:43 +01:00
|
|
|
| COMPROMISED termlist ';'
|
|
|
|
{ Tac t = tacCreate(TAC_COMPROMISED);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.tac= $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2009-04-28 15:28:16 +01:00
|
|
|
| HASHFUNCTION basictermlist ';'
|
|
|
|
{ Tac t = tacCreate(TAC_HASHFUNCTION);
|
|
|
|
t->t1.tac = $2;
|
|
|
|
t->t2.tac = tacCreate(TAC_UNDEF);
|
|
|
|
t->t3.tac = NULL; // Not secret: public
|
|
|
|
$$ = t;
|
|
|
|
}
|
2012-11-23 12:26:04 +00:00
|
|
|
| macrodecl
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2004-04-23 11:58:43 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
secretpref : /* empty */
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
}
|
|
|
|
| SECRET
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_SECRET);
|
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
typeinfo1 : /* empty */
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_UNDEF);
|
|
|
|
$$ = t;
|
|
|
|
}
|
2012-11-22 11:30:00 +00:00
|
|
|
| ':' basicterm
|
|
|
|
{
|
|
|
|
$$ = $2;
|
2004-04-23 11:58:43 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
typeinfoN : /* empty */
|
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_UNDEF);
|
|
|
|
$$ = t;
|
|
|
|
}
|
2006-05-16 16:00:21 +01:00
|
|
|
| ':' basictermlist
|
2004-04-23 11:58:43 +01:00
|
|
|
{
|
|
|
|
$$ = $2;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-04-29 14:25:43 +01:00
|
|
|
label : '_' ID
|
2004-04-23 11:58:43 +01:00
|
|
|
{ $$ = $2; }
|
|
|
|
;
|
|
|
|
|
2005-12-28 11:50:17 +00:00
|
|
|
optlabel : /* empty */
|
|
|
|
{ $$ = NULL; }
|
|
|
|
| label
|
|
|
|
{ }
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2006-05-16 16:00:21 +01:00
|
|
|
basicterm : ID
|
2004-04-23 11:58:43 +01:00
|
|
|
{
|
2012-11-22 11:30:00 +00:00
|
|
|
Tac t;
|
|
|
|
|
|
|
|
t = tacCreate(TAC_STRING);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $1;
|
2004-04-23 11:58:43 +01:00
|
|
|
$$ = t;
|
|
|
|
}
|
2006-05-16 16:00:21 +01:00
|
|
|
;
|
|
|
|
|
2012-11-22 11:30:00 +00:00
|
|
|
basicormacro : ID
|
|
|
|
{
|
|
|
|
List l;
|
|
|
|
Tac t;
|
|
|
|
|
|
|
|
/* check if it is in the list
|
|
|
|
* already */
|
|
|
|
l = findMacroDefinition($1);
|
|
|
|
if (l == NULL)
|
|
|
|
{
|
|
|
|
t = tacCreate(TAC_STRING);
|
|
|
|
t->t1.sym = $1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Tac macrotac;
|
|
|
|
|
|
|
|
macrotac = (Tac) l->data;
|
2012-11-23 10:55:29 +00:00
|
|
|
t = tacCopy(macrotac->t2.tac);
|
2012-11-22 11:30:00 +00:00
|
|
|
}
|
|
|
|
$$ = t;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
term : ID '(' termlist ')'
|
2004-04-23 11:58:43 +01:00
|
|
|
{
|
|
|
|
Tac t = tacCreate(TAC_STRING);
|
2004-05-26 09:26:40 +01:00
|
|
|
t->t1.sym = $1;
|
2013-04-26 10:36:41 +01:00
|
|
|
$$ = tacJoin(TAC_FCALL,tacTuple($3),t,NULL);
|
2004-04-23 11:58:43 +01:00
|
|
|
}
|
|
|
|
| '{' termlist '}' key
|
|
|
|
{
|
|
|
|
$$ = tacJoin(TAC_ENCRYPT,tacTuple($2),$4,NULL);
|
|
|
|
}
|
|
|
|
| '(' termlist ')'
|
|
|
|
{
|
|
|
|
$$ = tacTuple($2);
|
|
|
|
}
|
2012-11-22 11:30:00 +00:00
|
|
|
| basicormacro
|
|
|
|
{ }
|
2004-04-23 11:58:43 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
termlist : term
|
|
|
|
{ }
|
|
|
|
| term ',' termlist
|
|
|
|
{ $$ = tacCat($1,$3); }
|
|
|
|
;
|
|
|
|
|
2006-05-16 16:00:21 +01:00
|
|
|
basictermlist : basicterm
|
|
|
|
{ }
|
|
|
|
| basicterm ',' basictermlist
|
|
|
|
{ $$ = tacCat($1,$3); }
|
|
|
|
;
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
key : term
|
|
|
|
{ }
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2006-01-09 09:38:17 +00:00
|
|
|
//! error handler routing
|
2004-04-23 11:58:43 +01:00
|
|
|
int yyerror(char *s)
|
|
|
|
{
|
2006-01-09 09:38:17 +00:00
|
|
|
extern int yylineno; //!< defined and maintained in lex.c
|
|
|
|
extern char *yytext; //!< defined and maintained in lex.c
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2007-02-01 12:18:38 +00:00
|
|
|
error ("[%i] %s at symbol '%s'.\n", yylineno, s, yytext);
|
2007-01-06 14:45:29 +00:00
|
|
|
return 0;
|
2004-04-23 11:58:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|