aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_lemon_yaccer.y
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-30 13:35:07 +1000
committerDavid Walter Seikel2012-01-30 13:35:07 +1000
commit7b6c75728a6cd9a1138f0de9a9683d3fa9ea87e5 (patch)
treede6f9844f596e175fa76cb1eedfad7bc90cd8440 /LuaSL/src/LuaSL_lemon_yaccer.y
parentMore comment++ (diff)
downloadSledjHamr-7b6c75728a6cd9a1138f0de9a9683d3fa9ea87e5.zip
SledjHamr-7b6c75728a6cd9a1138f0de9a9683d3fa9ea87e5.tar.gz
SledjHamr-7b6c75728a6cd9a1138f0de9a9683d3fa9ea87e5.tar.bz2
SledjHamr-7b6c75728a6cd9a1138f0de9a9683d3fa9ea87e5.tar.xz
Patch up some more parser stuff.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y15
1 files changed, 8 insertions, 7 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index ed53fd4..5ae66ce 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -39,7 +39,7 @@ state(S) ::= LSL_STATE_CHANGE LSL_IDENTIFIER(I) stateBlock(B). { S = addState(
39 39
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); }
42//functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); } 42functionList(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(F) funcBlock(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL); 45functionBody(A) ::= function(F) funcBlock(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL);
@@ -55,8 +55,7 @@ function(A) ::= type(B) LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList(
55// Blocks. 55// Blocks.
56 56
57block(A) ::= funcBlock(B). { A = B; } 57block(A) ::= funcBlock(B). { A = B; }
58block(A) ::= statement(B). { A = B; } 58block(A) ::= statementList(B). { A = B; }
59funcBlock(A) ::= LSL_BLOCK_OPEN statementList(B) LSL_BLOCK_CLOSE. { A = B; }
60// Perhaps change this to block? No ,this is what differentiates it from a single statement, which functions can't handle. 59// Perhaps change this to block? No ,this is what differentiates it from a single statement, which functions can't handle.
61funcBlock(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); } 60funcBlock(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); }
62 61
@@ -64,6 +63,7 @@ funcBlock(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBl
64 63
65%nonassoc LSL_STATEMENT. 64%nonassoc LSL_STATEMENT.
66statementList(A) ::= statementList(B) statement(C). { A = collectStatements(compiler, B, C); } 65statementList(A) ::= statementList(B) statement(C). { A = collectStatements(compiler, B, C); }
66// This causes infinite loops (and about 150 conflicts) with - if () single statement;
67//statementList(A) ::= statement(C). { A = collectStatements(compiler, NULL, C); } 67//statementList(A) ::= statement(C). { A = collectStatements(compiler, NULL, C); }
68statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 68statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
69 69
@@ -72,10 +72,11 @@ statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
72statement(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); } 72statement(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); }
73statement(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 73statement(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
74 74
75ifBlock ::= ifBlock LSL_ELSE block. 75statement(A) ::= ifBlock(B). { A = B; }
76ifBlock ::= block. 76//ifBlock ::= ifBlock LSL_ELSE block.
77// The [LSL_ELSE] part causes a conflict. 77statement ::= LSL_ELSE block.
78statement(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 78ifBlock(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
79ifBlock(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
79 80
80statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } 81statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
81statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); } 82statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); }