diff --git a/.github/workflows/fossil.yml b/.github/workflows/fossil.yml index d95934b..8867e9b 100644 --- a/.github/workflows/fossil.yml +++ b/.github/workflows/fossil.yml @@ -37,5 +37,8 @@ jobs: # when running locally using `gh act` command run: sudo apt-get install -y fossil - - name: Run tests and coverage + - name: Run code tests and coverage run: xvfb-run -a npm run coverage-ci $GITHUB_STEP_SUMMARY + + - name: Run pikchr grammar tests + run: npm run grammar-test diff --git a/.vscode/settings.json b/.vscode/settings.json index a15cf51..e6e98e4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,7 @@ "fslckout", "humanise", "outfile", + "pikchr", "repourl", "sequentialize", "Technote", diff --git a/.vscodeignore b/.vscodeignore index bcaa37f..4c65069 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -11,3 +11,5 @@ docs/ images/ node_modules src/ +pikchr/test/* +pikchr/*.py diff --git a/package.json b/package.json index 2c0910b..4fc84ad 100644 --- a/package.json +++ b/package.json @@ -1063,6 +1063,31 @@ } ] } + ], + "languages": [ + { + "id": "pikchr", + "extensions": [ + ".pikchr" + ], + "icon": { + "dark": "pikchr/assets/pikchr.svg", + "light": "pikchr/assets/pikchr.svg" + } + } + ], + "grammars": [ + { + "language": "pikchr", + "scopeName": "source.pikchr", + "path": "./pikchr/pikchr.tmLanguage.json", + "injectTo": [ + "text.html.markdown" + ], + "embeddedLanguages": { + "meta.embedded.block.pikchr": "pikchr" + } + } ] }, "scripts": { @@ -1078,7 +1103,8 @@ "lint": "eslint ./src --ext .ts src media", "lint:fix": "eslint --fix --ext .ts src media", "esbuild-base": "esbuild ./src/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node", - "esbuild": "npm run esbuild-base -- --sourcemap" + "esbuild": "npm run esbuild-base -- --sourcemap", + "grammar-test": "vscode-tmgrammar-test ./pikchr/test/*.test.pikchr" }, "dependencies": { "vscode-nls": "^5.0.1" @@ -1105,11 +1131,12 @@ "mocha": "~10.2.0", "prettier": "~2.8.8", "sinon": "~17.0.1", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "vscode-tmgrammar-test": "^0.1.3" }, "__metadata": { "id": "e828bfe6-95e7-4c7a-a334-ae2cc5ba8788", "publisherDisplayName": "koog1000", "publisherId": "8e4cabe1-5c1f-4bf5-bbf3-8bb8d5de842c" } -} \ No newline at end of file +} diff --git a/pikchr/assets/pikchr.svg b/pikchr/assets/pikchr.svg new file mode 100644 index 0000000..36e0b42 --- /dev/null +++ b/pikchr/assets/pikchr.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/pikchr/pikchr.tmLanguage.json b/pikchr/pikchr.tmLanguage.json new file mode 100644 index 0000000..3121acb --- /dev/null +++ b/pikchr/pikchr.tmLanguage.json @@ -0,0 +1,671 @@ +{ + "scopeName": "source.pikchr", + "comment": "regexp test https://rubular.com/", + "patterns": [ + { + "include": "#statement-list" + } + ], + "repository": { + "statement-list": { + "patterns": [ + { + "include": "#whitespace" + }, + { + "include": "#statement" + }, + { + "include": "#eol" + } + ] + }, + "eol": { + "comment": "T_EOL was `\\Z|$|(;)`", + "match": "\\n\\Z|(;)\\s*", + "name": "punctuation.separator.delimiter.end.pikchr" + }, + "syntax-error": { + "comment": "T_ERROR (maybe)", + "match": "\\w+", + "name": "invalid.illegal.pikchr" + }, + "statement": { + "patterns": [ + { + "include": "#direction" + }, + { + "match": "(:?[A-Z]\\w*)(:)", + "captures": { + "1": { + "name": "variable.language.pikchr" + }, + "2": { + "name": "punctuation.separator.pikchr" + } + } + }, + { + "include": "#unnamed-statement" + }, + { + "include": "#define-id-codeblock" + }, + { + "include": "#lvalue" + }, + { + "begin": "\\s*(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.pikchr" + } + }, + "patterns": [ + { + "include": "#rvalue" + } + ], + "name": "meta.assignment.pickchr", + "applyEndPatternLast": true, + "end": "(?:)" + } + ] + }, + "define-id-codeblock": { + "begin": "(?<=^|;|:)\\s*\\b(define)\\b\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.directive.define.pikchr" + } + }, + "patterns": [ + { + "include": "#id" + }, + { + "begin": "{", + "captures": { + "0": { + "name": "punctuation.section.block.begin.bracket.curly.pikchr" + } + }, + "patterns": [ + { + "include": "#unnamed-statement" + } + ], + "end": "}", + "endCaptures": { + "0": { + "name": "punctuation.section.block.end.bracket.curly.pikchr" + } + } + } + ], + "end": "(?:(?DOT_L->{numproperty,dashproperty,colorproperty}", + "match": "\\b(\\.)(diameter|ht|height|rad|radius|thickness|width|wid|dashed|dotted|fill|color)\\s*", + "captures": { + "1": { + "name": "punctuation.separator.period.pikchr" + }, + "2": { + "name": "support.constant.property-value.pikchr" + } + } + }, + { + "begin": "(\\()\\s*", + "beginCaptures": { + "1": { + "name": "punctuation.parenthesis.begin.pikch" + } + }, + "patterns": [ + { + "include": "#expr" + } + ], + "end": "(\\))\\s*", + "endCaptures": { + "1": { + "name": "punctuation.parenthesis.end.pikchr" + } + } + }, + { + "include": "$self" + } + ] + }, + "object": { + "patterns": [ + { + "include": "#objctname" + }, + { + "include": "#nth" + }, + { + "patterns": [ + { + "include": "$self" + }, + { + "comment": "dot_u->placename", + "match": "(\\.)(:?[A-Z]\\w*)", + "captures": { + "1": { + "name": "punctuation.separator.period.pikchr" + }, + "2": { + "name": "entity.name.tag.pikchr" + } + } + } + ] + } + ] + }, + "objctname": { + "patterns": [ + { + "match": "\\bthis\\b", + "name": "tag.pikchr" + }, + { + "include": "#placename" + }, + { + "include": "$self" + } + ] + }, + "attribute-then": { + "begin": "\\b(then|go)\\b\\s*", + "beginCaptures": { + "1": { + "name": "keyword.pikchr" + } + }, + "patterns": [ + { + "include": "#edge" + }, + { + "match": "\\b(heading)\\b\\s*", + "captures": { + "1": { + "name": "pikchr.keyword" + } + } + } + ], + "applyEndPatternLast": true, + "end": "(?:)" + }, + "percent-sign": { + "match": "(%)\\s*", + "captures": { + "1": { + "name": "keyword.other.unit.percentage.pikchr" + } + } + }, + "number": { + "comment": "see `pik_atof` from pikchr.y", + "patterns": [ + { + "match": "\\b(0[xX]\\h{1,8})\\b\\s*", + "captures": { + "1": { + "name": "constant.numeric.pikchr" + } + } + }, + { + "match": "((?:\\d*\\.)?\\d+(in|cm|px|pt|pc|mm|%)?)\\b\\s*", + "captures": { + "1": { + "name": "constant.numeric.pikchr" + }, + "2": { + "name": "keyword.other.unit.$2.pikchr" + } + } + } + ] + }, + "placename": { + "patterns": [ + { + "match": "([A-Z]\\w*)\\s*", + "captures": { + "1": { + "name": "variable.language.pikchr" + } + } + }, + { + "comment": "color is a part of placename, according to pikchr.y", + "include": "#colorname" + } + ] + }, + "variable": { + "match": "^[a-z_$@][\\w$@]*", + "name": "entity.name.tag.pikchr" + }, + "attribute": { + "patterns": [ + { + "include": "#dashproperty" + }, + { + "include": "#boolproperty" + }, + { + "include": "#attribute-then" + }, + { + "include": "#go-until-even" + }, + { + "include": "#colorproperty-then-rvalue" + }, + { + "include": "#numproperty" + }, + { + "include": "#percent-sign" + }, + { + "include": "#string-then-text-attributes" + }, + { + "match": "\\b(:?close|chop|from|to|at)\\b", + "name": "keyword.pikchr" + }, + { + "match": "\\b(with)\\b", + "name": "constant.language.pikchr" + }, + { + "include": "#expr" + } + ] + }, + "dashproperty": { + "match": "\\b(dashed|dotted)\\b\\s*", + "captures": { + "1": { + "name": "entity.name.tag.pikchr" + } + } + }, + "boolproperty": { + "comment": "Properties with no argument", + "match": "(<->|<-|->)|\\b(cw|ccw|invis(ible)?|thick|thin|solid|same|chop|fit)\\b\\s*", + "captures": { + "1": { + "name": "entity.name.tag.pikchr" + }, + "2": { + "name": "entity.name.tag.pikchr" + } + } + }, + "nth": { + "patterns": [ + { + "comment": "last, previous", + "match": "\\b(last|previous)\\b\\s*", + "captures": { + "1": { + "name": "entity.name.type" + } + } + }, + { + "match": "\\b(first|\\d+(th|rd|nd|st))\\b\\s*", + "name": "constant.language.pikchr" + }, + { + "include": "#object-class" + } + ] + }, + "object-class": { + "match": "\\b(arc|arrow|box|circle|cylinder|diamond|dot|ellipse|file|line|move|oval|spline|text)\\b", + "name": "keyword.pikchr" + }, + "text-attribute": { + "match": "\\b(above|aligned|below|big|bold|mono|monospace|center|italic|ljust|rjust|small)\\b\\s*", + "name": "constant.other.pikchr" + }, + "text-position": { + "match": "\\b(above|aligned|below|big|bold|center|italic|ljust|mono|rjust|small)\\b\\s*", + "name": "constant.other.pikchr" + }, + "edge": { + "match": "\\b(bot|bottom|c|center|e|east|end|left|n|ne|north|nw|right|s|se|south|start|sw|t|top|w|west)\\b\\s*", + "name": "support.constant.edge.pikchr" + }, + "colorname": { + "patterns": [ + { + "match": "(?i)\\b(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\\b", + "name": "support.constant.color.w3c-standard-color-name.pikchr" + }, + { + "match": "(?i)\\b(aliceblue|antiquewhite|aquamarine|azure|beige|bisque|blanchedalmond|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|gainsboro|ghostwhite|gold|goldenrod|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|limegreen|linen|magenta|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|none|off|oldlace|olivedrab|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|rebeccapurple|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|thistle|tomato|turquoise|violet|wheat|whitesmoke|yellowgreen)\\b", + "name": "support.constant.color.w3c-extended-color-name.pikchr" + } + ] + }, + "string": { + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.pikchr" + } + }, + "end": "(\")\\s*", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.pikchr" + } + }, + "name": "string.quoted.double.pikchr", + "patterns": [ + { + "match": "\\\\\"", + "name": "constant.character.escape.pikchr" + }, + { + "match": "\\\\.", + "name": "invalid.illegal.unrecognized-string-escape.pikchr" + } + ] + }, + "direction": { + "match": "\\b(down|left|right|up)\\b\\s*", + "captures": { + "1": { + "name": "support.constant.direction.pikchr" + } + } + }, + "go-until-even": { + "patterns": [ + { + "match": "(\\bgo\\s+)?\\b(down|left|right|up)\\b\\s*", + "captures": { + "1": { + "name": "support.constant.direction.pikchr" + }, + "2": { + "name": "support.constant.direction.pikchr" + } + } + }, + { + "match": "\\b((?:until\\s+)?even\\s+with)\\b\\s*", + "captures": { + "1": { + "name": "constant.language.pikchr" + } + } + }, + { + "include": "#position" + } + ] + }, + "numproperty": { + "match": "\\b(diameter|ht|height|rad|radius|thickness|width|wid)\\b\\s+", + "captures": { + "1": { + "name": "support.constant.property-value.pikchr" + } + } + }, + "lvalue": { + "patterns": [ + { + "include": "#id-at-the-beggining" + } + ] + }, + "id-at-the-beggining": { + "comment": "didn't find the rule exactly", + "match": "(?<=^\\s*)(\\$?[a-z]+)", + "captures": { + "1": { + "name": "variable.pikchr" + } + } + }, + "id": { + "comment": "didn't find the rule exactly", + "match": "(?!\\b(?:then|from|at|diameter|ht|height|rad|radius|thickness|width|wid|with|dashed|dotted|fill|color|to|chop|even)\\b)(\\$?[a-zA-Z]+[a-zA-Z0-9_]*)\\s*", + "captures": { + "1": { + "name": "variable.language.pikchr" + } + } + }, + "rvalue": { + "patterns": [ + { + "include": "#expr" + }, + { + "include": "#placename" + } + ] + }, + "colorproperty-then-rvalue": { + "begin": "\\b(fill|color)\\b\\s*", + "beginCaptures": { + "1": { + "name": "keyword.pikchr" + } + }, + "applyEndPatternLast": true, + "patterns": [ + { + "include": "#rvalue" + } + ], + "end": "(?:)" + }, + "position": { + "patterns": [ + { + "include": "#place" + }, + { + "match": "\\b(above|below|heading|way between|between|of the way between|and)\\b\\s*", + "captures": { + "1": { + "name": "keyword.pikchr" + } + } + }, + { + "begin": "\\(\\s*", + "end": "\\)\\s*", + "beginCaptures": { + "0": { + "name": "punctuation.parenthesis.begin.pikchr" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.parenthesis.end.pikchr" + } + }, + "patterns": [ + { + "include": "#expr" + }, + { + "include": "#position" + } + ] + }, + { + "include": "#expr" + } + ] + }, + "place": { + "patterns": [ + { + "include": "#place2" + }, + { + "include": "#edge" + }, + { + "match": "\\b(of)\\b\\s*", + "captures": { + "1": { + "name": "keyword.control.of.pikchr" + } + } + } + ] + }, + "place2": { + "patterns": [ + { + "include": "#object" + }, + { + "include": "#dot_e-edge" + }, + { + "include": "#nth" + } + ] + }, + "dot_e-edge": { + "match": "(\\.)(bot|bottom|c|center|e|east|end|left|n|ne|north|nw|right|s|se|south|start|sw|t|top|w|west)\\b\\s*", + "captures": { + "1": { + "name": "punctuation.separator.period.pikchr" + }, + "2": { + "name": "entity.name.class.pikchr" + } + } + }, + "whitespace": { + "comment": "match T_WHITESPACE as seen in pikchr.y", + "patterns": [ + { + "match": " \\r\\n\\t\\f" + }, + { + "begin": "/\\*", + "end": "\\*/", + "name": "comment.block.pikchr" + }, + { + "match": "(?://|#).*$\\n?", + "name": "comment.line.pikchr" + } + ] + } + } +} \ No newline at end of file diff --git a/pikchr/test/advanced.test.pikchr b/pikchr/test/advanced.test.pikchr new file mode 100644 index 0000000..ea0b5e3 --- /dev/null +++ b/pikchr/test/advanced.test.pikchr @@ -0,0 +1,88 @@ +// SYNTAX TEST "source.pikchr" "long statements" + +line right even with $r left of X9 then up until even with VARIABLE.n +// <---- storage.type.class.pikchr +// ^^^^^ support.constant.direction.pikchr +// ^^^^ constant.language.pikchr +// ^^^^ constant.language.pikchr +// ^^ variable.language.pikchr +// ^^^^ support.constant.direction.pikchr +// ^^ keyword.control.of.pikchr +// ^^ variable.language.pikchr +// ^^^^ keyword.pikchr +// ^^ support.constant.direction.pikchr +// ^^^^^^^^^^ constant.language.pikchr +// ^^^^ constant.language.pikchr +// ^^^^^^^^ variable.language.pikchr + +circle rad 0.05 at Paper + (-0.055, -0.25) +// <------ storage.type.class.pikchr +// ^^^ support.constant.property-value.pikchr +// ^^^^ constant.numeric.pikchr +// ^^ keyword.pikchr +// ^^^^^ variable.language.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^ punctuation.parenthesis.begin.pikchr +// ^ ^ keyword.operator.arithmetic.pikchr +// ^^^^^ ^^^^ constant.numeric.pikchr +// ^ punctuation.parenthesis.end.pikchr + + +line thick right from 0.3cm below start of previous +// <---- storage.type.class.pikchr +// ^^^^^ entity.name.tag.pikchr +// ^^^^^ support.constant.direction.pikchr +// ^^^^ keyword.pikchr +// ^^^^^ constant.numeric.pikchr +// ^^ keyword.other.unit.cm.pikchr +// ^^^^^ keyword.pikchr +// ^^^^^ support.constant.edge.pikchr +// ^^ keyword.control.of.pikchr +// ^^^^^^^^ entity.name.type + +oval width OVAL1.height height OVAL1.width +// <---- storage.type.class.pikchr +// ^^^^^ ^^^^^^ support.constant.property-value.pikchr +// ^^^^^ variable.language.pikchr +// ^ ^ punctuation.separator.period.pikchr +// ^^^^^^ ^^^^^ support.constant.property-value.pikchr + +oval "" fit at $r*1.2 below 1/2 way between X0 and X9 +// <---- storage.type.class.pikchr +// ^^ string.quoted.double.pikchr +// ^^^ entity.name.tag.pikchr +// ^ -entity.name.tag.pikchr +// ^^ keyword.pikchr +// ^^ variable.language.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^^^ ^ ^ constant.numeric.pikchr +// ^^^^^ keyword.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^^^ ^^^^^^^ keyword.pikchr +// ^^ ^^ variable.language.pikchr +// ^^^ keyword.pikchr + +arrow from TYPENAME.e right even with ATTR +// <----- storage.type.class.pikchr +// ^^^^ keyword.pikchr +// ^^^^^^^^ ^^^^ variable.language.pikchr +// ^ punctuation.separator.period.pikchr +// ^ entity.name.class.pikchr +// ^^^^^ support.constant.direction.pikchr +// ^^^^ ^^^^ constant.language.pikchr + +box "expr" fit with .w at 1.75*$h below BTW.w +// <--- storage.type.class.pikchr +// ^^^^^^ string.quoted.double.pikchr +// ^^^ entity.name.tag.pikchr +// ^^^^ constant.language.pikchr +// ^ punctuation.separator.period.pikchr +// ^ entity.name.class.pikchr +// ^^ keyword.pikchr +// ^^^^ constant.numeric.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^^ variable.language.pikchr +// ^^^^^ keyword.pikchr +// ^^^ variable.language.pikchr +// ^ punctuation.separator.period.pikchr +// ^ entity.name.class.pikchr diff --git a/pikchr/test/attribute.test.pikchr b/pikchr/test/attribute.test.pikchr new file mode 100644 index 0000000..c981ce4 --- /dev/null +++ b/pikchr/test/attribute.test.pikchr @@ -0,0 +1,13 @@ +// SYNTAX TEST "source.pikchr" "checks for 'attribute' tree" + +arrow from C6 to C3P chop +// ^^^^ keyword.pikchr +// ^^ ^^^ variable.language.pikchr +// ^^ keyword.pikchr +// ^^^^ entity.name.tag.pikchr + +arrow right then down +// ^^^^^ support.constant.direction.pikchr +// ^^^^ keyword.pikchr +// ^ -keyword.pikchr +// ^^^^ support.constant.direction.pikchr diff --git a/pikchr/test/boolproperty.test.pikchr b/pikchr/test/boolproperty.test.pikchr new file mode 100644 index 0000000..828d5d6 --- /dev/null +++ b/pikchr/test/boolproperty.test.pikchr @@ -0,0 +1,40 @@ +// SYNTAX TEST "source.pikchr" "Properties with no argument" + +arrow cw +// ^ source.pikchr entity.name.tag.pikchr + +box ccw +// ^ source.pikchr entity.name.tag.pikchr + +box <- +// ^^ source.pikchr entity.name.tag.pikchr + +box -> +// ^^ source.pikchr entity.name.tag.pikchr + +box <-> +// ^^^ source.pikchr entity.name.tag.pikchr + +arrow invis +// ^^^^^ source.pikchr entity.name.tag.pikchr + +box invisible +// ^^^^^^^^^ source.pikchr entity.name.tag.pikchr + +box thick +// ^ source.pikchr entity.name.tag.pikchr + +box thin +// ^ source.pikchr entity.name.tag.pikchr + +arrow solid +// ^ source.pikchr entity.name.tag.pikchr + +cylinder same +// <-------- storage.type.class.pikchr +// ^ source.pikchr +// ^^^^ source.pikchr entity.name.tag.pikchr + +box same; +// <--- storage.type.class.pikchr +// ^^^^ source.pikchr entity.name.tag.pikchr diff --git a/pikchr/test/color.test.pikchr b/pikchr/test/color.test.pikchr new file mode 100644 index 0000000..d9dca92 --- /dev/null +++ b/pikchr/test/color.test.pikchr @@ -0,0 +1,458 @@ +// SYNTAX TEST "source.pikchr" "everything related to setting a color" + +box fill Red +// <--- storage.type.class.pikchr +// ^ source.pikchr +// ^^^^ keyword.pikchr +// ^ -keyword.pikchr +// ^^^ support.constant.color.w3c-standard-color-name.pikchr + +box fill aqua +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill black +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill blue +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill gray +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill green +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill lime +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill maroon +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill navy +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill olive +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill orange +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill purple +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill red +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill silver +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill teal +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill white +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box fill yellow +// ^ support.constant.color.w3c-standard-color-name.pikchr + +box color AliceBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color AntiqueWhite +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Aquamarine +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Azure +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Beige +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Bisque +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color BlanchedAlmond +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color BlueViolet +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Brown +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color BurlyWood +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color CadetBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Chartreuse +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Chocolate +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Coral +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color CornflowerBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Cornsilk +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Crimson +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Cyan +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkCyan +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkGoldenrod +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkKhaki +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkMagenta +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkOliveGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkOrange +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkOrchid +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkRed +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkSalmon +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkSeaGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkSlateBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkSlateGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkSlateGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkTurquoise +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DarkViolet +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DeepPink +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DeepSkyBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DimGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DimGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color DodgerBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Firebrick +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color FloralWhite +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color ForestGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Gainsboro +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color GhostWhite +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Gold +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Goldenrod +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color GreenYellow +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Grey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Honeydew +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color HotPink +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color IndianRed +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Indigo +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Ivory +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Khaki +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Lavender +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LavenderBlush +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LawnGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LemonChiffon +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightCoral +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightCyan +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightGoldenrodYellow +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightPink +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSalmon +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSeaGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSkyBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSlateGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSlateGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightSteelBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LightYellow +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color LimeGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Linen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Magenta +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumAquamarine +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumOrchid +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumPurple +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumSeaGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumSlateBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumSpringGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumTurquoise +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MediumVioletRed +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MidnightBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MintCream +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color MistyRose +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Moccasin +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color NavajoWhite +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color None /* Non-standard addition */ +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Off /* Non-standard addition */ +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color OldLace +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color OliveDrab +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color OrangeRed +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Orchid +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PaleGoldenrod +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PaleGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PaleTurquoise +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PaleVioletRed +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PapayaWhip +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PeachPuff +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Peru +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Pink +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Plum +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color PowderBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color RebeccaPurple +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color RosyBrown +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color RoyalBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SaddleBrown +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Salmon +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SandyBrown +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SeaGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Seashell +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Sienna +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SkyBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SlateBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SlateGray +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SlateGrey +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Snow +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SpringGreen +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color SteelBlue +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Tan +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Thistle +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Tomato +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Turquoise +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Violet +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color Wheat +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color WhiteSmoke +// ^ support.constant.color.w3c-extended-color-name.pikchr + +box color YellowGreen +// ^^^^^^^^^^^ support.constant.color.w3c-extended-color-name.pikchr + +circle fill 0xffff00 +// ^^^^^^^^ constant.numeric.pikchr \ No newline at end of file diff --git a/pikchr/test/homepage.example.test.pikchr b/pikchr/test/homepage.example.test.pikchr new file mode 100644 index 0000000..1bde67d --- /dev/null +++ b/pikchr/test/homepage.example.test.pikchr @@ -0,0 +1,39 @@ +// SYNTAX TEST "source.pikchr" "https://pikchr.org/home/doc/trunk/homepage.md" + +arrow right 200% "Markdown" "Source" +// <----- storage.type.class.pikchr +// ^ source.pikchr +// ^ source.pikchr +// ^ source.pikchr constant.numeric.pikchr +// ^ source.pikchr string.quoted.double.pikchr +// ^ source.pikchr +// ^ source.pikchr string.quoted.double.pikchr + +box rad 10px "Markdown" "Formatter" "(markdown.c)" fit +// <--- storage.type.class.pikchr +// ^ -storage.type.class.pikchr +// ^^^ support.constant.property-value.pikchr +// ^ source.pikchr +// ^^^^ source.pikchr constant.numeric.pikchr +// ^ source.pikchr +// ^ source.pikchr string.quoted.double.pikchr +// ^ source.pikchr +// ^ source.pikchr string.quoted.double.pikchr +// ^ source.pikchr +// ^ source.pikchr string.quoted.double.pikchr +// ^ source.pikchr +// ^ source.pikchr entity.name.tag.pikchr + +arrow <-> down 70% from last box.s +// <--- storage.type.class.pikchr +// ^ source.pikchr +// ^^^ source.pikchr entity.name.tag.pikchr +// ^^^^ support.constant.direction.pikchr +// ^^ constant.numeric.pikchr +// ^ keyword.other.unit.percentage.pikchr +// ^ source.pikchr +// ^^^^ keyword.pikchr +// ^^^^ entity.name.type +// ^^^ keyword.pikchr +// ^ punctuation.separator.period.pikchr +// ^ entity.name.class.pikchr diff --git a/pikchr/test/nth.test.pikchr b/pikchr/test/nth.test.pikchr new file mode 100644 index 0000000..93a8fd2 --- /dev/null +++ b/pikchr/test/nth.test.pikchr @@ -0,0 +1,33 @@ +// SYNTAX TEST "source.pikchr" "all checks for 'nth' tree" + +< +< all checks are `attribute -> at -> position -> place -> place2 -> nth -> ...` +< + +< +< `nth -> NTH -> classname` +< +box at 1st box +// ^^ keyword.pikchr +// ^^^ constant.language.pikchr +// ^^^ keyword.pikchr + +< +< `nth -> NTH -> last|previous -> classname` +< +box at 2nd previous box +// ^^ keyword.pikchr +// ^^^ constant.language.pikchr +// ^^^^^^^^ entity.name.type +// ^^^ keyword.pikchr + +< +< `nth -> last|previous -> classname +< + +box at last box +// ^^ keyword.pikchr +// ^^^^ entity.name.type +// ^^^ keyword.pikchr +box at previous box +// ^^^^^^^^ entity.name.type diff --git a/pikchr/test/place.test.pikchr b/pikchr/test/place.test.pikchr new file mode 100644 index 0000000..8fca197 --- /dev/null +++ b/pikchr/test/place.test.pikchr @@ -0,0 +1,16 @@ +// SYNTAX TEST "source.pikchr" "place node" + +arrow from last dot to X0 +// ^^^^ keyword.pikchr +// ^^^^ entity.name.type +// ^^^ keyword.pikchr +// ^^ keyword.pikchr +// ^^ variable.language.pikchr + +circle at end of first arrow +// ^^ keyword.pikchr +// ^^^ support.constant.edge.pikchr +// ^^ keyword.control.of.pikchr +// ^ -keyword.control.of.pikchr +// ^^^^^ constant.language.pikchr +// ^^^^^ keyword.pikchr diff --git a/pikchr/test/position.test.pikchr b/pikchr/test/position.test.pikchr new file mode 100644 index 0000000..59679ef --- /dev/null +++ b/pikchr/test/position.test.pikchr @@ -0,0 +1,38 @@ +// SYNTAX TEST "source.pikchr" "all checks for 'position' tree" + +< +< test for `position -> expr -> ',' -> expr` +< +box at 1 , 1 +// ^^ keyword.pikchr +// ^ ^ constant.numeric.pikchr +// ^ punctuation.separator.pikchr + +< +< `position -> place` +< +box at 1st box +// ^^ keyword.pikchr +// ^^^ constant.language.pikchr +// ^^^ keyword.pikchr + +< +< `position -> place -> + -> expr -> ',' -> expr` +< +box at 3rd box + 0.1,9.3 +// ^^ keyword.pikchr +// ^^^ constant.language.pikchr +// ^^^ keyword.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^^^ ^^^ constant.numeric.pikchr +// ^ punctuation.separator.pikchr + +< +< `position -> ( -> position -> )` +< +circle at (-0.055, -0.25) +// ^^ keyword.pikchr +// ^ punctuation.parenthesis.begin.pikchr +// ^ ^ keyword.operator.arithmetic.pikchr +// ^^^^^ ^^^^ constant.numeric.pikchr +// ^ punctuation.parenthesis.end.pikchr diff --git a/pikchr/test/statements.test.pikchr b/pikchr/test/statements.test.pikchr new file mode 100644 index 0000000..c96d341 --- /dev/null +++ b/pikchr/test/statements.test.pikchr @@ -0,0 +1,93 @@ +// SYNTAX TEST "source.pikchr" "first test" + +box +// <--- storage.type.class.pikchr + +cylinder ; +// <-------- storage.type.class.pikchr +// ^ source.pikchr + + +cylinder; +// <--- storage.type.class.pikchr +// ^ source.pikchr punctuation.separator.delimiter.end.pikchr + +cylinder;box +// <--- storage.type.class.pikchr +// ^ source.pikchr punctuation.separator.delimiter.end.pikchr +// ^ storage.type.class.pikchr + + +cylinder ; box +// <--- storage.type.class.pikchr +// ^ source.pikchr +// ^ source.pikchr punctuation.separator.delimiter.end.pikchr +// ^ source.pikchr +// ^ storage.type.class.pikchr + +arrow right +// <--- storage.type.class.pikchr +// ^ -storage.type.class.pikchr +// ^^^^^ support.constant.direction.pikchr + +diamond "hi" +// <--- storage.type.class.pikchr +// ^^^^ string.quoted.double.pikchr + + +Cat: box "box" +// <--- variable.language.pikchr +// ^ punctuation.separator.pikchr +// ^^^ storage.type.class.pikchr +// ^^^^^ string.quoted.double.pikchr + +box "hello, \"world\"" +// ^^^^^^^^^^^^^^^^^^ string.quoted.double.pikchr + +box "hello, \x" +// ^^^^^^^^^^^ source.pikchr string.quoted.double.pikchr +// ^^ invalid.illegal.unrecognized-string-escape.pikchr + +linewid = 0.25 +// <--- variable.pikchr +// ^ keyword.operator.assignment.pikchr +// ^^^^ constant.numeric.pikchr + +$r = 0.2in +// <-- variable.pikchr +// ^ keyword.operator.assignment.pikchr +// ^^^^^ constant.numeric.pikchr +// ^^ keyword.other.unit.in.pikchr + +linerad = 0.75*$r +// <------- variable.pikchr +// ^ -variable.pikchr +// ^ keyword.operator.assignment.pikchr +// ^^^^ constant.numeric.pikchr +// ^ keyword.operator.arithmetic.pikchr +// ^^ variable.language.pikchr + +boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05 +// <----- variable.pikchr +// ^^^^^^ ^^^^^^^^^ ^^ variable.language.pikchr +// ^ ^ ^ ^ keyword.operator.assignment.pikchr +// ^^ ^^ ^^ ^^^^ constant.numeric.pikchr +// ^ ^ ^ punctuation.separator.delimiter.end.pikchr + +left +// <- support.constant.direction.pikchr + +define par {} +// <------ keyword.control.directive.define.pikchr +// ^^^ variable.language.pikchr +// ^ punctuation.section.block.begin.bracket.curly.pikchr +// ^ punctuation.section.block.end.bracket.curly.pikchr + +line dashed +// ^^^^^^ entity.name.tag.pikchr + +line dotted +// ^^^^^^ entity.name.tag.pikchr + +"splines" +// <--------- string.quoted.double.pikchr diff --git a/pikchr/test/textposition.test.pikchr b/pikchr/test/textposition.test.pikchr new file mode 100644 index 0000000..6ba6dce --- /dev/null +++ b/pikchr/test/textposition.test.pikchr @@ -0,0 +1,40 @@ +// SYNTAX TEST "source.pikchr" "everything related to using text" + +box "" above +// ^^^^^ constant.other.pikchr + +box "" aligned +// ^^^^^^^ constant.other.pikchr + +box "" below +// ^^^^^ constant.other.pikchr + +box "" big +// ^^^ constant.other.pikchr + +box "" bold +// ^^^^ constant.other.pikchr + +box "" mono +// ^^^^ constant.other.pikchr + +box "" monospace +// ^^^^^^^^^ constant.other.pikchr + +box "" center +// ^^^^^^ constant.other.pikchr + +box "" italic +// ^^^^^^ constant.other.pikchr + +box "" ljust +// ^^^^^ constant.other.pikchr + +box "" rjust +// ^^^^^ constant.other.pikchr + +box "" small +// ^^^^^ constant.other.pikchr + +box "" small bold +// ^^^^^ ^^^^ constant.other.pikchr