aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-09 08:35:01 +1000
committerDavid Walter Seikel2012-01-09 08:35:01 +1000
commit64087ea4656abc8183691d578b1d14b66bb5f7e1 (patch)
treec54ddd458bf5890f54397e0f24605509bdf09f93 /LuaSL
parentImplement script, and add YYVALID for statement to help with recovering from ... (diff)
downloadSledjHamr-64087ea4656abc8183691d578b1d14b66bb5f7e1.zip
SledjHamr-64087ea4656abc8183691d578b1d14b66bb5f7e1.tar.gz
SledjHamr-64087ea4656abc8183691d578b1d14b66bb5f7e1.tar.bz2
SledjHamr-64087ea4656abc8183691d578b1d14b66bb5f7e1.tar.xz
One of these days I'll get spaces to work. Another hack at it.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.c15
-rw-r--r--LuaSL/src/LuaSL_lexer.l2
2 files changed, 12 insertions, 5 deletions
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
10static void outputIntegerToken(LSL_Leaf *content); 10static void outputIntegerToken(LSL_Leaf *content);
11static void outputOperationToken(LSL_Leaf *content); 11static void outputOperationToken(LSL_Leaf *content);
12static void outputStatementToken(LSL_Leaf *content); 12static void outputStatementToken(LSL_Leaf *content);
13static void outputSpaceToken(LSL_Leaf *content);
13 14
14LSL_Token LSL_Tokens[] = 15LSL_Token LSL_Tokens[] =
15{ 16{
16// {LSL_COMMENT, "/*", LSL_NONE, NULL, NULL, NULL}, 17// {LSL_COMMENT, "/*", LSL_NONE, NULL, NULL, NULL},
17// {LSL_COMMENT_LINE, "//", LSL_NONE, NULL, NULL, NULL}, 18// {LSL_COMMENT_LINE, "//", LSL_NONE, NULL, NULL, NULL},
18 {LSL_SPACE, " ", LSL_NONE, NULL, NULL, NULL}, 19 {LSL_SPACE, " ", LSL_NONE, outputSpaceToken, NULL, NULL},
19 20
20 // Operators, in order of precedence, low to high 21 // Operators, in order of precedence, low to high
21 // Left to right, unless oterwise stated. 22 // Left to right, unless oterwise stated.
@@ -358,7 +359,7 @@ static void outputAST(LSL_AST *ast)
358 if (ast->token->output) 359 if (ast->token->output)
359 ast->token->output(&(ast->content)); 360 ast->token->output(&(ast->content));
360 else 361 else
361 printf(" %s ", ast->token->token); 362 printf("%s", ast->token->token);
362 outputAST(ast->right); 363 outputAST(ast->right);
363 } 364 }
364} 365}
@@ -372,7 +373,7 @@ static void outputIntegerToken(LSL_Leaf *content)
372static void outputOperationToken(LSL_Leaf *content) 373static void outputOperationToken(LSL_Leaf *content)
373{ 374{
374 if (content) 375 if (content)
375 printf(" %s ", tokens[content->operationValue - lowestToken]->token); 376 printf("%s", tokens[content->operationValue - lowestToken]->token);
376} 377}
377 378
378static void outputStatementToken(LSL_Leaf *content) 379static void outputStatementToken(LSL_Leaf *content)
@@ -382,6 +383,12 @@ static void outputStatementToken(LSL_Leaf *content)
382 printf(";"); 383 printf(";");
383} 384}
384 385
386static void outputSpaceToken(LSL_Leaf *content)
387{
388 if (content)
389 printf("%s", content->spaceValue);
390}
391
385static void convertAST2Lua(LSL_AST *ast) 392static void convertAST2Lua(LSL_AST *ast)
386{ 393{
387 if (ast) 394 if (ast)
@@ -392,7 +399,7 @@ static void convertAST2Lua(LSL_AST *ast)
392 else if (ast->token->output) 399 else if (ast->token->output)
393 ast->token->output(&(ast->content)); 400 ast->token->output(&(ast->content));
394 else 401 else
395 printf(" %s ", ast->token->token); 402 printf("%s", ast->token->token);
396 convertAST2Lua(ast->right); 403 convertAST2Lua(ast->right);
397 } 404 }
398} 405}
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:]])*
30 /* 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. */ 30 /* 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. */
31 31
32 /* White space. */ 32 /* White space. */
33[[:space:]]+ %{ /* ECHO; yylval->spaceValue = strdup(yytext); return LSL_SPACE; */ %} 33[[:space:]]+ %{ ECHO; /* yylval->spaceValue = strdup(yytext); return LSL_SPACE; */ %}
34 34
35 /* Operations. */ 35 /* Operations. */
36"&&" { ECHO; return LSL_BOOL_AND; } 36"&&" { ECHO; return LSL_BOOL_AND; }