version 1.8, 2000/02/09 22:10:24
|
version 1.16, 2000/09/20 17:21:01
|
Line 1
|
Line 1
|
|
/* main CAPA parser |
|
Copyright (C) 1992-2000 Michigan State University |
|
|
|
The CAPA system 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. |
|
|
|
The CAPA system 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 the CAPA system; see the file COPYING. If not, |
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
Boston, MA 02111-1307, USA. |
|
|
|
As a special exception, you have permission to link this program |
|
with the TtH/TtM library and distribute executables, as long as you |
|
follow the requirements of the GNU GPL in regard to all of the |
|
software in the executable aside from TtH/TtM. |
|
*/ |
|
|
/* ========================================================================== */ |
/* ========================================================================== */ |
/* capaGrammarDef.y created by Isaac Tsai */ |
/* capaGrammarDef.y created by Isaac Tsai */ |
/* 1998, 1999 copyrighted by Isaac Tsai */ |
/* 1998, 1999 by Isaac Tsai */ |
/* no longer there is a length constrain on string concatenation July 13 1998 */ |
/* no longer there is a length constrain on string concatenation July 13 1998 */ |
/* /RMAP() function */ |
/* /RMAP() function */ |
/* TODO: new mechanism to collect answer informations */ |
/* TODO: new mechanism to collect answer informations */ |
Line 36
|
Line 60
|
case S_VAR: case S_CONSTANT: \ |
case S_VAR: case S_CONSTANT: \ |
printf("STR(%s)\n",(xx)->s_str); break; \ |
printf("STR(%s)\n",(xx)->s_str); break; \ |
} } |
} } |
#else |
#else /* YACC_DBUG */ |
#define YYDBUG_PR1(xx) { } |
#define YYDBUG_PR1(xx) { } |
#define YYDBUG_PR2(xx,yy) { } |
#define YYDBUG_PR2(xx,yy) { } |
#define YYDBUG_PR3(xx,yy,zz) { } |
#define YYDBUG_PR3(xx,yy,zz) { } |
#define YYDBUG_PR4(xx,yy,zz,aa) { } |
#define YYDBUG_PR4(xx,yy,zz,aa) { } |
#define YYDBUG_SYM(xx) { } |
#define YYDBUG_SYM(xx) { } |
#endif |
#endif /* YACC_DBUG */ |
|
|
int yylex(); |
int yylex(); |
void yyerror(char*); |
void yyerror(char*); |
Line 118 PointsList_t *LastPtsList;
|
Line 142 PointsList_t *LastPtsList;
|
%token ANS_OFF ANS_ON ANS_OR ANS_ORDERED |
%token ANS_OFF ANS_ON ANS_OR ANS_ORDERED |
%token ANS_PATH ANS_PCREDIT ANS_PLUS ANS_RANGE |
%token ANS_PATH ANS_PCREDIT ANS_PLUS ANS_RANGE |
%token ANS_SHOW_BR ANS_SIG ANS_TOLERANCE ANS_TRY ANS_TYPE |
%token ANS_SHOW_BR ANS_SIG ANS_TOLERANCE ANS_TRY ANS_TYPE |
%token ANS_UNFMT ANS_UNIT ANS_WEIGHT |
%token ANS_UNFMT ANS_UNIT ANS_VERBATIM ANS_WEIGHT |
%token VAR_RANGE VERBATIM |
%token VAR_RANGE VERBATIM |
%token SLASH FORMAT |
%token SLASH FORMAT |
%token EQ_op NE_op GT_op GE_op LT_op LE_op AND_op OR_op EoL |
%token EQ_op NE_op GT_op GE_op LT_op LE_op AND_op OR_op EoL |
Line 226 statement : IDENTIFIER '=' calc_expr
|
Line 250 statement : IDENTIFIER '=' calc_expr
|
case IDENTIFIER: |
case IDENTIFIER: |
case I_VAR: case I_CONSTANT: |
case I_VAR: case I_CONSTANT: |
case R_VAR: case R_CONSTANT: break; |
case R_VAR: case R_CONSTANT: break; |
case S_VAR: case S_CONSTANT: |
case S_VAR: case S_CONSTANT: /* free up original used spaces */ |
capa_mfree($1->s_str); $1->s_str = NULL; break; |
capa_mfree($1->s_str); $1->s_str = NULL; break; |
default: break; |
default: break; |
} |
} |
Line 506 ans_infospec : ANS_TOLERANCE '=' a_numbe
|
Line 530 ans_infospec : ANS_TOLERANCE '=' a_numbe
|
} |
} |
| ANS_SHOW_BR '=' ANS_OFF { LexiProblem_p->show_br = DONOT_SHOW; |
| ANS_SHOW_BR '=' ANS_OFF { LexiProblem_p->show_br = DONOT_SHOW; |
} |
} |
|
| ANS_VERBATIM '=' ANS_ON { LexiProblem_p->verbatim = DO_VERBATIM; |
|
} |
|
| ANS_VERBATIM '=' ANS_OFF { LexiProblem_p->verbatim = DONOT_VERBATIM; |
|
} |
| ANS_BOX_SHOW '=' ANS_ON { LexiProblem_p->show_ans_box = DO_SHOW; |
| ANS_BOX_SHOW '=' ANS_ON { LexiProblem_p->show_ans_box = DO_SHOW; |
} |
} |
| ANS_BOX_SHOW '=' ANS_OFF { LexiProblem_p->show_ans_box = DONOT_SHOW; |
| ANS_BOX_SHOW '=' ANS_OFF { LexiProblem_p->show_ans_box = DONOT_SHOW; |
Line 676 map_expr : startM '(' basic_constr '
|
Line 704 map_expr : startM '(' basic_constr '
|
a_sp=build_array_list($5,$7->s_argc); |
a_sp=build_array_list($5,$7->s_argc); |
result=do_map(key, a_sp->s_argp, $7->s_argp, a_sp->s_argc, FORWARD_MAP); |
result=do_map(key, a_sp->s_argp, $7->s_argp, a_sp->s_argc, FORWARD_MAP); |
free_arglist(a_sp->s_argp); |
free_arglist(a_sp->s_argp); |
|
a_sp->s_argp=NULL; |
} else { |
} else { |
sprintf(warn_msg,"/MAP arg. counts are not matched.\n"); |
sprintf(warn_msg,"/MAP arg. counts are not matched.\n"); |
capa_msg(MESSAGE_ERROR,warn_msg); |
capa_msg(MESSAGE_ERROR,warn_msg); |
Line 687 map_expr : startM '(' basic_constr '
|
Line 716 map_expr : startM '(' basic_constr '
|
capa_msg(MESSAGE_ERROR,warn_msg); |
capa_msg(MESSAGE_ERROR,warn_msg); |
} |
} |
free_arglist($5->s_argp); |
free_arglist($5->s_argp); |
free_arglist($7->s_argp); |
$5->s_argp=NULL; |
|
free_arglist($7->s_argp); |
|
$7->s_argp=NULL; |
} |
} |
| startR '(' basic_constr ';' var_list ';' arg_list ')' |
| startR '(' basic_constr ';' var_list ';' arg_list ')' |
{ char key[SMALL_LINE_BUFFER]; |
{ char key[SMALL_LINE_BUFFER]; |
Line 705 map_expr : startM '(' basic_constr '
|
Line 736 map_expr : startM '(' basic_constr '
|
a_sp=build_array_list($5,$7->s_argc); |
a_sp=build_array_list($5,$7->s_argc); |
result=do_map(key, a_sp->s_argp, $7->s_argp, a_sp->s_argc, FORWARD_MAP); |
result=do_map(key, a_sp->s_argp, $7->s_argp, a_sp->s_argc, FORWARD_MAP); |
free_arglist(a_sp->s_argp); |
free_arglist(a_sp->s_argp); |
|
a_sp->s_argp=NULL; |
} else { |
} else { |
sprintf(warn_msg,"/RMAP arg. counts are not matched.\n"); |
sprintf(warn_msg,"/RMAP arg. counts are not matched.\n"); |
capa_msg(MESSAGE_ERROR,warn_msg); |
capa_msg(MESSAGE_ERROR,warn_msg); |
Line 716 map_expr : startM '(' basic_constr '
|
Line 748 map_expr : startM '(' basic_constr '
|
capa_msg(MESSAGE_ERROR,warn_msg); |
capa_msg(MESSAGE_ERROR,warn_msg); |
} |
} |
free_arglist($5->s_argp); |
free_arglist($5->s_argp); |
|
$5->s_argp=NULL; |
free_arglist($7->s_argp); |
free_arglist($7->s_argp); |
|
$7->s_argp=NULL; |
} |
} |
; |
; |
|
|
Line 768 basic_constr : FUNCTION_ID '(' ')' {
|
Line 802 basic_constr : FUNCTION_ID '(' ')' {
|
$$ = do_function(tmp, $3->s_argc, $3->s_argp); |
$$ = do_function(tmp, $3->s_argc, $3->s_argp); |
capa_mfree(FuncStack[Func_idx].s_name); |
capa_mfree(FuncStack[Func_idx].s_name); |
free_arglist($3->s_argp); |
free_arglist($3->s_argp); |
|
$3->s_argp=NULL; |
} |
} |
YYDBUG_PR1(" basic_constr <= RETURN FUNCT "); YYDBUG_SYM($$); |
YYDBUG_PR1(" basic_constr <= RETURN FUNCT "); YYDBUG_SYM($$); |
|
|
Line 845 an_integer : I_CONSTANT
|
Line 880 an_integer : I_CONSTANT
|
a_real : R_CONSTANT { $$ = $1; } |
a_real : R_CONSTANT { $$ = $1; } |
; |
; |
|
|
an_array : ARRAY_ID '[' calc_expr ']' { $$=get_array_symbol($1,$3,1); } |
an_array : ARRAY_ID '[' calc_expr ']' { |
|
YYDBUG_PR1(" an_array <= ARRAY_ID '['calc_expr ']' "); |
|
$$=get_array_symbol($1,$3,1); |
|
} |
; |
; |
|
|
startQ : { /* first matching will occur before first line of input text */ |
startQ : { /* first matching will occur before first line of input text */ |
Line 926 Symbol *name,*index;int free_symbols;
|
Line 964 Symbol *name,*index;int free_symbols;
|
|
|
key = (char *)capa_malloc(idx_len+leng,1); |
key = (char *)capa_malloc(idx_len+leng,1); |
sprintf(key,"%s[%s]",name->s_name,tmp); |
sprintf(key,"%s[%s]",name->s_name,tmp); |
|
a_p = (Symbol *)NULL; |
a_p = find_arrayid(name->s_name); /* use the array name to search array tree */ |
a_p = find_arrayid(name->s_name); /* use the array name to search array tree */ |
|
if( a_p == NULL ) { |
|
return NULL; |
|
} |
/* did not check for error! */ |
/* did not check for error! */ |
s_p = find_array_by_index(a_p,key); /* use the index portion to search along array linked list */ |
s_p = find_array_by_index(a_p,key); /* use the index portion to search along array linked list */ |
capa_mfree((char *)tmp); capa_mfree((char *)key); |
capa_mfree((char *)tmp); capa_mfree((char *)key); |