dbaumgarten / yodk

Development Kit for Starbase's ingame programming language YOLOL
MIT License
57 stars 16 forks source link

Extension does not prioritize keywords as game does. #128

Closed Thaccus closed 2 months ago

Thaccus commented 1 year ago

Describe the bug The keyword parsing behavior does not match in game behavior with regards to prioritizing keywords in varables.

To Reproduce Steps to reproduce the behavior:

  1. Run the following code in game. Notice that :out will have the value 10 with no lineskip or other parsing errors: x=1 y=0 z=10 ifxtheny=zend:out=y goto1

  2. Paste the same code in VSCode with the vscode-yolol extension

  3. See that the "then" is assumed to be part of the same variable that "x" and "y" are part of as a conglomerated "xtheny" variable

  4. See see that the "end" is assumed to be part of the same variable as "z" as a conglomerated "zend" variable.

  5. Run the code without debugging, note the error expecting a "then" keyword

Expected behavior I expect the parser to identify if,then,else,end keywords and throw errors in a manner that matches the in game behavior.

Example Code/Screenshots x=1 y=0 z=10 ifxtheny=zend:out=y goto1 image image image

Platform:

Additional context I see that in the yodk/yolol.tmGrammar.json file "goto" is in the same match case as "if" "then" "else" and "end". It should be noted however that goto can not use the same no space behavior. As an example: if you remove the space in ":out=y goto1" in the provided example code, the line errors out. If you add a post-increment as ":out=y y++goto1" then the line parses just fine, but a pre-increment will fail. Other keywords like "endgotox"work just fine in both editor and game. I know this is probably only an issue for like 3 people and most of them won't even notice or care but ignoring such spacing requirements can save lines and therefore time. I keep having to re-learn where the extension and in-game behavior differ whenever I come back.

dbaumgarten commented 1 year ago

Hi, thanks for your report. That is actually a known difference between the game and yodk.

However, given how yodk is implemented (first tokenization then parsing) there is no way to mimic the game's behaviour without rewriting large parts of yodk.

Also, the ingame behaviour results in surprising errors if your variable-name contain yolol-keywords. For example a variable called "life" will result in surprise-errors, because it contains the keyword "if".

This is a case where that sentence from the readme applies: "In cases where full compatibility is not feasible, yodk will try to be "downward-compatible" to the game: Everything that works in yodk SHOULD also work in-game. But a few weird edge-cases that work in the game will be treated as errors in yodk."