Allow with_clause without "="

pull/70/head
Stephan Seitz 2021-11-28 12:25:39 +07:00
parent c60037a9d5
commit 90d1c56314
5 changed files with 71761 additions and 75182 deletions

@ -119,7 +119,7 @@ module.exports = grammar(clojure, {
name: 'commonlisp',
extras: ($, original) => [...original, $.block_comment],
conflicts: ($, original) => [...original, [$.for_clause], [$.accumulation_clause], [$.loop_macro, $.defun_keyword, $.package_lit]],
conflicts: ($, original) => [...original, [$.with_clause], [$.for_clause], [$.accumulation_clause], [$.loop_macro, $.defun_keyword, $.package_lit]],
rules: {
block_comment: _ => token(seq('#|', repeat(choice(/[^|]/, /\|[^#]/)), '|#')),
@ -226,7 +226,7 @@ module.exports = grammar(clojure, {
for_clause: $ => choice(seq(choice(clSymbol('for'), clSymbol('and'), clSymbol('as')), repeat($._gap), field('variable', $._form), optional(field('type', seq(repeat($._gap), $._form))),
repeat1($._for_part)), clSymbol('and')),
with_clause: $ => prec.left(seq(clSymbol('with'), repeat($._gap), $._form, optional(field('type', seq(repeat($._gap), $._form))), repeat($._gap), clSymbol("="), repeat($._gap), $._form)),
with_clause: $ => seq(clSymbol('with'), repeat($._gap), $._form, optional(field('type', repeat($._gap), $._form)), repeat($._gap), optional(clSymbol("=")), repeat($._gap), optional($._form)),
do_clause: $ => prec.left(seq(clSymbol('do'), repeat1(prec.left(seq(repeat($._gap), $._form, repeat($._gap)))))),
while_clause: $ => prec.left(seq(choice(clSymbol('while'), clSymbol('until')), repeat($._gap), $._form)),
repeat_clause: $ => prec.left(seq(clSymbol('repeat'), repeat($._gap), $._form)),

@ -2720,130 +2720,133 @@
]
},
"with_clause": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "cl"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "with"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
"name": "_form"
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "type",
"content": {
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
"type": "STRING",
"value": "cl"
},
{
"type": "SYMBOL",
"name": "_form"
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
]
},
{
"type": "STRING",
"value": "with"
}
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "cl"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "="
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
"name": "_form"
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "type",
"content": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
},
{
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_form"
"name": "_gap"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "cl"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "="
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_form"
},
{
"type": "BLANK"
}
]
}
]
},
"do_clause": {
"type": "PREC_LEFT",
@ -4190,6 +4193,9 @@
}
],
"conflicts": [
[
"with_clause"
],
[
"for_clause"
],

@ -4298,109 +4298,13 @@
"multiple": true,
"required": false,
"types": [
{
"type": "#",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": "char_lit",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "complex_num_lit",
"named": true
},
{
"type": "dis_expr",
"named": true
},
{
"type": "fancy_literal",
"named": true
},
{
"type": "include_reader_macro",
"named": true
},
{
"type": "kwd_lit",
"named": true
},
{
"type": "list_lit",
"named": true
},
{
"type": "nil_lit",
"named": true
},
{
"type": "num_lit",
"named": true
},
{
"type": "package_lit",
"named": true
},
{
"type": "path_lit",
"named": true
},
{
"type": "quoting_lit",
"named": true
},
{
"type": "read_cond_lit",
"named": true
},
{
"type": "self_referential_reader_macro",
"named": true
},
{
"type": "set_lit",
"named": true
},
{
"type": "splicing_read_cond_lit",
"named": true
},
{
"type": "str_lit",
"named": true
},
{
"type": "sym_lit",
"named": true
},
{
"type": "syn_quoting_lit",
"named": true
},
{
"type": "unquote_splicing_lit",
"named": true
},
{
"type": "unquoting_lit",
"named": true
},
{
"type": "var_quoting_lit",
"named": true
},
{
"type": "vec_lit",
"named": true
}
]
}

File diff suppressed because it is too large Load Diff

@ -1142,3 +1142,36 @@ Issue #6 (#\Replacement_Character)
(source
(char_lit))
================================================================================
loop with
================================================================================
(loop with values)
(loop with values = a)
(loop with values
finally
(return values))
--------------------------------------------------------------------------------
(source
(list_lit
(loop_macro
(loop_clause
(with_clause
(sym_lit)))))
(list_lit
(loop_macro
(loop_clause
(with_clause
(sym_lit)
(sym_lit)))))
(list_lit
(loop_macro
(loop_clause
(with_clause
(sym_lit)))
(loop_clause
(termination_clause
(list_lit
(sym_lit)
(sym_lit)))))))