--- loncom/homework/CAPA-converter/capaLexerDef.flex 2001/07/09 04:01:53 1.8 +++ loncom/homework/CAPA-converter/capaLexerDef.flex 2001/11/15 21:42:42 1.9 @@ -124,6 +124,7 @@ int IFcurrent[MAX_FUNC_NEST]; 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 */ #ifdef USE_DYNAMIC_SYMBOLS Symbol *SymbList_p; @@ -401,8 +402,7 @@ EndLine ([\r][\n]|[\n]) send("
\n");
                                  }
 ^{Spaces}"/HIN"{Alpha}*{Spaces}  { LLDBUG_PRL1("[HIN]"); 
-                                   start_mode(MODE_BLOCK,
-					      "condition=\"&hinton\"");
+                                   start_mode(MODE_HINT, "");
 				   BEGIN S_HINT; 
                                  }
 ^{Spaces}"/EXP"{Alpha}*{Spaces}  { start_mode(MODE_BLOCK,"condition=&explanation");
@@ -436,7 +436,7 @@ EndLine    ([\r][\n]|[\n])
                                 BEGIN S_ANSWER; 
                                 end_mode();
 				start_mode(MODE_ANSWER,NULL);
-                                send("]\n",While_idx);
@@ -656,50 +656,13 @@ EndLine    ([\r][\n]|[\n])
 }
 
 {
-{Alpha}{AlphaNum}*            { char   *aptr;
-                                char    tmp_str[QUARTER_K],warn_msg[ONE_K];
-                                int     ii, len;
-                                Symbol *tmp_p;
-                                
-                                /*tmp_p = find_identifier(yytext);*/
-                                switch(tmp_p->s_type) {
-                                  case IDENTIFIER:
-                                        sprintf(warn_msg,"var %s not defined.\n", yytext);
-                                        capa_msg(MESSAGE_ERROR,warn_msg);
-                                       break;
-                                  case I_VAR:
-                                  case I_CONSTANT: 
-                                         sprintf(tmp_str,"%ld",tmp_p->s_int);
-                                         len = strlen(tmp_str);
-                                         for(ii=0;ii< len;ii++) {
-                                           *Current_char_p++ = tmp_str[ii];
-                                         }
-                                       break;
-                                  case R_VAR:
-                                  case R_CONSTANT: 
-                                         sprintf(tmp_str,"%g",tmp_p->s_real);
-                                         len = strlen(tmp_str);
-                                         for(ii=0;ii< len;ii++) {
-                                           *Current_char_p++ = tmp_str[ii];
-                                         }
-                                       break;
-                                  case S_VAR:
-                                  case S_CONSTANT: 
-                                         len = strlen(tmp_p->s_str);
-                                         aptr = tmp_p->s_str;
-                                         for(ii=0;ii< len;ii++) {
-                                           *Current_char_p++ = *aptr++;
-                                         }
-                                       break;
-                                }
-				printf("FIXME!Hint: %s\n",yytext);
-                              }
+{Alpha}{AlphaNum}*            {send("${%s}",yytext);}
 {Space}+                      { }
 [)]                           {  yy_pop_state(); }
 }
 
 {
-{FileName}{Space}*             { end_mode();send("/res/capa/%s\n",yytext); BEGIN S_SKIP; }
+{FileName}{Space}*             { end_mode();send("/res/ohiou/%s\n",yytext); BEGIN S_SKIP; }
 {Identifier}{Space}*           { end_mode();send("$%s\n",yytext);  BEGIN S_SKIP; }
 }
 
@@ -738,19 +701,19 @@ EndLine    ([\r][\n]|[\n])
                              }
 
 [Pp][Cc][Rr]                 |
-[Hh][Gg][Rr]                 { if (firstparam) firstparam=0; else add_delayed("\">\n\t");
-                               add_delayed("\n\t");
+                               add_delayed("\n\t");
-			       add_delayed("\n\t");
+			       add_delayed("\n\t");
-			       add_delayed("\n\t");
+			       add_delayed("\n\t");
 			       dosend=1;
 			       flush_delayed();
-			       if (!firstparam) send("\">");
-			       send("\n\t\n\n");
+			       if (!firstparam) send("\" />");
+			       send("\n\t\n\n");
                              }
 }
 
@@ -876,6 +839,34 @@ EndLine    ([\r][\n]|[\n])
                              if (dosend) send("\" format=\"%s",yytext+1);
                            }
 
+{
+[;]   { 
+        if (sccount==0) {
+          send(",[\\");
+          sccount++;
+        } else if (sccount==1) {
+          send("],[");
+          sccount++;
+        }
+       }
+[,]     {
+        if (sccount==1) {
+          send(",\\");
+        } else {
+          send(",");
+        }
+      }
+[\)]  {
+        LLDBUG_PR1("[) in MAP]"); Pcount--; 
+        if(Pcount==0) {
+          BEGIN S_SKIP; 
+        }
+        /* you might need a ; in the string below */
+        send("]%c;\n",yytext[0]);
+        sccount=0;
+      }
+}
+
 {
 "=="                { LLDBUG_PR1("[==]"); send(yytext);  }
 "!="                { LLDBUG_PR1("[!=]"); send(yytext);  }
@@ -995,16 +986,6 @@ EndLine    ([\r][\n]|[\n])
                              }
 }
 
-{
-[;,]                         { LLDBUG_PR2("[%c]",yytext[0]); send("%c",yytext[0]);  }
-[\)]                         { LLDBUG_PR1("[) in MAP]"); Pcount--; 
-                               if(Pcount==0) {
-                                   BEGIN S_SKIP; 
-                               }
-                               send("%c",yytext[0]); 
-                             }
-}
-
 {
 {Space}+                 { /* ignore white spaces */ }
 [\\]{Space}*{EndLine}    { /* continuation */ }