Skip to content

Commit 1e766b2

Browse files
committed
Fix invalid color syntax generating color tokens
1 parent 1c67127 commit 1e766b2

7 files changed

+25
-26
lines changed

examples/tokenizer_tests.rpy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,13 @@ init python hide early in Namespace:
2121
self.items.append(item);
2222
return
2323

24+
label start:
25+
"Light Distraction\n{color=ff0000}{size=18}[distraction_percentages[0]]%% Chance{/size}{/color}"
26+
27+
menu:
28+
"It's a video game.":
29+
jump game
30+
31+
"It's an interactive book.":
32+
jump book
2433

src/tokenizer/atl-token-patterns.g.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
66
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
77
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
8-
// Last generated: 10/06/2023 21:08:08 (UTC+0)
8+
// Last generated: 14/06/2023 16:51:20 (UTC+0)
99

1010
import { KeywordTokenType, EntityTokenType, MetaTokenType, CharacterTokenType } from "./renpy-tokens";
1111
import { TokenPattern } from "./token-pattern-types";

src/tokenizer/python-token-patterns.g.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
66
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
77
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
8-
// Last generated: 10/06/2023 21:08:08 (UTC+0)
8+
// Last generated: 14/06/2023 16:51:20 (UTC+0)
99

1010
import { MetaTokenType, KeywordTokenType, EntityTokenType, CharacterTokenType, OperatorTokenType, LiteralTokenType } from "./renpy-tokens";
1111
import { TokenPattern } from "./token-pattern-types";

src/tokenizer/renpy-token-patterns.g.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
66
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
77
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
8-
// Last generated: 10/06/2023 21:08:08 (UTC+0)
8+
// Last generated: 14/06/2023 16:51:20 (UTC+0)
99

1010
import { MetaTokenType, CharacterTokenType, LiteralTokenType, EntityTokenType, KeywordTokenType, EscapedCharacterTokenType, OperatorTokenType } from "./renpy-tokens";
1111
import { TokenPattern } from "./token-pattern-types";
@@ -431,7 +431,6 @@ export const escapedUnicodeChar: TokenPattern = {
431431
};
432432

433433
export const hexLiteral: TokenPattern = {
434-
// Note: This pattern has no end check. Only use as include pattern!
435434
patterns: [
436435
{
437436
debugName: "hexLiteral.patterns![0]",
@@ -449,10 +448,10 @@ export const hexLiteral: TokenPattern = {
449448
{
450449
debugName: "hexLiteral.patterns![2]",
451450

452-
token: LiteralTokenType.Color, /*constant.color.renpy*/
453-
match: /(?:#[a-f0-9]*)?(.+)/dgi,
451+
match: /(#[a-f0-9]*)?(.+?)\b/dgi,
454452
captures: {
455-
1: { token: MetaTokenType.Invalid, /*invalid.illegal.character-not-allowed-here.renpy*/ },
453+
1: { token: LiteralTokenType.Color, /*constant.color.renpy*/ },
454+
2: { token: MetaTokenType.Invalid, /*invalid.illegal.character-not-allowed-here.renpy*/ },
456455
},
457456
},
458457
]
@@ -573,10 +572,7 @@ export const stringTagsBroken: TokenPattern = {
573572
1: { token: CharacterTokenType.OpenBracket, /*punctuation.definition.tag.begin.renpy*/ },
574573
2: { token: EntityTokenType.TagName, /*entity.name.tag.${2:/downcase}.renpy*/ },
575574
3: { token: OperatorTokenType.Assignment, /*punctuation.separator.key-value.renpy keyword.operator.assignment.renpy*/ },
576-
4: {
577-
token: LiteralTokenType.Color, /*constant.color.renpy*/
578-
patterns: [hexLiteral]
579-
},
575+
4: { patterns: [hexLiteral] },
580576
5: { token: CharacterTokenType.CloseBracket, /*punctuation.definition.tag.end.renpy*/ },
581577
},
582578
end: /({\/)\s*(\2)\s*(})/dg,
@@ -758,10 +754,7 @@ export const stringTags: TokenPattern = {
758754
1: { token: CharacterTokenType.OpenBracket, /*punctuation.definition.tag.begin.renpy*/ },
759755
2: { token: EntityTokenType.TagName, /*entity.name.tag.${2:/downcase}.renpy*/ },
760756
3: { token: OperatorTokenType.Assignment, /*punctuation.separator.key-value.renpy keyword.operator.assignment.renpy*/ },
761-
4: {
762-
token: LiteralTokenType.Color, /*constant.color.renpy*/
763-
patterns: [hexLiteral]
764-
},
757+
4: { patterns: [hexLiteral] },
765758
5: { token: CharacterTokenType.CloseBracket, /*punctuation.definition.tag.end.renpy*/ },
766759
},
767760
},

src/tokenizer/screen-token-patterns.g.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
66
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
77
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
8-
// Last generated: 10/06/2023 21:08:08 (UTC+0)
8+
// Last generated: 14/06/2023 16:51:20 (UTC+0)
99

1010
import { EntityTokenType, CharacterTokenType, KeywordTokenType, MetaTokenType } from "./renpy-tokens";
1111
import { TokenPattern } from "./token-pattern-types";

src/tokenizer/token-patterns.g.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
44
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
55
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
6-
// Last generated: 10/06/2023 21:08:08 (UTC+0)
6+
// Last generated: 14/06/2023 16:51:20 (UTC+0)
77

8-
import * as RenpyPatterns from "./renpy-token-patterns.g";
8+
import * as PythonPatterns from "./python-token-patterns.g";
99
import * as ScreenPatterns from "./screen-token-patterns.g";
1010
import * as AtlPatterns from "./atl-token-patterns.g";
11-
import * as PythonPatterns from "./python-token-patterns.g";
11+
import * as RenpyPatterns from "./renpy-token-patterns.g";
1212

1313
// Push all RenpyPatterns external includes
1414
RenpyPatterns.literal.patterns!.push(PythonPatterns.literal);
@@ -96,4 +96,4 @@ ScreenPatterns.screenLanguage.patterns!.splice(0, 0, RenpyPatterns.conditionals)
9696
PythonPatterns.stringUnicodeGuts.patterns!.splice(0, 0, RenpyPatterns.stringsInterior);
9797

9898

99-
export { RenpyPatterns, ScreenPatterns, AtlPatterns, PythonPatterns };
99+
export { PythonPatterns, ScreenPatterns, AtlPatterns, RenpyPatterns };

syntaxes/renpy.tmLanguage.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
}
330330
},
331331
"hex_literal": {
332-
"comment": "Note: This pattern has no end check. Only use as include pattern!",
333332
"patterns": [
334333
{
335334
"comment": "rgb, rgba, rrggbb, rrggbbaa",
@@ -341,10 +340,10 @@
341340
"name": "invalid.illegal.unexpected-number-of-hex-values.renpy"
342341
},
343342
{
344-
"match": "(?i)(?:#[a-f0-9]*)?(.+)",
345-
"name": "constant.color.renpy",
343+
"match": "(?i)(#[a-f0-9]*)?(.+?)\\b",
346344
"captures": {
347-
"1": { "name": "invalid.illegal.character-not-allowed-here.renpy" }
345+
"1": { "name": "constant.color.renpy" },
346+
"2": { "name": "invalid.illegal.character-not-allowed-here.renpy" }
348347
}
349348
}
350349
]
@@ -450,7 +449,6 @@
450449
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
451450
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
452451
"4": {
453-
"name": "constant.color.renpy",
454452
"patterns": [{ "include": "#hex_literal" }]
455453
},
456454
"5": { "name": "punctuation.definition.tag.end.renpy" }
@@ -611,7 +609,6 @@
611609
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
612610
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
613611
"4": {
614-
"name": "constant.color.renpy",
615612
"patterns": [{ "include": "#hex_literal" }]
616613
},
617614
"5": { "name": "punctuation.definition.tag.end.renpy" }

0 commit comments

Comments
 (0)