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

[WIP] New Ren'Py grammar #76

Closed
wants to merge 159 commits into from
Closed

[WIP] New Ren'Py grammar #76

wants to merge 159 commits into from

Conversation

LuqueDaniel
Copy link
Member

@LuqueDaniel LuqueDaniel commented Mar 8, 2022

Attempt to re-implement RenPy grammar.

Done:

TODO

  • Add ` delimiter for strings #5
  • Add support for type annotation in semantics.
  • Call/jump statements
  • ATL (+ transform, image, show, scene)
  • with/hide/at/from clauses
  • Say statements
  • Camera statements
  • Audio statements (play, stop, queue)
  • Screen statements
  • Window statements
  • Style statements
  • Translate statements
  • Reserved names
  • Audio string tags
  • Creator-defined statements (See https://www.renpy.org/doc/html/cds.html)

Any contribution to the new-syntax branch is welcome. Feedback and testing are also appreciated.

* Adds Ren'py comments and comments code tags Ej TODO, FIXME etc
* Use the Python grammar in RenPy's Python statements (python, init
  python, define and default)
Match strings:

- Double quoted (block and line)
- Single quoted (block and line)
- Back quoted (block and line)
@LuqueDaniel LuqueDaniel linked an issue Mar 14, 2022 that may be closed by this pull request
Copy link
Contributor

@multimokia multimokia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bugfix for init levels

syntaxes/renpy.tmLanguage_2.json Outdated Show resolved Hide resolved
Copy link
Contributor

@multimokia multimokia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added highlighting for the init level and the storemodule!

syntaxes/renpy.tmLanguage_2.json Outdated Show resolved Hide resolved
Copy link
Contributor

@multimokia multimokia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistent with the current version, and to avoid ambiguity with import statements/control flow, I've pulled these back to keyword.renpy.

With all changes this looks like:
image
image
image

syntaxes/renpy.tmLanguage_2.json Outdated Show resolved Hide resolved
@multimokia
Copy link
Contributor

Also wondering if it'll be possible to have the imported libraries be highlighted akin to Pylance's highlights:
image

duckdoom4 and others added 10 commits April 28, 2022 08:28
Some features where not captured and others where dismissed.

* Block ending is now correctly detected in nested blocks
* Block is also detected on partial invalid parameters
* Block is now correctly detected on all variants
* Block now correctly highlights any optional keywords in any order

* Single line now correctly detects define and default only if there is no other character in front
* Single line now highlights the variable it defines (Python highlighting seems to skip this for some reason?)
Adds back all the Renpy keywords that can be used outside of a python block
* fixed tabs
* label is now defined as a normal keyword instead of a control flow keyword
* label now supports having parameters
* labels can now also start with . _ or [a-zA-Z]
* stores can only start with [a-zA-Z_]
Improved block capture and keywords
* Added esbenp.prettier-vscode extension as a recommended plugin
* Updated to eslint instead of tslint
* Turned on format document on save
* Added .editorconfig for formatting options
Enable forced, consistent formatting
Adds back escaped chars, unicode, placeholders and tags.
Still needs some improvements
string tags:
* font tag is not self-closing
* fixed comment tag
* numbers like .5 where the 0 is left out are also valid

additional keywords:
 * layeredimage, voice, voice sustain, translate

Added voice to the say-statement. (kinda hacky atm, be else it would be considered a character)

Labels have an optional hide clause
@duckdoom4
Copy link
Collaborator

3 big one's left, then we are feature complete :D

@multimokia
Copy link
Contributor

Oh I caught a bug in the renpy if handling. If an if's condition spans multiple lines, syntax highlighting fails for it.
image
image
image

Note that this only applies to renpy code and not embedded python

@duckdoom4
Copy link
Collaborator

Should be fixed now :)

@LuqueDaniel
Copy link
Member Author

On Monday I want to release the first pre-release of 2.2 (2.1 pre-release), so it will be easier to test for anyone interested.

@multimokia
Copy link
Contributor

Awesome!

@multimokia
Copy link
Contributor

image
Caught a bug in the syntax where if you concatenate strings with text tags, the inner variables are colored as strings and not as variables.

image

This also applies in python blocks

@duckdoom4
Copy link
Collaborator

duckdoom4 commented Jul 16, 2022

Hi @multimokia. Thanks for yet another bug report! Since this is branch now live as pre release I would prefer if you make this an official issue ticket.
That makes it easier to keep track of and prevents others from double posting an issue.
In there you will also find a bug report template for syntax bugs, it would be helpful if you could fill that out. In there we request a source sample and some additional screenshots with the scope inspector enabled.
Thanks in advance :)

@multimokia
Copy link
Contributor

Can do!

@LuqueDaniel
Copy link
Member Author

🤔 Maybe I should create a develop branch and merge this PR there.

@duckdoom4
Copy link
Collaborator

🤔 Maybe I should create a develop branch and merge this PR there.

We could simply rename this branch. But a develop branch would be a good idea.

@LuqueDaniel LuqueDaniel deleted the new-syntax branch July 18, 2022 23:19
@LuqueDaniel
Copy link
Member Author

Done! I have renamed the branch to develop. You will need to update your local repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Small improvements topic:syntax
Projects
None yet
3 participants