Allow multiple gaps in loop_macro

pull/70/head
Stephan Seitz 2021-04-16 09:53:25 +07:00
parent a80e38cb47
commit e61888e097
5 changed files with 59028 additions and 69755 deletions

@ -91,20 +91,20 @@ module.exports = grammar(clojure, {
'='),
_for_part: $ => seq(optional($._gap), $.for_clause_word, optional($._gap), $._form),
_for_part: $ => seq(repeat($._gap), $.for_clause_word, repeat($._gap), $._form),
accumulation_verb: _ => /((collect|append|nconc|count|maximize|minimize)(ing)?|sum(ming)?)/,
for_clause: $ => seq(choice('for', 'and', 'as'), optional($._gap), field('variable', $._form),
for_clause: $ => seq(choice('for', 'and', 'as'), repeat($._gap), field('variable', $._form),
repeat1($._for_part)),
with_clause: $ => prec.left(seq('with', optional($._gap), $._form, optional($._gap), "=", optional($._gap), $._form)),
with_clause: $ => prec.left(seq('with', repeat($._gap), $._form, repeat($._gap), "=", repeat($._gap), $._form)),
do_clause: $ => prec.left(seq('do', repeat1(prec.left(seq(repeat($._gap), $._form, repeat($._gap)))))),
while_clause: $ => prec.left(seq(choice('while', 'until'), optional($._gap), $._form)),
repeat_clause: $ => prec.left(seq('repeat', optional($._gap), $._form)),
while_clause: $ => prec.left(seq(choice('while', 'until'), repeat($._gap), $._form)),
repeat_clause: $ => prec.left(seq('repeat', repeat($._gap), $._form)),
condition_clause: $ => prec.left(choice(seq(choice('when', 'if', 'unless', 'always', 'thereis', 'never'), repeat($._gap), $._form), "else")),
accumulation_clause: $ => seq($.accumulation_verb, optional($._gap), $._form, optional(seq(optional($._gap), 'into', optional($._gap), $._form))),
termination_clause: $ => prec.left(seq(choice('finally', 'return', 'initially'), optional($._gap), $._form)),
accumulation_clause: $ => seq($.accumulation_verb, repeat($._gap), $._form, optional(seq(repeat($._gap), 'into', repeat($._gap), $._form))),
termination_clause: $ => prec.left(seq(choice('finally', 'return', 'initially'), repeat($._gap), $._form)),
loop_clause: $ =>
@ -135,7 +135,7 @@ module.exports = grammar(clojure, {
seq(field('keyword', $.defun_keyword),
repeat($._gap),
field('function_name', $._form),
optional(field('specifier', seq(repeat($._gap), $.kwd_lit))),
optional(field('specifier', seq(repeat($._gap), choice($.kwd_lit, $.sym_lit)))),
repeat($._gap),
field('lambda_list', $.list_lit)),
seq(field('keyword', alias('lambda', $.defun_keyword)),
@ -184,7 +184,6 @@ module.exports = grammar(clojure, {
choice(// atom-ish
$.num_lit,
$.fancy_literal,
//$.defun_header,
$.kwd_lit,
$.str_lit,
$.char_lit,

@ -1835,32 +1835,22 @@
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
"name": "for_clause_word"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -1893,16 +1883,11 @@
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "FIELD",
@ -1932,48 +1917,33 @@
"value": "with"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
"name": "_form"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2045,16 +2015,11 @@
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2074,16 +2039,11 @@
"value": "repeat"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2158,16 +2118,11 @@
"name": "accumulation_verb"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2180,32 +2135,22 @@
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "STRING",
"value": "into"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2244,16 +2189,11 @@
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_gap"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_gap"
}
},
{
"type": "SYMBOL",
@ -2441,8 +2381,17 @@
}
},
{
"type": "SYMBOL",
"name": "kwd_lit"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "kwd_lit"
},
{
"type": "SYMBOL",
"name": "sym_lit"
}
]
}
]
}

@ -619,6 +619,10 @@
{
"type": "kwd_lit",
"named": true
},
{
"type": "sym_lit",
"named": true
}
]
}

File diff suppressed because it is too large Load Diff

@ -658,3 +658,90 @@ Loop (else)
(accumulation_clause
(accumulation_verb)
(sym_lit))))))
================================================================================
Multiple gaps in Loop
================================================================================
(defmethod cl-dot:graph-object-points-to
((graph any-graph) node)
(loop for edge in (graphviz-potential-edges graph node)
append
;; There must be a more graceful way to loop over sequences...
(loop for target in (coerce (graphviz-outgoing-edge-targets graph edge node) 'list)
for edge-number from 0
collect
(make-instance 'cl-dot:attributed
:attributes (graphviz-edge-attributes graph edge node target edge-number)
:object target))))
--------------------------------------------------------------------------------
(source
(list_lit
(defun
(defun_header
(defun_keyword)
(package_lit
(sym_lit)
(sym_lit))
(list_lit
(list_lit
(sym_lit)
(sym_lit))
(sym_lit)))
(list_lit
(loop_macro
(loop_clause
(for_clause
(sym_lit)
(for_clause_word)
(list_lit
(sym_lit)
(sym_lit)
(sym_lit))))
(loop_clause
(accumulation_clause
(accumulation_verb)
(comment)
(list_lit
(loop_macro
(loop_clause
(for_clause
(sym_lit)
(for_clause_word)
(list_lit
(sym_lit)
(list_lit
(sym_lit)
(sym_lit)
(sym_lit)
(sym_lit))
(quoting_lit
(sym_lit)))))
(loop_clause
(for_clause
(sym_lit)
(for_clause_word)
(num_lit)))
(loop_clause
(accumulation_clause
(accumulation_verb)
(list_lit
(sym_lit)
(quoting_lit
(package_lit
(sym_lit)
(sym_lit)))
(kwd_lit
(sym_lit))
(list_lit
(sym_lit)
(sym_lit)
(sym_lit)
(sym_lit)
(sym_lit)
(sym_lit))
(kwd_lit
(sym_lit))
(sym_lit)))))))))))))