From dc7af57b02a95b67fa4dc556861d327a020428bc Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 17 Jan 2012 10:29:48 +1000 Subject: Parser now understands state, function, and variable derlarations. Including scope. :-P --- LuaSL/src/LuaSL_LSL_tree.c | 188 ++++++++++++++++++++++++++++++++++++++--- LuaSL/src/LuaSL_LSL_tree.h | 59 ++++++++----- LuaSL/src/LuaSL_lemon_yaccer.y | 51 +++++------ LuaSL/src/LuaSL_lexer.l | 4 +- 4 files changed, 242 insertions(+), 60 deletions(-) (limited to 'LuaSL') diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index c593378..e37f794 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c @@ -10,9 +10,13 @@ static LSL_Leaf *evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_ static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); static void outputFloatToken(FILE *file, LSL_Leaf *content); +static void outputFunctionToken(FILE *file, LSL_Leaf *content); static void outputIntegerToken(FILE *file, LSL_Leaf *content); +static void outputParameterToken(FILE *file, LSL_Leaf *content); +static void outputParameterListToken(FILE *file, LSL_Leaf *content); static void outputParenthesisToken(FILE *file, LSL_Leaf *content); static void outputStatementToken(FILE *file, LSL_Leaf *content); +static void outputVariableToken(FILE *file, LSL_Leaf *content); LSL_Token LSL_Tokens[] = { @@ -95,7 +99,7 @@ LSL_Token LSL_Tokens[] = {LSL_TYPE_VECTOR, ST_NONE, "vector", LSL_NONE, NULL, NULL, NULL}, // Then the rest of the syntax tokens. - {LSL_IDENTIFIER, ST_NONE, "identifier", LSL_NONE, NULL, NULL, NULL}, + {LSL_IDENTIFIER, ST_NONE, "identifier", LSL_NONE, outputVariableToken, NULL, NULL}, {LSL_LABEL, ST_NONE, "@", LSL_NONE, NULL, NULL, NULL}, @@ -112,8 +116,9 @@ LSL_Token LSL_Tokens[] = {LSL_BLOCK_CLOSE, ST_NONE, "}", LSL_NONE, NULL, NULL, NULL}, {LSL_BLOCK_OPEN, ST_NONE, "{", LSL_NONE, NULL, NULL, NULL}, - {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, NULL, NULL, NULL}, - {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, NULL, NULL, NULL}, + {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputParameterToken, NULL, NULL}, + {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL, NULL}, + {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL, NULL}, {LSL_STATE, ST_NONE, "state", LSL_NONE, NULL, NULL, NULL}, {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL, NULL}, @@ -179,7 +184,6 @@ LSL_Token **tokens = NULL; int lowestToken = 999999; -/* Not actually used, but it might be some day. static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) { LSL_Leaf *leaf = calloc(1, sizeof(LSL_Leaf)); @@ -193,7 +197,6 @@ static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) return leaf; } -*/ void burnLeaf(LSL_Leaf *leaf) { @@ -278,14 +281,76 @@ LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) return lval; } -LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval) +LSL_Leaf *addParameter(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier) +{ + LSL_Identifier *result = calloc(1, sizeof(LSL_Identifier)); + + if ( (identifier) && (result)) + { + result->name = identifier->value.stringValue; + identifier->value.variableValue = result; + identifier->token = tokens[LSL_PARAMETER - lowestToken]; + identifier->left = type; + if (type) + { + identifier->basicType = type->basicType; + result->value.basicType = type->basicType; + } + } + return identifier; +} + +LSL_Leaf *collectParameters(LuaSL_yyparseParam *param, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam) +{ + LSL_Leaf *newList = newLeaf(LSL_PARAMETER_LIST, NULL, NULL); + + if (newList) + { + newList->left = list; + newList->value.listValue = newParam; + if ((list) && (list->value.listValue)) + { + list->value.listValue->right = comma; + } + } + + return newList; +} + +LSL_Leaf *addFunction(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close, LSL_Leaf *block) +{ + LSL_Function *func = calloc(1, sizeof(LSL_Function)); + + if (func) + { + if (identifier) + { + char *temp = identifier->value.stringValue; + + identifier->token = tokens[LSL_FUNCTION - lowestToken]; + identifier->value.functionValue = func; + identifier->value.functionValue->name = temp; + identifier->value.functionValue->block = block; + func->type = type; + if (type) + identifier->basicType = type->basicType; + else + identifier->basicType = OT_nothing; + func->params = addParenthesis(open, params, LSL_PARAMETER_LIST, close); + } + } + return identifier; +} + +LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval) { LSL_Parenthesis *parens = malloc(sizeof(LSL_Parenthesis)); if (parens) { parens->left = lval; - parens->expression = expr; + parens->contents = expr; + parens->type = type; parens->right = rval; if (lval) { @@ -297,6 +362,21 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval) return lval; } +LSL_Leaf *addState(LuaSL_yyparseParam *param, char *name, LSL_Leaf *state) +{ + LSL_State *result = calloc(1, sizeof(LSL_State)); + + if (result) + { + result->name = name; + param->script.scount++; + param->script.states = realloc(param->script.states, param->script.scount * sizeof(LSL_State *)); + param->script.states[param->script.scount - 1] = result; + } + + return state; +} + LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr) { LSL_Statement *stat = malloc(sizeof(LSL_Statement)); @@ -319,7 +399,8 @@ LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf * if (parens) { parens->left = lval; - parens->expression = expr; + parens->contents = expr; + parens->type = LSL_TYPECAST_OPEN; parens->right = rval; if (lval) { @@ -336,6 +417,57 @@ LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf * return lval; } +LSL_Leaf *addVariable(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr) +{ + LSL_Identifier *result = calloc(1, sizeof(LSL_Identifier)); + + if ( (identifier) && (result)) + { + result->name = identifier->value.stringValue; + identifier->value.variableValue = result; + identifier->left = type; + identifier->right = assignment; + if (assignment) + assignment->right = expr; + if (type) + { + identifier->basicType = type->basicType; + result->value.basicType = type->basicType; + } + if (param->currentBlock) + { + param->currentBlock->vcount++; + param->currentBlock->variables = realloc(param->currentBlock->variables, param->currentBlock->vcount * sizeof(LSL_Identifier *)); + param->currentBlock->variables[param->currentBlock->vcount - 1] = result; + } + else + { + param->script.vcount++; + param->script.variables = realloc(param->script.variables, param->script.vcount * sizeof(LSL_Identifier *)); + param->script.variables[param->script.vcount - 1] = result; + } + } + + return identifier; +} + +void beginBlock(LuaSL_yyparseParam *param, LSL_Leaf *block) +{ + LSL_Block *blok = malloc(sizeof(LSL_Block)); + + if (blok) + { + block->value.blockValue = blok; + blok->outerBlock = param->currentBlock; + param->currentBlock = blok; + } +} + +void endBlock(LuaSL_yyparseParam *param, LSL_Leaf *block) +{ + param->currentBlock = param->currentBlock->outerBlock; +} + static LSL_Leaf *evaluateLeaf(LSL_Leaf *leaf, LSL_Leaf *left, LSL_Leaf *right) { LSL_Leaf *result = NULL; @@ -601,7 +733,10 @@ static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL LSL_Leaf *result = NULL; if (content) - result = evaluateLeaf(content->value.parenthesis->expression, left, right); + { + if (LSL_PARAMETER_LIST != content->value.parenthesis->type) + result = evaluateLeaf(content->value.parenthesis->contents, left, right); + } return result; } @@ -653,18 +788,43 @@ static void outputFloatToken(FILE *file, LSL_Leaf *content) fprintf(file, "%g", content->value.floatValue); } +static void outputFunctionToken(FILE *file, LSL_Leaf *content) +{ + if (content) + { + LSL_Function *func = content->value.functionValue; + + outputLeaf(file, func->type); + fprintf(file, "%s", func->name); + outputLeaf(file, func->params); + outputLeaf(file, func->block); + } +} + static void outputIntegerToken(FILE *file, LSL_Leaf *content) { if (content) fprintf(file, "%d", content->value.integerValue); } +static void outputParameterToken(FILE *file, LSL_Leaf *content) +{ + if (content) + fprintf(file, "%s", content->value.parameterValue->name); +} + +static void outputParameterListToken(FILE *file, LSL_Leaf *content) +{ + if (content) + outputLeaf(file, content->value.listValue); +} + static void outputParenthesisToken(FILE *file, LSL_Leaf *content) { if (content) { fprintf(file, "%s", content->token->token); - outputLeaf(file, content->value.parenthesis->expression); + outputLeaf(file, content->value.parenthesis->contents); outputLeaf(file, content->value.parenthesis->right); } } @@ -680,6 +840,13 @@ static void outputStatementToken(FILE *file, LSL_Leaf *content) } } +static void outputVariableToken(FILE *file, LSL_Leaf *content) +{ + if (content) + fprintf(file, "%s", content->value.variableValue->name); +} + + static void convertLeaf2Lua(FILE *file, LSL_Leaf *leaf) { if (leaf) @@ -705,7 +872,6 @@ static void doneParsing(LuaSL_yyparseParam *param) char buffer[PATH_MAX]; char outName[PATH_MAX]; char luaName[PATH_MAX]; - int count; outputLeaf(stdout, param->ast); printf("\n"); diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index b547976..4113454 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -2,7 +2,7 @@ #ifndef __LSL_TREE_H__ #define __LSL_TREE_H__ -#define LUASL_DEBUG +//#define LUASL_DEBUG #include // So we can have NULL defined. @@ -218,8 +218,9 @@ struct _LSL_Leaf struct _LSL_Parenthesis { LSL_Leaf *left; - LSL_Leaf *expression; + LSL_Leaf *contents; LSL_Leaf *right; + LSL_Type type; }; struct _LSL_Identifier // For variables and function parameters. @@ -237,30 +238,32 @@ struct _LSL_Statement struct _LSL_Block { LSL_Block *outerBlock; - LSL_Statement *statements; - LSL_Identifier *scopeVariables; + LSL_Statement **statements; + LSL_Identifier **variables; // Those variables in this scope. + int scount, vcount; }; struct _LSL_Function { - char *name; - LSL_Block block; - LSL_Identifier *parameters; - LSL_Type type; // Return type. + char *name; + LSL_Leaf *type; + LSL_Leaf *params; + LSL_Leaf *block; }; struct _LSL_State { char *name; - LSL_Function *handlers; + LSL_Function **handlers; }; struct _LSL_Script { char *name; - LSL_Function *functions; - LSL_State *states; - LSL_Identifier *variables; + LSL_Function **functions; + LSL_State **states; + LSL_Identifier **variables; + int fcount, scount, vcount; }; // Define the type for flex and lemon. @@ -268,15 +271,18 @@ struct _LSL_Script typedef struct { - void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first. - int argc; - char **argv; - char fileName[PATH_MAX]; - FILE *file; - LSL_Leaf *ast; - char *ignorableText; - LSL_Leaf *lval; - int column, line; + void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first. + int argc; + char **argv; + char fileName[PATH_MAX]; + FILE *file; + LSL_Leaf *ast; + LSL_Script script; + char *ignorableText; + LSL_Leaf *lval; + int column, line; + LSL_Block *currentBlock; + LSL_Leaf *currentFunction; } LuaSL_yyparseParam; @@ -286,11 +292,18 @@ typedef struct void burnLeaf(LSL_Leaf *leaf); -LSL_Leaf *addExpression(LSL_Leaf *exp); +LSL_Leaf *addFunction(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close, LSL_Leaf *block); LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); -LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); +LSL_Leaf *addParameter(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *newParam); +LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); +LSL_Leaf *addState(LuaSL_yyparseParam *param, char *name, LSL_Leaf *state); LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr); +LSL_Leaf *addVariable(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr); + +void beginBlock(LuaSL_yyparseParam *param, LSL_Leaf *block); +LSL_Leaf *collectParameters(LuaSL_yyparseParam *param, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam); +void endBlock(LuaSL_yyparseParam *param, LSL_Leaf *block); void *ParseAlloc(void *(*mallocProc)(size_t)); void ParseTrace(FILE *TraceFILE, char *zTracePrompt); diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index d24f1a9..f79c228 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y @@ -12,8 +12,8 @@ %default_destructor {burnLeaf($$);} // The start symbol, just coz we need one. -// Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol. +// Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol. program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = param->ast; param->ast = A; } // Various forms of "space". The lexer takes care of them for us. @@ -24,7 +24,7 @@ program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = param->ast; p %nonassoc LSL_SCRIPT. script ::= script state. -script ::= script function. +script ::= script function(A). { if (NULL != A) A->left = param->ast; param->ast = A; } script ::= script statement(A). { if (NULL != A) A->left = param->ast; param->ast = A; } script ::= . @@ -32,25 +32,26 @@ script ::= . %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. -state ::= LSL_IDENTIFIER stateBlock. +state(S) ::= LSL_IDENTIFIER(I) stateBlock(B). { S = addState(param, I->value.stringValue, B); } // Function definitions. -%nonassoc LSL_PARAMETER LSL_FUNCTION. +%nonassoc LSL_PARAMETER LSL_PARAMETER_LIST LSL_FUNCTION. functionList ::= functionList function. functionList ::= . -parameter ::= type LSL_IDENTIFIER. -parameterList ::= parameterList LSL_COMMA parameter. -parameterList ::= parameter. -parameterList ::= . -function ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN parameterList LSL_PARENTHESIS_CLOSE funcBlock. // Causes a conflict when it's an empty parameterList with calling the same type of function. -function ::= type LSL_IDENTIFIER LSL_PARENTHESIS_OPEN parameterList LSL_PARENTHESIS_CLOSE funcBlock. +parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(param, B, C, D); } +parameterList(A) ::= parameter(D). { A = collectParameters(param, NULL, NULL, D); } +parameterList(A) ::= . { A = collectParameters(param, NULL, NULL, NULL); } +parameter(A) ::= type(B) LSL_IDENTIFIER(C). { A = addParameter(param, B, C); } +// Causes a conflict when it's an empty parameterList with calling the same type of function. +function(A) ::= LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F) funcBlock(G). { A = addFunction(param, NULL, C, D, E, F, G); } +function(A) ::= type(B) LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F) funcBlock(G). { A = addFunction(param, B, C, D, E, F, G); } // Blocks. -block ::= funcBlock. -block ::= statement. +block(A) ::= funcBlock(B). { A = B; } +block(A) ::= statement(B). { A = B; } funcBlock ::= LSL_BLOCK_OPEN statementList LSL_BLOCK_CLOSE. // Various forms of statement. @@ -66,7 +67,8 @@ statement ::= LSL_FOR LSL_PARENTHESIS_OPEN expr LSL_STATEMENT expr LSL_STATEMENT ifBlock ::= ifBlock LSL_ELSE block. ifBlock ::= block. -statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE ifBlock. [LSL_ELSE] // The [LSL_ELSE] part causes a conflict. +// The [LSL_ELSE] part causes a conflict. +statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE ifBlock. [LSL_ELSE] statement ::= LSL_JUMP LSL_IDENTIFIER LSL_STATEMENT. statement ::= LSL_RETURN expr LSL_STATEMENT. @@ -126,24 +128,25 @@ expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(NULL, B %right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE. %nonassoc LSL_TYPE_FLOAT LSL_TYPE_INTEGER LSL_TYPE_KEY LSL_TYPE_LIST LSL_TYPE_ROTATION LSL_TYPE_STRING LSL_TYPE_VECTOR. -type ::= LSL_TYPE_FLOAT. -type ::= LSL_TYPE_INTEGER. -type ::= LSL_TYPE_KEY. -type ::= LSL_TYPE_LIST. -type ::= LSL_TYPE_ROTATION. -type ::= LSL_TYPE_STRING. -type ::= LSL_TYPE_VECTOR. +type(A) ::= LSL_TYPE_FLOAT(B). { B->basicType = OT_float; A = B; } +type(A) ::= LSL_TYPE_INTEGER(B). { B->basicType = OT_integer; A = B; } +type(A) ::= LSL_TYPE_KEY(B). { B->basicType = OT_key; A = B; } +type(A) ::= LSL_TYPE_LIST(B). { B->basicType = OT_list; A = B; } +type(A) ::= LSL_TYPE_ROTATION(B). { B->basicType = OT_rotation; A = B; } +type(A) ::= LSL_TYPE_STRING(B). { B->basicType = OT_string; A = B; } +type(A) ::= LSL_TYPE_VECTOR(B). { B->basicType = OT_vector; A = B; } %left LSL_ANGLE_OPEN LSL_ANGLE_CLOSE. %nonassoc LSL_BRACKET_OPEN LSL_BRACKET_CLOSE. %nonassoc LSL_PARENTHESIS_OPEN LSL_PARENTHESIS_CLOSE LSL_EXPRESSION. -expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, D); } +expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, LSL_EXPRESSION, D); } expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D) expr(E). { A = addTypecast(B, C, D, E); } // Function call. -expr ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN exprList LSL_PARENTHESIS_CLOSE. // Casuses a conflict when exprList is empty with a function definition with no type and no parameters. +// Causes a conflict when exprList is empty with a function definition with no type and no parameters. +expr ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN exprList LSL_PARENTHESIS_CLOSE. // Variables and dealing with them. @@ -159,8 +162,8 @@ expr ::= identifier LSL_ASSIGNMENT_DIVIDE expr. expr ::= identifier LSL_ASSIGNMENT_PLAIN expr. // Hmm think this can have commas seperating the assignment parts. -statement ::= type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr LSL_STATEMENT. -statement ::= type LSL_IDENTIFIER LSL_STATEMENT. +statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(param, B, C, D, E)); } +statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(param, B, C, NULL, NULL)); } %right LSL_DOT LSL_IDENTIFIER. identifier ::= identifier LSL_DOT LSL_IDENTIFIER. diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index afc99ce..4dde0ac 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l @@ -74,8 +74,8 @@ STRING \"(\\.|[^\\"\n])*\" /* Other symbols. */ "@" %{ return common(yylval, yytext, yyextra, TRUE, LSL_LABEL); %} -"{" %{ return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_OPEN); %} -"}" %{ return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_CLOSE); %} +"{" %{ beginBlock(yyextra, yylval); return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_OPEN); %} +"}" %{ endBlock(yyextra, yylval); return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_CLOSE); %} ";" %{ return common(yylval, yytext, yyextra, TRUE, LSL_STATEMENT); %} /* Type keywords. */ -- cgit v1.1