aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_lemon_yaccer.y
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 13:11:24 +1000
committerDavid Walter Seikel2012-02-02 13:11:24 +1000
commit3e8a0aa78b54d3c7bfe25c512c12c75116bd70d8 (patch)
tree5c95db80c2b873045f2d8a6ca675e76075a8686f /LuaSL/src/LuaSL_lemon_yaccer.y
parentPartially implement parsing/outputting rotations and vectors. (diff)
downloadSledjHamr-3e8a0aa78b54d3c7bfe25c512c12c75116bd70d8.zip
SledjHamr-3e8a0aa78b54d3c7bfe25c512c12c75116bd70d8.tar.gz
SledjHamr-3e8a0aa78b54d3c7bfe25c512c12c75116bd70d8.tar.bz2
SledjHamr-3e8a0aa78b54d3c7bfe25c512c12c75116bd70d8.tar.xz
White space prettiness.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y168
1 files changed, 84 insertions, 84 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 8b6c3d7..c225b26 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -14,7 +14,7 @@
14// The start symbol, just coz we need one. 14// The start symbol, just coz we need one.
15 15
16// Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol. 16// Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol.
17program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } 17program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; }
18 18
19// Various forms of "space". The lexer takes care of them for us. 19// Various forms of "space". The lexer takes care of them for us.
20 20
@@ -23,138 +23,138 @@ program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = compiler->ast;
23// Basic script structure. 23// Basic script structure.
24 24
25%nonassoc LSL_SCRIPT. 25%nonassoc LSL_SCRIPT.
26script ::= script state(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } 26script ::= script state(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; }
27script ::= script functionBody(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } 27script ::= script functionBody(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; }
28script ::= script statement(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } 28script ::= script statement(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; }
29script ::= . 29script ::= .
30 30
31// State definitions. 31// State definitions.
32 32
33%nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. 33%nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE.
34stateBlock(A) ::= beginBlock(L) functionList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); } 34stateBlock(A) ::= beginBlock(L) functionList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); }
35state(A) ::= LSL_DEFAULT(I) stateBlock(B). { A = addState(compiler, NULL, I, B); } 35state(A) ::= LSL_DEFAULT(I) stateBlock(B). { A = addState(compiler, NULL, I, B); }
36state(A) ::= LSL_STATE_CHANGE(S) LSL_IDENTIFIER(I) stateBlock(B). { A = addState(compiler, S, I, B); } 36state(A) ::= LSL_STATE_CHANGE(S) LSL_IDENTIFIER(I) stateBlock(B). { A = addState(compiler, S, I, B); }
37 37
38// Function definitions. 38// Function definitions.
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); }
42functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); } 42functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL, C); }
43// No such thing as a function list with no functions. 43// No such thing as a function list with no functions.
44//functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 44//functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
45 45
46functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody returns an implied addStatement(compiler, NULL, F, NULL, F, NULL, NULL); 46functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody returns an implied addStatement(compiler, NULL, F, NULL, F, NULL, NULL);
47 47
48parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } 48parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); }
49parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } 49parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); }
50parameterList(A) ::= . { A = collectParameters(compiler, NULL, NULL, NULL); } 50parameterList(A) ::= . { A = collectParameters(compiler, NULL, NULL, NULL); }
51parameter(A) ::= type(B) LSL_IDENTIFIER(C). { A = addParameter(compiler, B, C); } 51parameter(A) ::= type(B) LSL_IDENTIFIER(C). { A = addParameter(compiler, B, C); }
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
55// Blocks. 55// Blocks.
56 56
57block(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); } 57block(A) ::= beginBlock(L) statementList(B) LSL_BLOCK_CLOSE(R). { A = addBlock(compiler, L, B, R); }
58 58
59// Various forms of statement. 59// Various forms of statement.
60 60
61%nonassoc LSL_STATEMENT. 61%nonassoc LSL_STATEMENT.
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. 65// Yes, you can have an empty block.
66statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } 66statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
67 67
68%nonassoc LSL_DO LSL_FOR 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.
69%nonassoc LSL_ELSE. 69%nonassoc LSL_ELSE.
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, 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, L, E, R, B, W); }
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 = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, B); } 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 = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, B); }
72statement(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 = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, S); } 72statement(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 = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, S); }
73 73
74statement(A) ::= ifBlock(B). { A = B; } 74statement(A) ::= ifBlock(B). { A = B; }
75ifBlock(A) ::= ifBlock(B) elseBlock(E). { A = addIfElse(compiler, B, E); } 75ifBlock(A) ::= ifBlock(B) elseBlock(E). { A = addIfElse(compiler, B, E); }
76ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } 76ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); }
77ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); } 77ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); }
78elseBlock(A) ::= LSL_ELSE(F) block(B). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, B, NULL); } 78elseBlock(A) ::= LSL_ELSE(F) block(B). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, B, NULL); }
79elseBlock(A) ::= LSL_ELSE(F) statement(S). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, S, NULL); } 79elseBlock(A) ::= LSL_ELSE(F) statement(S). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, S, NULL); }
80 80
81statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } 81statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); }
82statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, E, NULL, NULL, NULL); } 82statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, E, NULL, NULL, NULL); }
83statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, NULL); } 83statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, NULL); }
84statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } 84statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); }
85statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } 85statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); }
86statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } 86statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); }
87statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); } 87statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); }
88 88
89%nonassoc LSL_LABEL. 89%nonassoc LSL_LABEL.
90statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } 90statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); }
91 91
92beginBlock(A) ::= LSL_BLOCK_OPEN(B). { A = beginBlock(compiler, B); } 92beginBlock(A) ::= LSL_BLOCK_OPEN(B). { A = beginBlock(compiler, B); }
93 93
94// This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them. 94// This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them.
95statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, S, NULL, E, NULL, NULL, NULL); } 95statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, S, NULL, E, NULL, NULL, NULL); }
96 96
97// Various forms of expression. 97// Various forms of expression.
98 98
99// Used for function call params, and list contents. 99// Used for function call params, and list contents.
100exprList(A) ::= exprList(B) LSL_COMMA(C) expr(D). { A = collectArguments(compiler, B, C, D); } 100exprList(A) ::= exprList(B) LSL_COMMA(C) expr(D). { A = collectArguments(compiler, B, C, D); }
101exprList(A) ::= expr(D). { A = collectArguments(compiler, NULL, NULL, D); } 101exprList(A) ::= expr(D). { A = collectArguments(compiler, NULL, NULL, D); }
102exprList(A) ::= . { A = collectArguments(compiler, NULL, NULL, NULL); } 102exprList(A) ::= . { A = collectArguments(compiler, NULL, NULL, NULL); }
103 103
104%right LSL_BOOL_AND. 104%right LSL_BOOL_AND.
105expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(compiler, B, C, D); } 105expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(compiler, B, C, D); }
106%right LSL_BOOL_OR. 106%right LSL_BOOL_OR.
107expr(A) ::= expr(B) LSL_BOOL_OR(C) expr(D). { A = addOperation(compiler, B, C, D); } 107expr(A) ::= expr(B) LSL_BOOL_OR(C) expr(D). { A = addOperation(compiler, B, C, D); }
108 108
109%left LSL_BIT_AND LSL_BIT_XOR LSL_BIT_OR. 109%left LSL_BIT_AND LSL_BIT_XOR LSL_BIT_OR.
110expr(A) ::= expr(B) LSL_BIT_OR(C) expr(D). { A = addOperation(compiler, B, C, D); } 110expr(A) ::= expr(B) LSL_BIT_OR(C) expr(D). { A = addOperation(compiler, B, C, D); }
111expr(A) ::= expr(B) LSL_BIT_XOR(C) expr(D). { A = addOperation(compiler, B, C, D); } 111expr(A) ::= expr(B) LSL_BIT_XOR(C) expr(D). { A = addOperation(compiler, B, C, D); }
112expr(A) ::= expr(B) LSL_BIT_AND(C) expr(D). { A = addOperation(compiler, B, C, D); } 112expr(A) ::= expr(B) LSL_BIT_AND(C) expr(D). { A = addOperation(compiler, B, C, D); }
113 113
114%right LSL_EQUAL LSL_NOT_EQUAL. 114%right LSL_EQUAL LSL_NOT_EQUAL.
115expr(A) ::= expr(B) LSL_NOT_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } 115expr(A) ::= expr(B) LSL_NOT_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); }
116expr(A) ::= expr(B) LSL_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } 116expr(A) ::= expr(B) LSL_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); }
117%right LSL_LESS_THAN LSL_GREATER_THAN LSL_LESS_EQUAL LSL_GREATER_EQUAL. 117%right LSL_LESS_THAN LSL_GREATER_THAN LSL_LESS_EQUAL LSL_GREATER_EQUAL.
118expr(A) ::= expr(B) LSL_GREATER_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } 118expr(A) ::= expr(B) LSL_GREATER_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); }
119expr(A) ::= expr(B) LSL_LESS_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } 119expr(A) ::= expr(B) LSL_LESS_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); }
120expr(A) ::= expr(B) LSL_GREATER_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); } 120expr(A) ::= expr(B) LSL_GREATER_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); }
121expr(A) ::= expr(B) LSL_LESS_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); } 121expr(A) ::= expr(B) LSL_LESS_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); }
122 122
123%left LSL_LEFT_SHIFT LSL_RIGHT_SHIFT. 123%left LSL_LEFT_SHIFT LSL_RIGHT_SHIFT.
124expr(A) ::= expr(B) LSL_RIGHT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); } 124expr(A) ::= expr(B) LSL_RIGHT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); }
125expr(A) ::= expr(B) LSL_LEFT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); } 125expr(A) ::= expr(B) LSL_LEFT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); }
126 126
127%left LSL_SUBTRACT LSL_ADD LSL_CONCATENATE. 127%left LSL_SUBTRACT LSL_ADD LSL_CONCATENATE.
128expr(A) ::= expr(B) LSL_ADD(C) expr(D). { A = addOperation(compiler, B, C, D); } 128expr(A) ::= expr(B) LSL_ADD(C) expr(D). { A = addOperation(compiler, B, C, D); }
129expr(A) ::= expr(B) LSL_SUBTRACT(C) expr(D). { A = addOperation(compiler, B, C, D); } 129expr(A) ::= expr(B) LSL_SUBTRACT(C) expr(D). { A = addOperation(compiler, B, C, D); }
130%left LSL_DIVIDE LSL_MODULO LSL_MULTIPLY LSL_DOT_PRODUCT LSL_CROSS_PRODUCT. 130%left LSL_DIVIDE LSL_MODULO LSL_MULTIPLY LSL_DOT_PRODUCT LSL_CROSS_PRODUCT.
131expr(A) ::= expr(B) LSL_MULTIPLY(C) expr(D). { A = addOperation(compiler, B, C, D); } 131expr(A) ::= expr(B) LSL_MULTIPLY(C) expr(D). { A = addOperation(compiler, B, C, D); }
132expr(A) ::= expr(B) LSL_MODULO(C) expr(D). { A = addOperation(compiler, B, C, D); } 132expr(A) ::= expr(B) LSL_MODULO(C) expr(D). { A = addOperation(compiler, B, C, D); }
133expr(A) ::= expr(B) LSL_DIVIDE(C) expr(D). { A = addOperation(compiler, B, C, D); } 133expr(A) ::= expr(B) LSL_DIVIDE(C) expr(D). { A = addOperation(compiler, B, C, D); }
134 134
135%right LSL_BIT_NOT LSL_BOOL_NOT LSL_NEGATION. 135%right LSL_BIT_NOT LSL_BOOL_NOT LSL_NEGATION.
136expr(A) ::= LSL_BIT_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); } 136expr(A) ::= LSL_BIT_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); }
137expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); } 137expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); }
138expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(compiler, NULL, B, C); } 138expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(compiler, NULL, B, C); }
139 139
140// Types, typecasts, and expression reordering. 140// Types, typecasts, and expression reordering.
141 141
142%right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE. 142%right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE.
143%nonassoc LSL_TYPE_FLOAT LSL_TYPE_INTEGER LSL_TYPE_KEY LSL_TYPE_LIST LSL_TYPE_ROTATION LSL_TYPE_STRING LSL_TYPE_VECTOR. 143%nonassoc LSL_TYPE_FLOAT LSL_TYPE_INTEGER LSL_TYPE_KEY LSL_TYPE_LIST LSL_TYPE_ROTATION LSL_TYPE_STRING LSL_TYPE_VECTOR.
144type(A) ::= LSL_TYPE_FLOAT(B). { B->basicType = OT_float; A = B; } 144type(A) ::= LSL_TYPE_FLOAT(B). { B->basicType = OT_float; A = B; }
145type(A) ::= LSL_TYPE_INTEGER(B). { B->basicType = OT_integer; A = B; } 145type(A) ::= LSL_TYPE_INTEGER(B). { B->basicType = OT_integer; A = B; }
146type(A) ::= LSL_TYPE_KEY(B). { B->basicType = OT_key; A = B; } 146type(A) ::= LSL_TYPE_KEY(B). { B->basicType = OT_key; A = B; }
147type(A) ::= LSL_TYPE_LIST(B). { B->basicType = OT_list; A = B; } 147type(A) ::= LSL_TYPE_LIST(B). { B->basicType = OT_list; A = B; }
148type(A) ::= LSL_TYPE_ROTATION(B). { B->basicType = OT_rotation; A = B; } 148type(A) ::= LSL_TYPE_ROTATION(B). { B->basicType = OT_rotation; A = B; }
149type(A) ::= LSL_TYPE_STRING(B). { B->basicType = OT_string; A = B; } 149type(A) ::= LSL_TYPE_STRING(B). { B->basicType = OT_string; A = B; }
150type(A) ::= LSL_TYPE_VECTOR(B). { B->basicType = OT_vector; A = B; } 150type(A) ::= LSL_TYPE_VECTOR(B). { B->basicType = OT_vector; A = B; }
151 151
152%left LSL_ANGLE_OPEN LSL_ANGLE_CLOSE. 152%left LSL_ANGLE_OPEN LSL_ANGLE_CLOSE.
153%nonassoc LSL_BRACKET_OPEN LSL_BRACKET_CLOSE. 153%nonassoc LSL_BRACKET_OPEN LSL_BRACKET_CLOSE.
154%nonassoc LSL_PARENTHESIS_OPEN LSL_PARENTHESIS_CLOSE LSL_EXPRESSION. 154%nonassoc LSL_PARENTHESIS_OPEN LSL_PARENTHESIS_CLOSE LSL_EXPRESSION.
155 155
156expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, LSL_EXPRESSION, D); } 156expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, LSL_EXPRESSION, D); }
157expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D) expr(E). { A = addTypecast(B, C, D, E); } 157expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D) expr(E). { A = addTypecast(B, C, D, E); }
158 158
159// Function call. 159// Function call.
160 160
@@ -163,17 +163,17 @@ expr(A) ::= LSL_IDENTIFIER(B) LSL_PARENTHESIS_OPEN(C) exprList(D) LSL_PARENTHESI
163 163
164// Variables and dealing with them. 164// Variables and dealing with them.
165 165
166expr(A) ::= identifier(B). { A = B; } 166expr(A) ::= identifier(B). { A = B; }
167 167
168%right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. 168%right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN.
169// Yes, these can be expressions, and can happen in if statements and such. 169// Yes, these can be expressions, and can happen in if statements and such.
170expr(A) ::= identifier(B) LSL_ASSIGNMENT_CONCATENATE(C) expr(D). { A = addOperation(compiler, B, C, D); } 170expr(A) ::= identifier(B) LSL_ASSIGNMENT_CONCATENATE(C) expr(D). { A = addOperation(compiler, B, C, D); }
171expr(A) ::= identifier(B) LSL_ASSIGNMENT_ADD(C) expr(D). { A = addOperation(compiler, B, C, D); } 171expr(A) ::= identifier(B) LSL_ASSIGNMENT_ADD(C) expr(D). { A = addOperation(compiler, B, C, D); }
172expr(A) ::= identifier(B) LSL_ASSIGNMENT_SUBTRACT(C) expr(D) . { A = addOperation(compiler, B, C, D); } 172expr(A) ::= identifier(B) LSL_ASSIGNMENT_SUBTRACT(C) expr(D). { A = addOperation(compiler, B, C, D); }
173expr(A) ::= identifier(B) LSL_ASSIGNMENT_MULTIPLY(C) expr(D). { A = addOperation(compiler, B, C, D); } 173expr(A) ::= identifier(B) LSL_ASSIGNMENT_MULTIPLY(C) expr(D). { A = addOperation(compiler, B, C, D); }
174expr(A) ::= identifier(B) LSL_ASSIGNMENT_MODULO(C) expr(D). { A = addOperation(compiler, B, C, D); } 174expr(A) ::= identifier(B) LSL_ASSIGNMENT_MODULO(C) expr(D). { A = addOperation(compiler, B, C, D); }
175expr(A) ::= identifier(B) LSL_ASSIGNMENT_DIVIDE(C) expr(D). { A = addOperation(compiler, B, C, D); } 175expr(A) ::= identifier(B) LSL_ASSIGNMENT_DIVIDE(C) expr(D). { A = addOperation(compiler, B, C, D); }
176expr(A) ::= identifier(B) LSL_ASSIGNMENT_PLAIN(C) expr(D). { A = addOperation(compiler, B, C, D); } 176expr(A) ::= identifier(B) LSL_ASSIGNMENT_PLAIN(C) expr(D). { A = addOperation(compiler, B, C, D); }
177 177
178// 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. 178// 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.
179// Well, not in OpenSim at least, nor in SL. So we are safe. B-) 179// Well, not in OpenSim at least, nor in SL. So we are safe. B-)
@@ -182,14 +182,14 @@ statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_S
182statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, I, NULL, addVariable(compiler, T, I, NULL, NULL), NULL, NULL, I); } 182statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, I, NULL, addVariable(compiler, T, I, NULL, NULL), NULL, NULL, I); }
183 183
184%right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL LSL_VARIABLE. 184%right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL LSL_VARIABLE.
185identifier(A) ::= identifier(I) LSL_DOT(D) LSL_IDENTIFIER(B). { A = checkVariable(compiler, I, D, B); } 185identifier(A) ::= identifier(I) LSL_DOT(D) LSL_IDENTIFIER(B). { A = checkVariable(compiler, I, D, B); }
186identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B, NULL, NULL); } 186identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B, NULL, NULL); }
187 187
188%right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. 188%right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST.
189expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_DECREMENT_POST); } 189expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_DECREMENT_POST); }
190expr(A) ::= identifier(B) LSL_INCREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_INCREMENT_POST); } 190expr(A) ::= identifier(B) LSL_INCREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_INCREMENT_POST); }
191expr(A) ::= LSL_DECREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_DECREMENT_PRE); } 191expr(A) ::= LSL_DECREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_DECREMENT_PRE); }
192expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_INCREMENT_PRE); } 192expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_INCREMENT_PRE); }
193 193
194%nonassoc LSL_COMMA. 194%nonassoc LSL_COMMA.
195 195