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

Pikchr syntax fixes #176

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 130 additions & 105 deletions pikchr/pikchr.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@
"include": "#comment"
},
{
"include": "#statement"
"begin": "(?<=^|[;:{]|\\*/|\\G)\\s*",
"patterns": [
{
"include": "#statement"
},
{
"include": "#continuation"
}
],
"end": "(?:(?<!\\\\)(?:\\Z|$))|(;)|(?=]|})",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
},
{
"include": "#syntax-error"
}
]
},
Expand All @@ -28,29 +45,7 @@
"include": "#statement-direction"
},
{
"begin": "\\s*(:?[A-Z]\\w*)(:)",
"beginCaptures": {
"1": {
"name": "variable.language.pikchr"
},
"2": {
"name": "punctuation.separator.pikchr"
}
},
"patterns": [
{
"include": "#unnamed-statement"
},
{
"include": "#position"
}
],
"end": "(?<!\\\\)(?=\\n)|(;)",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
"include": "#statement-placename"
},
{
"include": "#unnamed-statement"
Expand All @@ -66,7 +61,7 @@
},
{
"comment": "assignment",
"begin": "(?<=^|;|:|\\*/)\\s*([$_@a-zA-Z]\\w*)\\s*([+-/*]?=)",
"begin": "\\G([$_@a-zA-Z]\\w*)\\s*([+-/*]?=)",
"beginCaptures": {
"1": {
"patterns": [
Expand All @@ -85,59 +80,91 @@
}
],
"name": "meta.assignment.pickchr",
"end": "(?:(?<!\\\\)(?:\\Z|$))|(;)",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
"end": "(?:(?<!\\\\)(?:\\Z|$))|(?=;)"
},
{
"comment": "macro expansion...",
"begin": "([$_@a-zA-Z]\\w*)\\s*(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.pikchr"
},
"2": {
"name": "punctuation.parenthesis.begin.pikchr"
}
},
"begin": "(?=[$_@a-zA-Z]\\w*)",
"patterns": [
{
"include": "#whitespace"
"include": "#macro-call"
},
{
"include": "#string"
"comment": "naked macro",
"match": "\\G([$_@a-zA-Z]\\w*)\\b",
"name": "entity.name.function.pikchr"
},
{
"include": "#expr"
"match": "[ \\t\\f]+"
},
{
"match": ",",
"name": "punctuation.separator.pikchr"
"include": "#attribute"
}
],
"name": "meta.macro.call.pikchr",
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.end.pikchr"
}
}
"applyEndPatternLast": true,
"end": "(?:)"
}
]
},
"macro-call": {
"comment": "macro can be anything => macto is incomplete",
"begin": "([$_@a-zA-Z]\\w*)\\s*(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.pikchr"
},
"2": {
"name": "punctuation.parenthesis.begin.pikchr"
}
},
"patterns": [
{
"comment": "naked macro",
"match": "([$_@a-zA-Z]\\w*)\\b",
"name": "entity.name.function.pikchr"
"include": "#whitespace"
},
{
"include": "#syntax-error"
"include": "#string"
},
{
"include": "#expr"
},
{
"match": ",",
"name": "punctuation.separator.pikchr"
}
]
],
"name": "meta.macro.call.pikchr",
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.end.pikchr"
}
}
},
"statement-placename": {
"begin": "\\G(:?[A-Z]\\w*|\\$[1-9])[ \\t\\f]*(:)[ \\t\\f]*",
"beginCaptures": {
"1": {
"name": "variable.language.place.pikchr"
},
"2": {
"name": "punctuation.separator.pikchr"
}
},
"patterns": [
{
"include": "#unnamed-statement"
},
{
"comment": "insert attributes, for when somebode uses a macro",
"include": "#attribute"
},
{
"include": "#position"
}
],
"end": "(?<!\\\\)(?=\\n)|(?=;|})"
},
"define-id-codeblock": {
"begin": "(?<=^|[;:{]|\\*/)\\s*\\b(define)\\b",
"begin": "\\G(define)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.directive.define.pikchr"
Expand Down Expand Up @@ -167,15 +194,10 @@
}
}
],
"end": "(?:(?<!\\\\)(?:\\Z|$))|(;)",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
"end": "(?:(?<!\\\\)(?:\\Z|$))|(?=;)"
},
"assert": {
"begin": "(?<=^|[;:{]|\\*/)\\s*\\b(assert)\\b\\s*(\\()",
"begin": "\\G(assert)\\b\\s*(\\()",
"beginCaptures": {
"1": {
"name": "keyword.control.directive.assert.pikchr"
Expand Down Expand Up @@ -204,7 +226,7 @@
}
},
"print-prlist": {
"begin": "(?<=^|;|:|\\*/)\\s*\\b(print)\\b",
"begin": "\\G(print)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.directive.define.pikchr"
Expand All @@ -218,12 +240,7 @@
"include": "#string"
}
],
"end": "(?:(?<!\\\\)(?:\\Z|$))|(;)",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
"end": "(?:(?<!\\\\)(?:\\Z|$))|(?=;)"
},
"unnamed-statement": {
"patterns": [
Expand All @@ -236,18 +253,13 @@
]
},
"classname-atributes": {
"begin": "(?<=^|[;:\"\\[{]|\\*/)\\s*(?:\\b(arc|arrow|box|circle|cylinder|diamond|dot|ellipse|file|line|move|oval|spline|text)\\b|(?=\"))",
"begin": "\\G(?:(arc|arrow|box|circle|cylinder|diamond|dot|ellipse|file|line|move|oval|spline|text)\\b|(?=\"))",
"beginCaptures": {
"1": {
"name": "storage.type.class.pikchr"
}
},
"end": "(?<!\\\\)(?=\\n)|(;)|(?=]|})",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
},
"end": "(?<!\\\\)(?=\\n)|(?=]|}|;)",
"patterns": [
{
"include": "#whitespace"
Expand All @@ -256,13 +268,16 @@
"include": "#attribute"
},
{
"match": "\\\\$",
"name": "punctuation.separator.continuation.line.pikchr"
"include": "#continuation"
}
]
},
"continuation": {
"match": "\\\\$",
"name": "punctuation.separator.continuation.line.pikchr"
},
"lb-rb-atributes": {
"begin": "(?<=^|;|:|\"|{|\\*/)\\s*(?=\\[)",
"begin": "\\G(?=\\[)",
"patterns": [
{
"begin": "\\[",
Expand All @@ -287,12 +302,7 @@
"include": "#attribute"
}
],
"end": "(?:(?<!\\\\)(?:\\Z|$))|(;)",
"endCaptures": {
"1": {
"name": "punctuation.separator.delimiter.end.pikchr"
}
}
"end": "(?:(?<!\\\\)(?:\\Z|$))|(?=;|})"
},
"string-then-text-attributes": {
"begin": "(?=\")",
Expand Down Expand Up @@ -463,7 +473,7 @@
"patterns": [
{
"match": "[A-Z]\\w*",
"name": "variable.language.pikchr"
"name": "variable.language.place.pikchr"
},
{
"comment": "color is a part of placename, according to pikchr.y",
Expand All @@ -472,7 +482,7 @@
]
},
"variable": {
"match": "^[a-z_$@][\\w$@]*",
"match": "^[a-z_$@][\\w]*",
"name": "entity.name.tag.pikchr"
},
"attribute": {
Expand Down Expand Up @@ -587,12 +597,18 @@
]
},
"statement-direction": {
"match": "(?<=^|[;:]|{|\\*/)\\s*(down|left|right|up)\\b",
"begin": "\\G(?:down|left|right|up)\\b",
"captures": {
"1": {
"0": {
"name": "support.constant.direction.pikchr"
}
}
},
"patterns": [
{
"include": "#syntax-error"
}
],
"end": "(?<!\\\\)(?=\\n)|(?=]|}|;)"
},
"direction": {
"match": "\\b(?:down|left|right|up)\\b",
Expand All @@ -617,8 +633,22 @@
"end": "(?:)"
},
"numproperty": {
"match": "\\b(:?diameter|ht|height|rad|radius|thickness|width|wid)\\b",
"name": "support.constant.property-value.pikchr"
"begin": "\\b(diameter|ht|height|rad|radius|thickness|width|wid)\\b[ \\t\\f]*",
"beginCaptures": {
"1": {
"name": "support.constant.property-value.pikchr"
}
},
"patterns": [
{
"include": "#comment"
},
{
"include": "#expr"
}
],
"applyEndPatternLast": true,
"end": "(?:)"
},
"lvalue": {
"patterns": [
Expand All @@ -634,13 +664,8 @@
"name": "entity.name.function.pikchr"
},
{
"comment": "didn't find the rule exactly",
"match": "(?!\\b(?:then)\\b)([a-zA-Z_$@][a-zA-Z0-9_]*)",
"captures": {
"1": {
"name": "variable.language.pikchr"
}
}
"match": "[a-zA-Z_$@][a-zA-Z0-9_]*",
"name": "variable.language.pikchr"
}
]
},
Expand Down Expand Up @@ -795,12 +820,12 @@
"comment": {
"patterns": [
{
"begin": "/\\*",
"begin": "\\s*/\\*",
"end": "\\*/",
"name": "comment.block.pikchr"
},
{
"match": "(?://|#).*$",
"match": "\\s*(?://|#).*$",
"name": "comment.line.pikchr"
}
]
Expand Down
Loading