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

Consider doing some syntactical validation of Lua/WFL code #8385

Open
CelticMinstrel opened this issue Feb 11, 2024 · 7 comments
Open

Consider doing some syntactical validation of Lua/WFL code #8385

CelticMinstrel opened this issue Feb 11, 2024 · 7 comments
Labels
Enhancement Issues that are requests for new features or changes to existing ones. Lua API Issues with the Lua engine and API. Schema WFL Issues involving the Wesnoth Formula Language engine and APIs. WML Tools Issues involving WML maintenance tools.

Comments

@CelticMinstrel
Copy link
Member

CelticMinstrel commented Feb 11, 2024

This feels like it might be asking a bit too much, but… I wonder if it would be reasonable for the schema to run at least a syntax check on any code included in keys that expect Lua or WFL code? Linting it would be even better, though that really feels like it might not be worth it, but I think just a syntax check could be done by compiling it and checking if that returns an error…

There are also a few other DSLs we have in WML, maybe those could be checked too (some of them might be checked already). For example, the CFG syntax for name generators or the progressive string syntax for animations.

@CelticMinstrel CelticMinstrel added Lua API Issues with the Lua engine and API. WFL Issues involving the Wesnoth Formula Language engine and APIs. Schema labels Feb 11, 2024
@Wedge009 Wedge009 added the Enhancement Issues that are requests for new features or changes to existing ones. label Feb 11, 2024
@cooljeanius
Copy link
Contributor

adding the "WML Tools" label because I think that'd be another place that it might be worth looking into doing this, besides the schema validator

@cooljeanius cooljeanius added the WML Tools Issues involving WML maintenance tools. label Feb 12, 2024
@CelticMinstrel
Copy link
Member Author

That's true – there's already a luacheck run in the CI, right? If that could somehow be adjusted to include Lua code embedded in WML, it would be quite helpful.

@CelticMinstrel
Copy link
Member Author

CelticMinstrel commented Feb 12, 2024

I don't see anything in luacheck to make it synthesize line numbers (like C++'s #line directive), so I think the best way to handle that would be a Python script that reads a WML file, passes any Lua chunks to luacheck on stdin (using the subprocess module probably), and processes the output to adjust the error messages to refer to the original WML file instead of just the chunk.

@cooljeanius
Copy link
Contributor

I don't see anything in luacheck to make it synthesize line numbers (like C++'s #line directive), so I think the best way to handle that would be a Python script that reads a WML file, passes any Lua chunks to luacheck on stdin (using the subprocess module probably), and processes the output to adjust the error messages to refer to the original WML file instead of just the chunk.

A new Python script, or could it just be done as part of wmllint?

@CelticMinstrel
Copy link
Member Author

Seems weird to insert luacheck into wmllint

@cooljeanius
Copy link
Contributor

Seems weird to insert luacheck into wmllint

I mean, it already runs an external spellchecking tool... also there seems to be some desire for something similar in #3817

@CelticMinstrel
Copy link
Member Author

That issue doesn't seem to be about Lua though; and an external spellchecking tool is a bit different from making it call luacheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Issues that are requests for new features or changes to existing ones. Lua API Issues with the Lua engine and API. Schema WFL Issues involving the Wesnoth Formula Language engine and APIs. WML Tools Issues involving WML maintenance tools.
Projects
None yet
Development

No branches or pull requests

3 participants