aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_lemon_yaccer.y
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-30 16:35:11 +1000
committerDavid Walter Seikel2012-01-30 16:35:11 +1000
commit162e7843bb3475a08eae13b2464092d72560eb9a (patch)
treee31803b318ea88f0752951ef10ea90a0f3a867dd /LuaSL/src/LuaSL_lemon_yaccer.y
parentClean up blocks / single statements. Also got rid of a lot of conflicts. (diff)
downloadSledjHamr-162e7843bb3475a08eae13b2464092d72560eb9a.zip
SledjHamr-162e7843bb3475a08eae13b2464092d72560eb9a.tar.gz
SledjHamr-162e7843bb3475a08eae13b2464092d72560eb9a.tar.bz2
SledjHamr-162e7843bb3475a08eae13b2464092d72560eb9a.tar.xz
Remove the else if stuff, and empty function lists. Add the else precedence hack back in.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y12
1 files changed, 7 insertions, 5 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index e15078b..78aa349 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -40,7 +40,8 @@ state(S) ::= LSL_STATE_CHANGE LSL_IDENTIFIER(I) stateBlock(B). { S = addState(
40%nonassoc LSL_PARAMETER LSL_PARAMETER_LIST LSL_FUNCTION. 40%nonassoc LSL_PARAMETER LSL_PARAMETER_LIST LSL_FUNCTION.
41functionList(A) ::= functionList(B) functionBody(C). { A = collectStatements(compiler, B, C); } 41functionList(A) ::= functionList(B) functionBody(C). { A = collectStatements(compiler, B, C); }
42functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); } 42functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); }
43functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 43// No such thing as a function list with no functions.
44//functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
44 45
45functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL); 46functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL);
46 47
@@ -48,7 +49,6 @@ parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectP
48parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } 49parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); }
49parameterList(A) ::= . { A = collectParameters(compiler, NULL, NULL, NULL); } 50parameterList(A) ::= . { A = collectParameters(compiler, NULL, NULL, NULL); }
50parameter(A) ::= type(B) LSL_IDENTIFIER(C). { A = addParameter(compiler, B, C); } 51parameter(A) ::= type(B) LSL_IDENTIFIER(C). { A = addParameter(compiler, B, C); }
51// Causes a conflict when it's an empty parameterList with calling the same type of function.
52function(A) ::= LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F). { A = addFunction(compiler, NULL, C, D, E, F); } 52function(A) ::= LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F). { A = addFunction(compiler, NULL, C, D, E, F); }
53function(A) ::= type(B) LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F). { A = addFunction(compiler, B, C, D, E, F); } 53function(A) ::= type(B) LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(E) LSL_PARENTHESIS_CLOSE(F). { A = addFunction(compiler, B, C, D, E, F); }
54 54
@@ -62,9 +62,10 @@ block(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(
62statementList(A) ::= statementList(B) statement(C). { A = collectStatements(compiler, B, C); } 62statementList(A) ::= statementList(B) statement(C). { A = collectStatements(compiler, B, C); }
63// This causes infinite loops (and about 150 conflicts) with - if () single statement; 63// This causes infinite loops (and about 150 conflicts) with - if () single statement;
64//statementList(A) ::= statement(C). { A = collectStatements(compiler, NULL, C); } 64//statementList(A) ::= statement(C). { A = collectStatements(compiler, NULL, C); }
65// Yes, you can have an empty block.
65statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 66statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
66 67
67%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_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE.
68%nonassoc LSL_ELSE. 69%nonassoc LSL_ELSE.
69statement(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); } 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); }
70statement(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, E1, R, B, NULL); } // three expressions, two semi colons 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, E1, R, B, NULL); } // three expressions, two semi colons
@@ -73,8 +74,8 @@ statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) e
73statement(A) ::= ifBlock(B). { A = B; } 74statement(A) ::= ifBlock(B). { A = B; }
74ifBlock ::= ifBlock LSL_ELSE block. 75ifBlock ::= ifBlock LSL_ELSE block.
75ifBlock ::= ifBlock LSL_ELSE statement. 76ifBlock ::= ifBlock LSL_ELSE statement.
76ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). /*[LSL_ELSE]*/ { A = addStatement(compiler, NULL, F->toKen->type, L, E, R, B, NULL); } // optional else, optional else if 77ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F->toKen->type, L, E, R, B, NULL); } // optional else, optional else if
77ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). /*[LSL_ELSE]*/ { A = addStatement(compiler, S, F->toKen->type, L, E, R, NULL, NULL); } // optional else, optional else if 78ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, S, F->toKen->type, L, E, R, NULL, NULL); } // optional else, optional else if
78 79
79statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } 80statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
80statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); } 81statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); }
@@ -175,6 +176,7 @@ expr(A) ::= identifier(B) LSL_ASSIGNMENT_PLAIN(C) expr(D). { A = addOperation(c
175 176
176// 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. 177// 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.
177// Well, not in OpenSim at least, nor in SL. So we are safe. B-) 178// Well, not in OpenSim at least, nor in SL. So we are safe. B-)
179// On the other hand, it might be legal to have comma separated bits in a for loop - for ((i = 1), (j=1); ...
178statement(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); } 180statement(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); }
179statement(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); } 181statement(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); }
180 182