Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PureScript #708

Open
wants to merge 178 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
b056a22
initial commit
Maskhjarna Aug 7, 2023
6bb03ff
purescript
Maskhjarna Aug 7, 2023
eba6271
fix
Maskhjarna Aug 7, 2023
977b39e
less haskell
Maskhjarna Aug 7, 2023
3cec835
add queries
Maskhjarna Aug 7, 2023
f62d45d
data
Maskhjarna Aug 15, 2023
a4cb665
type sum
Maskhjarna Aug 15, 2023
aafdc61
nested records
Maskhjarna Aug 15, 2023
f3710f6
compliment
Maskhjarna Aug 15, 2023
0865c02
tear stuff out
Maskhjarna Aug 16, 2023
6c245aa
this one too
Maskhjarna Aug 16, 2023
94e2574
function signatures and record expressions/patterns
Maskhjarna Aug 16, 2023
6cb0a28
record mutations
Maskhjarna Aug 16, 2023
8a73335
don't interpret braces as layouts
Maskhjarna Aug 16, 2023
5b91ac3
open types
Maskhjarna Aug 16, 2023
7d2f028
simple data? maybe?
Maskhjarna Aug 16, 2023
e414b29
add readme
Maskhjarna Aug 16, 2023
0d05d24
fix imports
Maskhjarna Aug 16, 2023
1289357
Merge branch 'main' of github.com:Maskhjarna/tree-sitter-purescript
Maskhjarna Aug 16, 2023
6e2317d
better module context
Maskhjarna Aug 16, 2023
a9af5de
add queries
Maskhjarna Aug 17, 2023
6422704
Update the queries file so test works
FredTheDino Aug 19, 2023
7b01a25
Add some very basic tests
FredTheDino Aug 19, 2023
b5c258d
Fix some of the imports, expand on the tests, remove pragma (which pu…
FredTheDino Aug 19, 2023
b07d3f3
Merge pull request #1 from FredTheDino/main
Maskhjarna Aug 21, 2023
f7c88da
remove unnecessary seq, fix broken _decl_module
Maskhjarna Aug 24, 2023
94b4ce7
- Remove support for Haskell-list comprehensions
FredTheDino Aug 27, 2023
dd0a1fa
Fix the parsing of multiple top level declarations that I broke 2 com…
FredTheDino Aug 27, 2023
004e849
Update the tests
FredTheDino Aug 27, 2023
81a50f0
Merge remote-tracking branch 'upstream/main'
FredTheDino Aug 27, 2023
5f5a030
Merge pull request #5 from FredTheDino/main
Maskhjarna Sep 6, 2023
2b88d55
Added Unicode versions of builtin operators to highlight queries
postsolar Sep 19, 2023
728be10
Kind declarations
postsolar Sep 20, 2023
995ebb2
Update the grammar
postsolar Sep 20, 2023
8380a4c
Add `foreign import data…` kind value declaration
postsolar Sep 20, 2023
433fb38
Update grammar
postsolar Sep 20, 2023
a691348
Make kind and kind values declarations be declared next to each other…
postsolar Sep 20, 2023
43093b5
Add tests for kind and kind value declarations
postsolar Sep 20, 2023
4131c3f
Update grammar
postsolar Sep 20, 2023
5549dc1
Triple-quote strings
postsolar Sep 20, 2023
8231d16
Include highlights updates for triple-quoted strings
postsolar Sep 20, 2023
c65d3ec
Qualified record updates
postsolar Sep 20, 2023
4b5e4a5
Fix qualified imports with dots
postsolar Sep 20, 2023
e31aed8
Add derive declarations, add tests for derive declarations
postsolar Sep 21, 2023
d14450f
Fix comments which start with non-alphanumerics
postsolar Sep 21, 2023
6f14212
Merge pull request #10 from postsolar/highlight-unicode-operators
Maskhjarna Sep 25, 2023
7b59bdf
Merge pull request #12 from postsolar/kind-declarations
Maskhjarna Sep 25, 2023
a47deb4
Merge pull request #13 from postsolar/triple-quote-strings
Maskhjarna Sep 25, 2023
0aad0ff
Merge pull request #14 from postsolar/qualified-record-updates
Maskhjarna Sep 25, 2023
6ffc25d
Merge pull request #15 from postsolar/qualified-import-as
Maskhjarna Sep 25, 2023
92af5e2
Merge pull request #16 from postsolar/derive-keywords
Maskhjarna Sep 25, 2023
a619f51
Merge pull request #17 from postsolar/fix-comments
Maskhjarna Sep 25, 2023
c29ac31
& -> &&
Maskhjarna Sep 25, 2023
26ad803
comment out broken tripple quoted string qurey
Maskhjarna Sep 26, 2023
a6a3105
Bring identifiers regex pattern in accordance with PS spec
postsolar Sep 26, 2023
e0d0378
Quoted record fields
postsolar Sep 26, 2023
2692624
Full rework of rows and records
postsolar Sep 29, 2023
671453d
Flatten row variable nodes
postsolar Sep 29, 2023
b8c9227
Typo and better comment
postsolar Sep 29, 2023
0ec5985
Merge pull request #20 from postsolar/fix-identifiers
Maskhjarna Oct 2, 2023
0e36a88
run tree sitter codegen; add back query for triple-quoted strings
Maskhjarna Oct 2, 2023
2aa8156
Fix open rows
postsolar Oct 7, 2023
e87796c
Remove splice expressions and fix patterns with records
postsolar Oct 7, 2023
540a933
Add more tests for records, clearer filenames for rows and records
postsolar Oct 7, 2023
e62ba0a
Cleanup top grammar
postsolar Oct 7, 2023
9e55c3b
Remove module `misc.js`
postsolar Oct 7, 2023
3f1fc3c
Add conflict rules for record updates
postsolar Oct 9, 2023
af670f7
Merge pull request #21 from postsolar/quoted-fields
Maskhjarna Oct 11, 2023
79f020f
Add makefile to build the library
tautologico Oct 16, 2023
8949c1f
Add .gitignore
postsolar Oct 31, 2023
7e6e1b8
Add .gitattributes
postsolar Oct 31, 2023
91e43d0
Add `parse/` dir to .gitignore
postsolar Oct 31, 2023
863905f
Add a script to remove ranges from `tree-sitter parse` output
postsolar Oct 31, 2023
2e644d3
Add more tests and make tests atomic
postsolar Nov 1, 2023
708396b
Remove old tests
postsolar Nov 1, 2023
adb86aa
Update tests with current parser output
postsolar Nov 1, 2023
7cc3a4f
Run codegen
postsolar Nov 1, 2023
c0d2815
Update literals
postsolar Nov 1, 2023
0b026d1
Simplify id.js, add infix expressions, fix operator declarations, ren…
postsolar Nov 1, 2023
07fd4b0
Update case-of expressions
postsolar Nov 1, 2023
c78b519
Remove multi-way if, make if-then-else support wildcards
postsolar Nov 1, 2023
610a13c
Remove Haskell-style lambda-case
postsolar Nov 1, 2023
20fa0ef
Remove arithmetic sequence expressions
postsolar Nov 1, 2023
8e0fc7d
Cleanup `rows_and_records.js`
postsolar Nov 1, 2023
29f2843
Fix newtypes declarations and simplify data declarations
postsolar Nov 1, 2023
37df657
Expression/operator sections
postsolar Nov 1, 2023
e740786
Merge pull request #1 from postsolar/infix-wildcards
postsolar Nov 1, 2023
b8cd7ca
Add .psc-ide to .gitignore
postsolar Nov 1, 2023
6ca9121
Add `?x` holes
postsolar Nov 1, 2023
d524f67
Add highlights queries for `?x` holes
postsolar Nov 2, 2023
0bd8386
Refactor `type.js`, `class.js`, `data.js`
postsolar Nov 2, 2023
524e0dc
A bit of cleanup
postsolar Nov 2, 2023
4147260
Flatten type operators' nodes
postsolar Nov 2, 2023
6aa19ae
Codegen
postsolar Nov 2, 2023
d9dfaf8
Update queries
postsolar Nov 2, 2023
bae54ec
Update tests
postsolar Nov 2, 2023
6552513
Make function/value declarations' nodes more consistent with other de…
postsolar Nov 2, 2023
69b99e8
Update tests
postsolar Nov 2, 2023
49ffb8b
Update queries
postsolar Nov 2, 2023
81093fc
Codegen
postsolar Nov 2, 2023
fc76315
Add instance names
postsolar Nov 2, 2023
b56100d
Update highlights for instance names
postsolar Nov 2, 2023
f08097c
Fix qualified type operators
postsolar Nov 2, 2023
93e098f
Codegen
postsolar Nov 2, 2023
83e8349
Revert "Make function/value declarations' nodes more consistent with …
postsolar Nov 4, 2023
de9ec54
Revert "Update tests"
postsolar Nov 4, 2023
2ac4138
Revert "Update queries"
postsolar Nov 4, 2023
349705d
Better binding for quantifiers
postsolar Nov 4, 2023
d3cb49a
Update tests and queries
postsolar Nov 4, 2023
15fcb81
Run codegen
postsolar Nov 4, 2023
31e4bfd
Better nodes for annotated quantifiers
postsolar Nov 4, 2023
eafa733
Fix qualified class names
postsolar Nov 4, 2023
409900c
Fix exports
postsolar Nov 4, 2023
11c63bb
Fix else-instances
postsolar Nov 4, 2023
81e3be3
Highlight queries for else-instances
postsolar Nov 4, 2023
11f47bf
Fix integers parsing
postsolar Nov 4, 2023
e92b9d7
Fix operators in patterns; minor cleanup in `pat.js`
postsolar Nov 4, 2023
a117985
Add record accessors
postsolar Nov 4, 2023
6b2942d
Add record access expressions (`{}.field` or `({}).field`)
postsolar Nov 4, 2023
ba6bba6
Add annotated type variable to typeclass heads
postsolar Nov 4, 2023
a085dce
Add highlight queries for record/row labels and accessors
postsolar Nov 4, 2023
3ec53fe
Add type roles support
postsolar Nov 4, 2023
593193b
Merge pull request #2 from postsolar/fix-signatures
postsolar Nov 4, 2023
1615ac3
Update README.md
postsolar Nov 4, 2023
9f44e54
Remove references to files in 'bindings' directory not present in repo.
tautologico Nov 5, 2023
812362a
Update README.md
postsolar Nov 7, 2023
ee2017d
Fix data constructors in operator declarations
postsolar Nov 7, 2023
9b4707d
Add new kind's type signatures
postsolar Nov 7, 2023
b4955d7
Create LICENSE
postsolar Nov 7, 2023
dddc2e8
Remove `pat_type_binder`
postsolar Nov 7, 2023
3974ea2
Remove pattern views
postsolar Nov 7, 2023
82a39e1
Merge pull request #8 from tautologico/add-makefile
postsolar Nov 7, 2023
e055b28
Expand the set of options for the LHS of record updates
postsolar Nov 8, 2023
19f94cc
Fix empty array pattern
postsolar Nov 8, 2023
4c48dcf
Merge branch 'main' into typed-record-patterns
postsolar Nov 8, 2023
43d30eb
Merge pull request #7 from postsolar/typed-record-patterns
postsolar Nov 8, 2023
8f14fde
Fix missing optional `where`-block in `case` branches
postsolar Nov 8, 2023
389de6c
Merge branch 'main' of https://github.com/postsolar/tree-sitter-pures…
postsolar Nov 8, 2023
3f43da5
Update LICENSE
postsolar Nov 8, 2023
b715f94
Fix triple-quoted strings
postsolar Nov 8, 2023
610e3f9
Fix triple-quote strings (again)
postsolar Nov 8, 2023
d13aa3e
Ok I think this time it works (triple-quote strings)
postsolar Nov 8, 2023
aa719f8
Fix `a.b` being identified as infix expression with '.' being the ope…
postsolar Nov 8, 2023
6cde3df
Update highlight queries for record access and record puns
postsolar Nov 8, 2023
ff16592
Merge pull request #11 from postsolar/fix-record-access
postsolar Nov 8, 2023
f590cfa
Add (n)vim queries
postsolar Nov 8, 2023
d86ad5b
Notes on (neo)vim support
postsolar Nov 8, 2023
f0b7de4
Quoted fields in record access expressions
postsolar Nov 8, 2023
b563925
Fix typo in queries
postsolar Nov 8, 2023
e214fce
Fix another typo in queries
postsolar Nov 8, 2023
5ef5592
Update README.md on grammar accuracy
postsolar Nov 8, 2023
f89bd14
Add .ignore
postsolar Nov 12, 2023
684ab30
Try fix `in` in ado blocks
postsolar Nov 13, 2023
fb815b7
Fix nested ado blocks
postsolar Nov 15, 2023
646238b
Add a failing test for an ado-notation case
postsolar Nov 15, 2023
560c21b
Merge pull request #14 from postsolar/fix-ado-in-kw
postsolar Nov 15, 2023
85a9095
Add some npm scripts and update license info in package.json
postsolar Nov 15, 2023
cfd217d
[README] Mention Zed editor support
postsolar Jan 29, 2024
2517b1e
Add a basic Nix devshell (#15)
postsolar Feb 15, 2024
3001de7
Fix target name in `binding.gyp`
maxdeviant Feb 8, 2024
e5b6975
Codegen with `tree-sitter` 0.20.9
postsolar Feb 23, 2024
08cdbb8
fix: scanner: make `state_new()` static (#17)
postsolar Feb 23, 2024
c10f702
Add Rust bindings
postsolar Feb 23, 2024
dff8059
Enable build by msvc
kazatsuyu Jan 31, 2024
7566cbf
A follow-up to MSVC builds
postsolar Feb 23, 2024
82ccfb7
Update `package.json`
postsolar Feb 23, 2024
0554811
Merge pull request #19 from postsolar/add-rust-bindings
postsolar Feb 23, 2024
46e9446
Remove `u` flag from JS regex expressions
postsolar Feb 25, 2024
cbd4c9b
Remove unnecessary conflicts
postsolar Feb 25, 2024
5c45dbb
Amend package.json
postsolar Feb 25, 2024
5b4a731
Update to 0.21.0 (#20)
postsolar Feb 26, 2024
daf9b3e
Update `.gitattributes` and `.gitignore`
postsolar Feb 26, 2024
d85ddc4
Add 'vendored_parsers/tree-sitter-purescript/' from commit 'daf9b3e2b…
bernhard-herzog Apr 30, 2024
712ea58
Add support for PureScript
bernhard-herzog May 2, 2024
66c85e2
Fix formatting
bernhard-herzog May 4, 2024
390ce9d
Merge branch 'master' into purescript
bernhard-herzog May 8, 2024
5181e88
Add PureScript sample files
bernhard-herzog May 10, 2024
ec4cda5
Update sample_files/compare.expected for PureScript support
bernhard-herzog May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-php-src",
extra_files: vec!["scanner.cc"],
},
TreeSitterParser {
name: "tree-sitter-purescript",
src_dir: "vendored_parsers/tree-sitter-purescript-src",
extra_files: vec!["scanner.c"],
},
TreeSitterParser {
name: "tree-sitter-python",
src_dir: "vendored_parsers/tree-sitter-python-src",
Expand Down
3 changes: 3 additions & 0 deletions sample_files/compare.expected
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ f80b47646e7dd2bd3a49393d00657465 -
sample_files/erlang_1.erl sample_files/erlang_2.erl
dccdb8f65d2f099ab1a8cb66011376a2 -

sample_files/fib_1.purs sample_files/fib_2.purs
1b9199c5084fe2647ef8cf04024cb2fa -

sample_files/hack_1.php sample_files/hack_2.php
c2bb0aa7d7b07d6ced79f6a5363e878b -

Expand Down
17 changes: 17 additions & 0 deletions sample_files/fib_1.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)


fib :: Int -> Int
fib 0 = 1
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)


main :: Effect Unit
main = do
log (show (fib 10))
18 changes: 18 additions & 0 deletions sample_files/fib_2.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)


fib :: Int -> Int
fib = go 1 1
where
go a _ 0 = a
go a b n = go b (a + b) (n - 1)


main :: Effect Unit
main = do
log (show (fib 10))
3 changes: 3 additions & 0 deletions src/parse/guess_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub(crate) enum Language {
Pascal,
Perl,
Php,
PureScript,
Python,
Qml,
R,
Expand Down Expand Up @@ -150,6 +151,7 @@ pub(crate) fn language_name(language: Language) -> &'static str {
Pascal => "Pascal",
Perl => "Perl",
Php => "PHP",
PureScript => "PureScript",
Python => "Python",
Qml => "QML",
R => "R",
Expand Down Expand Up @@ -333,6 +335,7 @@ pub(crate) fn language_globs(language: Language) -> Vec<glob::Pattern> {
Php => &[
"*.php", "*.phtml", "*.php3", "*.php4", "*.php5", "*.php7", "*.phps",
],
PureScript => &["*.purs"],
Python => &["*.py", "*.py3", "*.pyi", "*.bzl", "TARGETS", "BUCK", "DEPS"],
Qml => &["*.qml"],
R => &["*.R", "*.r", "*.rd", "*.rsx", ".Rprofile", "expr-dist"],
Expand Down
28 changes: 28 additions & 0 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extern "C" {
fn tree_sitter_pascal() -> ts::Language;
fn tree_sitter_php() -> ts::Language;
fn tree_sitter_perl() -> ts::Language;
fn tree_sitter_purescript() -> ts::Language;
fn tree_sitter_python() -> ts::Language;
fn tree_sitter_qmljs() -> ts::Language;
fn tree_sitter_r() -> ts::Language;
Expand Down Expand Up @@ -850,6 +851,33 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
sub_languages: vec![],
}
}
PureScript => {
let language = unsafe { tree_sitter_purescript() };
TreeSitterConfig {
language,
// The "qualified_" nodes seem to have the same problem
// as e.g. qualified_module in the TreeSitterConfig for
// haskell, namely that the periods between the
// identifiers do not show up in the AST, so we use the
// same workaround here and mark them as atom_nodes.
atom_nodes: vec![
"qualified_constructor",
"qualified_module",
"qualified_operator",
"qualified_variable",
"qualified_type",
]
.into_iter()
.collect(),
delimiter_tokens: vec![("(", ")"), ("[", "]"), ("{", "}")],
highlight_query: ts::Query::new(
language,
include_str!("../../vendored_parsers/highlights/purescript.scm"),
)
.unwrap(),
sub_languages: vec![],
}
}
Python => {
let language = unsafe { tree_sitter_python() };
TreeSitterConfig {
Expand Down
1 change: 1 addition & 0 deletions vendored_parsers/highlights/purescript.scm
1 change: 1 addition & 0 deletions vendored_parsers/tree-sitter-purescript-src
10 changes: 10 additions & 0 deletions vendored_parsers/tree-sitter-purescript/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text eol=lf

src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated
11 changes: 11 additions & 0 deletions vendored_parsers/tree-sitter-purescript/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text eol=lf

src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated

46 changes: 46 additions & 0 deletions vendored_parsers/tree-sitter-purescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Purs
.psc-ide-port

# direnv
.direnv
.envrc

# For small snippets of PS code to parse when debugging
parse/

# Rust artifacts
/Cargo.lock
/target/

# Node artifacts
/build/
/node_modules/

# Swift artifacts
/.build/

# Python artifacts
/dist/
*.egg-info
*.whl

# Zig artifacts
/zig-cache/
/zig-out/

# C artifacts
*.a
*.so
*.so.*
*.dylib
*.dll
*.pc

# Example dirs
/examples/*/

# Grammar volatiles
dsl.d.ts
*.wasm
*.obj
*.o
11 changes: 11 additions & 0 deletions vendored_parsers/tree-sitter-purescript/.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
src/grammar.json
src/node-types.json
src/parser.c
src/tree_sitter/
src/unicode.h

LICENSE

package.json

binding.gyp
71 changes: 71 additions & 0 deletions vendored_parsers/tree-sitter-purescript/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendored_parsers/tree-sitter-purescript/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "tree-sitter-purescript"
description = "PureScript grammar for the tree-sitter parsing library"
version = "0.1.0"
keywords = ["incremental", "parsing", "purescript"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/postsolar/tree-sitter-purescript"
edition = "2021"
license = "MIT"

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "~0.20.10"

[build-dependencies]
cc = "1.0"
22 changes: 22 additions & 0 deletions vendored_parsers/tree-sitter-purescript/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2014 Max Brunsfeld
Copyright (c) 2023 Maskhjarna, postsolar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading