From 2fa0def3e1656802c69d92ab066ef584214b3ce4 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 15 Jan 2009 07:42:42 -0700 Subject: Added compile support for multiline comments --- linden/indra/lscript/lscript_compile/indra.l | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'linden') diff --git a/linden/indra/lscript/lscript_compile/indra.l b/linden/indra/lscript/lscript_compile/indra.l index 3e62195..2616b47 100644 --- a/linden/indra/lscript/lscript_compile/indra.l +++ b/linden/indra/lscript/lscript_compile/indra.l @@ -36,7 +36,8 @@ FS (f|F) #include "llclickaction.h" void count(); -void comment(); +void line_comment(); +void block_comment(); void parse_string(); #define YYLMAX 16384 @@ -60,7 +61,8 @@ extern "C" { int yyerror(const char *fmt, ...); } %} %% -"//" { gInternalLine++; gInternalColumn = 0; comment(); } +"//" { gInternalLine++; gInternalColumn = 0; line_comment(); } +"/*" { block_comment(); } "integer" { count(); return(INTEGER); } "float" { count(); return(FLOAT_TYPE); } @@ -790,7 +792,7 @@ S32 yywrap() return(1); } -void comment() +void line_comment() { char c; @@ -798,6 +800,25 @@ void comment() ; } +void block_comment() +{ + char c1 = 0; + char c2 = yyinput(); + while (c2 != 0 && c2 != EOF && !(c1 == '*' && c2 == '/')) { + if (c2 == '\n') + { + gInternalLine++; + gInternalColumn = 0; + } + else if (c2 == '\t') + gInternalColumn += 4 - (gInternalColumn % 8); + else + gInternalColumn++; + c1 = c2; + c2 = yyinput(); + } +} + void count() { S32 i; -- cgit v1.1