diff --git a/pikchr/pikchr.tmLanguage.json b/pikchr/pikchr.tmLanguage.json index 4029c4f..eea7def 100644 --- a/pikchr/pikchr.tmLanguage.json +++ b/pikchr/pikchr.tmLanguage.json @@ -13,7 +13,24 @@ "include": "#comment" }, { - "include": "#statement" + "begin": "(?<=^|[;:{]|\\*/|\\G)\\s*", + "patterns": [ + { + "include": "#statement" + }, + { + "include": "#continuation" + } + ], + "end": "(?:(? 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": "(?,1/2 /*comment*/) // ^ ^ punctuation.bracket.angle.begin.pikchr // ^ ^ punctuation.bracket.angle.end.pikchr // ^ punctuation.parenthesis.end.pikchr -// ^^ ^^ ^^ ^^ variable.language.pikchr +// ^^ ^^ ^^ ^^ variable.language.place.pikchr // ^ ^ punctuation.separator.period.pikchr // ^ punctuation.separator.pikchr // ^^^^^^^^^^^ comment.block.pikchr "Pikchr source " rjust "code input " rjust at 2nd vertex /**/ of previous -// <---------------- ^^^^^^^^^^^^^ string.quoted.double.pikchr +// <---------------- string.quoted.double.pikchr +// ^^^^^^^^^^^^^ string.quoted.double.pikchr // ^^^^^ ^^^^^ ^^ ^^^^^^ ^^ keyword.pikchr // ^^ constant.language.pikchr // ^^^^ comment.block.pikchr // ^^^^^^^^ constant.language.pikchr diamond;One: [line ->] with .n at 1cm below previous -// <------- ^^^^ storage.type.class.pikchr +// <------- storage.type.class.pikchr +// ^^^^ storage.type.class.pikchr // ^ punctuation.separator.delimiter.end.pikchr -// ^^^ variable.language.pikchr +// ^^^ variable.language.place.pikchr // ^ punctuation.separator.pikchr // ^ punctuation.bracket.square.begin.pikchr // ^^ entity.name.tag.pikchr diff --git a/pikchr/test/attribute.test.pikchr b/pikchr/test/attribute.test.pikchr index 703801a..09eaeb3 100644 --- a/pikchr/test/attribute.test.pikchr +++ b/pikchr/test/attribute.test.pikchr @@ -2,7 +2,7 @@ arrow from C6 to C3P chop // ^^^^ ^^ keyword.pikchr -// ^^ ^^^ variable.language.pikchr +// ^^ ^^^ variable.language.place.pikchr // ^^^^ entity.name.tag.pikchr arrow right then down // ^^^^^ ^^^^ support.constant.edge.pikchr @@ -57,4 +57,4 @@ cylinder "B" at 5cm heading 125 from A // ^^^ string.quoted.double.pikchr // ^^ ^^^^^^^ ^^^^ keyword.pikchr // ^^^ ^^^ constant.numeric.pikchr -// ^ variable.language.pikchr +// ^ variable.language.place.pikchr diff --git a/pikchr/test/comments.test.pikchr b/pikchr/test/comments.test.pikchr index 93af4e4..504e082 100644 --- a/pikchr/test/comments.test.pikchr +++ b/pikchr/test/comments.test.pikchr @@ -19,3 +19,11 @@ box//test #! !! <-- comment.line.pikchr + # box +!! ^^^^^ comment.line.pikchr + // TEST: +!! ^^^^^^^^ comment.line.pikchr + /* TEST +!! ^^^^^^^ comment.block.pikchr + */ +!! ^^ comment.block.pikchr diff --git a/pikchr/test/macro.test.pikchr b/pikchr/test/macro.test.pikchr index 54b73b1..08efead 100644 --- a/pikchr/test/macro.test.pikchr +++ b/pikchr/test/macro.test.pikchr @@ -23,9 +23,10 @@ par() // <--- entity.name.function.pikchr // ^ punctuation.parenthesis.begin.pikchr // ^ punctuation.parenthesis.end.pikchr -par par +par() par() par par // <--- entity.name.function.pikchr -// ^^^ entity.name.function.pikchr +// ^^^ entity.name.function.pikchr +// ^^^ ^^^ variable.language.pikchr mymacro( /**/ "hi" /**/ ) // <------- entity.name.function.pikchr // ^ punctuation.parenthesis.begin.pikchr @@ -62,3 +63,34 @@ mymacro("o") mymacro("o") // <------- entity.name.function.pikchr // ^^^^^^^ entity.name.function.pikchr // ^^^ ^^^ string.quoted.double.pikchr +E2: emo at last move.end; +// <-- variable.language.place.pikchr +//^ punctuation.separator.pikchr +// ^^^ variable.language.pikchr +// ^^ keyword.pikchr +// ^^^^ constant.language.pikchr +// ^^^^ entity.name.function.pikchr +// ^ punctuation.separator.period.pikchr +// ^^^ constant.language.pikchr +define place_as_parameter {$1: [C1: circle radius 1;];} +// <------ keyword.control.directive.define.pikchr +// ^^^^^^^^^^^^^^^^^^ variable.language.pikchr +// ^ punctuation.section.block.begin.bracket.curly.pikchr +// ^^ ^^ variable.language.place.pikchr +// ^ punctuation.separator.pikchr +// ^ punctuation.bracket.square.begin.pikchr +// ^ punctuation.separator.pikchr +// ^^^^^^ storage.type.class.pikchr +// ^ ^ punctuation.separator.delimiter.end.pikchr +// ^ punctuation.bracket.square.end.pikchr +// ^ punctuation.section.block.end.bracket.curly.pikchr +define place_as_parameter {$1: [C1: circle radius 1;]} +// ^ punctuation.section.block.end.bracket.curly.pikchr +emo at last move.end; +// <--- entity.name.function.pikchr +// ^^ keyword.pikchr +// ^^^^ constant.language.pikchr +// ^^^^ entity.name.function.pikchr +// ^ punctuation.separator.period.pikchr +// ^^^ constant.language.pikchr +// ^ punctuation.separator.delimiter.end.pikchr diff --git a/pikchr/test/place.test.pikchr b/pikchr/test/place.test.pikchr index a8aaaed..7dad2e2 100644 --- a/pikchr/test/place.test.pikchr +++ b/pikchr/test/place.test.pikchr @@ -5,7 +5,7 @@ arrow from last dot to X0 // ^^^^ constant.language.pikchr // ^^^ entity.name.function.pikchr // ^^ keyword.pikchr -// ^^ variable.language.pikchr +// ^^ variable.language.place.pikchr circle at end of first arrow // ^^ keyword.pikchr // ^^^ support.constant.edge.pikchr diff --git a/pikchr/test/statements.test.pikchr b/pikchr/test/statements.test.pikchr index cd194a6..81f1f4f 100644 --- a/pikchr/test/statements.test.pikchr +++ b/pikchr/test/statements.test.pikchr @@ -4,6 +4,8 @@ box // <--- storage.type.class.pikchr box // <--- storage.type.class.pikchr +\ +// <- punctuation.separator.continuation.line.pikchr cylinder ; // <-------- storage.type.class.pikchr // ^ source.pikchr @@ -34,20 +36,21 @@ diamond "hi" Cat: box "box" -// <--- variable.language.pikchr +// <--- variable.language.place.pikchr // ^ punctuation.separator.pikchr // ^^^ 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 + Cat : box "box" +// ^^^ variable.language.place.pikchr +// ^ punctuation.separator.pikchr +// ^^^ storage.type.class.pikchr +// ^^^^^ string.quoted.double.pikchr box "hello, \"world\"" // ^^^^^^^^^^^^^^^^^^ string.quoted.double.pikchr -box "hello, \x" +box "hello, \x";;;; // ^^^^^^^^^^^ source.pikchr string.quoted.double.pikchr +// ^^^^ punctuation.separator.delimiter.end.pikchr linewid = 0.25 // <--- variable.language.pikchr // ^ keyword.operator.assignment.pikchr @@ -76,7 +79,10 @@ boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05 // ^ ^ ^ punctuation.separator.delimiter.end.pikchr left -// <- support.constant.direction.pikchr +// <---- support.constant.direction.pikchr +down with the sickness +// <---- support.constant.direction.pikchr +// ^^^^ ^^^ ^^^^^^^^ invalid.illegal.pikchr line dashed // ^^^^^^ entity.name.tag.pikchr