diff --git a/test/sandbox/lex/lolfx.l b/test/sandbox/lex/lolfx.l index d7a20d72..89752a9b 100644 --- a/test/sandbox/lex/lolfx.l +++ b/test/sandbox/lex/lolfx.l @@ -4,11 +4,17 @@ #include "lolfx.tab.h" %} +%x GLSL +%x HLSL %x C_COMMENT %x CPP_COMMENT %% +%{ +int comment_caller = INITIAL; +%} + /* * GLSL keywords */ @@ -449,7 +455,8 @@ * LolFx preprocessor directives */ -"#"[ \t]*"region" { return PREPROCESSOR_REGION; } +"#"[ \t]*"region GLSL" { BEGIN(GLSL); } +"#"[ \t]*"region HLSL" { BEGIN(HLSL); } "#"[ \t]*"pragma"[ \t]*"lolfx".* { /* ignore for now */ } /* @@ -533,8 +540,10 @@ * Ignore C comments */ -"/*" { BEGIN(C_COMMENT); } -"*/" { BEGIN(INITIAL); } +"/*" { comment_caller = GLSL; BEGIN(C_COMMENT); } +"/*" { comment_caller = HLSL; BEGIN(C_COMMENT); } +"/*" { comment_caller = INITIAL; BEGIN(C_COMMENT); } +"*/" { BEGIN(comment_caller); } [^*]* { } . { } @@ -542,8 +551,10 @@ * Ignore C++ comments */ -"//" { BEGIN(CPP_COMMENT); } -\n { BEGIN(INITIAL); } +"//" { comment_caller = GLSL; BEGIN(CPP_COMMENT); } +"//" { comment_caller = HLSL; BEGIN(CPP_COMMENT); } +"//" { comment_caller = INITIAL; BEGIN(CPP_COMMENT); } +\n { BEGIN(comment_caller); } .* { } %%