cyrusfirheir / twee3-language-tools

[ VSCode extension ] Syntax highlighting and programmatic language tools for Twee 3, and Twine 2 storyformats.
https://marketplace.visualstudio.com/items?itemName=cyrusfirheir.twee3-language-tools
MIT License
47 stars 16 forks source link

SugarCube 2 parameters parsing error #42

Closed ezsh closed 3 years ago

ezsh commented 3 years ago

I want to add a definition for a macro that takes either a single or three parameters. This exact case is covered in the wiki page (a |+ b&+ c). However, given the following definition:

NPC:
    name: NPC
    parameters:
        - string |+ string &+ string

and the code <<NPC "Captain">>, the extension complains "Expected type 'string' but there was no argumentsc2-ex(109)".

A workaround

parameters:
          - string
          - string &+ string &+ string

works fine.

ezsh commented 3 years ago

Example 3 for Maybe-Next and example 7 for Grouping seem to contradict each other? BTW, string |+ (string &+ string) results in a parsing error (complains on absent closing parenthesis).

cyrusfirheir commented 3 years ago

Patched in v0.13.1! string |+ string &+ string and string |+ (string &+ string) should work.

MinusGix commented 3 years ago

This pull-request https://github.com/cyrusfirheir/twee3-language-tools/pull/43 fixes the issue you were facing to behave correctly. None of the sugarcube macros actually use that form, which means that path was far less tested than it should have been.

The documentation was incorrect, example 3 is the correct version. Grouping example 7 was from how it behaved when I was first making the feature (it was just left to right), but that was incorrect now (since &+ binds 'harder' than |+). Thanks for pointing that out, fixed by PR https://github.com/cyrusfirheir/twee3-language-tools/pull/44 .

Though, I wasn't able to reproduce the parsing error for string |+ (string &+ string).
As Cyrus says, it should hopefully be patched. Thanks for opening the issue.