link to fmt configuration as example
[howl-parkour.git] / parkour / fmt / scheme / lispwords.lua
blob075b86e53d94817bfdd2858d9dc820015c8390f1
1 -- SPDX-License-Identifier: GPL-3.0-or-later
2 -- © 2020 Georgi Kirilov
4 require'lpeg'
5 local lpeg = lpeg
6 local P, Cc = lpeg.P, lpeg.Cc
8 local let_likes = (P'match-' + 'splicing-')^-1 * 'let' * (P'rec' + '*')^-1 * (P'-' * (P'syntax' + 'syntaxes' + 'values'))^-1 * -P(1)
9 local forfold_likes = 'for' * P'*'^-1 * '/' * (P'fold' + 'lists')
11 return {
12 -- If none of the string keys matched, this pattern is attempted
13 [0] = ('define' * ('*' + '-' * P(1)^1)^-1 * -P(1) +
14 (P'call-'^-1 * 'with-') * P(1)^1 +
15 let_likes) * Cc(1) +
16 forfold_likes * Cc(2),
18 ['begin'] = -1,
19 ['case-lambda'] = -1,
20 ['cond'] = -1,
21 ['delay'] = -1,
22 ['match-lambda'] = -1,
23 ['match-lambda*'] = -1,
24 ['sequence'] = -1,
25 ['syntax-parser'] = -1,
27 ['case'] = 1,
28 ['compile-time-case'] = 1,
29 ['eval-when'] = 1,
30 ['lambda'] = 1,
31 ['lambda*'] = 1,
32 ['library'] = 1,
33 ['local-even?'] = 1,
34 ['local-odd?'] = 1,
35 ['match'] = 1,
36 ['module'] = 1,
37 ['parameterize'] = 1,
38 ['struct'] = 1,
39 ['syntax-parameterize'] = 1,
40 ['syntax-parse'] = 1,
41 ['syntax-rules'] = 1,
42 ['unless'] = 1,
43 ['when'] = 1,
44 ['λ'] = 1,
46 ['do'] = 2,
47 ['do*'] = 2,
48 ['syntax-case'] = 2,
49 ['with-slots'] = 2,