From c6514fae843489ad7d042d46a23d16f1c4673478 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 11 Jun 2012 21:21:43 +0000 Subject: [PATCH] test: GLSL syntax fiddling. --- test/sandbox/lex/lolfx.l | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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); } .* { } %%