X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/6e77e91bbb048a0ee1a072715c0ce808c169ab38..8cb6370effd9f2dacc6dc9b662a43ea19ee637ac:/src/lexer.l diff --git a/src/lexer.l b/src/lexer.l index cabafca..0037b85 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -70,16 +70,29 @@ add_to_cbuf(char *s) <*>MOTHERFUCKER { fprintf(stderr,"You are a bad bad person!\n"); REJECT; } \/\/.*$ { ; /*comment, ignore*/ } -\/\/.*$ { ; /*comment, ignore*/ } +\/\/.*$ { add_to_cbuf(yytext); /*comment, ignore*/ } \/\/.*$ { ; /*comment, ignore*/ } \/\/.*$ { ; /*comment, ignore*/ } \/\* {BEGIN(COMMENT); before_comment = INITIAL; } -\/\* {BEGIN(COMMENT); before_comment = C_CODE; } +\/\* { + add_to_cbuf(yytext); + BEGIN(COMMENT); + before_comment = C_CODE; +} \/\* {BEGIN(COMMENT); before_comment = CLASS_CODE; } \/\* {BEGIN(COMMENT); before_comment = CLASS_CODE_I; } -\*\/ {BEGIN(before_comment);} -. { ; /* comment, ignore */ } -\n { ; /* comment, ignore */ } +\*\/ { + if(before_comment == C_CODE) add_to_cbuf(yytext); + BEGIN(before_comment); + } +. { + /* comment, ignore */ + if(before_comment == C_CODE) add_to_cbuf(yytext); + } +\n { + /* comment, ignore */ + if(before_comment == C_CODE) add_to_cbuf(yytext); + } ^\%h\{ { BEGIN(C_CODE); @@ -111,22 +124,21 @@ add_to_cbuf(char *s) \'\\\{\' { add_to_cbuf(yytext); } \'\}\' { add_to_cbuf(yytext); } \'\\\}\' { add_to_cbuf(yytext); } +\'\"\' { add_to_cbuf(yytext); } +\'\\\"\' { add_to_cbuf(yytext); } \\. { add_to_cbuf(yytext); } \" { BEGIN(C_CODE_STRING); add_to_cbuf(yytext); } -\\. { - add_to_cbuf(yytext); - } +\\. { add_to_cbuf(yytext); } \" { BEGIN(C_CODE); add_to_cbuf(yytext); } -. { - add_to_cbuf(yytext); - } +. { add_to_cbuf(yytext); } +\n { add_to_cbuf(yytext); } \{ { parenth_depth++; @@ -208,9 +220,11 @@ class { return '}'; } -[\n\t ] ; /*ignore*/ +[\t ] ; /*ignore*/ <*>. { yylval.line = line_no; return yytext[0]; } + +<*>[\n\r] ; /*ignore*/