From 64087ea4656abc8183691d578b1d14b66bb5f7e1 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 9 Jan 2012 08:35:01 +1000 Subject: One of these days I'll get spaces to work. Another hack at it. --- LuaSL/src/LuaSL_LSL_tree.c | 15 +++++++++++---- LuaSL/src/LuaSL_lexer.l | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'LuaSL') diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index 57e639a..48415fc 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c @@ -10,12 +10,13 @@ static void evaluateStatementToken(LSL_Leaf *content, LSL_Value *left, LSL_Value static void outputIntegerToken(LSL_Leaf *content); static void outputOperationToken(LSL_Leaf *content); static void outputStatementToken(LSL_Leaf *content); +static void outputSpaceToken(LSL_Leaf *content); LSL_Token LSL_Tokens[] = { // {LSL_COMMENT, "/*", LSL_NONE, NULL, NULL, NULL}, // {LSL_COMMENT_LINE, "//", LSL_NONE, NULL, NULL, NULL}, - {LSL_SPACE, " ", LSL_NONE, NULL, NULL, NULL}, + {LSL_SPACE, " ", LSL_NONE, outputSpaceToken, NULL, NULL}, // Operators, in order of precedence, low to high // Left to right, unless oterwise stated. @@ -358,7 +359,7 @@ static void outputAST(LSL_AST *ast) if (ast->token->output) ast->token->output(&(ast->content)); else - printf(" %s ", ast->token->token); + printf("%s", ast->token->token); outputAST(ast->right); } } @@ -372,7 +373,7 @@ static void outputIntegerToken(LSL_Leaf *content) static void outputOperationToken(LSL_Leaf *content) { if (content) - printf(" %s ", tokens[content->operationValue - lowestToken]->token); + printf("%s", tokens[content->operationValue - lowestToken]->token); } static void outputStatementToken(LSL_Leaf *content) @@ -382,6 +383,12 @@ static void outputStatementToken(LSL_Leaf *content) printf(";"); } +static void outputSpaceToken(LSL_Leaf *content) +{ + if (content) + printf("%s", content->spaceValue); +} + static void convertAST2Lua(LSL_AST *ast) { if (ast) @@ -392,7 +399,7 @@ static void convertAST2Lua(LSL_AST *ast) else if (ast->token->output) ast->token->output(&(ast->content)); else - printf(" %s ", ast->token->token); + printf("%s", ast->token->token); convertAST2Lua(ast->right); } } diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 4aff7fa..631a44b 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l @@ -30,7 +30,7 @@ NAME [[:alpha:]](_|[[:alpha:]]|[[:digit:]])* /* The order here is important, in mysterious ways. The more specific the lower in case of ambiguities like "floats contain integers". I think, not tested that well yet. */ /* White space. */ -[[:space:]]+ %{ /* ECHO; yylval->spaceValue = strdup(yytext); return LSL_SPACE; */ %} +[[:space:]]+ %{ ECHO; /* yylval->spaceValue = strdup(yytext); return LSL_SPACE; */ %} /* Operations. */ "&&" { ECHO; return LSL_BOOL_AND; } -- cgit v1.1