From 9e430425e05fa2cd3fa3468173cb929f78f72c12 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 23 Aug 2022 20:27:18 +0500 Subject: [PATCH 1/6] Fix inline signature (triple quotes) --- src/purescript.coffee | 19 ++++++++----------- test/Main.purs | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 78391f4..2d6008b 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -567,7 +567,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-|""")' + match: '({doubleColon})(.*)(?=<-)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -577,17 +577,14 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)' - captures: + begin: '({doubleColon})' + end: /(?=^\S)/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: { - name: 'meta.type-signature' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] - } - + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] ] double_colon_orphan: diff --git a/test/Main.purs b/test/Main.purs index f102207..a068ad7 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -478,6 +478,7 @@ px = Proxy :: Proxy """fdsfsdf fdsfdsfsdf """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" -- quotes after type def From 60fe623c95cb4bf24a356717512956742fe4df94 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:39:51 +0500 Subject: [PATCH 2/6] Add purs output ignore --- .gitignore | 2 + package-lock.json | 767 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 769 insertions(+) create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index ade14b9..495cf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_Store npm-debug.log node_modules +output +.psc-ide-port \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bb05cae --- /dev/null +++ b/package-lock.json @@ -0,0 +1,767 @@ +{ + "name": "language-purescript", + "version": "0.9.6", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "language-purescript", + "version": "0.9.6", + "license": "MIT", + "devDependencies": { + "coffee-script": "~1.9.0", + "season": "~2.0.0" + }, + "engines": { + "atom": ">= 0.105.0" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.2" + } + }, + "node_modules/async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "deprecated": "CoffeeScript on NPM has moved to \"coffeescript\" (no hyphen)", + "dev": true, + "bin": { + "cake": "bin/cake", + "coffee": "bin/coffee" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "dependencies": { + "nopt": "~2.1.2", + "StringScanner": "~0.0.3" + }, + "bin": { + "coffee": "bin/coffee" + }, + "engines": { + "node": "0.8.x || 0.10.x" + }, + "optionalDependencies": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "source-map": "0.1.11" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/cscodegen": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "optional": true, + "bin": { + "cake": "bin/cscodegen" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "dependencies": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "node_modules/escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "dependencies": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=0.4.0" + }, + "optionalDependencies": { + "source-map": ">= 0.1.2" + } + }, + "node_modules/escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "dependencies": { + "estraverse": "^2.0.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/escope/node_modules/estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "dependencies": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + }, + "bin": { + "esmangle": "bin/esmangle.js" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "dependencies": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esshorten/node_modules/estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "dependencies": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "dependencies": { + "wordwrap": "~0.0.2" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "dependencies": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + }, + "bin": { + "csonc": "bin/csonc" + } + }, + "node_modules/source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "dependencies": { + "amdefine": ">=0.0.4" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "node_modules/underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "dependencies": { + "underscore": "^1.9.1" + } + }, + "node_modules/wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "dev": true + }, + "coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "requires": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "nopt": "~2.1.2", + "source-map": "0.1.11", + "StringScanner": "~0.0.3" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "cscodegen": { + "version": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "from": "cscodegen@git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "optional": true + }, + "cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "requires": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "requires": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0", + "source-map": ">= 0.1.2" + } + }, + "escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "requires": { + "estraverse": "^2.0.0" + }, + "dependencies": { + "estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true + } + } + }, + "esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "requires": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + } + }, + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true + }, + "esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "requires": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "dependencies": { + "estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true + } + } + }, + "estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true + }, + "fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "requires": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "requires": { + "wordwrap": "~0.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "requires": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + } + }, + "source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true + }, + "underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "requires": { + "underscore": "^1.9.1" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} From a39cbcbb26301d7bf19bece29c9e779f18ba4b92 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:41:09 +0500 Subject: [PATCH 3/6] fixes for inline signatures, fixes for infix function --- grammars/purescript.cson | 1038 +++++++++++++++++++++++++------------- src/purescript.coffee | 32 +- test/Main.purs | 27 +- 3 files changed, 727 insertions(+), 370 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 169450d..b05fdd0 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -14,189 +14,637 @@ 'character': '(?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))' 'classConstraint': '(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*\\g)?)))' 'functionTypeDeclaration': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'recordFieldQuoted': '"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)"' + 'recordFieldDeclaration': '((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' 'ctorArgs': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+)' 'ctor': '(?:(?:\\b([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' 'typeDecl': '.+?' 'indentChar': '[ \\t]' 'indentBlockEnd': '^(?!\\1[ \\t]|[ \\t]*$)' 'maybeBirdTrack': '^' + 'doubleColon': '(?:::|∷)' 'patterns': [ { - 'name': 'keyword.operator.function.infix.purescript' - 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(`)' - 'captures': - '1': - 'name': 'punctuation.definition.entity.purescript' - '2': - 'name': 'punctuation.definition.entity.purescript' + 'include': '#module_declaration' } { - 'name': 'meta.declaration.module.purescript' - 'begin': '^\\s*\\b(module)(?!\')\\b' - 'end': '(where)' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'include': '#module_import' + } + { + 'include': '#type_synonym_declaration' + } + { + 'include': '#data_type_declaration' + } + { + 'include': '#typeclass_declaration' + } + { + 'include': '#instance_declaration' + } + { + 'include': '#derive_declaration' + } + { + 'include': '#infix_op_declaration' + } + { + 'include': '#foreign_import_data' + } + { + 'include': '#foreign_import' + } + { + 'include': '#function_type_declaration' + } + { + 'include': '#typed_hole' + } + { + 'include': '#keywords_orphan' + } + { + 'include': '#control_keywords' + } + { + 'include': '#function_infix' + } + { + 'include': '#data_ctor' + } + { + 'include': '#infix_op' + } + { + 'include': '#constants_numeric_decimal' + } + { + 'include': '#constant_numeric' + } + { + 'include': '#constant_boolean' + } + { + 'include': '#string_triple_quoted' + } + { + 'include': '#string_single_quoted' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#markup_newline' + } + { + 'include': '#double_colon_parens' + } + { + 'include': '#double_colon_inlined' + } + { + 'include': '#double_colon_orphan' + } + { + 'include': '#comments' + } + { + 'name': 'keyword.other.arrow.purescript' + 'match': '\\<-|-\\>' + } + { + 'name': 'keyword.operator.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } +] +'repository': + 'module_declaration': 'patterns': [ { - 'include': '#comments' + 'name': 'meta.declaration.module.purescript' + 'begin': '^\\s*\\b(module)(?!\')\\b' + 'end': '(\\bwhere\\b)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#module_name' + } + { + 'include': '#module_exports' + } + { + 'name': 'invalid.purescript' + 'match': '[a-z]+' + } + ] } + ] + 'function_infix': + 'patterns': [ { - 'include': '#module_name' + 'name': 'keyword.operator.function.infix.purescript' + 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*.*(`)' + 'captures': + '1': + 'name': 'punctuation.definition.entity.purescript' + '2': + 'name': 'punctuation.definition.entity.purescript' } + ] + 'typeclass_declaration': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'meta.declaration.typeclass.purescript' + 'begin': '^\\s*\\b(class)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'beginCaptures': + '1': + 'name': 'storage.type.class.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } + ] + 'instance_declaration': + 'patterns': [ { - 'name': 'invalid.purescript' - 'match': '[a-z]+' + 'name': 'meta.declaration.instance.purescript' + 'begin': '^\\s*\\b(else\\s+)?(newtype\\s+)?(instance)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.typeclass.purescript' - 'begin': '^\\s*\\b(class)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'beginCaptures': - '1': - 'name': 'storage.type.class.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'derive_declaration': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.declaration.derive.purescript' + 'begin': '^\\s*\\b(derive)(\\s+newtype)?(\\s+instance)?(?!\')\\b' + 'end': '^(?=\\S)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.instance.purescript' - 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(newtype\\s+)?(instance)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'foreign_import_data': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.foreign.data.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.kind-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + '5': + 'name': 'entity.name.type.purescript' + '6': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] } ] - } - { - 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.kind-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - '5': - 'name': 'entity.name.type.purescript' - '6': - 'name': 'keyword.other.double-colon.purescript' + 'foreign_import': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.foreign.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'entity.name.function.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] } + ] + 'module_import': + 'patterns': [ { - 'include': '#kind_signature' + 'name': 'meta.import.purescript' + 'begin': '^\\s*\\b(import)(?!\')\\b' + 'end': '^(?=\\S)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#module_name' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#comments' + } + { + 'include': '#module_exports' + } + { + 'match': '\\b(as|hiding)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] } ] - } - { - 'name': 'meta.foreign.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'entity.name.function.purescript' + 'type_kind_signature': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.declaration.type.data.signature.purescript' + 'begin': '^(data|newtype)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷))' + 'end': '(?=^\\S)' + 'beginCaptures': + '1': + 'name': 'storage.type.data.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + '3': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'match': '(?:(?:\\b([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' + 'captures': + '1': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + ] } + ] + 'data_type_declaration': + 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.declaration.type.data.purescript' + 'begin': '^(\\s)*(data|newtype)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'include': '#comments' + } + { + 'match': '(?<=(\\||=)\\s*)([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'captures': + '2': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.import.purescript' - 'begin': '^\\s*\\b(import)(?!\')\\b' - 'end': '($|(?=--))' - 'beginCaptures': - '1': + 'type_synonym_declaration': + 'patterns': [ + { + 'name': 'meta.declaration.type.type.purescript' + 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + { + 'include': '#comments' + } + ] + } + ] + 'infix_op_declaration': + 'patterns': [ + { + 'name': 'meta.infix.declaration.purescript' + 'begin': '^\\b(infix[l|r]?)(?!\')\\b' + 'end': '($)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#data_ctor' + } + { + 'name': 'constant.numeric.purescript' + 'match': ' \\d+ ' + } + { + 'match': '([\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+)' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + { + 'match': '\\b(type)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'entity.name.type.purescript' + } + { + 'match': '\\b(as|type)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] + } + ] + 'keywords_orphan': + 'patterns': [ + { 'name': 'keyword.other.purescript' + 'match': '^\\s*\\b(derive|where|data|type|newtype|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' + } + ] + 'typed_hole': 'patterns': [ { - 'include': '#module_name' + 'name': 'entity.name.function.typed-hole.purescript' + 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' } + ] + 'control_keywords': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'keyword.control.purescript' + 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' } + ] + 'constants_numeric_decimal': + 'patterns': [ + { + 'name': 'constant.numeric.decimal.purescript' + 'match': '(?x)\n(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ { - 'include': '#data_ctor' + 'include': '$self' } ] '2': + 'name': 'keyword.other.double-colon.purescript' + '3': 'name': 'meta.type-signature.purescript' 'patterns': [ { @@ -204,216 +652,66 @@ } ] } - { - 'match': '\\|' - 'captures': - '0': - 'name': 'punctuation.separator.pipe.purescript' - } - { - 'include': '#record_types' - } ] - } - { - 'name': 'meta.declaration.type.type.purescript' - 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'storage.type.data.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_inlined': + 'patterns': [ + { 'patterns': [ { - 'include': '#type_signature' + 'match': '((?:::|∷))(.*)(?=<-| """| })' + 'captures': + '1': + 'name': 'keyword.other.double-colon.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - 'patterns': [ - { - 'match': '=' - 'captures': - '0': - 'name': 'keyword.operator.assignment.purescript' - } - { - 'include': '#type_signature' - } - { - 'include': '#record_types' - } - { - 'include': '#comments' - } - ] - } - { - 'name': 'keyword.other.purescript' - 'match': '^\\s*\\b(derive|where|data|type|newtype|infix[lr]?|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' - } - { - 'name': 'entity.name.function.typed-hole.purescript' - 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - } - { - 'name': 'storage.type.purescript' - 'match': '^\\s*\\b(data|type|newtype)(?!\')\\b' - } - { - 'name': 'keyword.control.purescript' - 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' - } - { - 'name': 'constant.numeric.hex.purescript' - 'match': '\\b(?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - 'captures': - '1': - 'patterns': [ - { - 'include': '$self' - } - ] - '2': - 'name': 'keyword.other.double-colon.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_orphan': + 'patterns': [ + { + 'begin': '(\\s*)(?:(::|∷))(\\s*)$' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' 'patterns': [ { 'include': '#type_signature' } ] - } - { - 'begin': '^(\\s*)(?:(::|∷))' - 'beginCaptures': - '2': - 'name': 'keyword.other.double-colon.purescript' - 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' + } + ] + 'markup_newline': 'patterns': [ { - 'include': '#type_signature' + 'name': 'markup.other.escape.newline.purescript' + 'match': '\\\\$' } ] - } - { - 'include': '#data_ctor' - } - { - 'include': '#comments' - } - { - 'include': '#infix_op' - } - { - 'name': 'keyword.other.arrow.purescript' - 'match': '\\<-|-\\>' - } - { - 'name': 'keyword.operator.purescript' - 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' - } - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } -] -'repository': 'block_comment': 'patterns': [ { @@ -448,55 +746,10 @@ ] } ] - 'record_types': - 'patterns': [ - { - 'name': 'meta.type.record.purescript' - 'begin': '\\{' - 'beginCaptures': - '0': - 'name': 'keyword.operator.type.record.begin.purescript' - 'end': '\\}' - 'endCaptures': - '0': - 'name': 'keyword.operator.type.record.end.purescript' - 'patterns': [ - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } - { - 'include': '#record_field_declaration' - } - { - 'include': '#comments' - } - ] - } - ] 'comments': 'patterns': [ { - 'begin': '(^[ \\t]+)?(?=--+\\s+\\|)' - 'end': '(?!\\G)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.purescript' - 'patterns': [ - { - 'name': 'comment.line.double-dash.documentation.purescript' - 'begin': '(--+)\\s+(\\|)' - 'end': '\\n' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.comment.purescript' - '2': - 'name': 'punctuation.definition.comment.documentation.purescript' - } - ] - } - { - 'begin': '(^[ \\t]+)?(?=--+(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]))' + 'begin': '(^[ \\t]+)?(?=--+)' 'end': '(?!\\G)' 'beginCaptures': '1': @@ -595,6 +848,64 @@ { 'include': '#type_signature' } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] + 'row_types': + 'patterns': [ + { + 'name': 'meta.type.row.purescript' + 'begin': '\\((?=\\s*([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|"[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*"|"[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*")\\s*(::|∷))' + 'end': '(?=^\\S)' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } + ] + } + ] + 'record_types': + 'patterns': [ + { + 'name': 'meta.type.record.purescript' + 'begin': '\\{(?!-)' + 'beginCaptures': + '0': + 'name': 'keyword.operator.type.record.begin.purescript' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'keyword.operator.type.record.end.purescript' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } ] } ] @@ -602,8 +913,8 @@ 'patterns': [ { 'name': 'meta.record-field.type-declaration.purescript' - 'begin': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' - 'end': '(?=([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|})' + 'begin': '((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'end': '(?=((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|}| \\)|^(?!\\1[ \\t]|[ \\t]*$))' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '1': @@ -612,15 +923,22 @@ 'name': 'entity.other.attribute-name.purescript' 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } + { + 'name': 'string.quoted.double.purescript' + 'match': '\\"([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\"' + } ] '2': 'name': 'keyword.other.double-colon.purescript' 'patterns': [ + { + 'include': '#record_types' + } { 'include': '#type_signature' } { - 'include': '#record_types' + 'include': '#comments' } ] } @@ -646,6 +964,9 @@ ] 'type_signature': 'patterns': [ + { + 'include': '#record_types' + } { 'name': 'meta.class-constraints.purescript' 'match': '(?:(?:\\()(?:(?(?:(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*\\g)?))))(?:\\s*(?:,)\\s*\\g)?))(?:\\))(?:\\s*(=>|<=|⇐|⇒)))' @@ -674,11 +995,11 @@ } { 'name': 'keyword.other.arrow.purescript' - 'match': '->|→' + 'match': '(?|→)' } { 'name': 'keyword.other.big-arrow.purescript' - 'match': '=>|⇒' + 'match': '(?|⇒)' } { 'name': 'keyword.other.big-arrow-left.purescript' @@ -688,6 +1009,9 @@ 'name': 'keyword.other.forall.purescript' 'match': 'forall|∀' } + { + 'include': '#string_double_quoted' + } { 'include': '#generic_type' } @@ -697,6 +1021,10 @@ { 'include': '#comments' } + { + 'name': 'keyword.other.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } ] 'type_name': 'patterns': [ diff --git a/src/purescript.coffee b/src/purescript.coffee index 2d6008b..75924ac 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -173,7 +173,7 @@ purescriptGrammar = function_infix: patterns: [ name: 'keyword.operator.function.infix' - match: /(`){functionName}(`)/ + match: /(`){functionName}.*(`)/ captures: 1: name: 'punctuation.definition.entity' 2: name: 'punctuation.definition.entity' @@ -406,7 +406,7 @@ purescriptGrammar = include: '#data_ctor' , name: 'constant.numeric' - match: /\d+/ + match: / \d+ / , match: /({operator})/ captures: @@ -543,7 +543,7 @@ purescriptGrammar = '\\(', '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -567,25 +567,33 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-)' + match: '({doubleColon})(.*)(?=<-| """| })' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ include: '#type_signature' - ]} ] , patterns: [ - begin: '({doubleColon})' - end: /(?=^\S)/ - beginCaptures: + match: '({doubleColon})(.*)(?!<-| """| })' + captures: 1: name: 'keyword.other.double-colon' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] + 2: {name: 'meta.type-signature', patterns: [ + include: '#type_signature' + ]} ] + # , + # patterns: [ + # begin: '({doubleColon})' + # end: /(?=^\S)/ + # beginCaptures: + # 1: name: 'keyword.other.double-colon' + # patterns: [ + # include: "#record_types" + # include: '#type_signature' + # ] + # ] ] double_colon_orphan: patterns: [ diff --git a/test/Main.purs b/test/Main.purs index a068ad7..1095ad0 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -86,10 +86,10 @@ newtype MySub vnode msg = MySub (SubRec vnode msg) --- infix operators +-- infix operators (with numbers in hame) -- operators that contain -- within -infixr 0 apply as :--> -- comment as :--> -infixl 0 applyFlipped as <--: +infixr 0 apply2 as :--> -- comment as :--> +infixl 0 apply2Flipped as <--: --- @@ -385,6 +385,10 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 +-- infix function with params -- no proper +-- maybe no need because its weird +infixFun = 1 `flip add` 2 + -- function declaration, do, where toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment @@ -402,6 +406,17 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- no proper for params arrow first +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents + +-- no proper fro colons in string inside parens +x = ("func1 ::") + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -481,6 +496,12 @@ px = Proxy :: Proxy """fdsfsdf px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ y) + where + y = 1 + + -- quotes after type def From 26934ed3b5f57d8c1519274d48fea4589e8cd459 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:47:11 +0500 Subject: [PATCH 4/6] fix foreign import data --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- test/Main.purs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index b05fdd0..7fb008e 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -238,7 +238,7 @@ 'patterns': [ { 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.kind-signature.purescript' 'beginCaptures': diff --git a/src/purescript.coffee b/src/purescript.coffee index 75924ac..ca8efd1 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -238,7 +238,7 @@ purescriptGrammar = foreign_import_data: patterns: [ name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)(?:\s+({classNameOne})\s*({doubleColon}))?/ + begin: /^(\s*)(foreign)\s+(import)\s+(data)\s(?:\s+({classNameOne})\s*({doubleColon}))?/ end: /{indentBlockEnd}/ contentName: 'meta.kind-signature' beginCaptures: diff --git a/test/Main.purs b/test/Main.purs index 1095ad0..6dc35da 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -31,7 +31,7 @@ foreign import --comment foreign import data --comment foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment - +foreign import databaseName :: Db -> Name -- import data with record type foreign import data R :: { prop :: String } From e07f97a2f2ff4d688b3737be420ce4490e114b71 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 27 Dec 2023 16:20:04 +0500 Subject: [PATCH 5/6] fix double colon in quotes, add arrow first signature support --- grammars/purescript.cson | 31 +++++++++++++++++++++++++++- src/purescript.coffee | 33 ++++++++++++++++++++++++++++-- test/Main.purs | 44 ++++++++++++++++++++-------------------- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 7fb008e..7af54b6 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -57,6 +57,9 @@ { 'include': '#function_type_declaration' } + { + 'include': '#function_type_declaration_arrow_first' + } { 'include': '#typed_hole' } @@ -634,7 +637,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -857,6 +860,32 @@ ] } ] + 'function_type_declaration_arrow_first': + 'patterns': [ + { + 'name': 'meta.function.type-declaration.purescript' + 'begin': '^(\\s*)(?:\\s(::|∷)(?!.*<-))' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] 'row_types': 'patterns': [ { diff --git a/src/purescript.coffee b/src/purescript.coffee index ca8efd1..0fa7f16 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -76,6 +76,10 @@ purescriptGrammar = listMaybe('ctorArgs',/{ctorArgs}/,/\s+/) typeDecl: /.+?/ indentChar: /[ \t]/ + # In indent block here \1 means first captured group, + # + # So if the first capture block is (\s*) then end of indent block will be the line + # with less spaced then in captured block. indentBlockEnd: /^(?!\1{indentChar}|{indentChar}*$)/ maybeBirdTrack: /^/ doubleColon: ///(?: :: | ∷ )/// @@ -102,6 +106,8 @@ purescriptGrammar = include: '#foreign_import' , include: '#function_type_declaration' + , + include: '#function_type_declaration_arrow_first' , include: '#typed_hole' , @@ -541,9 +547,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()"]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()}]|\\(\\g\\))*)', + '(?(?:[^()"}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -747,7 +753,9 @@ purescriptGrammar = \s* (?: ( :: | ∷ ) (?! .* <- ) ) /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ contentName: 'meta.type-signature' beginCaptures: 2: name: 'entity.name.function' @@ -762,6 +770,27 @@ purescriptGrammar = include: '#row_types' ] + function_type_declaration_arrow_first: + name: 'meta.function.type-declaration' + begin: /// + ^ + ( \s* ) + (?: \s ( :: | ∷ ) (?! .* <- ) ) + /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'keyword.other.double-colon' + patterns: [ + include: '#double_colon' + , + include: '#type_signature' + , + include: '#record_types' + , + include: '#row_types' + ] row_types: patterns: [ name: 'meta.type.row' diff --git a/test/Main.purs b/test/Main.purs index 6dc35da..5df18b5 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -340,7 +340,7 @@ quoted = { "A": "a" -- comment , "B": fn (1 :: Int) x 2 -- typed param in parens , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Int) + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") , a: 2 } @@ -378,15 +378,10 @@ foo :: List Int -> List Int foo = map ?myHole - --- Function, forall - - -- infix functions infixFun = 1 `add` 2 --- infix function with params -- no proper --- maybe no need because its weird +-- infix function with params infixFun = 1 `flip add` 2 @@ -406,16 +401,11 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty --- no proper for params arrow first -_run - :: forall m - . Functor m - => Config - -> SpecT Aff Unit m Unit - -> m TestEvents --- no proper fro colons in string inside parens +-- colons in string inside parens x = ("func1 ::") +-- code coloring after end of quotes +text = (" ::" + global) -- signatures in ide tooltips SomeType :: (a :: Int) @@ -431,13 +421,9 @@ AVar :: Type → Type addIf false = const [] --- double colon inside quoted string -text = (" ::" + global) - - --- fn type signature without :: in the same line lacks highlighting --- it seems to be a bit harder case for proper handling --- maybe it's also a sign that it is better not to have it in the code :-) +-- fn type signature without (arrow first style) :: in the same line lacks +-- highlighting it seems to be a bit harder case for proper handling maybe it's +-- also a sign that it is better not to have it in the code :-) fn -- line orphan signature :: forall a. a -> String @@ -448,6 +434,20 @@ fn a = "1" -> b + "1" _ -> b + a +-- arrow first signature multiline +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents +_run c s = some + where + -- arrow first signature indented + some + :: Int + some = 1 + -- if' fn and if statement with if' = if true then "false" else "true" From e8b9f54e0c8e8821e48a9804a10352e36d474e68 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 8 May 2024 17:27:33 +0500 Subject: [PATCH 6/6] fixes for inline signature in colons --- grammars/purescript.cson | 46 ++++++++++---- src/purescript.coffee | 55 +++++++++------- test/Main.purs | 134 ++++++++++++++++++++------------------- 3 files changed, 132 insertions(+), 103 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 7af54b6..c412799 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -100,13 +100,13 @@ 'include': '#markup_newline' } { - 'include': '#double_colon_parens' + 'include': '#string_double_colon_parens' } { - 'include': '#double_colon_inlined' + 'include': '#double_colon_parens' } { - 'include': '#double_colon_orphan' + 'include': '#double_colon_inlined' } { 'include': '#comments' @@ -585,6 +585,25 @@ 'name': 'punctuation.definition.string.end.purescript' } ] + 'string_double_colon_parens': + 'patterns': [ + { + 'match': '\\((.*?)("(?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))*(::|∷)((?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_])))*")' + 'captures': + '1': + 'patterns': [ + { + 'include': '$self' + } + ] + '2': + 'patterns': [ + { + 'include': '$self' + } + ] + } + ] 'string_double_quoted': 'patterns': [ { @@ -637,7 +656,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -661,7 +680,7 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?=<-| """| })' + 'match': '((?:::|∷))(.*?)(?=<-| """)' 'captures': '1': 'name': 'keyword.other.double-colon.purescript' @@ -678,17 +697,16 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?!<-| """| })' - 'captures': + 'begin': '((?:::|∷))' + 'end': '(?=^(\\s|\\S))' + 'beginCaptures': '1': 'name': 'keyword.other.double-colon.purescript' - '2': - 'name': 'meta.type-signature.purescript' - 'patterns': [ - { - 'include': '#type_signature' - } - ] + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] } diff --git a/src/purescript.coffee b/src/purescript.coffee index 0fa7f16..578f443 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -135,12 +135,14 @@ purescriptGrammar = include: '#string_double_quoted' , include: '#markup_newline' + , + include: '#string_double_colon_parens' , include: '#double_colon_parens' , include: '#double_colon_inlined' - , - include: '#double_colon_orphan' + # , + # include: '#double_colon_orphan' , include: '#comments' , @@ -504,7 +506,23 @@ purescriptGrammar = # {character} macro has 4 capture groups, here 3-6 7: name: 'punctuation.definition.string.end' ] - + # To match string that containt double colon as string, to play well with + # #double_colon_parens rule. + string_double_colon_parens: + patterns: [ + match: [ + '\\(', + '(.*?)' + '("{character}*(::|∷)({character})*")', + ].join('') + captures: + 1: patterns: [ + include: '$self' + ] + 2: patterns: [ + include: '$self' + ] + ] string_double_quoted: patterns: [ name: 'string.quoted.double' @@ -547,9 +565,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()"]|\\(\\g\\))*)', + '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()"}]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -573,7 +591,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-| """| })' + match: '({doubleColon})(.*?)(?=<-| """)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -582,24 +600,15 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)(?!<-| """| })' - captures: + begin: '({doubleColon})' + end: /(?=^(\s|\S))/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [ - include: '#type_signature' - ]} + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] - # , - # patterns: [ - # begin: '({doubleColon})' - # end: /(?=^\S)/ - # beginCaptures: - # 1: name: 'keyword.other.double-colon' - # patterns: [ - # include: "#record_types" - # include: '#type_signature' - # ] - # ] ] double_colon_orphan: patterns: [ @@ -622,9 +631,9 @@ purescriptGrammar = # double_colon_orphan: # patterns: [ # begin: /// - # ^ # ( \s* ) # (?: ( :: | ∷ ) ) + # ( \s* ) # /// # beginCaptures: # 2: name: 'keyword.other.double-colon' diff --git a/test/Main.purs b/test/Main.purs index 5df18b5..187e0e9 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -33,22 +33,20 @@ foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment foreign import databaseName :: Db -> Name + -- import data with record type foreign import data R :: { prop :: String } - -- line comments with no space between first char --| some - -- comments with operators after --# some --! some - -- Containers @@ -111,7 +109,6 @@ infixl 2 Inl as $% infixr 2 Inr as %$ - -- type class signatures @@ -190,7 +187,6 @@ instance functorA :: Functor A where map = split -- comment - -- chained instances @@ -211,7 +207,6 @@ else instance showA :: MyShow a where else newtype instance showA :: MyShow a where - -- Records with fields that are reserved words @@ -328,23 +323,6 @@ type Quoted = } --- inlined record type def -quoted :: - { "A" :: Int -- comment - , a :: Boolean - , "B" :: Number - , b :: Int -- comment - , "x" :: SmallCap - } -quoted = - { "A": "a" -- comment - , "B": fn (1 :: Int) x 2 -- typed param in parens - , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") - , a: 2 - } - - -- inlined record type def inside foreign import foreign import createSource :: String -> @@ -356,23 +334,6 @@ foreign import createSource :: Effect EventSource --- proxy -proxy = Proxy :: Proxy Int -- k is Type - - --- orphan inline signature -x = 1 - :: - Int -x = {a: 1} :: - { | (a :: Int) } - - --- row type -intAtFoo :: forall r. Variant ( foo :: Int | r ) -intAtFoo = inj (Proxy :: Proxy "foo") 42 - - -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -381,6 +342,7 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 + -- infix function with params infixFun = 1 `flip add` 2 @@ -401,11 +363,74 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- INLINE SIGNATURES + + +-- inlined record type def +quoted :: + { "A" :: Int -- comment + , a :: Boolean + , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap + } +quoted = + { "A": "a" -- comment + , "B": fn (1 :: Int) x 2 -- typed param in parens + , "C": 1 :: Proxy "xxx" -- typed param without parens + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") + , a: 2 + } + + +-- proxy +p :: Proxy "xxx" +p = Proxy + --- colons in string inside parens -x = ("func1 ::") +proxy = Proxy :: Proxy Int -- k is Type + + +-- orphan inline signature +x = 1 + :: + Int +x = {a: 1} :: + { | (a :: Int) } + + +-- row type +-- no proper for ctor variant tag value (double_colon_inlined) +injFoo :: forall r. Variant ( foo :: Int | r ) +injFoo = inj (Proxy :: Proxy "foo") P.ddd Cons (some) + + +-- operators inside type signature ==> +type Schema + = { widgets :: { id :: Int } ==> Array Widget --comment + } + + +px = Proxy :: Proxy "fdsfsdf" + + +-- quotes after type def +px = Proxy :: Proxy """fdsfsdf + fdsfdsfsdf + """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ X) + where + y = 1 + + +-- double colons in string inside parens +x = ((x :: Int) "func1 ::" <> "func1 ::" <> ((show 1) :: Proxy "x" )) -- code coloring after end of quotes text = (" ::" + global) +text = (""" ::""" + global) + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -434,6 +459,7 @@ fn a = "1" -> b + "1" _ -> b + a + -- arrow first signature multiline _run :: forall m @@ -466,13 +492,6 @@ case' = if true else "true" --- operators inside type signature ==> -type Schema - = { widgets :: { id :: Int } ==> Array Widget --comment - } - - - -- constants @@ -485,23 +504,6 @@ decimal = 41.0 hex = 0xE0 -px = Proxy :: Proxy "fdsfsdf" - - --- quotes after type def -px = Proxy :: Proxy """fdsfsdf - fdsfdsfsdf - """ - -px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" - - -px = - ({ x = Set.empty :: Set X { x :: Int } } /\ y) - where - y = 1 - - -- quotes after type def