--- loncom/homework/CAPA-converter/capaLexerDef.flex 2000/05/03 15:35:11 1.2 +++ loncom/homework/CAPA-converter/capaLexerDef.flex 2000/11/21 18:43:29 1.6 @@ -140,7 +140,8 @@ extern Problem_t *LexiPro extern Problem_t *LastProblem_p; int first_run=1; int Stop_Parser; -int scriptopen=0; +static int dosend=1; +static int firstparam=1; #define FLEX #define YY_STACK_USED 1 /* for yy_push_state(), yy_pop_state() */ @@ -337,6 +338,7 @@ void newyy_input (char *buf,int *result, #endif int capa_eof(); + %} Alpha [a-zA-Z_] @@ -360,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 @@ -379,33 +381,33 @@ EndLine ([\r][\n]|[\n]) } { -{EndLine}{Spaces}"//"[^\n]*$ {LLDBUG_PRL2("[COMMENT<%s>]\n",yytext); - remove_delayed(); - send("%s",yytext); - send_delayed("\n\n"); +{EndLine}{Spaces}"//"[^\n]*$ {LLDBUG_PRL2("[COMMENT<%s>]\n",yytext); + send("# %s\n",&yytext[2]); } -[^\n]*{EndLine} BEGIN S_TEXT; +[^\n]*{EndLine} { + send("\n"); BEGIN S_TEXT; + } } { ^{Spaces}"/LET" | - ^{Spaces}"/BEG" { LLDBUG_PRL1("[LET]"); Pcount = 0; BEGIN S_LET; if (!scriptopen){send(""); } +{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]); } } @@ -961,15 +1071,11 @@ send("$%s",yytext); { ^{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); } } %% @@ -1581,6 +1687,7 @@ int capa_eof() LexiProblem_p=NULL; /* printf("\nCAPA EOF\n"); fflush(stdout); */ } + end_mode(); return (0); #endif /*AVOIDYYINPUT*/ }