dave@andromeda.rutgers.edu (Dave Bloom) (11/13/87)
Two Questions concerning the use of lex: (1) What is it PRECISELY that yymore() does? Does it: continue reading characters in the current rule until it finds a match, and then keeps the whole string in yytext? (This is how I see it, but the documentation is not very specific.) If it doesn't find a match, does the WHOLE STRING get checked in later rules? (2) From what I understand, you're always in START condition 0 unless you hit a BEGIN Q. (Where Q is a previously defined start condition) You finish the action where you hit the BEGIN Q statement and then start on a new token, but now all the patterns starting with a <Q> are available. Is this true? Is it true that a pattern that starts with <Q> can never be checked unless you hit a BEGIN Q in some previous action? I ask these questions because I am trying to recognize strings as anything between two " symbols including \" . This is what I have that doesn't work: \"[^"]*\" { if(yytext[yyleng-2] == '\\') { BEGIN Q; yymore(); } else return(STRING); } <Q>[^"]*\" { if(yytext[yyleng-2] == '\\') { BEGIN Q; yymore(); } else return(STRING); } I am more concerned whith what I'm doing wrong than how to do it right. If you have any ideas, please reply by email. (I rarely read this group.) Thanx. seismo \ pyramid \ Dave Bloom ihnp4!packard >!rutgers >!andromeda!dave Office: (201) 648-5083 allegra / hoxna /