diff options
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 5ae66ce..e15078b 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); } |
43 | functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } | 43 | functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } |
44 | 44 | ||
45 | functionBody(A) ::= function(F) funcBlock(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL); | 45 | functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL); |
46 | 46 | ||
47 | parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } | 47 | parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } |
48 | parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } | 48 | parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } |
@@ -54,10 +54,7 @@ function(A) ::= type(B) LSL_IDENTIFIER(C) LSL_PARENTHESIS_OPEN(D) parameterList( | |||
54 | 54 | ||
55 | // Blocks. | 55 | // Blocks. |
56 | 56 | ||
57 | block(A) ::= funcBlock(B). { A = B; } | 57 | block(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); } |
58 | block(A) ::= statementList(B). { A = B; } | ||
59 | // Perhaps change this to block? No ,this is what differentiates it from a single statement, which functions can't handle. | ||
60 | funcBlock(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); } | ||
61 | 58 | ||
62 | // Various forms of statement. | 59 | // Various forms of statement. |
63 | 60 | ||
@@ -71,10 +68,11 @@ statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } | |||
71 | %nonassoc LSL_ELSE. | 68 | %nonassoc LSL_ELSE. |
72 | statement(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); } | 69 | statement(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); } |
73 | statement(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 | 70 | statement(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 |
71 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F->toKen->type, L, E1, R, NULL, NULL); } // three expressions, two semi colons | ||
74 | 72 | ||
75 | statement(A) ::= ifBlock(B). { A = B; } | 73 | statement(A) ::= ifBlock(B). { A = B; } |
76 | //ifBlock ::= ifBlock LSL_ELSE block. | 74 | ifBlock ::= ifBlock LSL_ELSE block. |
77 | statement ::= LSL_ELSE block. | 75 | ifBlock ::= ifBlock LSL_ELSE statement. |
78 | ifBlock(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 | 76 | ifBlock(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 |
79 | ifBlock(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 | 77 | ifBlock(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 |
80 | 78 | ||
@@ -84,6 +82,7 @@ statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement( | |||
84 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 82 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } |
85 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 83 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } |
86 | statement(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 | statement(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); } |
85 | statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F->toKen->type, L, E, R, NULL, NULL); } | ||
87 | 86 | ||
88 | %nonassoc LSL_LABEL. | 87 | %nonassoc LSL_LABEL. |
89 | statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 88 | statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } |