local tokens can self reference #19

Merged
AlexErrant merged 1 commit from local_tokens_can_self_reference into main 2024-05-03 16:36:59 +02:00
AlexErrant commented 2024-05-02 20:24:12 +02:00 (Migrated from github.com)
No description provided.
AlexErrant (Migrated from github.com) reviewed 2024-05-02 20:25:38 +02:00
@ -34,2 +34,3 @@
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"ts-node": "^10.9.2"
},
AlexErrant (Migrated from github.com) commented 2024-05-02 20:25:37 +02:00

I had to add ts-node otherwise I couldn't run tests. Not sure if it was just my machine, but whatever.

I had to add `ts-node` otherwise I couldn't run tests. Not sure if it was just my machine, but whatever.
AlexErrant (Migrated from github.com) reviewed 2024-05-02 20:39:43 +02:00
@ -34,2 +34,3 @@
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"ts-node": "^10.9.2"
},
AlexErrant (Migrated from github.com) commented 2024-05-02 20:39:42 +02:00
Probably due to https://github.com/lezer-parser/generator/blob/d827142436db3724af4b4dd9162132ca343f34e0/.mocharc.cjs#L4
marijnh commented 2024-05-03 10:01:39 +02:00 (Migrated from github.com)

I've added the ts-node dependency in df7c098f93

What does "local tokens can self reference" mean? What problem does this PR solve?

I've added the ts-node dependency in df7c098f932f9e23e59d271d4c3ab27ab99e5799 What does "local tokens can self reference" mean? What problem does this PR solve?
AlexErrant commented 2024-05-03 15:03:41 +02:00 (Migrated from github.com)

Sorry I was perhaps too terse in my nonexistent description 😅

In the following:

@local tokens {
  Y { "y" }
  Z { "z" }
  Letter { Y | Z }
  @else stringContent
}

Letter references Y and Z in the local tokens block. It is "self-referencing". Please see the test for a more complete example.

This PR breaks out of the for loop early if rule is found. (In a way you can think of the original behavior as a bug because it doesn't make sense to write undefined into rule once it has been found.)

Without breaking out early, the test fails with: Error: Reference to token rule 'Y', which isn't found.

Sorry I was perhaps too terse in my nonexistent description 😅 In the following: ``` @local tokens { Y { "y" } Z { "z" } Letter { Y | Z } @else stringContent } ``` `Letter` references `Y` and `Z` in the local tokens block. It is "self-referencing". Please see the test for a more complete example. This PR breaks out of the for loop early if `rule` is found. (In a way you can think of the original behavior as a bug because it doesn't make sense to write `undefined` into `rule` once it has been found.) Without breaking out early, the test fails with: `Error: Reference to token rule 'Y', which isn't found`.
marijnh commented 2024-05-03 16:37:31 +02:00 (Migrated from github.com)

That makes sense. Merged!

That makes sense. Merged!
AlexErrant commented 2024-06-18 21:58:04 +02:00 (Migrated from github.com)

Just wondering, is it worth cutting a release for this? (I can always pnpm patch for my own proj, but I was just wondering if you were holding off for some reason.)

Just wondering, is it worth cutting a release for this? (I can always pnpm patch for my own proj, but I was just wondering if you were holding off for some reason.)
marijnh commented 2024-06-19 08:50:35 +02:00 (Migrated from github.com)

Done!

Done!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/generator!19
No description provided.