Support keyword specifiers in defmethod

pull/70/head
Stephan Seitz 2021-04-15 20:50:30 +07:00
parent 3c53430f7c
commit 14913f6702
6 changed files with 64216 additions and 48166 deletions

@ -38,7 +38,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], [$.accumulation_clause],],
rules: {
block_comment: _ => token(seq('#|', repeat(choice(/[^|]/, /\|[^#]/)), '|#')),
@ -131,6 +131,7 @@ module.exports = grammar(clojure, {
seq(field('keyword', $.defun_keyword),
repeat($._gap),
field('function_name', $._form),
optional(field('specifier', seq(repeat($._gap),$.kwd_lit))),
repeat($._gap),
field('lambda_list', $.list_lit)),
seq(field('keyword', alias('lambda', $.defun_keyword)),
@ -160,6 +161,7 @@ module.exports = grammar(clojure, {
)),
kwd_lit: $ => prec(PREC.KWD_LIT, seq(
optional('#'),
choice(':', '::'),
choice($.sym_lit, $.dotted_sym_lit),
)),
@ -173,7 +175,7 @@ module.exports = grammar(clojure, {
$.num_lit,
$.fancy_literal,
//$.defun_header,
$.kwd_lit,
$.kwd_lit,
$.str_lit,
$.char_lit,
$.nil_lit,

2
package-lock.json generated

@ -1,5 +1,5 @@
{
"name": "tree-sitter-common-lisp",
"name": "tree-sitter-commonlisp",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,

@ -438,6 +438,18 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
@ -2389,6 +2401,34 @@
"name": "_form"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "specifier",
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
"name": "kwd_lit"
}
]
}
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
@ -2681,6 +2721,9 @@
[
"for_clause"
],
[
"accumulation_clause"
],
[
"accumulation_clause"
]

@ -602,6 +602,24 @@
"named": true
}
]
},
"specifier": {
"multiple": true,
"required": false,
"types": [
{
"type": "comment",
"named": true
},
{
"type": "dis_expr",
"named": true
},
{
"type": "kwd_lit",
"named": true
}
]
}
},
"children": {

File diff suppressed because it is too large Load Diff

@ -92,6 +92,16 @@ Defun header
( defun a (a b)
(car 1 2)
2)
(defmethod input-gradient :around
(lazy-array output-gradient index)
(let ((input (nth index (lazy-array-inputs lazy-array)))
(value (call-next-method)))
(if (petalisp.type-inference:ntype=
(element-ntype value)
(element-ntype input))
value
(lazy #'coerce value (element-type input)))))
--------------------------------------------------------------------------------
(source
@ -120,7 +130,56 @@ Defun header
(sym_lit)
(num_lit)
(num_lit))
(num_lit))))
(num_lit)))
(list_lit
(defun
(defun_header
(defun_keyword)
(sym_lit)
(kwd_lit
(sym_lit))
(list_lit
(sym_lit)
(sym_lit)
(sym_lit)))
(list_lit
(sym_lit)
(list_lit
(list_lit
(sym_lit)
(list_lit
(sym_lit)
(sym_lit)
(list_lit
(sym_lit)
(sym_lit))))
(list_lit
(sym_lit)
(list_lit
(sym_lit))))
(list_lit
(sym_lit)
(list_lit
(package_lit
(dotted_sym_lit
(sym_lit)
(sym_lit))
(sym_lit))
(list_lit
(sym_lit)
(sym_lit))
(list_lit
(sym_lit)
(sym_lit)))
(sym_lit)
(list_lit
(sym_lit)
(var_quoting_lit
(sym_lit))
(sym_lit)
(list_lit
(sym_lit)
(sym_lit))))))))
================================================================================
Vectors