diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 94 |
1 files changed, 80 insertions, 14 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 32d6b46..046a2b5 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -51,24 +51,43 @@ expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(NULL, B | |||
51 | 51 | ||
52 | %right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE. | 52 | %right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE. |
53 | %nonassoc LSL_TYPE_FLOAT LSL_TYPE_INTEGER LSL_TYPE_KEY LSL_TYPE_LIST LSL_TYPE_ROTATION LSL_TYPE_STRING LSL_TYPE_VECTOR. | 53 | %nonassoc LSL_TYPE_FLOAT LSL_TYPE_INTEGER LSL_TYPE_KEY LSL_TYPE_LIST LSL_TYPE_ROTATION LSL_TYPE_STRING LSL_TYPE_VECTOR. |
54 | type ::= LSL_TYPE_FLOAT. | ||
55 | type ::= LSL_TYPE_INTEGER. | ||
56 | type ::= LSL_TYPE_KEY. | ||
57 | type ::= LSL_TYPE_LIST. | ||
58 | type ::= LSL_TYPE_ROTATION. | ||
59 | type ::= LSL_TYPE_STRING. | ||
60 | type ::= LSL_TYPE_VECTOR. | ||
61 | |||
54 | %left LSL_ANGLE_OPEN LSL_ANGLE_CLOSE. | 62 | %left LSL_ANGLE_OPEN LSL_ANGLE_CLOSE. |
55 | %nonassoc LSL_BRACKET_OPEN LSL_BRACKET_CLOSE. | 63 | %nonassoc LSL_BRACKET_OPEN LSL_BRACKET_CLOSE. |
56 | %nonassoc LSL_PARENTHESIS_OPEN LSL_PARENTHESIS_CLOSE LSL_EXPRESSION. | 64 | %nonassoc LSL_PARENTHESIS_OPEN LSL_PARENTHESIS_CLOSE LSL_EXPRESSION. |
57 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, D); } | 65 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, D); } |
58 | 66 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | |
59 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_FLOAT(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | 67 | //expr ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN exprList LSL_PARENTHESIS_CLOSE. |
60 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_INTEGER(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
61 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_KEY(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
62 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_LIST(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
63 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_ROTATION(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
64 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_STRING(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
65 | expr(A) ::= LSL_PARENTHESIS_OPEN(B) LSL_TYPE_VECTOR(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } | ||
66 | 68 | ||
67 | %right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. | 69 | %right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. |
70 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_CONCATENATE expr. | ||
71 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_ADD expr. | ||
72 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_SUBTRACT expr. | ||
73 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_MULTIPLY expr. | ||
74 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_MODULO expr. | ||
75 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_DIVIDE expr. | ||
76 | expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr. | ||
68 | %right LSL_DOT. | 77 | %right LSL_DOT. |
78 | expr ::= LSL_IDENTIFIER LSL_DOT LSL_IDENTIFIER. | ||
69 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. | 79 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. |
80 | expr ::= LSL_IDENTIFIER LSL_DECREMENT_PRE. | ||
81 | expr ::= LSL_IDENTIFIER LSL_INCREMENT_PRE. | ||
82 | expr ::= LSL_DECREMENT_PRE LSL_IDENTIFIER. | ||
83 | expr ::= LSL_INCREMENT_PRE LSL_IDENTIFIER. | ||
84 | |||
70 | %nonassoc LSL_COMMA. | 85 | %nonassoc LSL_COMMA. |
71 | 86 | ||
87 | exprList ::= exprList LSL_COMMA expr. | ||
88 | exprList ::= expr. | ||
89 | exprList ::= . | ||
90 | |||
72 | %nonassoc LSL_FLOAT. | 91 | %nonassoc LSL_FLOAT. |
73 | expr(A) ::= LSL_FLOAT(B). { B->basicType = OT_float; A = B; } | 92 | expr(A) ::= LSL_FLOAT(B). { B->basicType = OT_float; A = B; } |
74 | %nonassoc LSL_INTEGER. | 93 | %nonassoc LSL_INTEGER. |
@@ -76,24 +95,71 @@ expr(A) ::= LSL_INTEGER(B). { B->basicType = OT_integer; A = B; } | |||
76 | %nonassoc LSL_KEY. | 95 | %nonassoc LSL_KEY. |
77 | expr(A) ::= LSL_KEY(B). { B->basicType = OT_key; A = B; } | 96 | expr(A) ::= LSL_KEY(B). { B->basicType = OT_key; A = B; } |
78 | %nonassoc LSL_LIST. | 97 | %nonassoc LSL_LIST. |
98 | expr ::= LSL_BRACKET_OPEN exprList LSL_BRACKET_CLOSE. | ||
79 | %nonassoc LSL_ROTATION. | 99 | %nonassoc LSL_ROTATION. |
100 | expr ::= LSL_ANGLE_OPEN expr LSL_COMMA expr LSL_COMMA expr LSL_COMMA expr LSL_ANGLE_CLOSE. | ||
80 | %nonassoc LSL_STRING. | 101 | %nonassoc LSL_STRING. |
81 | expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; } | 102 | expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; } |
82 | %nonassoc LSL_VECTOR. | 103 | %nonassoc LSL_VECTOR. |
83 | 104 | expr ::= LSL_VECTOR. | |
84 | %nonassoc LSL_DO LSL_FOR LSL_ELSE LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. | 105 | expr ::= LSL_ANGLE_OPEN expr LSL_COMMA expr LSL_COMMA expr LSL_ANGLE_CLOSE. |
106 | |||
107 | %nonassoc LSL_DO LSL_FOR LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. | ||
108 | %nonassoc LSL_ELSE. | ||
109 | statement ::= LSL_DO block LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE LSL_STATEMENT. | ||
110 | statement ::= LSL_DO statement LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE LSL_STATEMENT. | ||
111 | statement ::= LSL_FOR LSL_PARENTHESIS_OPEN expr LSL_COMMA expr LSL_COMMA expr LSL_PARENTHESIS_CLOSE block. | ||
112 | statement ::= LSL_FOR LSL_PARENTHESIS_OPEN expr LSL_COMMA expr LSL_COMMA expr LSL_PARENTHESIS_CLOSE statement. | ||
113 | |||
114 | elseIfList ::= elseIfList elseIf. | ||
115 | elseIfList ::= . | ||
116 | elseIf ::= LSL_ELSE LSL_IF block. [LSL_ELSE] | ||
117 | //elseIf ::= LSL_ELSE LSL_IF statement. | ||
118 | |||
119 | statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE block elseIfList. [LSL_ELSE] | ||
120 | //statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE statement elseIfList. | ||
121 | statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE block elseIfList LSL_ELSE block. | ||
122 | //statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE statement elseIfList LSL_ELSE block. | ||
123 | //statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE block elseIfList LSL_ELSE statement. | ||
124 | //statement ::= LSL_IF LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE statement elseIfList LSL_ELSE statement. | ||
125 | |||
126 | statement ::= LSL_JUMP LSL_IDENTIFIER. | ||
127 | statement ::= LSL_RETURN expr LSL_STATEMENT. | ||
128 | statement ::= LSL_RETURN LSL_STATEMENT. | ||
129 | statement ::= LSL_STATE_CHANGE LSL_IDENTIFIER. | ||
130 | statement ::= LSL_WHILE LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE block LSL_STATEMENT. | ||
131 | statement ::= LSL_WHILE LSL_WHILE LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE statement LSL_STATEMENT. | ||
85 | 132 | ||
86 | %nonassoc LSL_LABEL. | 133 | %nonassoc LSL_LABEL. |
134 | target ::= LSL_LABEL LSL_IDENTIFIER. | ||
87 | 135 | ||
88 | %nonassoc LSL_STATEMENT. | 136 | %nonassoc LSL_IDENTIFIER LSL_STATEMENT. |
137 | statement ::= target LSL_STATEMENT. | ||
138 | statement ::= type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr LSL_STATEMENT. | ||
139 | statement ::= type LSL_IDENTIFIER LSL_STATEMENT. | ||
89 | statement(A) ::= expr(B) LSL_STATEMENT(D). { A = addStatement(D, LSL_EXPRESSION, B); } | 140 | statement(A) ::= expr(B) LSL_STATEMENT(D). { A = addStatement(D, LSL_EXPRESSION, B); } |
90 | 141 | ||
91 | %nonassoc LSL_IDENTIFIER LSL_SCRIPT. | 142 | statementList ::= statementList statement. |
92 | script ::= script statement(A). { A->left = param->ast; param->ast = A; } | 143 | statementList ::= . |
93 | script ::= statement(A). { A->left = param->ast; param->ast = A; } | ||
94 | 144 | ||
95 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE. | 145 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE. |
146 | block ::= LSL_BLOCK_OPEN statementList LSL_BLOCK_CLOSE. | ||
147 | |||
96 | %nonassoc LSL_PARAMETER LSL_FUNCTION LSL_STATE. | 148 | %nonassoc LSL_PARAMETER LSL_FUNCTION LSL_STATE. |
149 | parameter ::= type LSL_IDENTIFIER. | ||
150 | parameterList ::= parameterList LSL_COMMA parameter. | ||
151 | parameterList ::= parameter. | ||
152 | parameterList ::= . | ||
153 | function ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN parameterList LSL_PARENTHESIS_CLOSE block. | ||
154 | function ::= type LSL_IDENTIFIER LSL_PARENTHESIS_OPEN parameterList LSL_PARENTHESIS_CLOSE block. | ||
155 | |||
156 | state ::= LSL_IDENTIFIER block. | ||
157 | |||
158 | %nonassoc LSL_SCRIPT. | ||
159 | script ::= script state. | ||
160 | script ::= script function. | ||
161 | script ::= script statement(A). { A->left = param->ast; param->ast = A; } | ||
162 | script ::= statement(A). { A->left = param->ast; param->ast = A; } | ||
97 | 163 | ||
98 | %nonassoc LSL_SPACE LSL_COMMENT LSL_COMMENT_LINE LSL_UNKNOWN. | 164 | %nonassoc LSL_SPACE LSL_COMMENT LSL_COMMENT_LINE LSL_UNKNOWN. |
99 | 165 | ||