--- loncom/homework/CAPA-converter/capaLexerDef.flex 2000/04/12 20:06:16 1.1 +++ loncom/homework/CAPA-converter/capaLexerDef.flex 2000/11/21 18:43:29 1.6 @@ -140,6 +140,8 @@ extern Problem_t *LexiPro extern Problem_t *LastProblem_p; int first_run=1; int Stop_Parser; +static int dosend=1; +static int firstparam=1; #define FLEX #define YY_STACK_USED 1 /* for yy_push_state(), yy_pop_state() */ @@ -336,6 +338,7 @@ void newyy_input (char *buf,int *result, #endif int capa_eof(); + %} Alpha [a-zA-Z_] @@ -359,7 +362,7 @@ EndLine ([\r][\n]|[\n]) %x S_COMMENT S_HINT S_HINTEXLAINX S_IMPORT S_EXPLAIN S_ENDX S_UNIT S_IGNORE %x S_SKIP S_VARIABLE S_LET S_DEFINE S_TEXT S_MAP S_FIGURE S_ANSWER %x S_STRING S_ANSCONTINUE S_TRUE_FALSE_STMT S_IF_SKIP S_WHILE_SKIP -%x S_NEXT_LINE S_VERB +%x S_NEXT_LINE S_VERB S_ECHO S_STRINGINANS %array @@ -378,28 +381,33 @@ EndLine ([\r][\n]|[\n]) } { -^{Spaces}"//"[^\n]*$ { LLDBUG_PRL2("[COMMENT<%s>]\n",yytext); - send(&yytext[2]); - send("\n"); - BEGIN S_COMMENT; - } -. { send("\n"); BEGIN S_TEXT; } +{EndLine}{Spaces}"//"[^\n]*$ {LLDBUG_PRL2("[COMMENT<%s>]\n",yytext); + send("# %s\n",&yytext[2]); + } +[^\n]*{EndLine} { + send("\n"); BEGIN S_TEXT; + } } + { ^{Spaces}"/LET" | -^{Spaces}"/BEG" { LLDBUG_PRL1("[LET]"); Pcount = 0; init_funcstack(); BEGIN S_LET; RETURN(CAPA_LET); } + ^{Spaces}"/BEG" { LLDBUG_PRL1("[LET]"); Pcount = 0; BEGIN S_LET; start_mode(MODE_SCRIPT,NULL); +} ^{Spaces}"/VERB" { LLDBUG_PRL1("[VERBATIM]"); - Dynamic_buf = (char *)capa_malloc(sizeof(char),10); - Dynamic_buf_max = 10; - Dynamic_buf_cur = 0; - Dynamic_buf[0] = '\0'; BEGIN S_VERB; + start_mode(MODE_OUTTEXT,NULL); + send("
\n");
+                                 }
+^{Spaces}"/HIN"{Alpha}*{Spaces}  { LLDBUG_PRL1("[HIN]"); 
+                                   start_mode(MODE_BLOCK,
+					      "condition=\"&hinton\"");
+				   BEGIN S_HINT; 
                                  }
-^{Spaces}"/HIN"{Alpha}*{Spaces}  { LLDBUG_PRL1("[HIN]"); Current_char_p = String_buf;  BEGIN S_HINT; }
-^{Spaces}"/EXP"{Alpha}*{Spaces}  { LLDBUG_PRL1("[EXP]"); Current_char_p = String_buf;  BEGIN S_EXPLAIN; }
-^{Spaces}"/IMP"{Alpha}*{Space}+  { LLDBUG_PRL1("[IMP]"); BEGIN S_IMPORT; }
+^{Spaces}"/EXP"{Alpha}*{Spaces}  { start_mode(MODE_BLOCK,"condition=&explanation");
+                                   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]");  
                                     if ( (LexiProblem_p !=NULL) && 
 					 (LexiProblem_p->question != NULL) && 
@@ -409,7 +417,7 @@ EndLine    ([\r][\n]|[\n])
 				    } else {
 				      EndText_p=NULL;
 				    }
-				    End_of_input = 1; BEGIN S_IGNORE;RETURN(CAPA_END); 
+				    End_of_input = 1; BEGIN S_IGNORE; 
                                   }
 ^{Spaces}"/START"[^\n]*          { LLDBUG_PRL1("[START]");  
                                     if (LexiProblem_p !=NULL && 
@@ -419,15 +427,29 @@ EndLine    ([\r][\n]|[\n])
 				      StartText_p=NULL;
 				    }
 				    BEGIN S_TEXT;
-				    RETURN(CAPA_START); 
                                   }
                                   
 ^{Spaces}"/END"{Spaces}[\(]{Spaces}      { LLDBUG_PRL1("[END()]"); BEGIN S_ENDX; }
 ^"/DEF"                       { Bcount = 0; BEGIN S_DEFINE; RETURN(CAPA_DEF); }
-^{Spaces}"/ANS"               { LLDBUG_PRL2("[ANS(%s)]",yytext); Pcount = 0; BEGIN S_ANSWER; RETURN(CAPA_ANS); }
-^{Spaces}"/SUBJECTIVE"        { LLDBUG_PRL1("[SUBJECTIVE ANSWER]"); Pcount = 0; BEGIN S_ANSWER; RETURN(CAPA_SUBJ); }
-^{Spaces}"/MAP"               { LLDBUG_PRL1("[MAP]");  Pcount = 0; BEGIN S_MAP;   RETURN(CAPA_MAP); }
-^{Spaces}"/RMAP"              { LLDBUG_PRL1("[RMAP]"); Pcount = 0; BEGIN S_MAP;   RETURN(CAPA_RMAP); }
+^{Spaces}"/ANS"               { LLDBUG_PRL2("[ANS(%s)]",yytext); 
+                                Pcount = 0; 
+                                BEGIN S_ANSWER; 
+                                end_mode();
+				start_mode(MODE_ANSWER,NULL);
+                                send("]\n",While_idx);
@@ -480,34 +502,32 @@ EndLine    ([\r][\n]|[\n])
                                 LLDBUG_PR1("[DIS<]");
                                 init_funcstack();
                                 Pcount = 0; BEGIN S_VARIABLE; 
-                                RETURN(CAPA_VAR); 
+				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 */ 
-                                RETURN(EoL); }
+                                send("\n"); }
 [\\]{Space}*{EndLine}         { LLDBUG_PR2("[\\EoL continue](%s)",yytext); /* continuation on next line */ }                       
-^{Spaces}"//"[^\n]*{EndLine}		      { LLDBUG_PRL2("[COMMENT<%s>]\n",yytext);
-                                        send("\n");
-                                        send(&yytext[2]);
-                                        BEGIN S_COMMENT; 
+^{Spaces}"//"[^\n]*$		      { LLDBUG_PRL2("[COMMENT<%s>]\n",yytext);
+                                        start_mode(MODE_SCRIPT,NULL); 
+                                        send("# %s\n",&yytext[2]);
+					BEGIN S_COMMENT;
                                       }
+
 [^/\n\\]+$  |
 [/]         | 
-[\\]                          {  yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-                                yylval->s_str = strsave(yytext);
+[\\]                          {  start_mode(MODE_OUTTEXT,NULL);
                                 LLDBUG_PR2("[TEXT_LINE<%s>]",yytext);
-			        RETURN(TEXT_LINE); 
+				send(yytext);
 			      }
 ([^/\n])+[/] |
 ([^/\n])+[\\]                 { /* matches anything until a '/' or a '\' */
+                                start_mode(MODE_OUTTEXT,NULL);
                                 LLDBUG_PR2("[TEXT_LINE( )<%s>]",yytext);
                                 
                                 yyless(yyleng-1); /* push back the last char */
-                                yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-                                yylval->s_str = strsave(yytext);
-                                
                                 BEGIN S_TEXT;
-                                RETURN(TEXT_LINE); 
+				send(yytext);
                               }
 <>                       { 
 #ifdef AVOIDYYINPUT
@@ -526,7 +546,7 @@ EndLine    ([\r][\n]|[\n])
 				    }
 				  } else {
 				    sprintf(warn_msg,
-					    "at End-of-File, a /END is needed.\n");
+					"at End-of-File, a /END is needed.\n");
 				    capa_msg(MESSAGE_ERROR,warn_msg);
 				  }
 				  free_problems(LexiProblem_p);
@@ -612,35 +632,26 @@ EndLine    ([\r][\n]|[\n])
                                   int    ii;
                                 
                                   yyless(yyleng-1);
-                                  for(ii=0;ii{
 {EndLine}                     {  LLDBUG_PR1("[CR hint]");
-                                 yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-		                *Current_char_p++ = '\n'; *Current_char_p = '\0';
-	                         yylval->s_str = strsave(String_buf);
-                                 BEGIN S_TEXT; RETURN(HINT_LINE); 
+                                 send("\n"); 
+                                 BEGIN S_TEXT;
                               }
 }
 {
 {EndLine}                     {  LLDBUG_PR1("[CR explain]");
-                                 yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-		                *Current_char_p++ = '\n'; *Current_char_p = '\0';
-	                         yylval->s_str = strsave(String_buf);
-                                 BEGIN S_TEXT; RETURN(EXPLAIN_LINE); 
+                                 send("\n"); 
+                                 BEGIN S_TEXT;
                               }
 }
 
@@ -681,79 +692,109 @@ EndLine    ([\r][\n]|[\n])
                                          }
                                        break;
                                 }
+				printf("FIXME!Hint: %s\n",yytext);
                               }
 {Space}+                      { }
 [)]                           {  yy_pop_state(); }
 }
 
 {
-{FileName}{Space}*             { parse_filename(yytext);    BEGIN S_SKIP; }
-{Identifier}{Space}*           { parse_import_id(yytext);   BEGIN S_SKIP; }
+{FileName}{Space}*             { end_mode();send("/res/capa/%s\n",yytext); BEGIN S_SKIP; }
+{Identifier}{Space}*           { end_mode();send("$%s\n",yytext);  BEGIN S_SKIP; }
 }
 
 {
-[Pp][Ll][Uu][Ss]             { LLDBUG_PR1("[PLUS]");  RETURN(ANS_PLUS); }
-[Mm][Ii][Nn][Uu][Ss]         { LLDBUG_PR1("[MINUS]"); RETURN(ANS_MINUS); }
-[Cc][Ss]                     { LLDBUG_PR1("[CS]");    RETURN(ANS_CS); }
-[Cc][Ii]                     { LLDBUG_PR1("[CI]");    RETURN(ANS_CI); }
-[Mm][Cc]                     { LLDBUG_PR1("[MC]");    RETURN(ANS_MC); }
+[Pp][Ll][Uu][Ss]             { LLDBUG_PR1("[PLUS]"); add_delayed("+");}
+[Mm][Ii][Nn][Uu][Ss]         { LLDBUG_PR1("[MINUS]"); add_delayed("-");}
+
+[Cc][Ss]                     { LLDBUG_PR1("[CS]"); send("cs");}
+[Cc][Ii]                     { LLDBUG_PR1("[CI]"); send("ci");}
+[Mm][Cc]                     { LLDBUG_PR1("[MC]"); send("mc");}
+[Ff][Mm][Ll]                 { LLDBUG_PR1("[FORMULA]"); send("fml"); }
+
 [Oo][Nn]                     |
-[Yy][Ee][Ss]                 { LLDBUG_PR1("[ON]");    RETURN(ANS_ON); }
+[Yy][Ee][Ss]                 { LLDBUG_PR1("[ON]"); send("on");}
 [Oo][Ff][Ff]                 |
-[Nn][Oo]                     { LLDBUG_PR1("[OFF]");   RETURN(ANS_OFF); }
-[Ff][Mm][Ll]                 { LLDBUG_PR1("[FORMULA]");   RETURN(ANS_FORMULA); }
-[Ff][Mm][Tt]                 { LLDBUG_PR1("[FMT]");   RETURN(ANS_FMT); }
-[Uu][Nn][Ff][Mm][Tt]         { LLDBUG_PR1("[UNFMT]"); RETURN(ANS_UNFMT); }
-[,:%=@#-]                  { LLDBUG_PR2("[symbol(%s)]",yytext); return(yytext[0]); }
-"<"                          { LLDBUG_PR2("[symbol(%s)]",yytext); return(yytext[0]); }
-">"                          { LLDBUG_PR2("[symbol(%s)]",yytext); return(yytext[0]); }
-[Ss][Ii][Gg]                 { LLDBUG_PR2("[SIG(%s)]",yytext);  RETURN(ANS_SIG); }
-[Tt][Oo][Ll]                 { LLDBUG_PR2("[tol(%s)]",yytext);  RETURN(ANS_TOLERANCE); }
-[Ss][Tt][Rr]                 { LLDBUG_PR1("[STR]");   RETURN(ANS_COMPARE); }
-[Ww][Gg][Tt]                 { LLDBUG_PR1("[WGT]");   RETURN(ANS_WEIGHT); }
+[Nn][Oo]                     { LLDBUG_PR1("[OFF]"); send("off");}
+[Ff][Mm][Tt]                 { LLDBUG_PR1("[FMT]"); }
+[Uu][Nn][Ff][Mm][Tt]         { LLDBUG_PR1("[UNFMT]"); }
+
+[,=]                  { LLDBUG_PR2("[symbol(%s)]",yytext);}
+[%]                  { LLDBUG_PR2("[symbol(%s)]",yytext); 
+                       if (dosend==1) send("%s",yytext);
+                       if (dosend==2) add_delayed("%s",yytext);
+                     }
+[:@#-]                  { LLDBUG_PR2("[symbol(%s)]",yytext); 
+                          if (dosend==1) send("%s",yytext);
+                          if (dosend==2) add_delayed("%s",yytext);
+                        }
+"<"                          { LLDBUG_PR2("[symbol(%s)]",yytext);
+                               if (dosend==1) send("%s",yytext);
+                               if (dosend==2) add_delayed("%s",yytext);
+                             }
+">"                          { LLDBUG_PR2("[symbol(%s)]",yytext);
+                               if (dosend==1) send("%s",yytext);
+                               if (dosend==2) add_delayed("%s",yytext);
+                             }
+
 [Pp][Cc][Rr]                 |
-[Hh][Gg][Rr]                 { RETURN(ANS_PCREDIT); }
-[Pp][Aa][Tt][Hh]             { RETURN(ANS_PATH); }
-[Cc][Aa][Ll][Cc]             { RETURN(ANS_CALC); }
-[Tt][Rr][Yy]                 |
-[Tt][Rr][Ii][Ee][Ss]         { LLDBUG_PR1("[TRY]");     RETURN(ANS_TRY); }
-[Uu][Nn][Ii][Tt]             |
-[Uu][Nn][Ii][Tt][Ss]         { LLDBUG_PR1("[UNIT]");    RETURN(ANS_UNIT); }
-[Bb][Rr]                     { LLDBUG_PR1("[SHOW_BR]"); RETURN(ANS_SHOW_BR);  }
-[Vv][Ee][Rr][Bb][Aa][Tt][Ii][Mm] { LLDBUG_PR1("[VERBATIM]"); RETURN(ANS_VERBATIM); }
-[Aa][Nn][Ss][Bb][Oo][Xx]     { LLDBUG_PR1("[SHOW_ANS_BOX]"); RETURN(ANS_BOX_SHOW);  }
-[Hh][Ii][Nn][Tt]             { LLDBUG_PR1("[HINT]");    RETURN(ANS_HINT); }
-[Ee][Xx][Pp][Ll][Aa][Ii][Nn] { LLDBUG_PR1("[EXPLAIN]"); RETURN(ANS_EXPLAIN); }
-[Ee][Xx][Tt][Ee][Rr][Nn][Aa][Ll]  { LLDBUG_PR1("[EXTERNAL]"); RETURN(ANS_EXTERNAL); }
+[Hh][Gg][Rr]                 { if (firstparam) firstparam=0; else 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");
                              }
 }
 
-{
-{Alpha}{AlphaNum}*             { LLDBUG_PR2("[ID<%s>]",yytext);LLDBUG_PR2("[SYMB CNT=<%d>]", Symb_count); 
-                                 /*yylval = find_identifier(yytext);*/ RETURN(IDENTIFIER); 
+{
+{Alpha}{AlphaNum}*             { LLDBUG_PR2("[ID<%s>]",yytext);
+                                 LLDBUG_PR2("[SYMB CNT=<%d>]", Symb_count); 
+                                 if (dosend==1) send("$%s",yytext); 
+                                 if (dosend==2) add_delayed("$%s",yytext); 
                                }
 
-{Alpha}{AlphaNum}*{Space}*[(]  { char aline[MAX_FUNC_NAME];
-                                 int  i;          
-                                   for(i=0;i < (yyleng-1); i++) {
-                                     if( yytext[i] == ' ' || yytext[i] == '\t' || 
-                                         yytext[i] == 0   || yytext[i] == '(' )    break;
-                                     aline[i] = yytext[i];
-                                   }
-                                   aline[i] = 0;
-                                   LLDBUG_PR3("[FUNCT<%s:%d>]",aline,Func_idx);
-                            (FuncStack[Func_idx]).s_type = FUNCTION_ID;
-			    (FuncStack[Func_idx]).s_name = strsave(aline); /* free it in parser() */
-				   Func_idx++;
-				   yyless(yyleng-1); /* <-- push back '(' char  */
-				   RETURN(FUNCTION_ID); 
+{Alpha}{AlphaNum}*{Space}*[(]  { if (dosend==1) send("&%s",yytext);
+                                 if (dosend==2) add_delayed("&%s",yytext);
+				 Pcount++;
                                }
 {Alpha}{AlphaNum}*{Space}*[\[]  {  char aline[MAX_FUNC_NAME];
                                    int  i;   
@@ -779,71 +820,93 @@ EndLine    ([\r][\n]|[\n])
 {Number}+[Ee]{Number}+    |
 {Number}+[Ee]"-"{Number}+ |
 {Number}+"\."{Number}*    |
-"\."{Number}+             {  yylval = (Symbol *) capa_malloc(1, sizeof(Symbol)); /* *** */
-                             yylval->s_real = strtod(yytext, (char **) 0);
-                             yylval->s_type = R_CONSTANT;
-                             LLDBUG_PR2("[REAL<%s>]",yytext);
-                             RETURN(R_CONSTANT);
+"\."{Number}+             {  LLDBUG_PR2("[REAL<%s>]",yytext);
+			     if(dosend==1) send("%s",yytext);
+			     if(dosend==2) add_delayed("%s",yytext);
 			  }
 
-{Number}+                 {  yylval = (Symbol *) capa_malloc(1, sizeof(Symbol)); /* *** */
-                             yylval->s_int = strtol(yytext, (char **) 0, 0);
-                             yylval->s_type= I_CONSTANT;
-                             LLDBUG_PR2("[INT<%s>]",yytext);
-                             RETURN(I_CONSTANT);
+{Number}+                 {  LLDBUG_PR2("[INT<%s>]",yytext);
+                             if (dosend==1) send("%s",yytext);
+                             if (dosend==2) add_delayed("%s",yytext);
 			  }
-[\(]                      { LLDBUG_PR1("[dis let ans map (]"); Pcount++; return(yytext[0]); }
 [\[]                      { LLDBUG_PR1("[dis let ans map '[']");         return(yytext[0]); }
 [\]]                      { LLDBUG_PR1("[dis let ans map ']']");         return(yytext[0]); }
 {Space}+                  { /* LLDBUG_PR1("[SP ignored]");  Ignore Spaces */ }
-[\"]                      { LLDBUG_PR1("[TF,V,LET,ANS,MAP str\" ]"); 
+}
+
+{
+[\"]                      { LLDBUG_PR1("[TF,V,LET,MAP str\" ]"); 
                             Current_char_p = String_buf; 
-                            yy_push_state(S_STRING); 
+			    send("\"");
+                            yy_push_state(S_STRING);
                           }
 }
 
-[:]{Number}+[EeFf]   { char  num[ONE_TWO_EIGHT], fmt[SMALL_LINE_BUFFER];
-                             int   i;
-                             LLDBUG_PR2("[FORMAT<%s>]",yytext);
-                             for(i=0;is_type=FORMAT;
-                             switch( yytext[yyleng-1] ) {
-                               case 'e': sprintf(fmt,"%%.%de", i);
-                                         yylval->s_distype = E_FORMAT; break;
-                               case 'E': sprintf(fmt,"%%.%dE", i);
-                                         yylval->s_distype = E_FORMAT; break;
-                               case 'f': 
-                               case 'F': sprintf(fmt,"%%.%df", i);
-                                         yylval->s_distype = F_FORMAT; break;
-                             }
-                             yylval->s_str = strsave(fmt);
-                             RETURN(FORMAT);
+{
+[\"]                      { LLDBUG_PR1("[ANS str\" ]"); 
+                            Current_char_p = String_buf; 
+                            yy_push_state(S_STRINGINANS);
+                          }
+}
+
+{
+[\(]                      { LLDBUG_PR1("[dis let ans map (]"); 
+                            Pcount++; 
+			    if (Pcount > 1 ) {
+			      if (dosend==1) send(yytext);
+			      if (dosend==2) add_delayed(yytext);
+			    } 
+                          }
+}
+
+{
+[\(]                      { LLDBUG_PR1("[dis let ans map (]"); 
+                            Pcount++; 
+			    send(yytext);
+                          }
+}
+
+[:]{Number}+[EeFf]   { 
+                             end_delayed();
+                             send("&format(");
+                             flush_delayed();
+                             send(",\"%s\")",yytext+1);
+                           }
+[:]{Number}+[EeFf]   { 
+                             if (dosend) send("\" format=\"%s",yytext+1);
                            }
 
 {
-"=="                { LLDBUG_PR1("[==]"); RETURN(EQ_op);  }
-"!="                { LLDBUG_PR1("[!=]"); RETURN(NE_op);  }
-">"                 { LLDBUG_PR1("[>]");  RETURN(GT_op);  }
-">="                { LLDBUG_PR1("[>=]"); RETURN(GE_op);  }
-"<"                 { LLDBUG_PR1("[<]");  RETURN(LT_op);  }
-"<="                { LLDBUG_PR1("[<=]"); RETURN(LE_op);  }
-"&&"                { LLDBUG_PR1("[&&]"); RETURN(AND_op); }
-"||"                { LLDBUG_PR1("[||]"); RETURN(OR_op);  }
-"//"                { if(Pcount==0) BEGIN S_SKIP;         }
-{Operator}          { LLDBUG_PR2("[Op(%c) in VAR,TF_STMT,LET]",yytext[0]); return(yytext[0]); }
+"=="                { LLDBUG_PR1("[==]"); send(yytext);  }
+"!="                { LLDBUG_PR1("[!=]"); send(yytext);  }
+">"                 { LLDBUG_PR1("[>]");  send(yytext);  }
+">="                { LLDBUG_PR1("[>=]"); send(yytext);  }
+"<"                 { LLDBUG_PR1("[<]");  send(yytext);  }
+"<="                { LLDBUG_PR1("[<=]"); send(yytext);  }
+"&&"                { LLDBUG_PR1("[&&]"); send(yytext);  }
+"||"                { LLDBUG_PR1("[||]"); send(yytext);  }
+"//"                { if(Pcount==0) {
+			 send("; #");
+			 BEGIN S_ECHO;
+                      }
+                    }
+{Operator}          { LLDBUG_PR2("[Op(%c) in VAR,TF_STMT,LET]",yytext[0]); send(yytext); }
 }
 
 
 
 {
-[\)]                     { LLDBUG_PR1("[)]"); Pcount--; if(Pcount == 0)  BEGIN S_TEXT; return(yytext[0]); }
+[\)]                     { LLDBUG_PR1("[)]"); 
+                           Pcount--; 
+                           if(Pcount == 0) {
+                              BEGIN S_TEXT; 
+                              flush_delayed();
+                           } else {
+                              send(yytext); 
+                           }
+                         }
 [\\]{Space}*{EndLine}    { LLDBUG_PR2("[\\EoL continue in S_VARIABLE (DIS?)](%s)",yytext); /* continuation on next line */ }                       
-{EndLine}                { LLDBUG_PR1("[EoL within /dis()]\n"); RETURN(EoL); }
+{EndLine}                { LLDBUG_PR1("[EoL within /dis()]\n"); }
 .                   { char warn_msg[WARN_MSG_LENGTH]; 
                       sprintf(warn_msg,"When use a VARIABLE, an unexpected char [%c] is encountered.\n",yytext[0]);
                       capa_msg(MESSAGE_ERROR,warn_msg);
@@ -861,52 +924,84 @@ EndLine    ([\r][\n]|[\n])
 }
 
 {
-[\\][\\]            { char  *aptr = yytext;
-                      while( *aptr )   *Current_char_p++ = *aptr++;
+[\\][\\]            { /*char  *aptr = yytext;
+			while( *aptr )   *Current_char_p++ = *aptr++;*/
+                      send(yytext);
+                    }
+[\\][\"]            { /**Current_char_p++ = '"';*/ send("\\\"");  }
+[\\]{Space}*[\n]    { LLDBUG_PR2("[\\CR continue in S_STRING](%s)",yytext); /* continuation on next line */ }                       
+[\"]                { /* end of a string constant --   */
+                      send("\"");
+		      yy_pop_state();
+		    }
+{EndLine}           { /* check for termination of string constant */
+                      char warn_msg[WARN_MSG_LENGTH];
+                      
+                      sprintf(warn_msg,"STRING not terminated properly, an EoL encountered in the middle.\n%s\n",String_buf);
+                      capa_msg(MESSAGE_ERROR,warn_msg);
+                      yy_pop_state();
+                    }
+.                   { /*char  *aptr = yytext;
+			while( *aptr )   *Current_char_p++ = *aptr++;*/
+                      send(yytext);
+                    }
+}
+
+{
+[\\][\\]            { /*char  *aptr = yytext;
+			while( *aptr )   *Current_char_p++ = *aptr++;*/
+                      if (dosend==1) send("%s",yytext);
+		      if (dosend==2) add_delayed("%s",yytext);
+                    }
+[\\][\"]            { /**Current_char_p++ = '"';*/ 
+                      if (dosend==1) send("%s",yytext);
+		      if (dosend==2) add_delayed("%s",yytext);
                     }
-[\\][\"]            { *Current_char_p++ = '"';  }
 [\\]{Space}*[\n]    { LLDBUG_PR2("[\\CR continue in S_STRING](%s)",yytext); /* continuation on next line */ }                       
 [\"]                { /* end of a string constant --   */
-                      yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-		      *Current_char_p = '\0';
-	              yylval->s_str = strsave(String_buf);  /* ****   */
-		      yylval->s_type = S_CONSTANT;
-		      /* printf("STRING:%s\n", String_buf); */
-		      LLDBUG_PR2("[%s\"END str]",String_buf);
 		      yy_pop_state();
-		      RETURN(S_CONSTANT); }
+		    }
 {EndLine}           { /* check for termination of string constant */
                       char warn_msg[WARN_MSG_LENGTH];
                       
-                      *Current_char_p = '\0';
                       sprintf(warn_msg,"STRING not terminated properly, an EoL encountered in the middle.\n%s\n",String_buf);
                       capa_msg(MESSAGE_ERROR,warn_msg);
                       yy_pop_state();
                     }
-.                   { char  *aptr = yytext;
-                      while( *aptr )   *Current_char_p++ = *aptr++;
+.                   { /*char  *aptr = yytext;
+			while( *aptr )   *Current_char_p++ = *aptr++;*/
+                      if (dosend==1) send("%s",yytext);
+		      if (dosend==2) add_delayed("%s",yytext);
                     }
 }
 
-[\)]                  { LLDBUG_PR1("[) in LET]"); Pcount--; return(yytext[0]); }
+[\)]                  { LLDBUG_PR1("[) in LET]"); Pcount--;send(yytext); }
 
 {
 [^\n]+$                      {       }
-{EndLine}                    { BEGIN S_TEXT; RETURN(EoL);  }
+{EndLine}                    { BEGIN S_TEXT; }
+}
+
+{
+[^\n]+$                      { send(yytext); }
+{EndLine}                    { send(yytext); BEGIN S_TEXT; }
 }
 
 {
 [\\]{Space}*{EndLine}        { LLDBUG_PR1("[\\EoL let ans map]"); /* continuation */ }
-{EndLine}                    { LLDBUG_PR1("[EoL END let ans map]\n"); if(Pcount == 0) BEGIN S_TEXT; RETURN(EoL); }
+{EndLine}                    { LLDBUG_PR1("[EoL END let ans map]\n"); 
+                               if(Pcount == 0) BEGIN S_TEXT; 
+                               send(";%s",yytext); 
+                             }
 }
 
 {
-[;,]                         { LLDBUG_PR2("[%c]",yytext[0]); return(yytext[0]);  }
+[;,]                         { LLDBUG_PR2("[%c]",yytext[0]); send("%c",yytext[0]);  }
 [\)]                         { LLDBUG_PR1("[) in MAP]"); Pcount--; 
                                if(Pcount==0) {
                                    BEGIN S_SKIP; 
                                }
-                               return(yytext[0]); 
+                               send("%c",yytext[0]); 
                              }
 }
 
@@ -976,15 +1071,11 @@ EndLine    ([\r][\n]|[\n])
 
 {
 ^{Spaces}"/ENDVERB" { LLDBUG_PRL1("[END VERB]\n"); 
-                      yylval = (Symbol *) capa_malloc(1, sizeof(Symbol));
-		      yylval->s_str = strsave(Dynamic_buf);  /* ****   */
-		      yylval->s_type = S_CONSTANT;  
-		      capa_mfree(Dynamic_buf);
-		      Dynamic_buf_cur=-1;
-		      Dynamic_buf_max=0;
-		      BEGIN S_TEXT;   RETURN(VERBATIM);   
+		      BEGIN S_TEXT;
+		      puts("\n
\n"); + end_mode(); } -.*|{EndLine} { append_dynamic_buf(yytext); } +.*|{EndLine} { send(yytext); } } %% @@ -1596,6 +1687,7 @@ int capa_eof() LexiProblem_p=NULL; /* printf("\nCAPA EOF\n"); fflush(stdout); */ } + end_mode(); return (0); #endif /*AVOIDYYINPUT*/ }