3 local P
, S
= lpeg
.P
, lpeg
.S
4 local cwd
= (...):match
'(.-)[^%.]+$'
5 local l
= require(cwd
..'_lexer')
7 -- The LPeg patterns for atoms are taken from the scintillua lexer:
8 -- Copyright 2006-2017 Mitchell mitchell.att.foicica.com.
41 ['with-local-vars'] = 1,
61 local macro_prefix
= P('#?@') + '#?' +
62 -- XXX: treating datum comments as text is wasteful; better parse them as code:
64 '#' + '^' + '@' + '`' + "'"
77 local number = P('-')^
-1 * l
.digit^
1 * (S('./') * l
.digit^
1)^
-1
79 local word
= (l
.alpha
+ S('-!?*$=-')) * (l
.alnum
+ S('.-!?*$+-'))^
0
80 local identifier
= word
82 local clojure_keyword
= ':' * S(':')^
-1 * word
* ('/' * word
)^
-1
83 local clojure_symbol
= "\'" * word
* ('/' * word
)^
-1
86 lispwords
= lispwords
,
87 squarewords
= squarewords
,
88 prefix
= macro_prefix
,
90 atom
= function(pfx
) return clojure_keyword
+ clojure_symbol
+ pfx
* identifier
+ "λ" + number end,
91 word
= number + identifier
+ "\\" * l
.any