⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scan-ops_pddl.y

📁 intel ipp4.1性能库的一些例子。
💻 Y
📖 第 1 页 / 共 2 页
字号:
%{#ifdef YYDEBUG  extern int yydebug=1;#endif#include <stdio.h>#include <string.h> #include "ipp.h"#include "pddl.h"#include "pddl-types.h"#include "utilities.h"#include "memory.h"#ifndef SCAN_ERR#define SCAN_ERR#define DOMDEF_EXPECTED            0#define DOMAIN_EXPECTED            1#define DOMNAME_EXPECTED           2#define LBRACKET_EXPECTED          3#define RBRACKET_EXPECTED          4#define DOMDEFS_EXPECTED           5#define REQUIREM_EXPECTED          6#define TYPEDLIST_EXPECTED         7#define LITERAL_EXPECTED           8#define PRECONDDEF_UNCORRECT       9#define TYPEDEF_EXPECTED          10#define CONSTLIST_EXPECTED        11#define PREDDEF_EXPECTED          12 #define NAME_EXPECTED             13#define VARIABLE_EXPECTED         14#define ACTIONFUNCTOR_EXPECTED    15#define ATOM_FORMULA_EXPECTED     16#define EFFECT_DEF_EXPECTED       17#define NEG_FORMULA_EXPECTED      18#define NOT_SUPPORTED             19#define ACTION                    20#endif#define NAME_STR "name\0"#define VARIABLE_STR "variable\0"#define STANDARD_TYPE "OBJECT\0" static char * serrmsg[] = {  "domain definition expected",  "'domain' expected",  "domain name expected",  "'(' expected",  "')' expected",  "additional domain definitions expected",  "requirements (e.g. ':STRIPS') expected",  "typed list of <%s> expected",  "literal expected",  "uncorrect precondition definition",  "type definition expected",  "list of constants expected",  "predicate definition expected",  "<name> expected",  "<variable> expected",  "action functor expected",  "atomic formula expected",  "effect definition expected",  "negated atomic formula expected",  "requirement '%s' not supported by this IPP version",    "action definition is not correct",  NULL}; void opserr(int errno, char * par);static int sact_err;static char * sact_err_par = NULL;static PlOperator * scur_op = NULL;static Bool sis_negated = FALSE;int supported(char * str){  int i;  char * sup[] = { ":STRIPS", ":NEGATION", ":EQUALITY",":TYPING", 		   ":CONDITIONAL-EFFECTS", ":DISJUNCTIVE-PRECONDITIONS", 		   ":EXISTENTIAL-PRECONDITIONS", ":UNIVERSAL-PRECONDITIONS", 		   ":QUANTIFIED-PRECONDITIONS", ":ADL",		   ":DOMAIN-AXIOMS", ":SUBGOAL-THROUGH-AXIOMS",		   NULL };       for (i=0; NULL != sup[i]; i++)    {      if (SAME == strcmp(sup[i], str))	{	  return TRUE;	}    }  return FALSE;}%}%start file%union {  char string[MAX_LENGTH];  char* pstring;  PlNode* pPlNode;  FactList* pFactList;  TokenList* pTokenList;  TypedList* pTypedList;}%type <pPlNode> adl_effect%type <pPlNode> adl_effect_star%type <pPlNode> adl_goal_description%type <pPlNode> adl_goal_description_star%type <pTokenList> literal_term%type <pTokenList> term_star%type <pTypedList> typed_list_name%type <pTypedList> typed_list_variable%type <pstring> term%type <pTokenList> atomic_formula_term%type <pTokenList> name_plus%type <pstring> predicate%token DEFINE_TOK%token DOMAIN_TOK%token REQUIREMENTS_TOK%token TYPES_TOK%token EITHER_TOK%token CONSTANTS_TOK%token ACTION_TOK%token AXIOM_TOK%token VARS_TOK%token CONTEXT_TOK%token IMPLIES_TOK%token PRECONDITION_TOK%token PARAMETERS_TOK%token PREDICATES_TOK%token EFFECT_TOK%token AND_TOK%token NOT_TOK%token WHEN_TOK%token FORALL_TOK%token IMPLY_TOK%token OR_TOK%token EXISTS_TOK%token EQUAL_TOK%token <string> NAME%token <string> VARIABLE%token <string> TYPE%token OPEN_PAREN%token CLOSE_PAREN%%/**********************************************************************/file:{ opserr( DOMDEF_EXPECTED, NULL ); }domain_definition ;/* can be extended to support 'addenda' and similar stuff *//**********************************************************************/domain_definition : OPEN_PAREN  DEFINE_TOK  domain_name       {   /* initialize typetree */  gglobal_type_tree_list = new_type_tree_list( STANDARD_TYPE );}optional_domain_defs {  if ( gcmd_line.display_info ) {    fprintf(OUT, "\ndomain '%s' defined\n", gdomain_name);  }};/**********************************************************************/domain_name :OPEN_PAREN  DOMAIN_TOK  NAME  CLOSE_PAREN {   gdomain_name = new_token( strlen($3)+1 );  strcpy( gdomain_name, $3);};/**********************************************************************/optional_domain_defs:CLOSE_PAREN  /* end of domain */|require_def  optional_domain_defs|constants_def  optional_domain_defs|types_def  optional_domain_defs|axiom_def  optional_domain_defs|action_def  optional_domain_defs|predicates_def  optional_domain_defs;/**********************************************************************/predicates_def :OPEN_PAREN PREDICATES_TOK  predicates_list {}CLOSE_PAREN{ };/**********************************************************************/predicates_list :/* empty = finished */{}|OPEN_PAREN  NAME typed_list_variable  CLOSE_PAREN{  TypedListList *tll;  if ( gparse_predicates ) {    tll = gparse_predicates;    while ( tll->next ) {      tll = tll->next;    }    tll->next = new_TypedListList();    tll = tll->next;  } else {    tll = new_TypedListList();    gparse_predicates = tll;  }  tll->predicate = new_token( strlen( $2 ) + 1);  strcpy( tll->predicate, $2 );  tll->args = $3;}predicates_list;/**********************************************************************/require_def:OPEN_PAREN  REQUIREMENTS_TOK { opserr( REQUIREM_EXPECTED, NULL ); }NAME{   if ( !supported( $4 ) )    {      opserr( NOT_SUPPORTED, $4 );      yyerror();    }}require_key_star  CLOSE_PAREN;/**********************************************************************/require_key_star:/* empty */|NAME{   if ( !supported( $1 ) )    {      opserr( NOT_SUPPORTED, $1 );      yyerror();    }}require_key_star;/**********************************************************************/types_def:OPEN_PAREN  TYPES_TOK{   opserr( TYPEDEF_EXPECTED, NULL ); }typed_list_name  CLOSE_PAREN{  gparse_types = $4;}; /**********************************************************************/constants_def:OPEN_PAREN  CONSTANTS_TOK{   opserr( CONSTLIST_EXPECTED, NULL ); }typed_list_name  CLOSE_PAREN{  gparse_constants = $4;};/********************************************************************** * actions and their optional definitions **********************************************************************/action_def:OPEN_PAREN  ACTION_TOK  { opserr( ACTION, NULL ); }  NAME{   scur_op = new_pl_operator( $4 );}param_def  action_def_body  CLOSE_PAREN{  scur_op->next = gloaded_ops;  gloaded_ops = scur_op; };/**********************************************************************/param_def:/* empty */{   scur_op->params = NULL; }|PARAMETERS_TOK  OPEN_PAREN  typed_list_variable  CLOSE_PAREN{  TypedList *tl;  scur_op->parse_params = $3;  for (tl = scur_op->parse_params; tl; tl = tl->next) {    /* to be able to distinguish params from :VARS      */    scur_op->number_of_real_params++;  }}/**********************************************************************/action_def_body:/* empty */|VARS_TOK  OPEN_PAREN  typed_list_variable  CLOSE_PAREN  action_def_body{  TypedList *tl = NULL;  /* add vars as parameters    */  if ( scur_op->parse_params ) {    for( tl = scur_op->parse_params; tl->next; tl = tl->next ) {      /* empty, get to the end of list        */    }    tl->next = $3;    tl = tl->next;  } else {    scur_op->parse_params = $3;  }}|PRECONDITION_TOK  adl_goal_description{   scur_op->preconds = $2; }action_def_body|EFFECT_TOK  adl_effect{   scur_op->effects = $2; }action_def_body;/********************************************************************** * axioms (most of an axioms definition is handled by rules defined * for actions) **********************************************************************/axiom_def:OPEN_PAREN  AXIOM_TOK {  /* returns new operator the name of which is AXIOM plus a number */  scur_op = new_axiom_op_list(); }VARS_TOK  OPEN_PAREN  typed_list_variable  CLOSE_PAREN{  scur_op->parse_params = $6;}CONTEXT_TOK  adl_goal_description{   scur_op->preconds = $10; }IMPLIES_TOK  literal_term  {  PlNode * tmp;  if (TRUE == sis_negated)    {      tmp = new_pl_node(NOT);      tmp->sons = new_pl_node(ATOM);      tmp->sons->atom = $13;      sis_negated = FALSE;    }  else    {      tmp = new_pl_node(ATOM);      tmp->atom = $13;    }  scur_op->effects = tmp;}CLOSE_PAREN{  /* Allowing complete "effects" is more than UCPOP and PDDL do,     but this can easily be checked: the effect must be a single     literal, otherwise axiom effects may become a little complicated */  scur_op->next = gloaded_axioms;  gloaded_axioms = scur_op;  /* save axioms separately for now, after preprocessing they may     be added to the other operators */};/**********************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -