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.
10 local macro_prefix
= P('#.') + ',@' + ',.' + ',' + '`' + "'"
21 local number = P('-')^
-1 * l
.digit^
1 * (S('./') * l
.digit^
1)^
-1
22 local word
= l
.alpha
* (l
.alnum
+ '_' + '-')^
0
23 local entity
= '&' * word
24 local identifier
= word
27 prefix
= macro_prefix
,
29 atom
= function(pfx
) return pfx
* identifier
+ number + entity
+ "..." + "." end,
30 word
= number + identifier
+ "\\" * l
.any