Skip to content

Commit f12cd25

Browse files
authored
bug: this is giving me headaches (#255)
* bug: this is giving me headaches * fix: processing this keywords
1 parent 6d16438 commit f12cd25

File tree

7 files changed

+946
-131
lines changed

7 files changed

+946
-131
lines changed

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ tests:
22
npm run test
33

44
snapshots:
5-
npx jest --update-snapshots
5+
npx jest --update-snapshot

src/molang/syntax/parse.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ function trimEnding(tokens: Token[]): Token[] {
135135
*/
136136
function convertToken(token: Token) {
137137
switch (token.type) {
138+
case TokenType.Identifier:
139+
switch (token.value) {
140+
case "this":
141+
return VariableNode.create({
142+
scope: "this",
143+
names: [],
144+
position: token.position,
145+
});
146+
}
147+
break;
148+
138149
case TokenType.NamespacedIdentifier:
139150
const parts = token.value.split(".");
140151

test/data/dataset-valid.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const valid_syntaxes = [
3232
"1.5 - math.pow(1.5, 1.0 - 015.0 * query.modified_move_speed) * query.camera_rotation(0)",
3333
"math.clamp(math.sqrt(math.pow(query.position_delta(0), 2.0) + math.pow(query.position_delta(2), 2.0)), 0.0, 0.1)",
3434
"math.sin(variable.attack_time * 180) * -175",
35+
"-90.0 - ((math.sin(variable.attack_time * 180.0) * 57.3) * 1.2 - (math.sin((1.0 - (1.0 - variable.attack_time) * (1.0 - variable.attack_time)) * 180.0) * 57.3) * 0.4) - (math.sin(query.life_time * 76.776372) * 2.865) - this",
3536

3637
// Render controller
3738
"!variable.has_trim",

test/graph/__snapshots__/mermaid.test.ts.snap

Lines changed: 117 additions & 34 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)