Skip to content

Commit

Permalink
Added style statement + other fixes (#337)
Browse files Browse the repository at this point in the history
- Added low level patterns based on the official grammar specification
- Added style statement support with all the currently known properties
- Fixed python functions being parsed as variables
- Improved parsing of the following statements:
 - pause
 - conditionals (if/elif/else)
 - at
 - as
 - with
 - behind
 - onlayer
 - zorder
- Improved screen language support slightly (WIP!)
  • Loading branch information
duckdoom4 authored Jun 8, 2023
1 parent 7021943 commit e33f321
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 51 deletions.
16 changes: 9 additions & 7 deletions examples/unit_test.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,14 @@
translate piglatin python:
style.default.font = "stonecutter.ttf"

old "These two lines will be combined together to form a long line.\n\nThis line will be separate."
new _p("""
These two lines will be combined together
to form a long line. Bork bork bork.
This line will be separate. Bork bork bork.
""")

frame:
style_prefix "pref"
has vbox
Expand All @@ -1214,13 +1222,7 @@
This line will be separate.
""")

old "These two lines will be combined together to form a long line.\n\nThis line will be separate."
new _p("""
These two lines will be combined together
to form a long line. Bork bork bork.
This line will be separate. Bork bork bork.
""")


#endregion Translation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "languague-renpy",
"displayName": "Ren'Py Language",
"description": "Adds rich support for the Ren'Py programming language to Visual Studio Code.",
"version": "2.3.2",
"version": "2.3.3",
"publisher": "LuqueDaniel",
"license": "MIT",
"homepage": "https://github.com/LuqueDaniel/vscode-language-renpy",
Expand Down
9 changes: 4 additions & 5 deletions syntaxes/renpy.python.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,19 @@
},
"member-access": {
"name": "meta.member.access.python",
"contentName": "variable.name.python",
"begin": "(\\.)\\s*(?!\\.)",
"end": "(?<=\\S)(?=\\W)|(^|(?<=\\s))(?=[^\\\\\\w\\s])|$",
"beginCaptures": {
"1": { "name": "punctuation.separator.period.python" }
},
"end": "(?<=\\S)(?=\\W)|(^|(?<=\\s))(?=[^\\\\\\w\\s])|$",
"patterns": [{ "include": "#function-call" }, { "include": "#member-access-base" }, { "include": "#member-access-attribute" }]
},
"member-access-base": {
"patterns": [{ "include": "#magic-names" }, { "include": "#illegal-names" }, { "include": "#illegal-object-name" }, { "include": "#special-names" }, { "include": "#line-continuation" }, { "include": "#item-access" }]
},
"member-access-attribute": {
"comment": "Highlight attribute access in otherwise non-specialized cases.",
"name": "meta.attribute.python",
"name": "variable.name.python meta.attribute.python",
"match": "\\b([[:alpha:]_]\\w*)\\b"
},
"special-names": {
Expand Down Expand Up @@ -868,7 +867,7 @@
"item-access": {
"patterns": [
{
"name": "meta.item-access.python",
"name": "variable.name.python meta.item-access.python",
"begin": "\\b(?=[[:alpha:]_]\\w*\\s*\\[)",
"end": "(\\])",
"endCaptures": {
Expand Down Expand Up @@ -967,7 +966,7 @@
{ "include": "#builtin-possible-callables" },
{
"comment": "Some color schemas support meta.function-call.generic scope",
"name": "meta.function-call.generic.python",
"name": "entity.name.function.call.python meta.function-call.generic.python",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
Expand Down
17 changes: 15 additions & 2 deletions syntaxes/renpy.screen.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
]
},
"screen-build-in-properties": {
"comment": "https://www.renpy.org/doc/html/atl.html#list-of-transform-properties",
"comment": "These are the ATL keywords, will need to fix this later",
"patterns": [
{
"comment": "Special manipulation keywords",
Expand All @@ -37,6 +37,18 @@
"4": { "name": "keyword.counterclockwise.renpy" }
}
},
{
"comment": "Special manipulation keywords",
"match": "\\b(?<!\\.)(key|input|(image)?button|grid|auto|mousearea|side|timer|[vh]?bar|viewport|scrollbars|mousewheel|vpgrid|imagemap)\\b",
"captures": {
"1": { "name": "keyword.other.screen.renpy" }
}
},
{
"comment": "Random props",
"name": "entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:[xy]padding|area|(un)?hovered|draggable|cols|spacing|side_[xy]align)\\b"
},
{
"comment": "position props (int, absolute, or a float)",
"name": "entity.name.tag.css.transform.renpy",
Expand Down Expand Up @@ -248,7 +260,7 @@
"3": { "name": "punctuation.section.block.begin.renpy" }
},
"end": "^(?=(?!\\1)[ \\t]*[^\\s#]|\\1[^\\s#])",
"patterns": [{ "include": "source.renpy.atl#atl" }]
"patterns": [{ "include": "#screen-language" }]
},
"screen": {
"patterns": [
Expand Down Expand Up @@ -278,6 +290,7 @@
"screen-language": {
"comment": "https://www.renpy.org/doc/html/screens.html#screen-language",
"patterns": [
{ "include": "source.renpy#conditionals" },
{ "include": "#screen-frame" },
{ "include": "#screen-window" },
{ "include": "#screen-box" },
Expand Down
Loading

0 comments on commit e33f321

Please sign in to comment.