version 1.20, 2002/03/20 18:19:59
|
version 1.21, 2002/09/12 15:54:06
|
Line 152 int While_idx, Wcount;
|
Line 152 int While_idx, Wcount;
|
int sccount; /* Semi-colon count for MAP and RMAP */ |
int sccount; /* Semi-colon count for MAP and RMAP */ |
int HINTflag=0; |
int HINTflag=0; |
int EXPflag=0; |
int EXPflag=0; |
|
int EVALflag=0; |
|
int compound_answer=0; |
|
int essay_answer=0; |
|
|
#ifdef USE_DYNAMIC_SYMBOLS |
#ifdef USE_DYNAMIC_SYMBOLS |
Symbol *SymbList_p; |
Symbol *SymbList_p; |
Line 244 void newyy_input (char *buf,int *result,
|
Line 247 void newyy_input (char *buf,int *result,
|
} \ |
} \ |
Input_idx = 0; \ |
Input_idx = 0; \ |
first_run=0; \ |
first_run=0; \ |
yyin = Input_stream[Input_idx]; LIDBUG_PR1("<<yy_input() startup>>\n"); \ |
yyin = Input_stream[Input_idx]; LIDBUG_PR1("<<yy_input() startup>>\n"); \ |
} \ |
} \ |
out_of_char = 0; \ |
out_of_char = 0; \ |
if ( Lexi_buf[Input_idx] == NULL ) { \ |
if ( Lexi_buf[Input_idx] == NULL ) { \ |
Line 435 EndLine ([\r][\n]|[\n])
|
Line 438 EndLine ([\r][\n]|[\n])
|
HINTflag=-1; |
HINTflag=-1; |
} |
} |
change_destination(HINT_DEST); |
change_destination(HINT_DEST); |
|
send("\t",NULL); |
BEGIN S_HINT; |
BEGIN S_HINT; |
} |
} |
^{Spaces}"/EXP"{Alpha}*{Spaces} { |
^{Spaces}"/EXP"{Alpha}*{Spaces} { |
Line 443 EndLine ([\r][\n]|[\n])
|
Line 447 EndLine ([\r][\n]|[\n])
|
EXPflag=-1; |
EXPflag=-1; |
} |
} |
change_destination(EXP_DEST); |
change_destination(EXP_DEST); |
|
send("\t",NULL); |
LLDBUG_PRL1("[EXP]"); Current_char_p = String_buf; BEGIN S_EXPLAIN; } |
LLDBUG_PRL1("[EXP]"); Current_char_p = String_buf; BEGIN S_EXPLAIN; } |
^{Spaces}"/IMP"{Alpha}*{Space}+ { LLDBUG_PRL1("[IMP]"); BEGIN S_IMPORT; end_mode(); } |
^{Spaces}"/IMP"{Alpha}*{Space}+ { LLDBUG_PRL1("[IMP]"); BEGIN S_IMPORT; end_mode(); } |
^{Spaces}"/END" { LLDBUG_PRL1("[END]"); |
^{Spaces}"/END" { LLDBUG_PRL1("[END]"); |
Line 476 EndLine ([\r][\n]|[\n])
|
Line 481 EndLine ([\r][\n]|[\n])
|
send("<numericalresponse answer=\""); |
send("<numericalresponse answer=\""); |
dosend=1; |
dosend=1; |
firstparam=1; |
firstparam=1; |
|
compound_answer=0; |
|
essay_answer=0; |
} |
} |
^{Spaces}"/SUBJECTIVE" { LLDBUG_PRL1("[SUBJECTIVE ANSWER]"); |
^{Spaces}"/SUBJECTIVE" { LLDBUG_PRL1("[SUBJECTIVE ANSWER]"); |
Pcount = 0; |
Pcount = 0; |
BEGIN S_ANSWER; |
BEGIN S_ANSWER; |
end_mode(); |
end_mode(); |
start_mode(MODE_ANSWER,NULL); |
start_mode(MODE_ANSWER,NULL); |
send("<capasubjectiveresponse"); |
send("<essayresponse"); |
dosend=1; |
dosend=1; |
firstparam=1; |
firstparam=1; |
|
compound_answer=0; |
|
essay_answer=-1; |
} |
} |
^{Spaces}"/MAP" { LLDBUG_PRL1("[MAP]"); Pcount = 0; sccount = 0; BEGIN S_MAP; start_mode(MODE_SCRIPT,NULL);send("&map("); } |
^{Spaces}"/MAP" { LLDBUG_PRL1("[MAP]"); Pcount = 0; sccount = 0; BEGIN S_MAP; start_mode(MODE_SCRIPT,NULL);send("&map("); } |
^{Spaces}"/RMAP" { LLDBUG_PRL1("[RMAP]"); Pcount = 0; sccount = 0; BEGIN S_MAP; start_mode(MODE_SCRIPT,NULL);send("&rmap("); } |
^{Spaces}"/RMAP" { LLDBUG_PRL1("[RMAP]"); Pcount = 0; sccount = 0; BEGIN S_MAP; start_mode(MODE_SCRIPT,NULL);send("&rmap("); } |
Line 569 EndLine ([\r][\n]|[\n])
|
Line 578 EndLine ([\r][\n]|[\n])
|
delete_cache(); |
delete_cache(); |
LLDBUG_PRL2("[ENDIF <IFcount=%d>]\n",IFcount); |
LLDBUG_PRL2("[ENDIF <IFcount=%d>]\n",IFcount); |
} |
} |
"/AND" { LLDBUG_PRL1("[AND]"); /*implict in LON-CAPA*/} |
|
"/DIS" { /* since S_VARIABLE treat {Space} as null, so here we do not match ( */ |
"/DIS" { /* since S_VARIABLE treat {Space} as null, so here we do not match ( */ |
/* so that between /DIS and ( can have as many {Space} as we want */ |
/* so that between /DIS and ( can have as many {Space} as we want */ |
|
start_mode(MODE_OUTTEXT,NULL); |
LLDBUG_PR1("[DIS<]"); |
LLDBUG_PR1("[DIS<]"); |
init_funcstack(); |
init_funcstack(); |
Pcount = 0; BEGIN S_VARIABLE; |
Pcount = 0; BEGIN S_VARIABLE; |
|
send("<display>"); |
start_delayed(); |
start_delayed(); |
} |
} |
"/OR" { LLDBUG_PRL1("[OR]"); BEGIN S_ANSCONTINUE; RETURN(ANS_OR); } |
|
{EndLine} { LLDBUG_PR1("[EoL within S_TEXT]\n"); /* end of the whole text line */ |
{EndLine} { LLDBUG_PR1("[EoL within S_TEXT]\n"); /* end of the whole text line */ |
send("\n"); } |
send("\n"); } |
[\\]{Space}*{EndLine} { LLDBUG_PR2("[\\EoL continue](%s)",yytext); /* continuation on next line */ } |
[\\]{Space}*{EndLine} { LLDBUG_PR2("[\\EoL continue](%s)",yytext); /* continuation on next line */ } |
Line 707 EndLine ([\r][\n]|[\n])
|
Line 716 EndLine ([\r][\n]|[\n])
|
} |
} |
[/] { send("/"); } |
[/] { send("/"); } |
[\\] { send("\\"); } |
[\\] { send("\\"); } |
[\\]{Space}*[\n] { LLDBUG_PR1("[\\CR hint explain continue]"); /* Hint and explain continuation */ } |
[\\]{Space}*[\n] { LLDBUG_PR1("[\\CR hint explain continue]"); /* Hint and explain continuation */ send("\n\t");} |
[^/\n\\]+$ {char *aptr = yytext; |
[^/\n\\]+$ {char *aptr = yytext; |
send(aptr); |
send(aptr); |
} |
} |
Line 734 EndLine ([\r][\n]|[\n])
|
Line 743 EndLine ([\r][\n]|[\n])
|
} |
} |
|
|
<S_IMPORT>{ |
<S_IMPORT>{ |
{FileName}{Space}* { char *endquote; |
{FileName}{Space}* { |
|
char *endquote; |
end_mode(); |
end_mode(); |
start_mode(MODE_IMPORT,NULL); |
start_mode(MODE_IMPORT,NULL); |
/* Get rid of leading and trailing quotes */ |
/* Get rid of leading and trailing quotes */ |
Line 750 EndLine ([\r][\n]|[\n])
|
Line 760 EndLine ([\r][\n]|[\n])
|
} |
} |
{Identifier}{Space}* { end_mode(); |
{Identifier}{Space}* { end_mode(); |
start_mode(MODE_IMPORT,NULL); |
start_mode(MODE_IMPORT,NULL); |
send("$%s",yytext); |
send("${%s}",yytext); |
end_mode(); |
end_mode(); |
BEGIN S_SKIP; |
BEGIN S_SKIP; |
} |
} |
Line 782 EndLine ([\r][\n]|[\n])
|
Line 792 EndLine ([\r][\n]|[\n])
|
if (dosend==2) add_delayed("%s",yytext); |
if (dosend==2) add_delayed("%s",yytext); |
} |
} |
"<" { LLDBUG_PR2("[symbol(%s)]",yytext); |
"<" { LLDBUG_PR2("[symbol(%s)]",yytext); |
|
if (!EVALflag) { |
if (dosend==1) send("%s",yytext); |
if (dosend==1) send("%s",yytext); |
if (dosend==2) add_delayed("%s",yytext); |
if (dosend==2) add_delayed("%s",yytext); |
} |
} |
|
} |
">" { LLDBUG_PR2("[symbol(%s)]",yytext); |
">" { LLDBUG_PR2("[symbol(%s)]",yytext); |
|
if (!EVALflag) { |
if (dosend==1) send("%s",yytext); |
if (dosend==1) send("%s",yytext); |
if (dosend==2) add_delayed("%s",yytext); |
if (dosend==2) add_delayed("%s",yytext); |
|
} else { |
|
EVALflag = 0; |
|
} |
} |
} |
|
|
[Pp][Cc][Rr] | |
[Pp][Cc][Rr] | |
Line 821 EndLine ([\r][\n]|[\n])
|
Line 837 EndLine ([\r][\n]|[\n])
|
|
|
[Ss][Tt][Rr] { LLDBUG_PR1("[STR]"); send("\" type=\""); dosend=1; } |
[Ss][Tt][Rr] { LLDBUG_PR1("[STR]"); send("\" type=\""); dosend=1; } |
[Ee][Vv][Aa][Ll] | |
[Ee][Vv][Aa][Ll] | |
[Ee][Vv][Aa][Ll][Uu][Aa][Tt][Ee] { LLDBUG_PR1("[EVAL]");send("\" eval="); dosend=1;} |
[Ee][Vv][Aa][Ll][Uu][Aa][Tt][Ee] { LLDBUG_PR1("[EVAL]");send("\" eval=\""); EVALflag=1; dosend=1;} |
[Uu][Nn][Ii][Tt] | |
[Uu][Nn][Ii][Tt] | |
[Uu][Nn][Ii][Tt][Ss] { LLDBUG_PR1("[UNIT]"); send("\" unit=\""); dosend=1;} |
[Uu][Nn][Ii][Tt][Ss] { LLDBUG_PR1("[UNIT]"); send("\" unit=\""); dosend=1;} |
|
|
Line 842 EndLine ([\r][\n]|[\n])
|
Line 858 EndLine ([\r][\n]|[\n])
|
if(Pcount==0) { |
if(Pcount==0) { |
BEGIN S_ANSCONTINUE; |
BEGIN S_ANSCONTINUE; |
} |
} |
|
if (essay_answer) { |
|
send(">\n\t"); |
|
} else { |
send("\">\n\t"); |
send("\">\n\t"); |
|
} |
dosend=1; |
dosend=1; |
flush_delayed(); |
flush_delayed(); |
if (firstparam!=1) send("\" />\n"); |
if (firstparam!=1) send("\" />\n"); |
|
if (essay_answer) { |
|
send(" <textfield>Enter your answer here.</textfield>\n"); |
|
} else { |
send("\t<textline />\n"); |
send("\t<textline />\n"); |
|
} |
/* Fill in Hints */ |
/* Fill in Hints */ |
if ( !is_dest_empty(HINT_DEST) ) { |
if ( !is_dest_empty(HINT_DEST) ) { |
send("<hintgroup>\n\t<hintpart on=\"default\">\n\t<startouttext />"); |
send("\t<hintgroup>\n\t<hintpart on=\"default\">\n\t<startouttext />"); |
end_streams(HINT_DEST,0); |
end_streams(HINT_DEST,0); |
HINTflag=0; |
HINTflag=0; |
send("\t<endouttext />\n\t</hintpart>\n</hintgroup>\n"); |
send("\t<endouttext />\n\t</hintpart>\n\t</hintgroup>\n"); |
|
} |
|
if (essay_answer) { |
|
send("</essayresponse>\n"); |
|
} else { |
|
send("</numericalresponse>\n"); |
} |
} |
send("\n</numericalresponse>\n"); |
|
|
|
if ( !is_dest_empty(EXP_DEST) ) { |
} |
send("<postanswerdate>\n\t<startouttext />\n"); |
} |
end_streams(EXP_DEST,0); |
|
EXPflag=0; |
<S_VARIABLE>{ |
send("\t<endouttext />\n</postanswerdate>\n"); |
{Alpha}{AlphaNum}* { LLDBUG_PR2("[ID<%s>]",yytext); |
|
LLDBUG_PR2("[SYMB CNT=<%d>]", Symb_count); |
|
if(Pcount <= 1) { |
|
if (dosend==1) send("${%s}",yytext); |
|
if (dosend==2) add_delayed("${%s}",yytext); |
|
} else { |
|
if (dosend==1) send("$%s",yytext); |
|
if (dosend==2) add_delayed("$%s",yytext); |
} |
} |
} |
} |
} |
} |
Line 878 EndLine ([\r][\n]|[\n])
|
Line 913 EndLine ([\r][\n]|[\n])
|
} |
} |
{Alpha}{AlphaNum}*{Space}*[\[] { |
{Alpha}{AlphaNum}*{Space}*[\[] { |
LLDBUG_PR2("[ARRAY<%s>]",yytext); |
LLDBUG_PR2("[ARRAY<%s>]",yytext); |
|
|
yyless(yyleng-1); /*<-- push back char '[' */ |
yyless(yyleng-1); /*<-- push back char '[' */ |
if (dosend==1) send("$%s",yytext); |
if (dosend==1) send("$%s",yytext); |
if (dosend==2) add_delayed("$%s",yytext); |
if (dosend==2) add_delayed("$%s",yytext); |
Line 980 EndLine ([\r][\n]|[\n])
|
Line 1014 EndLine ([\r][\n]|[\n])
|
} |
} |
} |
} |
|
|
|
<S_VARIABLE>{ |
|
"+" { send(".");} |
|
} |
|
|
<S_VARIABLE,S_TRUE_FALSE_STMT,S_LET,S_MAP>{ |
<S_VARIABLE,S_TRUE_FALSE_STMT,S_LET,S_MAP>{ |
"==" { LLDBUG_PR1("[==]"); send(yytext); } |
"==" { LLDBUG_PR1("[==]"); send(" eq "); } |
"!=" { LLDBUG_PR1("[!=]"); send(yytext); } |
"!=" { LLDBUG_PR1("[!=]"); send(" ne "); } |
">" { LLDBUG_PR1("[>]"); send(yytext); } |
">" { LLDBUG_PR1("[>]"); send(yytext); } |
">=" { LLDBUG_PR1("[>=]"); send(yytext); } |
">=" { LLDBUG_PR1("[>=]"); send(yytext); } |
"<" { LLDBUG_PR1("[<]"); send(yytext); } |
"<" { LLDBUG_PR1("[<]"); send(yytext); } |
Line 1004 EndLine ([\r][\n]|[\n])
|
Line 1042 EndLine ([\r][\n]|[\n])
|
[\)] { LLDBUG_PR1("[)]"); |
[\)] { LLDBUG_PR1("[)]"); |
Pcount--; |
Pcount--; |
if(Pcount == 0) { |
if(Pcount == 0) { |
|
send("</display>"); |
BEGIN S_TEXT; |
BEGIN S_TEXT; |
flush_delayed(); |
flush_delayed(); |
} else { |
} else { |
Line 1027 EndLine ([\r][\n]|[\n])
|
Line 1066 EndLine ([\r][\n]|[\n])
|
send_stream(0,"\">\n"); |
send_stream(0,"\">\n"); |
send_stream(1,") {\n"); |
send_stream(1,") {\n"); |
BEGIN S_NEXT_LINE; |
BEGIN S_NEXT_LINE; |
|
} else { |
|
send_stream(0,")"); |
|
send_stream(1,")"); |
} |
} |
} |
} |
[\\]{Space}*{EndLine} { |
[\\]{Space}*{EndLine} { |
Line 1056 EndLine ([\r][\n]|[\n])
|
Line 1098 EndLine ([\r][\n]|[\n])
|
[%] { /*Escape percent signs so that vasprintf doesn't choke */ |
[%] { /*Escape percent signs so that vasprintf doesn't choke */ |
send("%%"); |
send("%%"); |
} |
} |
|
[\'] { /* Escape single quotes so that perl doesn't choke */ |
|
send("\\\'"); |
|
} |
{EndLine} { /* check for termination of string constant */ |
{EndLine} { /* check for termination of string constant */ |
char warn_msg[WARN_MSG_LENGTH]; |
char warn_msg[WARN_MSG_LENGTH]; |
|
|
Line 1118 EndLine ([\r][\n]|[\n])
|
Line 1163 EndLine ([\r][\n]|[\n])
|
} |
} |
|
|
<S_ANSCONTINUE>{ |
<S_ANSCONTINUE>{ |
{Space}+ { /* ignore white spaces */ } |
{Spaces}{EndLine}{Spaces}"/AND" { LLDBUG_PR1("[AND]"); |
[\\]{Space}*{EndLine} { /* continuation */ } |
compound_answer=-1; |
{EndLine} { /* end of answer and/or other answers */ LLDBUG_PR1("[complete an answer<EoL>]"); |
/* implicit in LON-CAPA */ } |
BEGIN S_TEXT; } |
{Spaces}{EndLine}{Spaces}"/OR" { LLDBUG_PR1("[OR]"); |
"/AND" { LLDBUG_PR1("[AND]"); /* implicit in LON-CAPA */ } |
compound_answer=-1; |
"/OR" { LLDBUG_PR1("[OR]"); RETURN(ANS_OR); } |
/*RETURN(ANS_OR); */ } |
|
{Spaces}{EndLine}{Spaces}"/ANS" { LLDBUG_PRL2("[ANS(%s)]",yytext); |
|
Pcount = 0; |
|
BEGIN S_ANSWER; |
|
end_mode(); |
|
if (!compound_answer) { |
|
if ( !is_dest_empty(EXP_DEST) ) { |
|
send("<postanswerdate>\n\t<startouttext />\n"); |
|
end_streams(EXP_DEST,0); |
|
EXPflag=0; |
|
send("\t<endouttext />\n</postanswerdate>\n"); |
|
} |
|
send("</part>\n<part>\n"); |
|
} |
|
start_mode(MODE_ANSWER,NULL); |
|
send("<numericalresponse answer=\""); |
|
dosend=1; |
|
firstparam=1; |
|
compound_answer=0; |
|
essay_answer=0; |
|
} |
|
{Spaces}{EndLine} { |
|
/* end of answer and/or other answers */ |
|
LLDBUG_PR1("[complete an answer<EoL>]"); |
|
if ( !is_dest_empty(EXP_DEST) ) { |
|
send("<postanswerdate>\n\t<startouttext />\n"); |
|
end_streams(EXP_DEST,0); |
|
EXPflag=0; |
|
send("\t<endouttext />\n</postanswerdate>\n"); |
|
} |
|
send("</part>\n<part>\n"); |
|
BEGIN S_TEXT; |
|
} |
|
{Spaces} { /* Do nothing */ } |
} |
} |
|
|
<S_NEXT_LINE>{ |
<S_NEXT_LINE>{ |