aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-20 17:19:25 +1000
committerDavid Walter Seikel2012-01-20 17:19:25 +1000
commita1110536f78c820e91f491928bd0471a470202cb (patch)
tree01c7b38c7f4ed3e888bf8f44c5d158a96eeba5bc /LuaSL
parentRun both test scripts. (diff)
downloadSledjHamr-a1110536f78c820e91f491928bd0471a470202cb.zip
SledjHamr-a1110536f78c820e91f491928bd0471a470202cb.tar.gz
SledjHamr-a1110536f78c820e91f491928bd0471a470202cb.tar.bz2
SledjHamr-a1110536f78c820e91f491928bd0471a470202cb.tar.xz
Clean up parentesis and typecast a bit.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h3
-rw-r--r--LuaSL/src/LuaSL_compile.c43
2 files changed, 21 insertions, 25 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index c2d3260..4b5c067 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -173,9 +173,8 @@ struct _LSL_Leaf
173 173
174struct _LSL_Parenthesis 174struct _LSL_Parenthesis
175{ 175{
176 LSL_Leaf *left;
177 LSL_Leaf *contents; 176 LSL_Leaf *contents;
178 LSL_Leaf *right; 177 Eina_Strbuf *rightIgnorableText;
179 LSL_Type type; 178 LSL_Type type;
180}; 179};
181 180
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 3538ad4..4f51ee4 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -466,10 +466,11 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf
466 466
467 if (parens) 467 if (parens)
468 { 468 {
469 parens->left = lval;
470 parens->contents = expr; 469 parens->contents = expr;
471 parens->type = type; 470 parens->type = type;
472 parens->right = rval; 471 parens->rightIgnorableText = rval->ignorableText;
472 // Actualy, at this point, rval is no longer needed.
473// rval->ignorableText = eina_strbuf_new();
473 if (lval) 474 if (lval)
474 { 475 {
475 lval->value.parenthesis = parens; 476 lval->value.parenthesis = parens;
@@ -512,26 +513,17 @@ LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr)
512 513
513LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr) 514LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr)
514{ 515{
515 LSL_Parenthesis *parens = calloc(1, sizeof(LSL_Parenthesis)); 516 addParenthesis(lval, expr, LSL_TYPECAST_OPEN, rval);
516 517 if (lval)
517 if (parens)
518 { 518 {
519 parens->left = lval; 519 if (type)
520 parens->contents = expr; 520 lval->basicType = type->basicType;
521 parens->type = LSL_TYPECAST_OPEN; 521 // Actualy, at this point, type is no longer needed.
522 parens->right = rval; 522 lval->token = tokens[LSL_TYPECAST_OPEN - lowestToken];
523 if (lval)
524 {
525 lval->value.parenthesis = parens;
526 if (type)
527 lval->basicType = type->basicType;
528 lval->token = tokens[LSL_TYPECAST_OPEN - lowestToken];
529 }
530 if (rval)
531 {
532 rval->token = tokens[LSL_TYPECAST_CLOSE - lowestToken];
533 }
534 } 523 }
524// if (rval)
525// rval->token = tokens[LSL_TYPECAST_CLOSE - lowestToken];
526
535 return lval; 527 return lval;
536} 528}
537 529
@@ -937,9 +929,14 @@ static void outputParenthesisToken(FILE *file, outputMode mode, LSL_Leaf *conten
937{ 929{
938 if (content) 930 if (content)
939 { 931 {
940 fprintf(file, "%s", content->token->token); 932 fprintf(file, "(");
941 outputLeaf(file, mode, content->value.parenthesis->contents); 933 if (LSL_TYPECAST_OPEN == content->value.parenthesis->type)
942 outputLeaf(file, mode, content->value.parenthesis->right); 934 fprintf(file, "%s", allowed[content->basicType].name); // TODO - We are missing the type ignorable text here.
935 else
936 outputLeaf(file, mode, content->value.parenthesis->contents);
937 fprintf(file, "%s)", eina_strbuf_string_get(content->value.parenthesis->rightIgnorableText));
938 if (LSL_TYPECAST_OPEN == content->value.parenthesis->type)
939 outputLeaf(file, mode, content->value.parenthesis->contents);
943 } 940 }
944} 941}
945 942