version 1.10, 2001/11/18 09:49:43
|
version 1.15, 2001/12/05 18:58:21
|
Line 1
|
Line 1
|
|
/* The LearningOnline Network with CAPA |
|
* CAPA lexer dfinition, heavily modified to become a LON-CAPA convertor |
|
* $Id$ |
|
* |
|
* Copyright Michigan State University Board of Trustees |
|
* |
|
* This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
* |
|
* LON-CAPA 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. |
|
* |
|
* LON-CAPA 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 LON-CAPA; if not, write to the Free Software |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
* |
|
* /home/httpd/html/adm/gpl.txt |
|
* |
|
* http://www.lon-capa.org/ |
|
*/ |
|
|
/*------------------------------------------------------------------------*/ |
/*------------------------------------------------------------------------*/ |
/* capaLexerDef.flex created by Isaac Tsai Jul 15 1996 */ |
/* capaLexerDef.flex created by Isaac Tsai Jul 15 1996 */ |
/* added /END(variable) */ |
/* added /END(variable) */ |
Line 123 int IFcount;
|
Line 150 int IFcount;
|
WhileLoop_t WhileStack[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ |
WhileLoop_t WhileStack[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ |
int While_idx, Wcount; |
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 EXPflag=0; |
|
|
#ifdef USE_DYNAMIC_SYMBOLS |
#ifdef USE_DYNAMIC_SYMBOLS |
Symbol *SymbList_p; |
Symbol *SymbList_p; |
Line 400 EndLine ([\r][\n]|[\n])
|
Line 429 EndLine ([\r][\n]|[\n])
|
send("<PRE>\n"); |
send("<PRE>\n"); |
} |
} |
^{Spaces}"/HIN"{Alpha}*{Spaces} { LLDBUG_PRL1("[HIN]"); |
^{Spaces}"/HIN"{Alpha}*{Spaces} { LLDBUG_PRL1("[HIN]"); |
start_mode(MODE_HINT, ""); |
/* start_mode(MODE_HINT, "");*/ |
|
if (!HINTflag) { |
|
start_streams(HINT_DEST,1); |
|
HINTflag=-1; |
|
} |
|
change_destination(HINT_DEST); |
BEGIN S_HINT; |
BEGIN S_HINT; |
} |
} |
^{Spaces}"/EXP"{Alpha}*{Spaces} { start_mode(MODE_BLOCK,"condition=&explanation"); |
^{Spaces}"/EXP"{Alpha}*{Spaces} { |
|
if (!EXPflag) { |
|
start_streams(EXP_DEST,1); |
|
EXPflag=-1; |
|
} |
|
change_destination(EXP_DEST); |
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 489 EndLine ([\r][\n]|[\n])
|
Line 528 EndLine ([\r][\n]|[\n])
|
LLDBUG_PRL2("[IF <IFcount=%d>]",IFcount); |
LLDBUG_PRL2("[IF <IFcount=%d>]",IFcount); |
BEGIN S_TRUE_FALSE_STMT; |
BEGIN S_TRUE_FALSE_STMT; |
if ( IFcount == 1) { |
if ( IFcount == 1) { |
start_streams(2); |
start_streams(DEFAULT_DEST, 2); |
watch_mode[1]=1; |
change_destination(DEFAULT_DEST); |
|
watch_mode[current_dest][1]=1; |
} |
} |
end_mode_stream(0); |
end_mode_stream(DEFAULT_DEST, 0); |
start_mode_stream(1,MODE_SCRIPT,NULL); |
start_mode_stream(DEFAULT_DEST,1,MODE_SCRIPT,NULL); |
for(i=1;i<IFcount;i++) {send("\t",NULL);} |
for(i=1;i<IFcount;i++) {send("\t",NULL);} |
send_stream(0,"<block condition=\"",NULL); |
send_stream(0,"<block condition=\"",NULL); |
send_stream(1,"if (",NULL); |
send_stream(1,"if (",NULL); |
Line 502 EndLine ([\r][\n]|[\n])
|
Line 542 EndLine ([\r][\n]|[\n])
|
} |
} |
^{Spaces}"/ELSE"([^\n])* { int i; |
^{Spaces}"/ELSE"([^\n])* { int i; |
LLDBUG_PRL2("[ELSE <IFcount=%d>]\n",IFcount); |
LLDBUG_PRL2("[ELSE <IFcount=%d>]\n",IFcount); |
end_mode_stream(0); |
end_mode_stream(DEFAULT_DEST,0); |
for(i=1;i<IFcount;i++) {send("\t",NULL);} |
for(i=1;i<IFcount;i++) {send("\t",NULL);} |
send_stream(0, |
send_stream(0, |
"</block>\n<block condition=\"!(%s)\">", |
"</block>\n<block condition=\"!(%s)\">", |
Line 511 EndLine ([\r][\n]|[\n])
|
Line 551 EndLine ([\r][\n]|[\n])
|
} |
} |
^{Spaces}"/ENDIF"([^\n])* { int i; |
^{Spaces}"/ENDIF"([^\n])* { int i; |
IFcount--; |
IFcount--; |
end_mode_stream(0); |
end_mode_stream(DEFAULT_DEST,0); |
for(i=0;i<IFcount;i++) {send("\t",NULL);} |
for(i=0;i<IFcount;i++) {send("\t",NULL);} |
send_stream(0,"</block>"); |
send_stream(0,"</block>"); |
send_stream(1,"}"); |
send_stream(1,"}"); |
if (IFcount == 0) { |
if (IFcount == 0) { |
if (watch_mode[1]) { |
if (watch_mode[current_dest][1]) { |
end_streams(1); |
end_streams(DEFAULT_DEST,1); |
} else { |
} else { |
end_streams(0); |
end_streams(DEFAULT_DEST,0); |
} |
} |
|
change_destination(DEFAULT_DEST); |
} |
} |
delete_cache(); |
delete_cache(); |
LLDBUG_PRL2("[ENDIF <IFcount=%d>]\n",IFcount); |
LLDBUG_PRL2("[ENDIF <IFcount=%d>]\n",IFcount); |
Line 671 EndLine ([\r][\n]|[\n])
|
Line 712 EndLine ([\r][\n]|[\n])
|
<S_HINT>{ |
<S_HINT>{ |
{EndLine} { LLDBUG_PR1("[CR hint]"); |
{EndLine} { LLDBUG_PR1("[CR hint]"); |
send("\n"); |
send("\n"); |
|
change_destination(DEFAULT_DEST); |
BEGIN S_TEXT; |
BEGIN S_TEXT; |
} |
} |
} |
} |
<S_EXPLAIN>{ |
<S_EXPLAIN>{ |
{EndLine} { LLDBUG_PR1("[CR explain]"); |
{EndLine} { LLDBUG_PR1("[CR explain]"); |
send("\n"); |
send("\n"); |
|
change_destination(DEFAULT_DEST); |
BEGIN S_TEXT; |
BEGIN S_TEXT; |
} |
} |
} |
} |
Line 688 EndLine ([\r][\n]|[\n])
|
Line 731 EndLine ([\r][\n]|[\n])
|
} |
} |
|
|
<S_IMPORT>{ |
<S_IMPORT>{ |
{FileName}{Space}* { |
{FileName}{Space}* { char *endquote; |
end_mode(); |
end_mode(); |
start_mode(MODE_IMPORT,NULL); |
start_mode(MODE_IMPORT,NULL); |
send("%s/%s",import_prefix,yytext); |
/* Get rid of leading and trailing quotes */ |
end_mode(); |
endquote = strrchr(yytext,'\"'); |
BEGIN S_SKIP; |
*endquote = '\0'; |
|
if (yytext[1] == '/') { |
|
send("%s%s",import_prefix,&yytext[1]); |
|
} else { |
|
send("%s",&yytext[1]); |
|
} |
|
end_mode(); |
|
BEGIN S_SKIP; |
} |
} |
{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 766 EndLine ([\r][\n]|[\n])
|
Line 816 EndLine ([\r][\n]|[\n])
|
dosend=2; |
dosend=2; |
} |
} |
|
|
[Ss][Tt][Rr] { LLDBUG_PR1("[STR]"); send("\" str=\""); 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="); dosend=1;} |
[Uu][Nn][Ii][Tt] | |
[Uu][Nn][Ii][Tt] | |
Line 793 EndLine ([\r][\n]|[\n])
|
Line 843 EndLine ([\r][\n]|[\n])
|
dosend=1; |
dosend=1; |
flush_delayed(); |
flush_delayed(); |
if (firstparam!=1) send("\" />\n"); |
if (firstparam!=1) send("\" />\n"); |
send("\t<textline />\n</numericalresponse>\n"); |
send("\t<textline />\n"); |
|
/* Fill in Hints */ |
|
if ( !is_dest_empty(HINT_DEST) ) { |
|
send("<hintgroup>\n\t<hintpart on=\"default\">\n\t<startouttext />"); |
|
end_streams(HINT_DEST,0); |
|
HINTflag=0; |
|
send("\t<endouttext />\n\t</hintpart>\n</hintgroup>\n"); |
|
} |
|
send("\n</numericalresponse>\n"); |
|
|
|
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"); |
|
} |
} |
} |
} |
} |
|
|
Line 930 EndLine ([\r][\n]|[\n])
|
Line 995 EndLine ([\r][\n]|[\n])
|
BEGIN S_ECHO; |
BEGIN S_ECHO; |
} |
} |
} |
} |
|
[%] {send("%%");} |
{Operator} { LLDBUG_PR2("[Op(%c) in VAR,TF_STMT,LET]",yytext[0]); send(yytext); } |
{Operator} { LLDBUG_PR2("[Op(%c) in VAR,TF_STMT,LET]",yytext[0]); send(yytext); } |
} |
} |
|
|
Line 988 EndLine ([\r][\n]|[\n])
|
Line 1054 EndLine ([\r][\n]|[\n])
|
send("'"); |
send("'"); |
yy_pop_state(); |
yy_pop_state(); |
} |
} |
|
[%] { /*Escape percent signs so that vasprintf 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]; |
|
|