Yesterday17 / ZenScript

Visual Studio Code extension/Language Server for ZenScript, includes highlight, code snippet and language server(WIP). Works with 👇
https://github.com/Yesterday17/Probe
MIT License
33 stars 4 forks source link

closing bracket not always detected #50

Open Magnymbus opened 2 years ago

Magnymbus commented 2 years ago

getting expecting token of type BR_CLOSE, even though the closing bracket is there and the script works in game. I tried going through the JSON and javascript to try and fix it myself but I have no idea why only the first set is working. I thought it might be a weird regex edge case, but that didn't work.

Here's my script BTW. The bracket pairs in question are the <Container>s

import crafttweaker.api.recipe.type.Recipe;
import crafttweaker.api.recipe.type.CraftingRecipe;
import crafttweaker.api.world.Container;

for recipe in craftingTable.getRecipesByOutput(<tag:items:minecraft:stairs>) {
  println((recipe as Recipe<Container>).resultItem.commandString + ": - " + (recipe as Recipe<Container>).ingredients[0].commandString); 
}
Magnymbus commented 2 years ago

After some messing around, it seems like it's only detected properly when it's the first part of the token. If any part of the full identifier precedes the "<" it won't find the ">".

Magnymbus commented 2 years ago

Wait... That means it's probably interpreting that as a lessthan rather than a bracket

Yesterday17 commented 2 years ago

The extension is (at least for now) ZenScript only. CraftTweaker had an upgrade on Minecraft 1.13+ and upgrade ZenScript to a new language which has similar grammar to the old one, called ZenCode. ZenCode support is WIP. I don't have enough time to develop it, and I'm not familiar with Minecraft in higher version.(Still playing GT New Horizon)

Progress in the past: Lexer and parser are completed, but not integrated in the extension.


For your problem, I believe it's treated as LESS_THAN.


Type parameter exists in ZenCode, which uses <(called T_LESS or LT): https://github.com/Yesterday17/ZenScript/blob/ba6526e3752c08fd4d0f959d5f664bf254890bbc/server/parser/zencode/ZenCode.bnf#L25

But LT only exists in bracket handler in ZenScript: https://github.com/Yesterday17/ZenScript/blob/ba6526e3752c08fd4d0f959d5f664bf254890bbc/server/parser/zenscript/zsParser.ts#L660

Magnymbus commented 2 years ago

Just wanted to pop back in to let you know that this seems to actually be fixed in the current build and is only giving me bracket errors in the version on marketplace. In fact, a lot of weird errors are gone now that I've cloned from master rather than using the release.