aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_lemon_yaccer.y
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-28 14:54:41 +1000
committerDavid Walter Seikel2012-01-28 14:54:41 +1000
commit0d060b7ef6ea3cdd3ae505f41826d96d3ca12070 (patch)
tree32b477bc406dd30ed119e5f1de97ea1750ff4353 /LuaSL/src/LuaSL_lemon_yaccer.y
parentDocument the other Clist use, and change it's name while I'm at it. (diff)
downloadSledjHamr-0d060b7ef6ea3cdd3ae505f41826d96d3ca12070.zip
SledjHamr-0d060b7ef6ea3cdd3ae505f41826d96d3ca12070.tar.gz
SledjHamr-0d060b7ef6ea3cdd3ae505f41826d96d3ca12070.tar.bz2
SledjHamr-0d060b7ef6ea3cdd3ae505f41826d96d3ca12070.tar.xz
Add some of the flow control stuff, still needs lots of work.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y28
1 files changed, 14 insertions, 14 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 42b02c7..f5b5981 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -42,7 +42,7 @@ functionList(A) ::= functionList(B) functionBody(C). { A = collectStatements(
42//functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); } 42//functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); }
43functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 43functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
44 44
45functionBody(A) ::= function(B) funcBlock(C). { A = addFunctionBody(compiler, B, C); } 45functionBody(A) ::= function(F) funcBlock(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL);
46 46
47parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } 47parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); }
48parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } 48parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); }
@@ -67,26 +67,26 @@ statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
67 67
68%nonassoc LSL_DO LSL_FOR LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. 68%nonassoc LSL_DO LSL_FOR LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE.
69%nonassoc LSL_ELSE. 69%nonassoc LSL_ELSE.
70statement ::= LSL_DO block LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE LSL_STATEMENT. 70statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, L, E, R, B, W); }
71statement ::= LSL_FOR LSL_PARENTHESIS_OPEN expr LSL_STATEMENT expr LSL_STATEMENT expr LSL_PARENTHESIS_CLOSE block. 71statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->token->type, L, NULL, R, B, NULL); } // three expressions, two semi colons
72 72
73ifBlock ::= ifBlock LSL_ELSE block. 73ifBlock ::= ifBlock LSL_ELSE block.
74ifBlock ::= block. 74ifBlock ::= block.
75// The [LSL_ELSE] part causes a conflict. 75// The [LSL_ELSE] part causes a conflict.
76statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE ifBlock. [LSL_ELSE] 76statement(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) ifBlock(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F->token->type, L, E, R, B, NULL); } // optional else, optional else if
77 77
78statement ::= LSL_JUMP LSL_IDENTIFIER LSL_STATEMENT. 78statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); }
79statement ::= LSL_RETURN expr LSL_STATEMENT. 79statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, E, NULL, NULL, NULL); }
80statement ::= LSL_RETURN LSL_STATEMENT. 80statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, NULL); }
81statement ::= LSL_STATE_CHANGE LSL_DEFAULT LSL_STATEMENT. 81statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); }
82statement ::= LSL_STATE_CHANGE LSL_IDENTIFIER LSL_STATEMENT. 82statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); }
83statement ::= LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE block. 83statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->token->type, L, E, R, B, NULL); }
84 84
85%nonassoc LSL_LABEL. 85%nonassoc LSL_LABEL.
86statement ::= LSL_LABEL LSL_IDENTIFIER LSL_STATEMENT. 86statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); }
87 87
88// This might be bogus, or might be valid LSL, but it let us test the expression parser by evaluating them. 88// This might be bogus, or might be valid LSL, but it let us test the expression parser by evaluating them.
89statement(A) ::= expr(B) LSL_STATEMENT(D). { A = addStatement(D, LSL_EXPRESSION, B); } 89statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_EXPRESSION, NULL, E, NULL, NULL, NULL); }
90 90
91// Various forms of expression. 91// Various forms of expression.
92 92
@@ -171,8 +171,8 @@ expr(A) ::= identifier(B) LSL_ASSIGNMENT_PLAIN(C) expr(D). { A = addOperation(c
171 171
172// Hmm think this can have commas seperating the assignment parts, or is that only in C?. If so, best to separate them when converting to Lua, as it uses that syntax for something else. 172// Hmm think this can have commas seperating the assignment parts, or is that only in C?. If so, best to separate them when converting to Lua, as it uses that syntax for something else.
173// Well, not in OpenSim at least, nor in SL. So we are safe. B-) 173// Well, not in OpenSim at least, nor in SL. So we are safe. B-)
174statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(compiler, B, C, D, E)); } 174statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_IDENTIFIER, NULL, addVariable(compiler, T, I, D, E), NULL, NULL, I); }
175statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(compiler, B, C, NULL, NULL)); } 175statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_IDENTIFIER, NULL, addVariable(compiler, T, I, NULL, NULL), NULL, NULL, I); }
176 176
177%right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL. 177%right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL.
178identifier(A) ::= identifier LSL_DOT LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); A->basicType = OT_float; } // Just a stub to get it to work for now. 178identifier(A) ::= identifier LSL_DOT LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); A->basicType = OT_float; } // Just a stub to get it to work for now.