Merge commit 'c7e814975ab0d0d04333d1f32391c41180c58919'

html_output
Wilfred Hughes 2022-01-29 18:19:41 +07:00
commit 7e3bdaf125
12 changed files with 4260 additions and 96 deletions

@ -0,0 +1,4 @@
test
node_modules
build
*.lisp

@ -1,13 +1,13 @@
[package]
name = "tree-sitter-commonlisp"
description = "Common Lisp grammar for the tree-sitter parsing library"
version = "0.2.0"
version = "0.3.0"
keywords = ["incremental", "parsing", "lisp"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/theHamsta/tree-sitter-commonlisp"
edition = "2018"
authors = ["Stephan Seitz"]
license = "GPLv3"
license = "MIT"
build = "bindings/rust/build.rs"
include = [
@ -21,7 +21,7 @@ include = [
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = "0.19.5"
tree-sitter = "0.20.1"
[build-dependencies]
cc = "1.0"

@ -15,3 +15,7 @@ Macros with special respresentation in syntax tree (when written with lowercase
- loop macro
This grammar is used in https://github.com/Wilfred/difftastic to generate syntax-ware diffs for Common Lisp.
## Additional Highlighting Support
Install https://github.com/theHamsta/nvim-treesitter-commonlisp to get highlighting of all functions and macros in the `cl` namespace.

@ -238,7 +238,7 @@ module.exports = grammar(clojure, {
_for_part: $ => seq(repeat($._gap), $.for_clause_word, repeat($._gap), $._form),
accumulation_verb: _ => loopSymbol(/((collect|append|nconc|count|maximize|minimize)(ing)?|sum(ming)?)/),
accumulation_verb: _ => loopSymbol(/(maximize|minimize|(collect|append|nconc|count)(ing)?|sum(ming)?|maximizing|minimizing)/),
for_clause: $ => choice(seq(choice(loopSymbol('for'), loopSymbol('and'), loopSymbol('as')), repeat($._gap), field('variable', $._form), optional(field('type', seq(repeat($._gap), $._form))),
repeat1($._for_part)), loopSymbol('and')),
with_clause: $ => seq(loopSymbol('with'), repeat($._gap), choice($._form, seq($._form, repeat($._gap), field('type', $._form))), repeat($._gap), optSeq(loopSymbol("="), repeat($._gap)), optSeq($._form, repeat($._gap))),

@ -1,13 +0,0 @@
try {
module.exports = require("./build/Release/tree_sitter_lisp_binding");
} catch (error) {
try {
module.exports = require("./build/Debug/tree_sitter_lisp_binding");
} catch (_) {
throw error
}
}
try {
module.exports.nodeTypeInfo = require("./src/node-types.json");
} catch (_) {}

@ -1,19 +1,19 @@
{
"name": "tree-sitter-commonlisp",
"version": "0.2.0",
"version": "0.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "tree-sitter-commonlisp",
"version": "0.2.0",
"license": "GPL-3.0-or-later",
"version": "0.3.0",
"license": "MIT",
"dependencies": {
"nan": "^2.14.2",
"nan": "^2.15.0",
"tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure-1.git#95c7959c461406381b42113dcf4591008c663d21"
},
"devDependencies": {
"tree-sitter-cli": "^0.19.4"
"tree-sitter-cli": "^0.20.4"
}
},
"node_modules/nan": {
@ -22,9 +22,9 @@
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
},
"node_modules/tree-sitter-cli": {
"version": "0.19.5",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.19.5.tgz",
"integrity": "sha512-kRzKrUAwpDN9AjA3b0tPBwT1hd8N2oQvvvHup2OEsX6mdsSMLmAvR+NSqK9fe05JrRbVvG8mbteNUQsxlMQohQ==",
"version": "0.20.4",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.4.tgz",
"integrity": "sha512-G42x0Ev7mxA8WLUfZY+two5LIhPf6R/m7qDZtKxOzE77zXi6didNI/vf17kHaKaRXJrWnyCxHFaVQFO2LL81yg==",
"dev": true,
"hasInstallScript": true,
"bin": {
@ -58,9 +58,9 @@
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
},
"tree-sitter-cli": {
"version": "0.19.5",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.19.5.tgz",
"integrity": "sha512-kRzKrUAwpDN9AjA3b0tPBwT1hd8N2oQvvvHup2OEsX6mdsSMLmAvR+NSqK9fe05JrRbVvG8mbteNUQsxlMQohQ==",
"version": "0.20.4",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.4.tgz",
"integrity": "sha512-G42x0Ev7mxA8WLUfZY+two5LIhPf6R/m7qDZtKxOzE77zXi6didNI/vf17kHaKaRXJrWnyCxHFaVQFO2LL81yg==",
"dev": true
},
"tree-sitter-clojure": {

@ -1,15 +1,15 @@
{
"name": "tree-sitter-commonlisp",
"version": "0.2.0",
"version": "0.3.0",
"description": "Tree-sitter grammar for Common Lisp",
"main": "bindings/node",
"scripts": {
"test": "tree-sitter generate && tree-sitter test"
},
"author": "Stephan Seitz",
"license": "GPL-3.0-or-later",
"license": "MIT",
"dependencies": {
"nan": "^2.14.2",
"nan": "^2.15.0",
"tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure-1.git#95c7959c461406381b42113dcf4591008c663d21"
},
"repository": {
@ -17,6 +17,6 @@
"url": "git://github.com/theHamsta/tree-sitter-common-lisp.git"
},
"devDependencies": {
"tree-sitter-cli": "^0.19.4"
"tree-sitter-cli": "^0.20.4"
}
}

@ -1,28 +0,0 @@
#include "tree_sitter/parser.h"
#include <node.h>
#include "nan.h"
using namespace v8;
extern "C" TSLanguage * tree_sitter_lisp();
namespace {
NAN_METHOD(New) {}
void Init(Local<Object> exports, Local<Object> module) {
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_lisp());
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("lisp").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
}
NODE_MODULE(tree_sitter_lisp_binding, Init)
} // namespace

@ -2550,7 +2550,7 @@
},
{
"type": "PATTERN",
"value": "((collect|append|nconc|count|maximize|minimize)(ing)?|sum(ming)?)"
"value": "(maximize|minimize|(collect|append|nconc|count)(ing)?|sum(ming)?|maximizing|minimizing)"
}
]
},

File diff suppressed because it is too large Load Diff

@ -123,6 +123,7 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
/*

@ -1316,3 +1316,29 @@ Chars #\(
(sym_lit)
(char_lit)
(sym_lit)))
================================================================================
Issue #10
================================================================================
(loop for s in symbols
maximizing (length (symbol-name s)))
--------------------------------------------------------------------------------
(source
(list_lit
(loop_macro
(loop_clause
(for_clause
(sym_lit)
(for_clause_word)
(sym_lit)))
(loop_clause
(accumulation_clause
(accumulation_verb)
(list_lit
(sym_lit)
(list_lit
(sym_lit)
(sym_lit))))))))