Add ~/.../ formatter specifier again

pull/70/head
Stephan Seitz 2021-04-18 21:35:24 +07:00
parent 22f7f3ec3e
commit 44775c87e7
5 changed files with 63832 additions and 63653 deletions

@ -27,6 +27,9 @@ const PREC = {
const SYMBOL_HEAD = const SYMBOL_HEAD =
/[^:\f\n\r\t ()\[\]{}"@^;`\\,#'\u000B\u001C\u001D\u001E\u001F\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200a\u205f\u3000]/; /[^:\f\n\r\t ()\[\]{}"@^;`\\,#'\u000B\u001C\u001D\u001E\u001F\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200a\u205f\u3000]/;
const SYMBOL_WITHOUT_SLASH =
/[^:\f\n\r\t ()\[\]{}"@^;/`\\,#'\u000B\u001C\u001D\u001E\u001F\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200a\u205f\u3000]/;
const SYMBOL_BODY = const SYMBOL_BODY =
choice(SYMBOL_HEAD, choice(SYMBOL_HEAD,
/[#']/); /[#']/);
@ -39,14 +42,6 @@ function clSymbol(symbol) {
return seq(optional(seq('cl', ':')), symbol) return seq(optional(seq('cl', ':')), symbol)
} }
function srepeat(...args) {
return repeat(seq(...args))
}
function sep1(rule, separator) {
return seq(rule, repeat(seq(separator, rule)))
}
module.exports = grammar(clojure, { module.exports = grammar(clojure, {
name: 'commonlisp', name: 'commonlisp',
@ -107,7 +102,7 @@ module.exports = grammar(clojure, {
/[<>]/, /[<>]/,
';', ';',
seq(field('numberOfArgs', $._format_token), '*'), seq(field('numberOfArgs', $._format_token), '*'),
//seq('/', $._form, '/', $._form, /[tT]/), // causes problems with paths seq('/', choice($._package_lit_without_slash, $._sym_lit_without_slash), '/'),
'?', '?',
"Newline", "Newline",
seq(repeat(choice($._format_token, ',')), /[$rRbBdDgGxXeEoOsS]/), seq(repeat(choice($._format_token, ',')), /[$rRbBdDgGxXeEoOsS]/),
@ -223,14 +218,18 @@ module.exports = grammar(clojure, {
repeat(choice(field('value', $._form), $._gap)), repeat(choice(field('value', $._form), $._gap)),
field('close', ")"))), field('close', ")"))),
//dotted_sym_lit: $ => prec.left(PREC.DOTTET_LIT, seq($.sym_lit, repeat1(seq(".", $.sym_lit)))),
package_lit: $ => prec(PREC.PACKAGE_LIT, seq( package_lit: $ => prec(PREC.PACKAGE_LIT, seq(
field('package', $.sym_lit), // Make optional, instead of keywords? field('package', $.sym_lit), // Make optional, instead of keywords?
choice(':', '::'), choice(':', '::'),
field('symbol', $.sym_lit) field('symbol', $.sym_lit)
)), )),
_package_lit_without_slash: $ => alias(prec(PREC.PACKAGE_LIT, seq(
field('package', $._sym_lit_without_slash), // Make optional, instead of keywords?
choice(':', '::'),
field('symbol', $._sym_lit_without_slash)
)), 'package_lit'),
kwd_lit: $ => prec(PREC.KWD_LIT, seq( kwd_lit: $ => prec(PREC.KWD_LIT, seq(
choice(':', '::'), choice(':', '::'),
$.kwd_symbol, $.kwd_symbol,
@ -239,6 +238,9 @@ module.exports = grammar(clojure, {
sym_lit: _ => sym_lit: _ =>
seq(SYMBOL), seq(SYMBOL),
_sym_lit_without_slash: _ =>
alias(repeat1(SYMBOL_WITHOUT_SLASH), 'sym_lit'),
kwd_symbol: _ => kwd_symbol: _ =>
seq(SYMBOL), seq(SYMBOL),

@ -1991,6 +1991,32 @@
} }
] ]
}, },
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_package_lit_without_slash"
},
{
"type": "SYMBOL",
"name": "_sym_lit_without_slash"
}
]
},
{
"type": "STRING",
"value": "/"
}
]
},
{ {
"type": "STRING", "type": "STRING",
"value": "?" "value": "?"
@ -3518,6 +3544,61 @@
] ]
} }
}, },
"_package_lit_without_slash": {
"type": "ALIAS",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "package",
"content": {
"type": "SYMBOL",
"name": "_sym_lit_without_slash"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "STRING",
"value": "::"
}
]
},
{
"type": "FIELD",
"name": "symbol",
"content": {
"type": "SYMBOL",
"name": "_sym_lit_without_slash"
}
}
]
}
},
"named": false,
"value": "package_lit"
},
"_sym_lit_without_slash": {
"type": "ALIAS",
"content": {
"type": "REPEAT1",
"content": {
"type": "PATTERN",
"value": "[^:\\f\\n\\r\\t ()\\[\\]{}\"@^;/`\\\\,#'\\u000B\\u001C\\u001D\\u001E\\u001F\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2008\\u2009\\u200a\\u205f\\u3000]"
}
},
"named": false,
"value": "sym_lit"
},
"kwd_symbol": { "kwd_symbol": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

@ -1486,6 +1486,16 @@
} }
] ]
}, },
"package": {
"multiple": false,
"required": false,
"types": [
{
"type": "package_lit",
"named": false
}
]
},
"repetitions": { "repetitions": {
"multiple": false, "multiple": false,
"required": false, "required": false,
@ -1499,6 +1509,16 @@
"named": true "named": true
} }
] ]
},
"symbol": {
"multiple": false,
"required": false,
"types": [
{
"type": "package_lit",
"named": false
}
]
} }
}, },
"children": { "children": {
@ -2395,7 +2415,7 @@
"fields": { "fields": {
"package": { "package": {
"multiple": false, "multiple": false,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "sym_lit", "type": "sym_lit",
@ -2405,7 +2425,7 @@
}, },
"symbol": { "symbol": {
"multiple": false, "multiple": false,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "sym_lit", "type": "sym_lit",
@ -4494,6 +4514,10 @@
"type": ".", "type": ".",
"named": false "named": false
}, },
{
"type": "/",
"named": false
},
{ {
"type": ":", "type": ":",
"named": false "named": false
@ -4678,6 +4702,10 @@
"type": "on", "type": "on",
"named": false "named": false
}, },
{
"type": "package_lit",
"named": false
},
{ {
"type": "repeat", "type": "repeat",
"named": false "named": false

File diff suppressed because it is too large Load Diff

@ -885,4 +885,10 @@ Format
(format_prefix_parameters) (format_prefix_parameters)
(format_directive_type))) (format_directive_type)))
(num_lit) (num_lit)
(num_lit))) (num_lit))
(list_lit
(sym_lit)
(str_lit
(format_specifier
(format_directive_type))))
(num_lit))