diff options
Diffstat (limited to 'examples/manual/yymore.lex')
-rw-r--r-- | examples/manual/yymore.lex | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/manual/yymore.lex b/examples/manual/yymore.lex new file mode 100644 index 0000000..27d7012 --- /dev/null +++ b/examples/manual/yymore.lex @@ -0,0 +1,29 @@ +/* + * yymore.lex: An example of using yymore() + * to good effect. + */ + +%{ +#include <memory.h> + +void yyerror(char *message) +{ + printf("Error: %s\n",message); +} + +%} + +%x STRING + +%% +\" BEGIN(STRING); + +<STRING>[^\\\n"]* yymore(); +<STRING><<EOF>> yyerror("EOF in string."); BEGIN(INITIAL); +<STRING>\n yyerror("Unterminated string."); BEGIN(INITIAL); +<STRING>\\\n yymore(); +<STRING>\" { + yytext[yyleng-1] = '\0'; + printf("string = \"%s\"",yytext); BEGIN(INITIAL); + } +%% |