Merge commit '01c17ac04f65143d3ae5e93354d808db4c9eb0a2'

pull/70/head
Wilfred Hughes 2021-11-27 18:21:09 +07:00
commit 430c300f04
8 changed files with 64262 additions and 63439 deletions

@ -16,3 +16,14 @@ jobs:
run: npm ci
- name: Run tests
run: npm test
- name: Parse Petalisp
run: |
git submodule init
git submodule update
if (( $(node_modules/tree-sitter-cli/tree-sitter parse test/Petalisp/**/*.lisp -q | wc -l) > 2 )); then # There are 2 known failures (strings that are not format strings but use ~X syntax)
exit 1
else
echo "Successfully parsed Petalisp"
fi
- name: Run tests
run: npm test

@ -0,0 +1,3 @@
[submodule "test/Petalisp"]
path = test/Petalisp
url = https://github.com/marcoheisig/Petalisp.git

@ -119,7 +119,7 @@ module.exports = grammar(clojure, {
name: 'commonlisp',
extras: ($, original) => [...original, $.block_comment],
conflicts: ($, original) => [...original, [$.for_clause], [$.accumulation_clause],],
conflicts: ($, original) => [...original, [$.for_clause], [$.accumulation_clause], [$.loop_macro, $.defun_keyword, $.package_lit]],
rules: {
block_comment: _ => token(seq('#|', repeat(choice(/[^|]/, /\|[^#]/)), '|#')),
@ -257,7 +257,7 @@ module.exports = grammar(clojure, {
repeat(choice($.loop_clause, $._gap)),
field('close', ")"))),
defun_keyword: _ => clSymbol(choice('defun', 'defmacro', 'defgeneric', 'defmethod')),
defun_keyword: _ => prec(10, clSymbol(choice('defun', 'defmacro', 'defgeneric', 'defmethod'))),
defun_header: $ =>
choice(
@ -294,11 +294,11 @@ module.exports = grammar(clojure, {
repeat(choice(field('value', $._form), $._gap)),
field('close', ")"))),
package_lit: $ => prec(PREC.PACKAGE_LIT, seq(
package_lit: $ => prec(PREC.PACKAGE_LIT, choice(seq(
field('package', choice($.sym_lit, 'cl')), // Make optional, instead of keywords?
choice(':', '::'),
field('symbol', $.sym_lit)
)),
), prec(1, 'cl'))),
_package_lit_without_slash: $ => seq(
field('package', choice($._sym_lit_without_slash, 'cl')), // Make optional, instead of keywords?

@ -1645,8 +1645,39 @@
]
},
"derefing_lit": {
"type": "SYMBOL",
"name": "complex_num_lit"
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_metadata_lit"
}
},
{
"type": "FIELD",
"name": "marker",
"content": {
"type": "STRING",
"value": "@"
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_form"
}
}
]
},
"quoting_lit": {
"type": "SEQ",
@ -3737,51 +3768,55 @@
}
},
"defun_keyword": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "cl"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "defun"
},
{
"type": "STRING",
"value": "defmacro"
},
{
"type": "STRING",
"value": "defgeneric"
},
{
"type": "STRING",
"value": "defmethod"
}
]
}
]
"type": "PREC",
"value": 10,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "cl"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "defun"
},
{
"type": "STRING",
"value": "defmacro"
},
{
"type": "STRING",
"value": "defgeneric"
},
{
"type": "STRING",
"value": "defmethod"
}
]
}
]
}
},
"defun_header": {
"type": "CHOICE",
@ -4008,44 +4043,57 @@
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "package",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "sym_lit"
},
{
"type": "STRING",
"value": "cl"
}
]
}
},
{
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
"type": "FIELD",
"name": "package",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "sym_lit"
},
{
"type": "STRING",
"value": "cl"
}
]
}
},
{
"type": "STRING",
"value": "::"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "STRING",
"value": "::"
}
]
},
{
"type": "FIELD",
"name": "symbol",
"content": {
"type": "SYMBOL",
"name": "sym_lit"
}
}
]
},
{
"type": "FIELD",
"name": "symbol",
"type": "PREC",
"value": 1,
"content": {
"type": "SYMBOL",
"name": "sym_lit"
"type": "STRING",
"value": "cl"
}
}
]
@ -4296,6 +4344,11 @@
],
[
"accumulation_clause"
],
[
"loop_macro",
"defun_keyword",
"package_lit"
]
],
"precedences": [],

@ -2218,7 +2218,7 @@
"fields": {
"package": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "cl",
@ -2232,7 +2232,7 @@
},
"symbol": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "sym_lit",

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
Subproject commit 3b6cb42933f7f4b2d63b2d48c0d92c19a6b701b8

@ -1109,3 +1109,19 @@ Self-references
(sym_lit)))
(list_lit
(sym_lit)))))
================================================================================
Issue #5 (defpackage)
================================================================================
(defpackage foo-bar
(:use cl))
--------------------------------------------------------------------------------
(source
(list_lit
(sym_lit)
(sym_lit)
(list_lit
(kwd_lit
(kwd_symbol))
(package_lit))))