--- loncom/homework/CAPA-converter/capaLexerDef.flex 2001/12/04 15:17:57 1.14 +++ loncom/homework/CAPA-converter/capaLexerDef.flex 2001/12/05 18:58:21 1.15 @@ -1,6 +1,6 @@ /* The LearningOnline Network with CAPA * CAPA lexer dfinition, heavily modified to become a LON-CAPA convertor - * $Id: capaLexerDef.flex,v 1.14 2001/12/04 15:17:57 albertel Exp $ + * $Id: capaLexerDef.flex,v 1.15 2001/12/05 18:58:21 albertel Exp $ * * Copyright Michigan State University Board of Trustees * @@ -150,6 +150,8 @@ int IFcount; WhileLoop_t WhileStack[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ int While_idx, Wcount; int sccount; /* Semi-colon count for MAP and RMAP */ +int HINTflag=0; +int EXPflag=0; #ifdef USE_DYNAMIC_SYMBOLS Symbol *SymbList_p; @@ -427,10 +429,20 @@ EndLine ([\r][\n]|[\n]) send("
\n");
                                  }
 ^{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; 
                                  }
-^{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; }
 ^{Spaces}"/IMP"{Alpha}*{Space}+  { LLDBUG_PRL1("[IMP]"); BEGIN S_IMPORT; end_mode(); }
 ^{Spaces}"/END"                  { LLDBUG_PRL1("[END]");  
@@ -516,11 +528,12 @@ EndLine    ([\r][\n]|[\n])
                                 LLDBUG_PRL2("[IF ]",IFcount);
 				BEGIN S_TRUE_FALSE_STMT;
 				if ( IFcount == 1) {
- 				  start_streams(2);
-				  watch_mode[1]=1;
+ 				  start_streams(DEFAULT_DEST, 2);
+                                  change_destination(DEFAULT_DEST);
+				  watch_mode[current_dest][1]=1;
 				}
-				end_mode_stream(0);
-				start_mode_stream(1,MODE_SCRIPT,NULL);
+				end_mode_stream(DEFAULT_DEST, 0);
+				start_mode_stream(DEFAULT_DEST,1,MODE_SCRIPT,NULL);
 				for(i=1;i]\n",IFcount);
-				end_mode_stream(0);
+				end_mode_stream(DEFAULT_DEST,0);
 				for(i=1;i\n",
@@ -538,16 +551,17 @@ EndLine    ([\r][\n]|[\n])
                               }
 ^{Spaces}"/ENDIF"([^\n])*     { int i;
 				IFcount--;
-				end_mode_stream(0);
+				end_mode_stream(DEFAULT_DEST,0);
 				for(i=0;i");
 				send_stream(1,"}");
 				if (IFcount == 0) {
-				  if (watch_mode[1]) {
-				    end_streams(1);
+				  if (watch_mode[current_dest][1]) {
+				    end_streams(DEFAULT_DEST,1);
  				  } else {
-				    end_streams(0);
+				    end_streams(DEFAULT_DEST,0);
 				  }
+                                  change_destination(DEFAULT_DEST);
 				}
 				delete_cache();
 				LLDBUG_PRL2("[ENDIF ]\n",IFcount); 
@@ -698,12 +712,14 @@ EndLine    ([\r][\n]|[\n])
 {
 {EndLine}                     {  LLDBUG_PR1("[CR hint]");
                                  send("\n"); 
+                                 change_destination(DEFAULT_DEST);
                                  BEGIN S_TEXT;
                               }
 }
 {
 {EndLine}                     {  LLDBUG_PR1("[CR explain]");
                                  send("\n"); 
+                                 change_destination(DEFAULT_DEST);
                                  BEGIN S_TEXT;
                               }
 }
@@ -800,7 +816,7 @@ EndLine    ([\r][\n]|[\n])
                                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][Uu][Aa][Tt][Ee] { LLDBUG_PR1("[EVAL]");send("\" eval="); dosend=1;}
 [Uu][Nn][Ii][Tt]             |
@@ -827,7 +843,22 @@ EndLine    ([\r][\n]|[\n])
 			       dosend=1;
 			       flush_delayed();
 			       if (firstparam!=1) send("\" />\n");
-			       send("\t\n\n");
+			       send("\t\n");
+                         /* Fill in Hints */ 
+			       if ( !is_dest_empty(HINT_DEST) ) {
+			         send("\n\t\n\t");
+                                 end_streams(HINT_DEST,0);
+                                 HINTflag=0;
+                                 send("\t\n\t\n\n");
+			       }
+			       send("\n\n");
+
+			       if ( !is_dest_empty(EXP_DEST) ) {
+			         send("\n\t\n");
+                                 end_streams(EXP_DEST,0);
+                                 EXPflag=0;
+                                 send("\t\n\n");
+                               }
                              }
 }