?? scan-ops_pddl.y
字號:
* Goal description providing full ADL. * RETURNS a tree with the connectives in the nodes and the atomic * predicates in the leafs. **********************************************************************/adl_goal_description:literal_term{ if (TRUE == sis_negated) { $$ = new_pl_node(NOT); $$->sons = new_pl_node(ATOM); $$->sons->atom = $1; sis_negated = FALSE; } else { $$ = new_pl_node(ATOM); $$->atom = $1; }}|OPEN_PAREN AND_TOK adl_goal_description_star CLOSE_PAREN{ $$ = new_pl_node(AND); $$->sons = $3;}|OPEN_PAREN OR_TOK adl_goal_description_star CLOSE_PAREN{ $$ = new_pl_node(OR); $$->sons = $3;}|OPEN_PAREN NOT_TOK adl_goal_description CLOSE_PAREN{ $$ = new_pl_node(NOT); $$->sons = $3;}|OPEN_PAREN IMPLY_TOK adl_goal_description adl_goal_description CLOSE_PAREN{ PlNode * np = new_pl_node(NOT); np->sons = $3; np->next = $4; $$ = new_pl_node(OR); $$->sons = np;}|OPEN_PAREN EXISTS_TOK OPEN_PAREN typed_list_variable CLOSE_PAREN adl_goal_description CLOSE_PAREN{ PlNode *pln; pln = new_pl_node(EX); pln->parse_vars = $4; $$ = pln; pln->sons = $6;}|OPEN_PAREN FORALL_TOK OPEN_PAREN typed_list_variable CLOSE_PAREN adl_goal_description CLOSE_PAREN{ PlNode *pln; pln = new_pl_node(ALL); pln->parse_vars = $4; $$ = pln; pln->sons = $6;};/**********************************************************************/adl_goal_description_star:/* empty */{ $$ = NULL;}|adl_goal_description adl_goal_description_star{ $1->next = $2; $$ = $1;}/********************************************************************** * effects as allowed in pddl are saved in IPP data structures * describes everything after the keyword :effect *********************************************************************/adl_effect:literal_term{ if (TRUE == sis_negated) { $$ = new_pl_node(NOT); $$->sons = new_pl_node(ATOM); $$->sons->atom = $1; sis_negated = FALSE; } else { $$ = new_pl_node(ATOM); $$->atom = $1; }}|OPEN_PAREN AND_TOK adl_effect_star CLOSE_PAREN{ $$ = new_pl_node(AND); $$->sons = $3;}|OPEN_PAREN NOT_TOK adl_effect CLOSE_PAREN{ $$ = new_pl_node(NOT); $$->sons = $3;}|OPEN_PAREN FORALL_TOK OPEN_PAREN typed_list_variable CLOSE_PAREN adl_effect CLOSE_PAREN{ PlNode *pln; pln = new_pl_node(ALL); pln->parse_vars = $4; $$ = pln; pln->sons = $6;}|OPEN_PAREN WHEN_TOK adl_goal_description adl_effect CLOSE_PAREN{ /* This will be conditional effects in IPP representation, but here a formula like (WHEN p q) will be saved as: [WHEN] [sons] / \ [p] [q] That means, the first son is p, and the second one is q. */ $$ = new_pl_node(WHEN); $3->next = $4; $$->sons = $3;};/**********************************************************************/adl_effect_star:{ $$ = NULL; }|adl_effect adl_effect_star{ $1->next = $2; $$ = $1;};/********************************************************************** * some expressions used in many different rules **********************************************************************/literal_term:OPEN_PAREN NOT_TOK atomic_formula_term CLOSE_PAREN{ $$ = $3; sis_negated = TRUE;/* $$ = new_token_list(); *//* $$->item = new_token( strlen($3->item)+2 ); *//* sprintf($$->item, "!%s", $3->item); *//* $$->next = $3->next; */}|atomic_formula_term{ $$ = $1;};/**********************************************************************/atomic_formula_term:OPEN_PAREN predicate term_star CLOSE_PAREN{ $$ = new_token_list(); $$->item = $2; $$->next = $3;};/**********************************************************************/term_star:/* empty */{ $$ = NULL; }|term term_star{ $$ = new_token_list(); $$->item = $1; $$->next = $2;};/**********************************************************************/term:NAME{ $$ = new_token( strlen($1)+1 ); strcpy( $$, $1 );}|VARIABLE{ $$ = new_token( strlen($1)+1 ); strcpy( $$, $1 );};/**********************************************************************/name_plus:NAME{ $$ = new_token_list(); $$->item = new_token( strlen($1)+1 ); strcpy( $$->item, $1 );}|NAME name_plus{ $$ = new_token_list(); $$->item = new_token( strlen($1)+1 ); strcpy( $$->item, $1 ); $$->next = $2;}/**********************************************************************/predicate:NAME{ $$ = new_token( strlen($1)+1 ); strcpy( $$, $1 );}|EQUAL_TOK{ $$ = new_token( strlen(EQ_STR)+1 ); strcpy( $$, EQ_STR );};/**********************************************************************/typed_list_name: /* returns TypedList *//* empty */{ $$ = NULL; }|NAME EITHER_TOK name_plus CLOSE_PAREN typed_list_name{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); $$->type = $3; $$->next = $5;}|NAME TYPE typed_list_name /* end of list for one type */{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); $$->type = new_token_list(); $$->type->item = new_token( strlen($2)+1 ); strcpy( $$->type->item, $2 ); $$->next = $3;}|NAME typed_list_name /* a list element (gets type from next one) */{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); if ( $2 ) {/* another element (already typed) is following */ $$->type = copy_token_list( $2->type ); } else {/* no further element - it must be an untyped list */ $$->type = new_token_list(); $$->type->item = new_token( strlen(STANDARD_TYPE)+1 ); strcpy( $$->type->item, STANDARD_TYPE ); } $$->next = $2;};/***********************************************/typed_list_variable: /* returns TypedList *//* empty */{ $$ = NULL; }|VARIABLE EITHER_TOK name_plus CLOSE_PAREN typed_list_variable{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); $$->type = $3; $$->next = $5;}|VARIABLE TYPE typed_list_variable /* end of list for one type */{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); $$->type = new_token_list(); $$->type->item = new_token( strlen($2)+1 ); strcpy( $$->type->item, $2 ); $$->next = $3;}|VARIABLE typed_list_variable /* a list element (gets type from next one) */{ $$ = new_TypedList(); $$->name = new_token( strlen($1)+1 ); strcpy( $$->name, $1 ); if ( $2 ) {/* another element (already typed) is following */ $$->type = copy_token_list( $2->type ); } else {/* no further element - it must be an untyped list */ $$->type = new_token_list(); $$->type->item = new_token( strlen(STANDARD_TYPE)+1 ); strcpy( $$->type->item, STANDARD_TYPE ); } $$->next = $2;};%%#include "lex.ops_pddl.c"/********************************************************************** * Functions **********************************************************************//* call bison -pops -bscan-ops scan-ops.y*/void opserr(int errno, char * par){ sact_err = errno; if (NULL != sact_err_par) { free(sact_err_par); } if (NULL != par) { sact_err_par = new_token(strlen(par)+1); strcpy(sact_err_par, par); } else { sact_err_par = NULL; }} int yyerror(char * msg){ fflush(stdout); fprintf(stderr, "\n%s: syntax error in line %d, '%s':\n", gact_filename, lineno, yytext); if (NULL != sact_err_par) { fprintf(stderr, "%s %s\n", serrmsg[sact_err], sact_err_par); } else { fprintf(stderr, "%s\n", serrmsg[sact_err]); } switch (sact_err) { case NOT_SUPPORTED: exit( NOT_SUPPORTED_ERROR_CODE ); default: exit( OPS_PARSE_ERROR_CODE ); }}void load_ops_file(char * filename){ FILE * fp;/* pointer to input files */ char tmp[MAX_LENGTH] = ""; /* open operator file */ if( ( fp = fopen( filename, "r" ) ) == NULL ) { sprintf(tmp, "\nipp: can't find operator file: %s\n\n", filename ); perror(tmp); exit( OPS_MISSING_ERROR_CODE ); } gact_filename = filename; lineno = 1; yyin = fp; yyparse(); fclose( fp );/* and close file again */}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -