Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display error when using else macro before elseif macro #87

Open
MinusGix opened this issue Jan 23, 2022 · 3 comments
Open

Display error when using else macro before elseif macro #87

MinusGix opened this issue Jan 23, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers sugarcube-2 Relating to the SugarCube-2 Story Format

Comments

@MinusGix
Copy link
Collaborator

IT would be useful to provide an error when putting the else macro before the elseif macro in an if statement.

<<if $thing>>
<<else>> /* Should error */
<<elseif>>
<</if>>

While we could add a complex feature to the children's tags to allow specifying complex patterns, I think this can be resolved in a good enough manner by just adding a field to a children called after which specifies the names of other children that it must appear after.

children: [
    "elseif",
    {
       "name": "else",
       "max": 1,
       "after": ["elseif"]
    }
]

And so if it sees an else before elseif (which isn't too complex of a modification of the existing counting code), then it produces an error.

@MinusGix MinusGix added enhancement New feature or request good first issue Good for newcomers sugarcube-2 Relating to the SugarCube-2 Story Format labels Jan 23, 2022
@pramod74
Copy link

Hi @MinusGix,

I would like to work on this issue. I understand that the validation needs to be updated in sugarcube-2/macros.json. Kindly confirm, and assign me this issue.

@MinusGix
Copy link
Collaborator Author

The issue is about implementing the checks to validate the proposed after field, and so would need more than just modifications to the macros.json file. See: https://github.com/cyrusfirheir/twee3-language-tools/blob/master/src/sugarcube-2/macros.ts#L518 (I'm open to splitting off that bit of code to a separate function to make it cleaner, too).
If you still feel up for it, then I can assign this to you.

@pramod74
Copy link

Thanks for the update, @MinusGix. I am sorry but this seems to be beyond my current level of expertise. Apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers sugarcube-2 Relating to the SugarCube-2 Story Format
Projects
None yet
Development

No branches or pull requests

2 participants