Skip to content

Commit

Permalink
Syntax fixes and update typescript patterns (#339)
Browse files Browse the repository at this point in the history
Move token string converters
  • Loading branch information
duckdoom4 authored Jun 10, 2023
1 parent e33f321 commit 3745d66
Show file tree
Hide file tree
Showing 14 changed files with 1,445 additions and 746 deletions.
104 changes: 78 additions & 26 deletions src/tokenizer/atl-token-patterns.g.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// THIS FILE HAS BEEN GENERATED BY THE `syntax-to-token-pattern.py` GENERATOR
// DO NOT EDIT THIS FILE DIRECTLY! INSTEAD RUN THE PYTHON SCRIPT.
// ANY MANUAL EDITS MADE TO THIS FILE WILL BE OVERWRITTEN. YOU HAVE BEEN WARNED.
// Last generated: 01/06/2023 14:57:48 (UTC+0)
// Last generated: 10/06/2023 21:08:08 (UTC+0)

import { KeywordTokenType, EntityTokenType, MetaTokenType, CharacterTokenType } from "./renpy-tokens";
import { TokenPattern } from "./token-pattern-types";
Expand Down Expand Up @@ -35,91 +35,91 @@ export const atlBuildInProperties: TokenPattern = {
debugName: "atlBuildInProperties.patterns![1]",

// position props (int, absolute, or a float)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:xpos|ypos|xanchor|yanchor|xcenter|ycenter|radius)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![2]",

// position pair props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:pos|anchor|xycenter|around|alignaround|matrixanchor)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![3]",

// float props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:xalign|yalign|zoom|xzoom|yzoom|alpha|additive|angle|delay|events|zpos)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![4]",

// float pair props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:align|knot)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![5]",

// int props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:xoffset|yoffset|xtile|ytile)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![6]",

// int pair props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:offset)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![7]",

// boolean props
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:rotate_pad|transform_anchor|nearest|crop_relative|subpixel|zzoom)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![8]",

// ('#float' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:rotate|xpan|ypan|blur)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![9]",

// ('#position' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:xsize|ysize)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![10]",

// ('\(int, int, int, int\)' | '\(float, float, float, float\)' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:crop)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![11]",

// ('\(int, int\)' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:corner1|corner2)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![12]",

// ('\(position, position\)' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:xysize)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![13]",

// ('#string' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:fit)\b/g,
},
{
Expand All @@ -133,28 +133,37 @@ export const atlBuildInProperties: TokenPattern = {
debugName: "atlBuildInProperties.patterns![15]",

// ('#Matrix' | '#MatrixColor' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:matrixcolor)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![16]",

// ('#Matrix' | '#TransformMatrix' | None)
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:matrixtransform)\b/g,
},
{
debugName: "atlBuildInProperties.patterns![17]",

// ('#bool' | '#float' | '\(float, float, float\)')
token: EntityTokenType.PropertyName, /*support.type.property-name.transform.renpy*/
token: EntityTokenType.TagName, /*support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy*/
match: /\b(?<!\.)(?:perspective)\b/g,
},
]
};

export const atlSimpleExpression: TokenPattern = {
patterns: [atlBuildInProperties]
patterns: [
atlBuildInProperties,
{
debugName: "atlSimpleExpression.patterns![21]",

// Tokenize identifiers
token: EntityTokenType.VariableName, /*variable.name.python*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
};

export const atlExpression: TokenPattern = {
Expand Down Expand Up @@ -284,7 +293,7 @@ export const atlEventName: TokenPattern = {
{
debugName: "atlEventName.patterns![2]",

token: MetaTokenType.FunctionCall, /*entity.name.function.renpy meta.function-call.generic.renpy*/
token: MetaTokenType.FunctionCall, /*entity.name.function.event.renpy meta.function-call.generic.renpy*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
Expand All @@ -296,7 +305,7 @@ export const atlEventDefName: TokenPattern = {
{
debugName: "atlEventDefName.patterns![2]",

token: EntityTokenType.FunctionName, /*entity.name.function.renpy*/
token: EntityTokenType.FunctionName, /*entity.name.function.event.def.renpy*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
Expand Down Expand Up @@ -353,7 +362,7 @@ export const atlFunction: TokenPattern = {
{
debugName: "atlFunction.captures![2].patterns![1]",

token: MetaTokenType.FunctionCall, /*entity.name.function.renpy meta.function-call.generic.renpy*/
token: MetaTokenType.FunctionCall, /*entity.name.function.atl-function.renpy meta.function-call.generic.renpy*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
Expand All @@ -376,24 +385,67 @@ export const atlWarperName: TokenPattern = {
{
debugName: "atlWarperName.patterns![3]",

token: MetaTokenType.FunctionCall, /*entity.name.function.renpy meta.function-call.generic.renpy*/
token: MetaTokenType.FunctionCall, /*entity.name.function.warper.renpy meta.function-call.generic.renpy*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
};

export const atlWarperBroken: TokenPattern = {
debugName: "atlWarperBroken",

// TODO: This doesn't work right now, we can't assume all identifiers are warpers
token: MetaTokenType.ATLWarper, /*meta.atl.warper.renpy*/
begin: /(?<=^[ \t]*)([a-zA-Z_]\w*)\b/dgm,
beginCaptures: {
1: { patterns: [atlWarperName] },
},
end: /(?=[ \t]*#)|$/gm,
patterns: [atlSimpleExpression]
};

export const atlWarper: TokenPattern = {
debugName: "atlWarper",

// https://www.renpy.org/doc/html/atl.html#warpers
// (TODO: For now we only support build-in warper highlighting) https://www.renpy.org/doc/html/atl.html#warpers
token: MetaTokenType.ATLWarper, /*meta.atl.warper.renpy*/
begin: /\b(?<!\.)([a-zA-Z_]\w*)\b[ \t]*/dg,
begin: /(?<=^[ \t]*)(linear|ease|easein|easeout|ease_back|ease_bounce|ease_circ|ease_cubic|ease_elastic|ease_expo|ease_quad|ease_quart|ease_quint|easein_back|easein_bounce|easein_circ|easein_cubic|easein_elastic|easein_expo|easein_quad|easein_quart|easein_quint|easeout_back|easeout_bounce|easeout_circ|easeout_cubic|easeout_elastic|easeout_expo|easeout_quad|easeout_quart|easeout_quint)\b/dgm,
beginCaptures: {
1: { patterns: [atlWarperName] },
},
end: /(?!\G)/g,
end: /(?=[ \t]*#)|$/gm,
patterns: [atlSimpleExpression]
};

export const atlFallback: TokenPattern = {
// TODO: This is a temp fix for missing pattern references
patterns: [
]
};

export const transform: TokenPattern = {
debugName: "transform",

contentToken: MetaTokenType.TransformBlock, /*meta.transform.block.renpy*/
begin: /^([ \t]+)?(transform)\b[ \t]*(.*)?(:)/dgm,
beginCaptures: {
1: { token: CharacterTokenType.Whitespace, /*punctuation.whitespace.leading.renpy*/ },
2: { token: KeywordTokenType.Transform, /*keyword.transform.renpy*/ },
3: {
patterns: [
{
debugName: "transform.beginCaptures![3].patterns![0]",

token: EntityTokenType.VariableName, /*variable.name.transform.renpy*/
match: /\b([a-zA-Z_]\w*)\b/g,
},
]
},
4: { token: CharacterTokenType.Colon, /*punctuation.section.atl.begin.renpy*/ },
},
end: /^(?=(?!\1)[ \t]*[^\s#]|\1[^\s#])/gm,
patterns: [atl]
};

// Push pattern references that were not defined on include
atl.patterns!.push(atlKeywords, atlBlocks, atlSimpleExpression, atlWarper, atlEvent, atlOn, atlFunction);
atl.patterns!.push(atlKeywords, atlWarper, atlBlocks, atlSimpleExpression, atlEvent, atlOn, atlFunction, atlFallback);
Loading

0 comments on commit 3745d66

Please sign in to comment.