lisp.py 141 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848
  1. """
  2. pygments.lexers.lisp
  3. ~~~~~~~~~~~~~~~~~~~~
  4. Lexers for Lispy languages.
  5. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. import re
  9. from pygments.lexer import RegexLexer, include, bygroups, words, default
  10. from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
  11. Number, Punctuation, Literal, Error, Whitespace
  12. from pygments.lexers.python import PythonLexer
  13. from pygments.lexers._scheme_builtins import scheme_keywords, scheme_builtins
  14. __all__ = ['SchemeLexer', 'CommonLispLexer', 'HyLexer', 'RacketLexer',
  15. 'NewLispLexer', 'EmacsLispLexer', 'ShenLexer', 'CPSALexer',
  16. 'XtlangLexer', 'FennelLexer']
  17. class SchemeLexer(RegexLexer):
  18. """
  19. A Scheme lexer.
  20. This parser is checked with pastes from the LISP pastebin
  21. at http://paste.lisp.org/ to cover as much syntax as possible.
  22. It supports the full Scheme syntax as defined in R5RS.
  23. .. versionadded:: 0.6
  24. """
  25. name = 'Scheme'
  26. url = 'http://www.scheme-reports.org/'
  27. aliases = ['scheme', 'scm']
  28. filenames = ['*.scm', '*.ss']
  29. mimetypes = ['text/x-scheme', 'application/x-scheme']
  30. flags = re.DOTALL | re.MULTILINE
  31. # valid names for identifiers
  32. # well, names can only not consist fully of numbers
  33. # but this should be good enough for now
  34. valid_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
  35. # Use within verbose regexes
  36. token_end = r'''
  37. (?=
  38. \s # whitespace
  39. | ; # comment
  40. | \#[;|!] # fancy comments
  41. | [)\]] # end delimiters
  42. | $ # end of file
  43. )
  44. '''
  45. # Recognizing builtins.
  46. def get_tokens_unprocessed(self, text):
  47. for index, token, value in super().get_tokens_unprocessed(text):
  48. if token is Name.Function or token is Name.Variable:
  49. if value in scheme_keywords:
  50. yield index, Keyword, value
  51. elif value in scheme_builtins:
  52. yield index, Name.Builtin, value
  53. else:
  54. yield index, token, value
  55. else:
  56. yield index, token, value
  57. # Scheme has funky syntactic rules for numbers. These are all
  58. # valid number literals: 5.0e55|14, 14/13, -1+5j, +1@5, #b110,
  59. # #o#Iinf.0-nan.0i. This is adapted from the formal grammar given
  60. # in http://www.r6rs.org/final/r6rs.pdf, section 4.2.1. Take a
  61. # deep breath ...
  62. # It would be simpler if we could just not bother about invalid
  63. # numbers like #b35. But we cannot parse 'abcdef' without #x as a
  64. # number.
  65. number_rules = {}
  66. for base in (2, 8, 10, 16):
  67. if base == 2:
  68. digit = r'[01]'
  69. radix = r'( \#[bB] )'
  70. elif base == 8:
  71. digit = r'[0-7]'
  72. radix = r'( \#[oO] )'
  73. elif base == 10:
  74. digit = r'[0-9]'
  75. radix = r'( (\#[dD])? )'
  76. elif base == 16:
  77. digit = r'[0-9a-fA-F]'
  78. radix = r'( \#[xX] )'
  79. # Radix, optional exactness indicator.
  80. prefix = rf'''
  81. (
  82. {radix} (\#[iIeE])?
  83. | \#[iIeE] {radix}
  84. )
  85. '''
  86. # Simple unsigned number or fraction.
  87. ureal = rf'''
  88. (
  89. {digit}+
  90. ( / {digit}+ )?
  91. )
  92. '''
  93. # Add decimal numbers.
  94. if base == 10:
  95. decimal = r'''
  96. (
  97. # Decimal part
  98. (
  99. [0-9]+ ([.][0-9]*)?
  100. | [.][0-9]+
  101. )
  102. # Optional exponent
  103. (
  104. [eEsSfFdDlL] [+-]? [0-9]+
  105. )?
  106. # Optional mantissa width
  107. (
  108. \|[0-9]+
  109. )?
  110. )
  111. '''
  112. ureal = rf'''
  113. (
  114. {decimal} (?!/)
  115. | {ureal}
  116. )
  117. '''
  118. naninf = r'(nan.0|inf.0)'
  119. real = rf'''
  120. (
  121. [+-] {naninf} # Sign mandatory
  122. | [+-]? {ureal} # Sign optional
  123. )
  124. '''
  125. complex_ = rf'''
  126. (
  127. {real}? [+-] ({naninf}|{ureal})? i
  128. | {real} (@ {real})?
  129. )
  130. '''
  131. num = rf'''(?x)
  132. (
  133. {prefix}
  134. {complex_}
  135. )
  136. # Need to ensure we have a full token. 1+ is not a
  137. # number followed by something else, but a function
  138. # name.
  139. {token_end}
  140. '''
  141. number_rules[base] = num
  142. # If you have a headache now, say thanks to RnRS editors.
  143. # Doing it this way is simpler than splitting the number(10)
  144. # regex in a floating-point and a no-floating-point version.
  145. def decimal_cb(self, match):
  146. if '.' in match.group():
  147. token_type = Number.Float # includes [+-](inf|nan).0
  148. else:
  149. token_type = Number.Integer
  150. yield match.start(), token_type, match.group()
  151. # --
  152. # The 'scheme-root' state parses as many expressions as needed, always
  153. # delegating to the 'scheme-value' state. The latter parses one complete
  154. # expression and immediately pops back. This is needed for the LilyPondLexer.
  155. # When LilyPond encounters a #, it starts parsing embedded Scheme code, and
  156. # returns to normal syntax after one expression. We implement this
  157. # by letting the LilyPondLexer subclass the SchemeLexer. When it finds
  158. # the #, the LilyPondLexer goes to the 'value' state, which then pops back
  159. # to LilyPondLexer. The 'root' state of the SchemeLexer merely delegates the
  160. # work to 'scheme-root'; this is so that LilyPondLexer can inherit
  161. # 'scheme-root' and redefine 'root'.
  162. tokens = {
  163. 'root': [
  164. default('scheme-root'),
  165. ],
  166. 'scheme-root': [
  167. default('value'),
  168. ],
  169. 'value': [
  170. # the comments
  171. # and going to the end of the line
  172. (r';.*?$', Comment.Single),
  173. # multi-line comment
  174. (r'#\|', Comment.Multiline, 'multiline-comment'),
  175. # commented form (entire sexpr following)
  176. (r'#;[([]', Comment, 'commented-form'),
  177. # commented datum
  178. (r'#;', Comment, 'commented-datum'),
  179. # signifies that the program text that follows is written with the
  180. # lexical and datum syntax described in r6rs
  181. (r'#!r6rs', Comment),
  182. # whitespaces - usually not relevant
  183. (r'\s+', Whitespace),
  184. # numbers
  185. (number_rules[2], Number.Bin, '#pop'),
  186. (number_rules[8], Number.Oct, '#pop'),
  187. (number_rules[10], decimal_cb, '#pop'),
  188. (number_rules[16], Number.Hex, '#pop'),
  189. # strings, symbols, keywords and characters
  190. (r'"', String, 'string'),
  191. (r"'" + valid_name, String.Symbol, "#pop"),
  192. (r'#:' + valid_name, Keyword.Declaration, '#pop'),
  193. (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char, "#pop"),
  194. # constants
  195. (r'(#t|#f)', Name.Constant, '#pop'),
  196. # special operators
  197. (r"('|#|`|,@|,|\.)", Operator),
  198. # first variable in a quoted string like
  199. # '(this is syntactic sugar)
  200. (r"(?<='\()" + valid_name, Name.Variable, '#pop'),
  201. (r"(?<=#\()" + valid_name, Name.Variable, '#pop'),
  202. # Functions -- note that this also catches variables
  203. # defined in let/let*, but there is little that can
  204. # be done about it.
  205. (r'(?<=\()' + valid_name, Name.Function, '#pop'),
  206. # find the remaining variables
  207. (valid_name, Name.Variable, '#pop'),
  208. # the famous parentheses!
  209. # Push scheme-root to enter a state that will parse as many things
  210. # as needed in the parentheses.
  211. (r'[([]', Punctuation, 'scheme-root'),
  212. # Pop one 'value', one 'scheme-root', and yet another 'value', so
  213. # we get back to a state parsing expressions as needed in the
  214. # enclosing context.
  215. (r'[)\]]', Punctuation, '#pop:3'),
  216. ],
  217. 'multiline-comment': [
  218. (r'#\|', Comment.Multiline, '#push'),
  219. (r'\|#', Comment.Multiline, '#pop'),
  220. (r'[^|#]+', Comment.Multiline),
  221. (r'[|#]', Comment.Multiline),
  222. ],
  223. 'commented-form': [
  224. (r'[([]', Comment, '#push'),
  225. (r'[)\]]', Comment, '#pop'),
  226. (r'[^()[\]]+', Comment),
  227. ],
  228. 'commented-datum': [
  229. (rf'(?x).*?{token_end}', Comment, '#pop'),
  230. ],
  231. 'string': [
  232. # Pops back from 'string', and pops 'value' as well.
  233. ('"', String, '#pop:2'),
  234. # Hex escape sequences, R6RS-style.
  235. (r'\\x[0-9a-fA-F]+;', String.Escape),
  236. # We try R6RS style first, but fall back to Guile-style.
  237. (r'\\x[0-9a-fA-F]{2}', String.Escape),
  238. # Other special escape sequences implemented by Guile.
  239. (r'\\u[0-9a-fA-F]{4}', String.Escape),
  240. (r'\\U[0-9a-fA-F]{6}', String.Escape),
  241. # Escape sequences are not overly standardized. Recognizing
  242. # a single character after the backslash should be good enough.
  243. # NB: we have DOTALL.
  244. (r'\\.', String.Escape),
  245. # The rest
  246. (r'[^\\"]+', String),
  247. ]
  248. }
  249. class CommonLispLexer(RegexLexer):
  250. """
  251. A Common Lisp lexer.
  252. .. versionadded:: 0.9
  253. """
  254. name = 'Common Lisp'
  255. url = 'https://lisp-lang.org/'
  256. aliases = ['common-lisp', 'cl', 'lisp']
  257. filenames = ['*.cl', '*.lisp']
  258. mimetypes = ['text/x-common-lisp']
  259. flags = re.IGNORECASE | re.MULTILINE
  260. # couple of useful regexes
  261. # characters that are not macro-characters and can be used to begin a symbol
  262. nonmacro = r'\\.|[\w!$%&*+-/<=>?@\[\]^{}~]'
  263. constituent = nonmacro + '|[#.:]'
  264. terminated = r'(?=[ "()\'\n,;`])' # whitespace or terminating macro characters
  265. # symbol token, reverse-engineered from hyperspec
  266. # Take a deep breath...
  267. symbol = r'(\|[^|]+\||(?:%s)(?:%s)*)' % (nonmacro, constituent)
  268. def __init__(self, **options):
  269. from pygments.lexers._cl_builtins import BUILTIN_FUNCTIONS, \
  270. SPECIAL_FORMS, MACROS, LAMBDA_LIST_KEYWORDS, DECLARATIONS, \
  271. BUILTIN_TYPES, BUILTIN_CLASSES
  272. self.builtin_function = BUILTIN_FUNCTIONS
  273. self.special_forms = SPECIAL_FORMS
  274. self.macros = MACROS
  275. self.lambda_list_keywords = LAMBDA_LIST_KEYWORDS
  276. self.declarations = DECLARATIONS
  277. self.builtin_types = BUILTIN_TYPES
  278. self.builtin_classes = BUILTIN_CLASSES
  279. RegexLexer.__init__(self, **options)
  280. def get_tokens_unprocessed(self, text):
  281. stack = ['root']
  282. for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
  283. if token is Name.Variable:
  284. if value in self.builtin_function:
  285. yield index, Name.Builtin, value
  286. continue
  287. if value in self.special_forms:
  288. yield index, Keyword, value
  289. continue
  290. if value in self.macros:
  291. yield index, Name.Builtin, value
  292. continue
  293. if value in self.lambda_list_keywords:
  294. yield index, Keyword, value
  295. continue
  296. if value in self.declarations:
  297. yield index, Keyword, value
  298. continue
  299. if value in self.builtin_types:
  300. yield index, Keyword.Type, value
  301. continue
  302. if value in self.builtin_classes:
  303. yield index, Name.Class, value
  304. continue
  305. yield index, token, value
  306. tokens = {
  307. 'root': [
  308. default('body'),
  309. ],
  310. 'multiline-comment': [
  311. (r'#\|', Comment.Multiline, '#push'), # (cf. Hyperspec 2.4.8.19)
  312. (r'\|#', Comment.Multiline, '#pop'),
  313. (r'[^|#]+', Comment.Multiline),
  314. (r'[|#]', Comment.Multiline),
  315. ],
  316. 'commented-form': [
  317. (r'\(', Comment.Preproc, '#push'),
  318. (r'\)', Comment.Preproc, '#pop'),
  319. (r'[^()]+', Comment.Preproc),
  320. ],
  321. 'body': [
  322. # whitespace
  323. (r'\s+', Whitespace),
  324. # single-line comment
  325. (r';.*$', Comment.Single),
  326. # multi-line comment
  327. (r'#\|', Comment.Multiline, 'multiline-comment'),
  328. # encoding comment (?)
  329. (r'#\d*Y.*$', Comment.Special),
  330. # strings and characters
  331. (r'"(\\.|\\\n|[^"\\])*"', String),
  332. # quoting
  333. (r":" + symbol, String.Symbol),
  334. (r"::" + symbol, String.Symbol),
  335. (r":#" + symbol, String.Symbol),
  336. (r"'" + symbol, String.Symbol),
  337. (r"'", Operator),
  338. (r"`", Operator),
  339. # decimal numbers
  340. (r'[-+]?\d+\.?' + terminated, Number.Integer),
  341. (r'[-+]?\d+/\d+' + terminated, Number),
  342. (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' +
  343. terminated, Number.Float),
  344. # sharpsign strings and characters
  345. (r"#\\." + terminated, String.Char),
  346. (r"#\\" + symbol, String.Char),
  347. # vector
  348. (r'#\(', Operator, 'body'),
  349. # bitstring
  350. (r'#\d*\*[01]*', Literal.Other),
  351. # uninterned symbol
  352. (r'#:' + symbol, String.Symbol),
  353. # read-time and load-time evaluation
  354. (r'#[.,]', Operator),
  355. # function shorthand
  356. (r'#\'', Name.Function),
  357. # binary rational
  358. (r'#b[+-]?[01]+(/[01]+)?', Number.Bin),
  359. # octal rational
  360. (r'#o[+-]?[0-7]+(/[0-7]+)?', Number.Oct),
  361. # hex rational
  362. (r'#x[+-]?[0-9a-f]+(/[0-9a-f]+)?', Number.Hex),
  363. # radix rational
  364. (r'#\d+r[+-]?[0-9a-z]+(/[0-9a-z]+)?', Number),
  365. # complex
  366. (r'(#c)(\()', bygroups(Number, Punctuation), 'body'),
  367. # array
  368. (r'(#\d+a)(\()', bygroups(Literal.Other, Punctuation), 'body'),
  369. # structure
  370. (r'(#s)(\()', bygroups(Literal.Other, Punctuation), 'body'),
  371. # path
  372. (r'#p?"(\\.|[^"])*"', Literal.Other),
  373. # reference
  374. (r'#\d+=', Operator),
  375. (r'#\d+#', Operator),
  376. # read-time comment
  377. (r'#+nil' + terminated + r'\s*\(', Comment.Preproc, 'commented-form'),
  378. # read-time conditional
  379. (r'#[+-]', Operator),
  380. # special operators that should have been parsed already
  381. (r'(,@|,|\.)', Operator),
  382. # special constants
  383. (r'(t|nil)' + terminated, Name.Constant),
  384. # functions and variables
  385. (r'\*' + symbol + r'\*', Name.Variable.Global),
  386. (symbol, Name.Variable),
  387. # parentheses
  388. (r'\(', Punctuation, 'body'),
  389. (r'\)', Punctuation, '#pop'),
  390. ],
  391. }
  392. def analyse_text(text):
  393. """Competes with Visual Prolog on *.cl"""
  394. # This is a *really* good indicator (and not conflicting with Visual Prolog)
  395. # '(defun ' first on a line
  396. # section keyword alone on line e.g. 'clauses'
  397. if re.search(r'^\s*\(defun\s', text):
  398. return 0.8
  399. else:
  400. return 0
  401. class HyLexer(RegexLexer):
  402. """
  403. Lexer for Hy source code.
  404. .. versionadded:: 2.0
  405. """
  406. name = 'Hy'
  407. url = 'http://hylang.org/'
  408. aliases = ['hylang']
  409. filenames = ['*.hy']
  410. mimetypes = ['text/x-hy', 'application/x-hy']
  411. special_forms = (
  412. 'cond', 'for', '->', '->>', 'car',
  413. 'cdr', 'first', 'rest', 'let', 'when', 'unless',
  414. 'import', 'do', 'progn', 'get', 'slice', 'assoc', 'with-decorator',
  415. ',', 'list_comp', 'kwapply', '~', 'is', 'in', 'is-not', 'not-in',
  416. 'quasiquote', 'unquote', 'unquote-splice', 'quote', '|', '<<=', '>>=',
  417. 'foreach', 'while',
  418. 'eval-and-compile', 'eval-when-compile'
  419. )
  420. declarations = (
  421. 'def', 'defn', 'defun', 'defmacro', 'defclass', 'lambda', 'fn', 'setv'
  422. )
  423. hy_builtins = ()
  424. hy_core = (
  425. 'cycle', 'dec', 'distinct', 'drop', 'even?', 'filter', 'inc',
  426. 'instance?', 'iterable?', 'iterate', 'iterator?', 'neg?',
  427. 'none?', 'nth', 'numeric?', 'odd?', 'pos?', 'remove', 'repeat',
  428. 'repeatedly', 'take', 'take_nth', 'take_while', 'zero?'
  429. )
  430. builtins = hy_builtins + hy_core
  431. # valid names for identifiers
  432. # well, names can only not consist fully of numbers
  433. # but this should be good enough for now
  434. valid_name = r'(?!#)[\w!$%*+<=>?/.#:-]+'
  435. def _multi_escape(entries):
  436. return words(entries, suffix=' ')
  437. tokens = {
  438. 'root': [
  439. # the comments - always starting with semicolon
  440. # and going to the end of the line
  441. (r';.*$', Comment.Single),
  442. # whitespaces - usually not relevant
  443. (r',+', Text),
  444. (r'\s+', Whitespace),
  445. # numbers
  446. (r'-?\d+\.\d+', Number.Float),
  447. (r'-?\d+', Number.Integer),
  448. (r'0[0-7]+j?', Number.Oct),
  449. (r'0[xX][a-fA-F0-9]+', Number.Hex),
  450. # strings, symbols and characters
  451. (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
  452. (r"'" + valid_name, String.Symbol),
  453. (r"\\(.|[a-z]+)", String.Char),
  454. (r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
  455. (r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
  456. # keywords
  457. (r'::?' + valid_name, String.Symbol),
  458. # special operators
  459. (r'~@|[`\'#^~&@]', Operator),
  460. include('py-keywords'),
  461. include('py-builtins'),
  462. # highlight the special forms
  463. (_multi_escape(special_forms), Keyword),
  464. # Technically, only the special forms are 'keywords'. The problem
  465. # is that only treating them as keywords means that things like
  466. # 'defn' and 'ns' need to be highlighted as builtins. This is ugly
  467. # and weird for most styles. So, as a compromise we're going to
  468. # highlight them as Keyword.Declarations.
  469. (_multi_escape(declarations), Keyword.Declaration),
  470. # highlight the builtins
  471. (_multi_escape(builtins), Name.Builtin),
  472. # the remaining functions
  473. (r'(?<=\()' + valid_name, Name.Function),
  474. # find the remaining variables
  475. (valid_name, Name.Variable),
  476. # Hy accepts vector notation
  477. (r'(\[|\])', Punctuation),
  478. # Hy accepts map notation
  479. (r'(\{|\})', Punctuation),
  480. # the famous parentheses!
  481. (r'(\(|\))', Punctuation),
  482. ],
  483. 'py-keywords': PythonLexer.tokens['keywords'],
  484. 'py-builtins': PythonLexer.tokens['builtins'],
  485. }
  486. def analyse_text(text):
  487. if '(import ' in text or '(defn ' in text:
  488. return 0.9
  489. class RacketLexer(RegexLexer):
  490. """
  491. Lexer for Racket source code (formerly
  492. known as PLT Scheme).
  493. .. versionadded:: 1.6
  494. """
  495. name = 'Racket'
  496. url = 'http://racket-lang.org/'
  497. aliases = ['racket', 'rkt']
  498. filenames = ['*.rkt', '*.rktd', '*.rktl']
  499. mimetypes = ['text/x-racket', 'application/x-racket']
  500. # Generated by example.rkt
  501. _keywords = (
  502. '#%app', '#%datum', '#%declare', '#%expression', '#%module-begin',
  503. '#%plain-app', '#%plain-lambda', '#%plain-module-begin',
  504. '#%printing-module-begin', '#%provide', '#%require',
  505. '#%stratified-body', '#%top', '#%top-interaction',
  506. '#%variable-reference', '->', '->*', '->*m', '->d', '->dm', '->i',
  507. '->m', '...', ':do-in', '==', '=>', '_', 'absent', 'abstract',
  508. 'all-defined-out', 'all-from-out', 'and', 'any', 'augment', 'augment*',
  509. 'augment-final', 'augment-final*', 'augride', 'augride*', 'begin',
  510. 'begin-for-syntax', 'begin0', 'case', 'case->', 'case->m',
  511. 'case-lambda', 'class', 'class*', 'class-field-accessor',
  512. 'class-field-mutator', 'class/c', 'class/derived', 'combine-in',
  513. 'combine-out', 'command-line', 'compound-unit', 'compound-unit/infer',
  514. 'cond', 'cons/dc', 'contract', 'contract-out', 'contract-struct',
  515. 'contracted', 'define', 'define-compound-unit',
  516. 'define-compound-unit/infer', 'define-contract-struct',
  517. 'define-custom-hash-types', 'define-custom-set-types',
  518. 'define-for-syntax', 'define-local-member-name', 'define-logger',
  519. 'define-match-expander', 'define-member-name',
  520. 'define-module-boundary-contract', 'define-namespace-anchor',
  521. 'define-opt/c', 'define-sequence-syntax', 'define-serializable-class',
  522. 'define-serializable-class*', 'define-signature',
  523. 'define-signature-form', 'define-struct', 'define-struct/contract',
  524. 'define-struct/derived', 'define-syntax', 'define-syntax-rule',
  525. 'define-syntaxes', 'define-unit', 'define-unit-binding',
  526. 'define-unit-from-context', 'define-unit/contract',
  527. 'define-unit/new-import-export', 'define-unit/s', 'define-values',
  528. 'define-values-for-export', 'define-values-for-syntax',
  529. 'define-values/invoke-unit', 'define-values/invoke-unit/infer',
  530. 'define/augment', 'define/augment-final', 'define/augride',
  531. 'define/contract', 'define/final-prop', 'define/match',
  532. 'define/overment', 'define/override', 'define/override-final',
  533. 'define/private', 'define/public', 'define/public-final',
  534. 'define/pubment', 'define/subexpression-pos-prop',
  535. 'define/subexpression-pos-prop/name', 'delay', 'delay/idle',
  536. 'delay/name', 'delay/strict', 'delay/sync', 'delay/thread', 'do',
  537. 'else', 'except', 'except-in', 'except-out', 'export', 'extends',
  538. 'failure-cont', 'false', 'false/c', 'field', 'field-bound?', 'file',
  539. 'flat-murec-contract', 'flat-rec-contract', 'for', 'for*', 'for*/and',
  540. 'for*/async', 'for*/first', 'for*/fold', 'for*/fold/derived',
  541. 'for*/hash', 'for*/hasheq', 'for*/hasheqv', 'for*/last', 'for*/list',
  542. 'for*/lists', 'for*/mutable-set', 'for*/mutable-seteq',
  543. 'for*/mutable-seteqv', 'for*/or', 'for*/product', 'for*/set',
  544. 'for*/seteq', 'for*/seteqv', 'for*/stream', 'for*/sum', 'for*/vector',
  545. 'for*/weak-set', 'for*/weak-seteq', 'for*/weak-seteqv', 'for-label',
  546. 'for-meta', 'for-syntax', 'for-template', 'for/and', 'for/async',
  547. 'for/first', 'for/fold', 'for/fold/derived', 'for/hash', 'for/hasheq',
  548. 'for/hasheqv', 'for/last', 'for/list', 'for/lists', 'for/mutable-set',
  549. 'for/mutable-seteq', 'for/mutable-seteqv', 'for/or', 'for/product',
  550. 'for/set', 'for/seteq', 'for/seteqv', 'for/stream', 'for/sum',
  551. 'for/vector', 'for/weak-set', 'for/weak-seteq', 'for/weak-seteqv',
  552. 'gen:custom-write', 'gen:dict', 'gen:equal+hash', 'gen:set',
  553. 'gen:stream', 'generic', 'get-field', 'hash/dc', 'if', 'implies',
  554. 'import', 'include', 'include-at/relative-to',
  555. 'include-at/relative-to/reader', 'include/reader', 'inherit',
  556. 'inherit-field', 'inherit/inner', 'inherit/super', 'init',
  557. 'init-depend', 'init-field', 'init-rest', 'inner', 'inspect',
  558. 'instantiate', 'interface', 'interface*', 'invariant-assertion',
  559. 'invoke-unit', 'invoke-unit/infer', 'lambda', 'lazy', 'let', 'let*',
  560. 'let*-values', 'let-syntax', 'let-syntaxes', 'let-values', 'let/cc',
  561. 'let/ec', 'letrec', 'letrec-syntax', 'letrec-syntaxes',
  562. 'letrec-syntaxes+values', 'letrec-values', 'lib', 'link', 'local',
  563. 'local-require', 'log-debug', 'log-error', 'log-fatal', 'log-info',
  564. 'log-warning', 'match', 'match*', 'match*/derived', 'match-define',
  565. 'match-define-values', 'match-lambda', 'match-lambda*',
  566. 'match-lambda**', 'match-let', 'match-let*', 'match-let*-values',
  567. 'match-let-values', 'match-letrec', 'match-letrec-values',
  568. 'match/derived', 'match/values', 'member-name-key', 'mixin', 'module',
  569. 'module*', 'module+', 'nand', 'new', 'nor', 'object-contract',
  570. 'object/c', 'only', 'only-in', 'only-meta-in', 'open', 'opt/c', 'or',
  571. 'overment', 'overment*', 'override', 'override*', 'override-final',
  572. 'override-final*', 'parameterize', 'parameterize*',
  573. 'parameterize-break', 'parametric->/c', 'place', 'place*',
  574. 'place/context', 'planet', 'prefix', 'prefix-in', 'prefix-out',
  575. 'private', 'private*', 'prompt-tag/c', 'protect-out', 'provide',
  576. 'provide-signature-elements', 'provide/contract', 'public', 'public*',
  577. 'public-final', 'public-final*', 'pubment', 'pubment*', 'quasiquote',
  578. 'quasisyntax', 'quasisyntax/loc', 'quote', 'quote-syntax',
  579. 'quote-syntax/prune', 'recontract-out', 'recursive-contract',
  580. 'relative-in', 'rename', 'rename-in', 'rename-inner', 'rename-out',
  581. 'rename-super', 'require', 'send', 'send*', 'send+', 'send-generic',
  582. 'send/apply', 'send/keyword-apply', 'set!', 'set!-values',
  583. 'set-field!', 'shared', 'stream', 'stream*', 'stream-cons', 'struct',
  584. 'struct*', 'struct-copy', 'struct-field-index', 'struct-out',
  585. 'struct/c', 'struct/ctc', 'struct/dc', 'submod', 'super',
  586. 'super-instantiate', 'super-make-object', 'super-new', 'syntax',
  587. 'syntax-case', 'syntax-case*', 'syntax-id-rules', 'syntax-rules',
  588. 'syntax/loc', 'tag', 'this', 'this%', 'thunk', 'thunk*', 'time',
  589. 'unconstrained-domain->', 'unit', 'unit-from-context', 'unit/c',
  590. 'unit/new-import-export', 'unit/s', 'unless', 'unquote',
  591. 'unquote-splicing', 'unsyntax', 'unsyntax-splicing', 'values/drop',
  592. 'when', 'with-continuation-mark', 'with-contract',
  593. 'with-contract-continuation-mark', 'with-handlers', 'with-handlers*',
  594. 'with-method', 'with-syntax', 'λ'
  595. )
  596. # Generated by example.rkt
  597. _builtins = (
  598. '*', '*list/c', '+', '-', '/', '<', '</c', '<=', '<=/c', '=', '=/c',
  599. '>', '>/c', '>=', '>=/c', 'abort-current-continuation', 'abs',
  600. 'absolute-path?', 'acos', 'add-between', 'add1', 'alarm-evt',
  601. 'always-evt', 'and/c', 'andmap', 'angle', 'any/c', 'append', 'append*',
  602. 'append-map', 'apply', 'argmax', 'argmin', 'arithmetic-shift',
  603. 'arity-at-least', 'arity-at-least-value', 'arity-at-least?',
  604. 'arity-checking-wrapper', 'arity-includes?', 'arity=?',
  605. 'arrow-contract-info', 'arrow-contract-info-accepts-arglist',
  606. 'arrow-contract-info-chaperone-procedure',
  607. 'arrow-contract-info-check-first-order', 'arrow-contract-info?',
  608. 'asin', 'assf', 'assoc', 'assq', 'assv', 'atan',
  609. 'bad-number-of-results', 'banner', 'base->-doms/c', 'base->-rngs/c',
  610. 'base->?', 'between/c', 'bitwise-and', 'bitwise-bit-field',
  611. 'bitwise-bit-set?', 'bitwise-ior', 'bitwise-not', 'bitwise-xor',
  612. 'blame-add-car-context', 'blame-add-cdr-context', 'blame-add-context',
  613. 'blame-add-missing-party', 'blame-add-nth-arg-context',
  614. 'blame-add-range-context', 'blame-add-unknown-context',
  615. 'blame-context', 'blame-contract', 'blame-fmt->-string',
  616. 'blame-missing-party?', 'blame-negative', 'blame-original?',
  617. 'blame-positive', 'blame-replace-negative', 'blame-source',
  618. 'blame-swap', 'blame-swapped?', 'blame-update', 'blame-value',
  619. 'blame?', 'boolean=?', 'boolean?', 'bound-identifier=?', 'box',
  620. 'box-cas!', 'box-immutable', 'box-immutable/c', 'box/c', 'box?',
  621. 'break-enabled', 'break-parameterization?', 'break-thread',
  622. 'build-chaperone-contract-property', 'build-compound-type-name',
  623. 'build-contract-property', 'build-flat-contract-property',
  624. 'build-list', 'build-path', 'build-path/convention-type',
  625. 'build-string', 'build-vector', 'byte-pregexp', 'byte-pregexp?',
  626. 'byte-ready?', 'byte-regexp', 'byte-regexp?', 'byte?', 'bytes',
  627. 'bytes->immutable-bytes', 'bytes->list', 'bytes->path',
  628. 'bytes->path-element', 'bytes->string/latin-1', 'bytes->string/locale',
  629. 'bytes->string/utf-8', 'bytes-append', 'bytes-append*',
  630. 'bytes-close-converter', 'bytes-convert', 'bytes-convert-end',
  631. 'bytes-converter?', 'bytes-copy', 'bytes-copy!',
  632. 'bytes-environment-variable-name?', 'bytes-fill!', 'bytes-join',
  633. 'bytes-length', 'bytes-no-nuls?', 'bytes-open-converter', 'bytes-ref',
  634. 'bytes-set!', 'bytes-utf-8-index', 'bytes-utf-8-length',
  635. 'bytes-utf-8-ref', 'bytes<?', 'bytes=?', 'bytes>?', 'bytes?', 'caaaar',
  636. 'caaadr', 'caaar', 'caadar', 'caaddr', 'caadr', 'caar', 'cadaar',
  637. 'cadadr', 'cadar', 'caddar', 'cadddr', 'caddr', 'cadr',
  638. 'call-in-nested-thread', 'call-with-atomic-output-file',
  639. 'call-with-break-parameterization',
  640. 'call-with-composable-continuation', 'call-with-continuation-barrier',
  641. 'call-with-continuation-prompt', 'call-with-current-continuation',
  642. 'call-with-default-reading-parameterization',
  643. 'call-with-escape-continuation', 'call-with-exception-handler',
  644. 'call-with-file-lock/timeout', 'call-with-immediate-continuation-mark',
  645. 'call-with-input-bytes', 'call-with-input-file',
  646. 'call-with-input-file*', 'call-with-input-string',
  647. 'call-with-output-bytes', 'call-with-output-file',
  648. 'call-with-output-file*', 'call-with-output-string',
  649. 'call-with-parameterization', 'call-with-semaphore',
  650. 'call-with-semaphore/enable-break', 'call-with-values', 'call/cc',
  651. 'call/ec', 'car', 'cartesian-product', 'cdaaar', 'cdaadr', 'cdaar',
  652. 'cdadar', 'cdaddr', 'cdadr', 'cdar', 'cddaar', 'cddadr', 'cddar',
  653. 'cdddar', 'cddddr', 'cdddr', 'cddr', 'cdr', 'ceiling', 'channel-get',
  654. 'channel-put', 'channel-put-evt', 'channel-put-evt?',
  655. 'channel-try-get', 'channel/c', 'channel?', 'chaperone-box',
  656. 'chaperone-channel', 'chaperone-continuation-mark-key',
  657. 'chaperone-contract-property?', 'chaperone-contract?', 'chaperone-evt',
  658. 'chaperone-hash', 'chaperone-hash-set', 'chaperone-of?',
  659. 'chaperone-procedure', 'chaperone-procedure*', 'chaperone-prompt-tag',
  660. 'chaperone-struct', 'chaperone-struct-type', 'chaperone-vector',
  661. 'chaperone?', 'char->integer', 'char-alphabetic?', 'char-blank?',
  662. 'char-ci<=?', 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?',
  663. 'char-downcase', 'char-foldcase', 'char-general-category',
  664. 'char-graphic?', 'char-in', 'char-in/c', 'char-iso-control?',
  665. 'char-lower-case?', 'char-numeric?', 'char-punctuation?',
  666. 'char-ready?', 'char-symbolic?', 'char-title-case?', 'char-titlecase',
  667. 'char-upcase', 'char-upper-case?', 'char-utf-8-length',
  668. 'char-whitespace?', 'char<=?', 'char<?', 'char=?', 'char>=?', 'char>?',
  669. 'char?', 'check-duplicate-identifier', 'check-duplicates',
  670. 'checked-procedure-check-and-extract', 'choice-evt',
  671. 'class->interface', 'class-info', 'class-seal', 'class-unseal',
  672. 'class?', 'cleanse-path', 'close-input-port', 'close-output-port',
  673. 'coerce-chaperone-contract', 'coerce-chaperone-contracts',
  674. 'coerce-contract', 'coerce-contract/f', 'coerce-contracts',
  675. 'coerce-flat-contract', 'coerce-flat-contracts', 'collect-garbage',
  676. 'collection-file-path', 'collection-path', 'combinations', 'compile',
  677. 'compile-allow-set!-undefined', 'compile-context-preservation-enabled',
  678. 'compile-enforce-module-constants', 'compile-syntax',
  679. 'compiled-expression-recompile', 'compiled-expression?',
  680. 'compiled-module-expression?', 'complete-path?', 'complex?', 'compose',
  681. 'compose1', 'conjoin', 'conjugate', 'cons', 'cons/c', 'cons?', 'const',
  682. 'continuation-mark-key/c', 'continuation-mark-key?',
  683. 'continuation-mark-set->context', 'continuation-mark-set->list',
  684. 'continuation-mark-set->list*', 'continuation-mark-set-first',
  685. 'continuation-mark-set?', 'continuation-marks',
  686. 'continuation-prompt-available?', 'continuation-prompt-tag?',
  687. 'continuation?', 'contract-continuation-mark-key',
  688. 'contract-custom-write-property-proc', 'contract-exercise',
  689. 'contract-first-order', 'contract-first-order-passes?',
  690. 'contract-late-neg-projection', 'contract-name', 'contract-proc',
  691. 'contract-projection', 'contract-property?',
  692. 'contract-random-generate', 'contract-random-generate-fail',
  693. 'contract-random-generate-fail?',
  694. 'contract-random-generate-get-current-environment',
  695. 'contract-random-generate-stash', 'contract-random-generate/choose',
  696. 'contract-stronger?', 'contract-struct-exercise',
  697. 'contract-struct-generate', 'contract-struct-late-neg-projection',
  698. 'contract-struct-list-contract?', 'contract-val-first-projection',
  699. 'contract?', 'convert-stream', 'copy-directory/files', 'copy-file',
  700. 'copy-port', 'cos', 'cosh', 'count', 'current-blame-format',
  701. 'current-break-parameterization', 'current-code-inspector',
  702. 'current-command-line-arguments', 'current-compile',
  703. 'current-compiled-file-roots', 'current-continuation-marks',
  704. 'current-contract-region', 'current-custodian', 'current-directory',
  705. 'current-directory-for-user', 'current-drive',
  706. 'current-environment-variables', 'current-error-port', 'current-eval',
  707. 'current-evt-pseudo-random-generator',
  708. 'current-force-delete-permissions', 'current-future',
  709. 'current-gc-milliseconds', 'current-get-interaction-input-port',
  710. 'current-inexact-milliseconds', 'current-input-port',
  711. 'current-inspector', 'current-library-collection-links',
  712. 'current-library-collection-paths', 'current-load',
  713. 'current-load-extension', 'current-load-relative-directory',
  714. 'current-load/use-compiled', 'current-locale', 'current-logger',
  715. 'current-memory-use', 'current-milliseconds',
  716. 'current-module-declare-name', 'current-module-declare-source',
  717. 'current-module-name-resolver', 'current-module-path-for-load',
  718. 'current-namespace', 'current-output-port', 'current-parameterization',
  719. 'current-plumber', 'current-preserved-thread-cell-values',
  720. 'current-print', 'current-process-milliseconds', 'current-prompt-read',
  721. 'current-pseudo-random-generator', 'current-read-interaction',
  722. 'current-reader-guard', 'current-readtable', 'current-seconds',
  723. 'current-security-guard', 'current-subprocess-custodian-mode',
  724. 'current-thread', 'current-thread-group',
  725. 'current-thread-initial-stack-size',
  726. 'current-write-relative-directory', 'curry', 'curryr',
  727. 'custodian-box-value', 'custodian-box?', 'custodian-limit-memory',
  728. 'custodian-managed-list', 'custodian-memory-accounting-available?',
  729. 'custodian-require-memory', 'custodian-shutdown-all', 'custodian?',
  730. 'custom-print-quotable-accessor', 'custom-print-quotable?',
  731. 'custom-write-accessor', 'custom-write-property-proc', 'custom-write?',
  732. 'date', 'date*', 'date*-nanosecond', 'date*-time-zone-name', 'date*?',
  733. 'date-day', 'date-dst?', 'date-hour', 'date-minute', 'date-month',
  734. 'date-second', 'date-time-zone-offset', 'date-week-day', 'date-year',
  735. 'date-year-day', 'date?', 'datum->syntax', 'datum-intern-literal',
  736. 'default-continuation-prompt-tag', 'degrees->radians',
  737. 'delete-directory', 'delete-directory/files', 'delete-file',
  738. 'denominator', 'dict->list', 'dict-can-functional-set?',
  739. 'dict-can-remove-keys?', 'dict-clear', 'dict-clear!', 'dict-copy',
  740. 'dict-count', 'dict-empty?', 'dict-for-each', 'dict-has-key?',
  741. 'dict-implements/c', 'dict-implements?', 'dict-iter-contract',
  742. 'dict-iterate-first', 'dict-iterate-key', 'dict-iterate-next',
  743. 'dict-iterate-value', 'dict-key-contract', 'dict-keys', 'dict-map',
  744. 'dict-mutable?', 'dict-ref', 'dict-ref!', 'dict-remove',
  745. 'dict-remove!', 'dict-set', 'dict-set!', 'dict-set*', 'dict-set*!',
  746. 'dict-update', 'dict-update!', 'dict-value-contract', 'dict-values',
  747. 'dict?', 'directory-exists?', 'directory-list', 'disjoin', 'display',
  748. 'display-lines', 'display-lines-to-file', 'display-to-file',
  749. 'displayln', 'double-flonum?', 'drop', 'drop-common-prefix',
  750. 'drop-right', 'dropf', 'dropf-right', 'dump-memory-stats',
  751. 'dup-input-port', 'dup-output-port', 'dynamic->*', 'dynamic-get-field',
  752. 'dynamic-object/c', 'dynamic-place', 'dynamic-place*',
  753. 'dynamic-require', 'dynamic-require-for-syntax', 'dynamic-send',
  754. 'dynamic-set-field!', 'dynamic-wind', 'eighth', 'empty',
  755. 'empty-sequence', 'empty-stream', 'empty?',
  756. 'environment-variables-copy', 'environment-variables-names',
  757. 'environment-variables-ref', 'environment-variables-set!',
  758. 'environment-variables?', 'eof', 'eof-evt', 'eof-object?',
  759. 'ephemeron-value', 'ephemeron?', 'eprintf', 'eq-contract-val',
  760. 'eq-contract?', 'eq-hash-code', 'eq?', 'equal-contract-val',
  761. 'equal-contract?', 'equal-hash-code', 'equal-secondary-hash-code',
  762. 'equal<%>', 'equal?', 'equal?/recur', 'eqv-hash-code', 'eqv?', 'error',
  763. 'error-display-handler', 'error-escape-handler',
  764. 'error-print-context-length', 'error-print-source-location',
  765. 'error-print-width', 'error-value->string-handler', 'eval',
  766. 'eval-jit-enabled', 'eval-syntax', 'even?', 'evt/c', 'evt?',
  767. 'exact->inexact', 'exact-ceiling', 'exact-floor', 'exact-integer?',
  768. 'exact-nonnegative-integer?', 'exact-positive-integer?', 'exact-round',
  769. 'exact-truncate', 'exact?', 'executable-yield-handler', 'exit',
  770. 'exit-handler', 'exn', 'exn-continuation-marks', 'exn-message',
  771. 'exn:break', 'exn:break-continuation', 'exn:break:hang-up',
  772. 'exn:break:hang-up?', 'exn:break:terminate', 'exn:break:terminate?',
  773. 'exn:break?', 'exn:fail', 'exn:fail:contract',
  774. 'exn:fail:contract:arity', 'exn:fail:contract:arity?',
  775. 'exn:fail:contract:blame', 'exn:fail:contract:blame-object',
  776. 'exn:fail:contract:blame?', 'exn:fail:contract:continuation',
  777. 'exn:fail:contract:continuation?', 'exn:fail:contract:divide-by-zero',
  778. 'exn:fail:contract:divide-by-zero?',
  779. 'exn:fail:contract:non-fixnum-result',
  780. 'exn:fail:contract:non-fixnum-result?', 'exn:fail:contract:variable',
  781. 'exn:fail:contract:variable-id', 'exn:fail:contract:variable?',
  782. 'exn:fail:contract?', 'exn:fail:filesystem',
  783. 'exn:fail:filesystem:errno', 'exn:fail:filesystem:errno-errno',
  784. 'exn:fail:filesystem:errno?', 'exn:fail:filesystem:exists',
  785. 'exn:fail:filesystem:exists?', 'exn:fail:filesystem:missing-module',
  786. 'exn:fail:filesystem:missing-module-path',
  787. 'exn:fail:filesystem:missing-module?', 'exn:fail:filesystem:version',
  788. 'exn:fail:filesystem:version?', 'exn:fail:filesystem?',
  789. 'exn:fail:network', 'exn:fail:network:errno',
  790. 'exn:fail:network:errno-errno', 'exn:fail:network:errno?',
  791. 'exn:fail:network?', 'exn:fail:object', 'exn:fail:object?',
  792. 'exn:fail:out-of-memory', 'exn:fail:out-of-memory?', 'exn:fail:read',
  793. 'exn:fail:read-srclocs', 'exn:fail:read:eof', 'exn:fail:read:eof?',
  794. 'exn:fail:read:non-char', 'exn:fail:read:non-char?', 'exn:fail:read?',
  795. 'exn:fail:syntax', 'exn:fail:syntax-exprs',
  796. 'exn:fail:syntax:missing-module',
  797. 'exn:fail:syntax:missing-module-path',
  798. 'exn:fail:syntax:missing-module?', 'exn:fail:syntax:unbound',
  799. 'exn:fail:syntax:unbound?', 'exn:fail:syntax?', 'exn:fail:unsupported',
  800. 'exn:fail:unsupported?', 'exn:fail:user', 'exn:fail:user?',
  801. 'exn:fail?', 'exn:misc:match?', 'exn:missing-module-accessor',
  802. 'exn:missing-module?', 'exn:srclocs-accessor', 'exn:srclocs?', 'exn?',
  803. 'exp', 'expand', 'expand-once', 'expand-syntax', 'expand-syntax-once',
  804. 'expand-syntax-to-top-form', 'expand-to-top-form', 'expand-user-path',
  805. 'explode-path', 'expt', 'externalizable<%>', 'failure-result/c',
  806. 'false?', 'field-names', 'fifth', 'file->bytes', 'file->bytes-lines',
  807. 'file->lines', 'file->list', 'file->string', 'file->value',
  808. 'file-exists?', 'file-name-from-path', 'file-or-directory-identity',
  809. 'file-or-directory-modify-seconds', 'file-or-directory-permissions',
  810. 'file-position', 'file-position*', 'file-size',
  811. 'file-stream-buffer-mode', 'file-stream-port?', 'file-truncate',
  812. 'filename-extension', 'filesystem-change-evt',
  813. 'filesystem-change-evt-cancel', 'filesystem-change-evt?',
  814. 'filesystem-root-list', 'filter', 'filter-map', 'filter-not',
  815. 'filter-read-input-port', 'find-executable-path', 'find-files',
  816. 'find-library-collection-links', 'find-library-collection-paths',
  817. 'find-relative-path', 'find-system-path', 'findf', 'first',
  818. 'first-or/c', 'fixnum?', 'flat-contract', 'flat-contract-predicate',
  819. 'flat-contract-property?', 'flat-contract?', 'flat-named-contract',
  820. 'flatten', 'floating-point-bytes->real', 'flonum?', 'floor',
  821. 'flush-output', 'fold-files', 'foldl', 'foldr', 'for-each', 'force',
  822. 'format', 'fourth', 'fprintf', 'free-identifier=?',
  823. 'free-label-identifier=?', 'free-template-identifier=?',
  824. 'free-transformer-identifier=?', 'fsemaphore-count', 'fsemaphore-post',
  825. 'fsemaphore-try-wait?', 'fsemaphore-wait', 'fsemaphore?', 'future',
  826. 'future?', 'futures-enabled?', 'gcd', 'generate-member-key',
  827. 'generate-temporaries', 'generic-set?', 'generic?', 'gensym',
  828. 'get-output-bytes', 'get-output-string', 'get-preference',
  829. 'get/build-late-neg-projection', 'get/build-val-first-projection',
  830. 'getenv', 'global-port-print-handler', 'group-by', 'group-execute-bit',
  831. 'group-read-bit', 'group-write-bit', 'guard-evt', 'handle-evt',
  832. 'handle-evt?', 'has-blame?', 'has-contract?', 'hash', 'hash->list',
  833. 'hash-clear', 'hash-clear!', 'hash-copy', 'hash-copy-clear',
  834. 'hash-count', 'hash-empty?', 'hash-eq?', 'hash-equal?', 'hash-eqv?',
  835. 'hash-for-each', 'hash-has-key?', 'hash-iterate-first',
  836. 'hash-iterate-key', 'hash-iterate-key+value', 'hash-iterate-next',
  837. 'hash-iterate-pair', 'hash-iterate-value', 'hash-keys', 'hash-map',
  838. 'hash-placeholder?', 'hash-ref', 'hash-ref!', 'hash-remove',
  839. 'hash-remove!', 'hash-set', 'hash-set!', 'hash-set*', 'hash-set*!',
  840. 'hash-update', 'hash-update!', 'hash-values', 'hash-weak?', 'hash/c',
  841. 'hash?', 'hasheq', 'hasheqv', 'identifier-binding',
  842. 'identifier-binding-symbol', 'identifier-label-binding',
  843. 'identifier-prune-lexical-context',
  844. 'identifier-prune-to-source-module',
  845. 'identifier-remove-from-definition-context',
  846. 'identifier-template-binding', 'identifier-transformer-binding',
  847. 'identifier?', 'identity', 'if/c', 'imag-part', 'immutable?',
  848. 'impersonate-box', 'impersonate-channel',
  849. 'impersonate-continuation-mark-key', 'impersonate-hash',
  850. 'impersonate-hash-set', 'impersonate-procedure',
  851. 'impersonate-procedure*', 'impersonate-prompt-tag',
  852. 'impersonate-struct', 'impersonate-vector', 'impersonator-contract?',
  853. 'impersonator-ephemeron', 'impersonator-of?',
  854. 'impersonator-prop:application-mark', 'impersonator-prop:blame',
  855. 'impersonator-prop:contracted',
  856. 'impersonator-property-accessor-procedure?', 'impersonator-property?',
  857. 'impersonator?', 'implementation?', 'implementation?/c', 'in-bytes',
  858. 'in-bytes-lines', 'in-combinations', 'in-cycle', 'in-dict',
  859. 'in-dict-keys', 'in-dict-pairs', 'in-dict-values', 'in-directory',
  860. 'in-hash', 'in-hash-keys', 'in-hash-pairs', 'in-hash-values',
  861. 'in-immutable-hash', 'in-immutable-hash-keys',
  862. 'in-immutable-hash-pairs', 'in-immutable-hash-values',
  863. 'in-immutable-set', 'in-indexed', 'in-input-port-bytes',
  864. 'in-input-port-chars', 'in-lines', 'in-list', 'in-mlist',
  865. 'in-mutable-hash', 'in-mutable-hash-keys', 'in-mutable-hash-pairs',
  866. 'in-mutable-hash-values', 'in-mutable-set', 'in-naturals',
  867. 'in-parallel', 'in-permutations', 'in-port', 'in-producer', 'in-range',
  868. 'in-sequences', 'in-set', 'in-slice', 'in-stream', 'in-string',
  869. 'in-syntax', 'in-value', 'in-values*-sequence', 'in-values-sequence',
  870. 'in-vector', 'in-weak-hash', 'in-weak-hash-keys', 'in-weak-hash-pairs',
  871. 'in-weak-hash-values', 'in-weak-set', 'inexact->exact',
  872. 'inexact-real?', 'inexact?', 'infinite?', 'input-port-append',
  873. 'input-port?', 'inspector?', 'instanceof/c', 'integer->char',
  874. 'integer->integer-bytes', 'integer-bytes->integer', 'integer-in',
  875. 'integer-length', 'integer-sqrt', 'integer-sqrt/remainder', 'integer?',
  876. 'interface->method-names', 'interface-extension?', 'interface?',
  877. 'internal-definition-context-binding-identifiers',
  878. 'internal-definition-context-introduce',
  879. 'internal-definition-context-seal', 'internal-definition-context?',
  880. 'is-a?', 'is-a?/c', 'keyword->string', 'keyword-apply', 'keyword<?',
  881. 'keyword?', 'keywords-match', 'kill-thread', 'last', 'last-pair',
  882. 'lcm', 'length', 'liberal-define-context?', 'link-exists?', 'list',
  883. 'list*', 'list*of', 'list->bytes', 'list->mutable-set',
  884. 'list->mutable-seteq', 'list->mutable-seteqv', 'list->set',
  885. 'list->seteq', 'list->seteqv', 'list->string', 'list->vector',
  886. 'list->weak-set', 'list->weak-seteq', 'list->weak-seteqv',
  887. 'list-contract?', 'list-prefix?', 'list-ref', 'list-set', 'list-tail',
  888. 'list-update', 'list/c', 'list?', 'listen-port-number?', 'listof',
  889. 'load', 'load-extension', 'load-on-demand-enabled', 'load-relative',
  890. 'load-relative-extension', 'load/cd', 'load/use-compiled',
  891. 'local-expand', 'local-expand/capture-lifts',
  892. 'local-transformer-expand', 'local-transformer-expand/capture-lifts',
  893. 'locale-string-encoding', 'log', 'log-all-levels', 'log-level-evt',
  894. 'log-level?', 'log-max-level', 'log-message', 'log-receiver?',
  895. 'logger-name', 'logger?', 'magnitude', 'make-arity-at-least',
  896. 'make-base-empty-namespace', 'make-base-namespace', 'make-bytes',
  897. 'make-channel', 'make-chaperone-contract',
  898. 'make-continuation-mark-key', 'make-continuation-prompt-tag',
  899. 'make-contract', 'make-custodian', 'make-custodian-box',
  900. 'make-custom-hash', 'make-custom-hash-types', 'make-custom-set',
  901. 'make-custom-set-types', 'make-date', 'make-date*',
  902. 'make-derived-parameter', 'make-directory', 'make-directory*',
  903. 'make-do-sequence', 'make-empty-namespace',
  904. 'make-environment-variables', 'make-ephemeron', 'make-exn',
  905. 'make-exn:break', 'make-exn:break:hang-up', 'make-exn:break:terminate',
  906. 'make-exn:fail', 'make-exn:fail:contract',
  907. 'make-exn:fail:contract:arity', 'make-exn:fail:contract:blame',
  908. 'make-exn:fail:contract:continuation',
  909. 'make-exn:fail:contract:divide-by-zero',
  910. 'make-exn:fail:contract:non-fixnum-result',
  911. 'make-exn:fail:contract:variable', 'make-exn:fail:filesystem',
  912. 'make-exn:fail:filesystem:errno', 'make-exn:fail:filesystem:exists',
  913. 'make-exn:fail:filesystem:missing-module',
  914. 'make-exn:fail:filesystem:version', 'make-exn:fail:network',
  915. 'make-exn:fail:network:errno', 'make-exn:fail:object',
  916. 'make-exn:fail:out-of-memory', 'make-exn:fail:read',
  917. 'make-exn:fail:read:eof', 'make-exn:fail:read:non-char',
  918. 'make-exn:fail:syntax', 'make-exn:fail:syntax:missing-module',
  919. 'make-exn:fail:syntax:unbound', 'make-exn:fail:unsupported',
  920. 'make-exn:fail:user', 'make-file-or-directory-link',
  921. 'make-flat-contract', 'make-fsemaphore', 'make-generic',
  922. 'make-handle-get-preference-locked', 'make-hash',
  923. 'make-hash-placeholder', 'make-hasheq', 'make-hasheq-placeholder',
  924. 'make-hasheqv', 'make-hasheqv-placeholder',
  925. 'make-immutable-custom-hash', 'make-immutable-hash',
  926. 'make-immutable-hasheq', 'make-immutable-hasheqv',
  927. 'make-impersonator-property', 'make-input-port',
  928. 'make-input-port/read-to-peek', 'make-inspector',
  929. 'make-keyword-procedure', 'make-known-char-range-list',
  930. 'make-limited-input-port', 'make-list', 'make-lock-file-name',
  931. 'make-log-receiver', 'make-logger', 'make-mixin-contract',
  932. 'make-mutable-custom-set', 'make-none/c', 'make-object',
  933. 'make-output-port', 'make-parameter', 'make-parent-directory*',
  934. 'make-phantom-bytes', 'make-pipe', 'make-pipe-with-specials',
  935. 'make-placeholder', 'make-plumber', 'make-polar', 'make-prefab-struct',
  936. 'make-primitive-class', 'make-proj-contract',
  937. 'make-pseudo-random-generator', 'make-reader-graph', 'make-readtable',
  938. 'make-rectangular', 'make-rename-transformer',
  939. 'make-resolved-module-path', 'make-security-guard', 'make-semaphore',
  940. 'make-set!-transformer', 'make-shared-bytes', 'make-sibling-inspector',
  941. 'make-special-comment', 'make-srcloc', 'make-string',
  942. 'make-struct-field-accessor', 'make-struct-field-mutator',
  943. 'make-struct-type', 'make-struct-type-property',
  944. 'make-syntax-delta-introducer', 'make-syntax-introducer',
  945. 'make-temporary-file', 'make-tentative-pretty-print-output-port',
  946. 'make-thread-cell', 'make-thread-group', 'make-vector',
  947. 'make-weak-box', 'make-weak-custom-hash', 'make-weak-custom-set',
  948. 'make-weak-hash', 'make-weak-hasheq', 'make-weak-hasheqv',
  949. 'make-will-executor', 'map', 'match-equality-test',
  950. 'matches-arity-exactly?', 'max', 'mcar', 'mcdr', 'mcons', 'member',
  951. 'member-name-key-hash-code', 'member-name-key=?', 'member-name-key?',
  952. 'memf', 'memq', 'memv', 'merge-input', 'method-in-interface?', 'min',
  953. 'mixin-contract', 'module->exports', 'module->imports',
  954. 'module->language-info', 'module->namespace',
  955. 'module-compiled-cross-phase-persistent?', 'module-compiled-exports',
  956. 'module-compiled-imports', 'module-compiled-language-info',
  957. 'module-compiled-name', 'module-compiled-submodules',
  958. 'module-declared?', 'module-path-index-join',
  959. 'module-path-index-resolve', 'module-path-index-split',
  960. 'module-path-index-submodule', 'module-path-index?', 'module-path?',
  961. 'module-predefined?', 'module-provide-protected?', 'modulo', 'mpair?',
  962. 'mutable-set', 'mutable-seteq', 'mutable-seteqv', 'n->th',
  963. 'nack-guard-evt', 'namespace-anchor->empty-namespace',
  964. 'namespace-anchor->namespace', 'namespace-anchor?',
  965. 'namespace-attach-module', 'namespace-attach-module-declaration',
  966. 'namespace-base-phase', 'namespace-mapped-symbols',
  967. 'namespace-module-identifier', 'namespace-module-registry',
  968. 'namespace-require', 'namespace-require/constant',
  969. 'namespace-require/copy', 'namespace-require/expansion-time',
  970. 'namespace-set-variable-value!', 'namespace-symbol->identifier',
  971. 'namespace-syntax-introduce', 'namespace-undefine-variable!',
  972. 'namespace-unprotect-module', 'namespace-variable-value', 'namespace?',
  973. 'nan?', 'natural-number/c', 'negate', 'negative?', 'never-evt',
  974. 'new-∀/c', 'new-∃/c', 'newline', 'ninth', 'non-empty-listof',
  975. 'non-empty-string?', 'none/c', 'normal-case-path', 'normalize-arity',
  976. 'normalize-path', 'normalized-arity?', 'not', 'not/c', 'null', 'null?',
  977. 'number->string', 'number?', 'numerator', 'object%', 'object->vector',
  978. 'object-info', 'object-interface', 'object-method-arity-includes?',
  979. 'object-name', 'object-or-false=?', 'object=?', 'object?', 'odd?',
  980. 'one-of/c', 'open-input-bytes', 'open-input-file',
  981. 'open-input-output-file', 'open-input-string', 'open-output-bytes',
  982. 'open-output-file', 'open-output-nowhere', 'open-output-string',
  983. 'or/c', 'order-of-magnitude', 'ormap', 'other-execute-bit',
  984. 'other-read-bit', 'other-write-bit', 'output-port?', 'pair?',
  985. 'parameter-procedure=?', 'parameter/c', 'parameter?',
  986. 'parameterization?', 'parse-command-line', 'partition', 'path->bytes',
  987. 'path->complete-path', 'path->directory-path', 'path->string',
  988. 'path-add-suffix', 'path-convention-type', 'path-element->bytes',
  989. 'path-element->string', 'path-element?', 'path-for-some-system?',
  990. 'path-list-string->path-list', 'path-only', 'path-replace-suffix',
  991. 'path-string?', 'path<?', 'path?', 'pathlist-closure', 'peek-byte',
  992. 'peek-byte-or-special', 'peek-bytes', 'peek-bytes!', 'peek-bytes!-evt',
  993. 'peek-bytes-avail!', 'peek-bytes-avail!*', 'peek-bytes-avail!-evt',
  994. 'peek-bytes-avail!/enable-break', 'peek-bytes-evt', 'peek-char',
  995. 'peek-char-or-special', 'peek-string', 'peek-string!',
  996. 'peek-string!-evt', 'peek-string-evt', 'peeking-input-port',
  997. 'permutations', 'phantom-bytes?', 'pi', 'pi.f', 'pipe-content-length',
  998. 'place-break', 'place-channel', 'place-channel-get',
  999. 'place-channel-put', 'place-channel-put/get', 'place-channel?',
  1000. 'place-dead-evt', 'place-enabled?', 'place-kill', 'place-location?',
  1001. 'place-message-allowed?', 'place-sleep', 'place-wait', 'place?',
  1002. 'placeholder-get', 'placeholder-set!', 'placeholder?',
  1003. 'plumber-add-flush!', 'plumber-flush-all',
  1004. 'plumber-flush-handle-remove!', 'plumber-flush-handle?', 'plumber?',
  1005. 'poll-guard-evt', 'port->bytes', 'port->bytes-lines', 'port->lines',
  1006. 'port->list', 'port->string', 'port-closed-evt', 'port-closed?',
  1007. 'port-commit-peeked', 'port-count-lines!', 'port-count-lines-enabled',
  1008. 'port-counts-lines?', 'port-display-handler', 'port-file-identity',
  1009. 'port-file-unlock', 'port-next-location', 'port-number?',
  1010. 'port-print-handler', 'port-progress-evt',
  1011. 'port-provides-progress-evts?', 'port-read-handler',
  1012. 'port-try-file-lock?', 'port-write-handler', 'port-writes-atomic?',
  1013. 'port-writes-special?', 'port?', 'positive?', 'predicate/c',
  1014. 'prefab-key->struct-type', 'prefab-key?', 'prefab-struct-key',
  1015. 'preferences-lock-file-mode', 'pregexp', 'pregexp?', 'pretty-display',
  1016. 'pretty-format', 'pretty-print', 'pretty-print-.-symbol-without-bars',
  1017. 'pretty-print-abbreviate-read-macros', 'pretty-print-columns',
  1018. 'pretty-print-current-style-table', 'pretty-print-depth',
  1019. 'pretty-print-exact-as-decimal', 'pretty-print-extend-style-table',
  1020. 'pretty-print-handler', 'pretty-print-newline',
  1021. 'pretty-print-post-print-hook', 'pretty-print-pre-print-hook',
  1022. 'pretty-print-print-hook', 'pretty-print-print-line',
  1023. 'pretty-print-remap-stylable', 'pretty-print-show-inexactness',
  1024. 'pretty-print-size-hook', 'pretty-print-style-table?',
  1025. 'pretty-printing', 'pretty-write', 'primitive-closure?',
  1026. 'primitive-result-arity', 'primitive?', 'print', 'print-as-expression',
  1027. 'print-boolean-long-form', 'print-box', 'print-graph',
  1028. 'print-hash-table', 'print-mpair-curly-braces',
  1029. 'print-pair-curly-braces', 'print-reader-abbreviations',
  1030. 'print-struct', 'print-syntax-width', 'print-unreadable',
  1031. 'print-vector-length', 'printable/c', 'printable<%>', 'printf',
  1032. 'println', 'procedure->method', 'procedure-arity',
  1033. 'procedure-arity-includes/c', 'procedure-arity-includes?',
  1034. 'procedure-arity?', 'procedure-closure-contents-eq?',
  1035. 'procedure-extract-target', 'procedure-keywords',
  1036. 'procedure-reduce-arity', 'procedure-reduce-keyword-arity',
  1037. 'procedure-rename', 'procedure-result-arity', 'procedure-specialize',
  1038. 'procedure-struct-type?', 'procedure?', 'process', 'process*',
  1039. 'process*/ports', 'process/ports', 'processor-count', 'progress-evt?',
  1040. 'promise-forced?', 'promise-running?', 'promise/c', 'promise/name?',
  1041. 'promise?', 'prop:arity-string', 'prop:arrow-contract',
  1042. 'prop:arrow-contract-get-info', 'prop:arrow-contract?', 'prop:blame',
  1043. 'prop:chaperone-contract', 'prop:checked-procedure', 'prop:contract',
  1044. 'prop:contracted', 'prop:custom-print-quotable', 'prop:custom-write',
  1045. 'prop:dict', 'prop:dict/contract', 'prop:equal+hash', 'prop:evt',
  1046. 'prop:exn:missing-module', 'prop:exn:srclocs',
  1047. 'prop:expansion-contexts', 'prop:flat-contract',
  1048. 'prop:impersonator-of', 'prop:input-port',
  1049. 'prop:liberal-define-context', 'prop:object-name',
  1050. 'prop:opt-chaperone-contract', 'prop:opt-chaperone-contract-get-test',
  1051. 'prop:opt-chaperone-contract?', 'prop:orc-contract',
  1052. 'prop:orc-contract-get-subcontracts', 'prop:orc-contract?',
  1053. 'prop:output-port', 'prop:place-location', 'prop:procedure',
  1054. 'prop:recursive-contract', 'prop:recursive-contract-unroll',
  1055. 'prop:recursive-contract?', 'prop:rename-transformer', 'prop:sequence',
  1056. 'prop:set!-transformer', 'prop:stream', 'proper-subset?',
  1057. 'pseudo-random-generator->vector', 'pseudo-random-generator-vector?',
  1058. 'pseudo-random-generator?', 'put-preferences', 'putenv', 'quotient',
  1059. 'quotient/remainder', 'radians->degrees', 'raise',
  1060. 'raise-argument-error', 'raise-arguments-error', 'raise-arity-error',
  1061. 'raise-blame-error', 'raise-contract-error', 'raise-mismatch-error',
  1062. 'raise-not-cons-blame-error', 'raise-range-error',
  1063. 'raise-result-error', 'raise-syntax-error', 'raise-type-error',
  1064. 'raise-user-error', 'random', 'random-seed', 'range', 'rational?',
  1065. 'rationalize', 'read', 'read-accept-bar-quote', 'read-accept-box',
  1066. 'read-accept-compiled', 'read-accept-dot', 'read-accept-graph',
  1067. 'read-accept-infix-dot', 'read-accept-lang', 'read-accept-quasiquote',
  1068. 'read-accept-reader', 'read-byte', 'read-byte-or-special',
  1069. 'read-bytes', 'read-bytes!', 'read-bytes!-evt', 'read-bytes-avail!',
  1070. 'read-bytes-avail!*', 'read-bytes-avail!-evt',
  1071. 'read-bytes-avail!/enable-break', 'read-bytes-evt', 'read-bytes-line',
  1072. 'read-bytes-line-evt', 'read-case-sensitive', 'read-cdot', 'read-char',
  1073. 'read-char-or-special', 'read-curly-brace-as-paren',
  1074. 'read-curly-brace-with-tag', 'read-decimal-as-inexact',
  1075. 'read-eval-print-loop', 'read-language', 'read-line', 'read-line-evt',
  1076. 'read-on-demand-source', 'read-square-bracket-as-paren',
  1077. 'read-square-bracket-with-tag', 'read-string', 'read-string!',
  1078. 'read-string!-evt', 'read-string-evt', 'read-syntax',
  1079. 'read-syntax/recursive', 'read/recursive', 'readtable-mapping',
  1080. 'readtable?', 'real->decimal-string', 'real->double-flonum',
  1081. 'real->floating-point-bytes', 'real->single-flonum', 'real-in',
  1082. 'real-part', 'real?', 'reencode-input-port', 'reencode-output-port',
  1083. 'regexp', 'regexp-match', 'regexp-match*', 'regexp-match-evt',
  1084. 'regexp-match-exact?', 'regexp-match-peek',
  1085. 'regexp-match-peek-immediate', 'regexp-match-peek-positions',
  1086. 'regexp-match-peek-positions*',
  1087. 'regexp-match-peek-positions-immediate',
  1088. 'regexp-match-peek-positions-immediate/end',
  1089. 'regexp-match-peek-positions/end', 'regexp-match-positions',
  1090. 'regexp-match-positions*', 'regexp-match-positions/end',
  1091. 'regexp-match/end', 'regexp-match?', 'regexp-max-lookbehind',
  1092. 'regexp-quote', 'regexp-replace', 'regexp-replace*',
  1093. 'regexp-replace-quote', 'regexp-replaces', 'regexp-split',
  1094. 'regexp-try-match', 'regexp?', 'relative-path?', 'relocate-input-port',
  1095. 'relocate-output-port', 'remainder', 'remf', 'remf*', 'remove',
  1096. 'remove*', 'remove-duplicates', 'remq', 'remq*', 'remv', 'remv*',
  1097. 'rename-contract', 'rename-file-or-directory',
  1098. 'rename-transformer-target', 'rename-transformer?', 'replace-evt',
  1099. 'reroot-path', 'resolve-path', 'resolved-module-path-name',
  1100. 'resolved-module-path?', 'rest', 'reverse', 'round', 'second',
  1101. 'seconds->date', 'security-guard?', 'semaphore-peek-evt',
  1102. 'semaphore-peek-evt?', 'semaphore-post', 'semaphore-try-wait?',
  1103. 'semaphore-wait', 'semaphore-wait/enable-break', 'semaphore?',
  1104. 'sequence->list', 'sequence->stream', 'sequence-add-between',
  1105. 'sequence-andmap', 'sequence-append', 'sequence-count',
  1106. 'sequence-filter', 'sequence-fold', 'sequence-for-each',
  1107. 'sequence-generate', 'sequence-generate*', 'sequence-length',
  1108. 'sequence-map', 'sequence-ormap', 'sequence-ref', 'sequence-tail',
  1109. 'sequence/c', 'sequence?', 'set', 'set!-transformer-procedure',
  1110. 'set!-transformer?', 'set->list', 'set->stream', 'set-add', 'set-add!',
  1111. 'set-box!', 'set-clear', 'set-clear!', 'set-copy', 'set-copy-clear',
  1112. 'set-count', 'set-empty?', 'set-eq?', 'set-equal?', 'set-eqv?',
  1113. 'set-first', 'set-for-each', 'set-implements/c', 'set-implements?',
  1114. 'set-intersect', 'set-intersect!', 'set-map', 'set-mcar!', 'set-mcdr!',
  1115. 'set-member?', 'set-mutable?', 'set-phantom-bytes!',
  1116. 'set-port-next-location!', 'set-remove', 'set-remove!', 'set-rest',
  1117. 'set-some-basic-contracts!', 'set-subtract', 'set-subtract!',
  1118. 'set-symmetric-difference', 'set-symmetric-difference!', 'set-union',
  1119. 'set-union!', 'set-weak?', 'set/c', 'set=?', 'set?', 'seteq', 'seteqv',
  1120. 'seventh', 'sgn', 'shared-bytes', 'shell-execute', 'shrink-path-wrt',
  1121. 'shuffle', 'simple-form-path', 'simplify-path', 'sin',
  1122. 'single-flonum?', 'sinh', 'sixth', 'skip-projection-wrapper?', 'sleep',
  1123. 'some-system-path->string', 'sort', 'special-comment-value',
  1124. 'special-comment?', 'special-filter-input-port', 'split-at',
  1125. 'split-at-right', 'split-common-prefix', 'split-path', 'splitf-at',
  1126. 'splitf-at-right', 'sqr', 'sqrt', 'srcloc', 'srcloc->string',
  1127. 'srcloc-column', 'srcloc-line', 'srcloc-position', 'srcloc-source',
  1128. 'srcloc-span', 'srcloc?', 'stop-after', 'stop-before', 'stream->list',
  1129. 'stream-add-between', 'stream-andmap', 'stream-append', 'stream-count',
  1130. 'stream-empty?', 'stream-filter', 'stream-first', 'stream-fold',
  1131. 'stream-for-each', 'stream-length', 'stream-map', 'stream-ormap',
  1132. 'stream-ref', 'stream-rest', 'stream-tail', 'stream/c', 'stream?',
  1133. 'string', 'string->bytes/latin-1', 'string->bytes/locale',
  1134. 'string->bytes/utf-8', 'string->immutable-string', 'string->keyword',
  1135. 'string->list', 'string->number', 'string->path',
  1136. 'string->path-element', 'string->some-system-path', 'string->symbol',
  1137. 'string->uninterned-symbol', 'string->unreadable-symbol',
  1138. 'string-append', 'string-append*', 'string-ci<=?', 'string-ci<?',
  1139. 'string-ci=?', 'string-ci>=?', 'string-ci>?', 'string-contains?',
  1140. 'string-copy', 'string-copy!', 'string-downcase',
  1141. 'string-environment-variable-name?', 'string-fill!', 'string-foldcase',
  1142. 'string-join', 'string-len/c', 'string-length', 'string-locale-ci<?',
  1143. 'string-locale-ci=?', 'string-locale-ci>?', 'string-locale-downcase',
  1144. 'string-locale-upcase', 'string-locale<?', 'string-locale=?',
  1145. 'string-locale>?', 'string-no-nuls?', 'string-normalize-nfc',
  1146. 'string-normalize-nfd', 'string-normalize-nfkc',
  1147. 'string-normalize-nfkd', 'string-normalize-spaces', 'string-port?',
  1148. 'string-prefix?', 'string-ref', 'string-replace', 'string-set!',
  1149. 'string-split', 'string-suffix?', 'string-titlecase', 'string-trim',
  1150. 'string-upcase', 'string-utf-8-length', 'string<=?', 'string<?',
  1151. 'string=?', 'string>=?', 'string>?', 'string?', 'struct->vector',
  1152. 'struct-accessor-procedure?', 'struct-constructor-procedure?',
  1153. 'struct-info', 'struct-mutator-procedure?',
  1154. 'struct-predicate-procedure?', 'struct-type-info',
  1155. 'struct-type-make-constructor', 'struct-type-make-predicate',
  1156. 'struct-type-property-accessor-procedure?', 'struct-type-property/c',
  1157. 'struct-type-property?', 'struct-type?', 'struct:arity-at-least',
  1158. 'struct:arrow-contract-info', 'struct:date', 'struct:date*',
  1159. 'struct:exn', 'struct:exn:break', 'struct:exn:break:hang-up',
  1160. 'struct:exn:break:terminate', 'struct:exn:fail',
  1161. 'struct:exn:fail:contract', 'struct:exn:fail:contract:arity',
  1162. 'struct:exn:fail:contract:blame',
  1163. 'struct:exn:fail:contract:continuation',
  1164. 'struct:exn:fail:contract:divide-by-zero',
  1165. 'struct:exn:fail:contract:non-fixnum-result',
  1166. 'struct:exn:fail:contract:variable', 'struct:exn:fail:filesystem',
  1167. 'struct:exn:fail:filesystem:errno',
  1168. 'struct:exn:fail:filesystem:exists',
  1169. 'struct:exn:fail:filesystem:missing-module',
  1170. 'struct:exn:fail:filesystem:version', 'struct:exn:fail:network',
  1171. 'struct:exn:fail:network:errno', 'struct:exn:fail:object',
  1172. 'struct:exn:fail:out-of-memory', 'struct:exn:fail:read',
  1173. 'struct:exn:fail:read:eof', 'struct:exn:fail:read:non-char',
  1174. 'struct:exn:fail:syntax', 'struct:exn:fail:syntax:missing-module',
  1175. 'struct:exn:fail:syntax:unbound', 'struct:exn:fail:unsupported',
  1176. 'struct:exn:fail:user', 'struct:srcloc',
  1177. 'struct:wrapped-extra-arg-arrow', 'struct?', 'sub1', 'subbytes',
  1178. 'subclass?', 'subclass?/c', 'subprocess', 'subprocess-group-enabled',
  1179. 'subprocess-kill', 'subprocess-pid', 'subprocess-status',
  1180. 'subprocess-wait', 'subprocess?', 'subset?', 'substring', 'suggest/c',
  1181. 'symbol->string', 'symbol-interned?', 'symbol-unreadable?', 'symbol<?',
  1182. 'symbol=?', 'symbol?', 'symbols', 'sync', 'sync/enable-break',
  1183. 'sync/timeout', 'sync/timeout/enable-break', 'syntax->datum',
  1184. 'syntax->list', 'syntax-arm', 'syntax-column', 'syntax-debug-info',
  1185. 'syntax-disarm', 'syntax-e', 'syntax-line',
  1186. 'syntax-local-bind-syntaxes', 'syntax-local-certifier',
  1187. 'syntax-local-context', 'syntax-local-expand-expression',
  1188. 'syntax-local-get-shadower', 'syntax-local-identifier-as-binding',
  1189. 'syntax-local-introduce', 'syntax-local-lift-context',
  1190. 'syntax-local-lift-expression', 'syntax-local-lift-module',
  1191. 'syntax-local-lift-module-end-declaration',
  1192. 'syntax-local-lift-provide', 'syntax-local-lift-require',
  1193. 'syntax-local-lift-values-expression',
  1194. 'syntax-local-make-definition-context',
  1195. 'syntax-local-make-delta-introducer',
  1196. 'syntax-local-module-defined-identifiers',
  1197. 'syntax-local-module-exports',
  1198. 'syntax-local-module-required-identifiers', 'syntax-local-name',
  1199. 'syntax-local-phase-level', 'syntax-local-submodules',
  1200. 'syntax-local-transforming-module-provides?', 'syntax-local-value',
  1201. 'syntax-local-value/immediate', 'syntax-original?', 'syntax-position',
  1202. 'syntax-property', 'syntax-property-preserved?',
  1203. 'syntax-property-symbol-keys', 'syntax-protect', 'syntax-rearm',
  1204. 'syntax-recertify', 'syntax-shift-phase-level', 'syntax-source',
  1205. 'syntax-source-module', 'syntax-span', 'syntax-taint',
  1206. 'syntax-tainted?', 'syntax-track-origin',
  1207. 'syntax-transforming-module-expression?',
  1208. 'syntax-transforming-with-lifts?', 'syntax-transforming?', 'syntax/c',
  1209. 'syntax?', 'system', 'system*', 'system*/exit-code',
  1210. 'system-big-endian?', 'system-idle-evt', 'system-language+country',
  1211. 'system-library-subpath', 'system-path-convention-type', 'system-type',
  1212. 'system/exit-code', 'tail-marks-match?', 'take', 'take-common-prefix',
  1213. 'take-right', 'takef', 'takef-right', 'tan', 'tanh',
  1214. 'tcp-abandon-port', 'tcp-accept', 'tcp-accept-evt',
  1215. 'tcp-accept-ready?', 'tcp-accept/enable-break', 'tcp-addresses',
  1216. 'tcp-close', 'tcp-connect', 'tcp-connect/enable-break', 'tcp-listen',
  1217. 'tcp-listener?', 'tcp-port?', 'tentative-pretty-print-port-cancel',
  1218. 'tentative-pretty-print-port-transfer', 'tenth', 'terminal-port?',
  1219. 'the-unsupplied-arg', 'third', 'thread', 'thread-cell-ref',
  1220. 'thread-cell-set!', 'thread-cell-values?', 'thread-cell?',
  1221. 'thread-dead-evt', 'thread-dead?', 'thread-group?', 'thread-receive',
  1222. 'thread-receive-evt', 'thread-resume', 'thread-resume-evt',
  1223. 'thread-rewind-receive', 'thread-running?', 'thread-send',
  1224. 'thread-suspend', 'thread-suspend-evt', 'thread-try-receive',
  1225. 'thread-wait', 'thread/suspend-to-kill', 'thread?', 'time-apply',
  1226. 'touch', 'transplant-input-port', 'transplant-output-port', 'true',
  1227. 'truncate', 'udp-addresses', 'udp-bind!', 'udp-bound?', 'udp-close',
  1228. 'udp-connect!', 'udp-connected?', 'udp-multicast-interface',
  1229. 'udp-multicast-join-group!', 'udp-multicast-leave-group!',
  1230. 'udp-multicast-loopback?', 'udp-multicast-set-interface!',
  1231. 'udp-multicast-set-loopback!', 'udp-multicast-set-ttl!',
  1232. 'udp-multicast-ttl', 'udp-open-socket', 'udp-receive!',
  1233. 'udp-receive!*', 'udp-receive!-evt', 'udp-receive!/enable-break',
  1234. 'udp-receive-ready-evt', 'udp-send', 'udp-send*', 'udp-send-evt',
  1235. 'udp-send-ready-evt', 'udp-send-to', 'udp-send-to*', 'udp-send-to-evt',
  1236. 'udp-send-to/enable-break', 'udp-send/enable-break', 'udp?', 'unbox',
  1237. 'uncaught-exception-handler', 'unit?', 'unspecified-dom',
  1238. 'unsupplied-arg?', 'use-collection-link-paths',
  1239. 'use-compiled-file-paths', 'use-user-specific-search-paths',
  1240. 'user-execute-bit', 'user-read-bit', 'user-write-bit', 'value-blame',
  1241. 'value-contract', 'values', 'variable-reference->empty-namespace',
  1242. 'variable-reference->module-base-phase',
  1243. 'variable-reference->module-declaration-inspector',
  1244. 'variable-reference->module-path-index',
  1245. 'variable-reference->module-source', 'variable-reference->namespace',
  1246. 'variable-reference->phase',
  1247. 'variable-reference->resolved-module-path',
  1248. 'variable-reference-constant?', 'variable-reference?', 'vector',
  1249. 'vector->immutable-vector', 'vector->list',
  1250. 'vector->pseudo-random-generator', 'vector->pseudo-random-generator!',
  1251. 'vector->values', 'vector-append', 'vector-argmax', 'vector-argmin',
  1252. 'vector-copy', 'vector-copy!', 'vector-count', 'vector-drop',
  1253. 'vector-drop-right', 'vector-fill!', 'vector-filter',
  1254. 'vector-filter-not', 'vector-immutable', 'vector-immutable/c',
  1255. 'vector-immutableof', 'vector-length', 'vector-map', 'vector-map!',
  1256. 'vector-member', 'vector-memq', 'vector-memv', 'vector-ref',
  1257. 'vector-set!', 'vector-set*!', 'vector-set-performance-stats!',
  1258. 'vector-split-at', 'vector-split-at-right', 'vector-take',
  1259. 'vector-take-right', 'vector/c', 'vector?', 'vectorof', 'version',
  1260. 'void', 'void?', 'weak-box-value', 'weak-box?', 'weak-set',
  1261. 'weak-seteq', 'weak-seteqv', 'will-execute', 'will-executor?',
  1262. 'will-register', 'will-try-execute', 'with-input-from-bytes',
  1263. 'with-input-from-file', 'with-input-from-string',
  1264. 'with-output-to-bytes', 'with-output-to-file', 'with-output-to-string',
  1265. 'would-be-future', 'wrap-evt', 'wrapped-extra-arg-arrow',
  1266. 'wrapped-extra-arg-arrow-extra-neg-party-argument',
  1267. 'wrapped-extra-arg-arrow-real-func', 'wrapped-extra-arg-arrow?',
  1268. 'writable<%>', 'write', 'write-byte', 'write-bytes',
  1269. 'write-bytes-avail', 'write-bytes-avail*', 'write-bytes-avail-evt',
  1270. 'write-bytes-avail/enable-break', 'write-char', 'write-special',
  1271. 'write-special-avail*', 'write-special-evt', 'write-string',
  1272. 'write-to-file', 'writeln', 'xor', 'zero?', '~.a', '~.s', '~.v', '~a',
  1273. '~e', '~r', '~s', '~v'
  1274. )
  1275. _opening_parenthesis = r'[([{]'
  1276. _closing_parenthesis = r'[)\]}]'
  1277. _delimiters = r'()[\]{}",\'`;\s'
  1278. _symbol = r'(?:\|[^|]*\||\\[\w\W]|[^|\\%s]+)+' % _delimiters
  1279. _exact_decimal_prefix = r'(?:#e)?(?:#d)?(?:#e)?'
  1280. _exponent = r'(?:[defls][-+]?\d+)'
  1281. _inexact_simple_no_hashes = r'(?:\d+(?:/\d+|\.\d*)?|\.\d+)'
  1282. _inexact_simple = (r'(?:%s|(?:\d+#+(?:\.#*|/\d+#*)?|\.\d+#+|'
  1283. r'\d+(?:\.\d*#+|/\d+#+)))' % _inexact_simple_no_hashes)
  1284. _inexact_normal_no_hashes = r'(?:%s%s?)' % (_inexact_simple_no_hashes,
  1285. _exponent)
  1286. _inexact_normal = r'(?:%s%s?)' % (_inexact_simple, _exponent)
  1287. _inexact_special = r'(?:(?:inf|nan)\.[0f])'
  1288. _inexact_real = r'(?:[-+]?%s|[-+]%s)' % (_inexact_normal,
  1289. _inexact_special)
  1290. _inexact_unsigned = r'(?:%s|%s)' % (_inexact_normal, _inexact_special)
  1291. tokens = {
  1292. 'root': [
  1293. (_closing_parenthesis, Error),
  1294. (r'(?!\Z)', Text, 'unquoted-datum')
  1295. ],
  1296. 'datum': [
  1297. (r'(?s)#;|#![ /]([^\\\n]|\\.)*', Comment),
  1298. (r';[^\n\r\x85\u2028\u2029]*', Comment.Single),
  1299. (r'#\|', Comment.Multiline, 'block-comment'),
  1300. # Whitespaces
  1301. (r'(?u)\s+', Whitespace),
  1302. # Numbers: Keep in mind Racket reader hash prefixes, which
  1303. # can denote the base or the type. These don't map neatly
  1304. # onto Pygments token types; some judgment calls here.
  1305. # #d or no prefix
  1306. (r'(?i)%s[-+]?\d+(?=[%s])' % (_exact_decimal_prefix, _delimiters),
  1307. Number.Integer, '#pop'),
  1308. (r'(?i)%s[-+]?(\d+(\.\d*)?|\.\d+)([deflst][-+]?\d+)?(?=[%s])' %
  1309. (_exact_decimal_prefix, _delimiters), Number.Float, '#pop'),
  1310. (r'(?i)%s[-+]?(%s([-+]%s?i)?|[-+]%s?i)(?=[%s])' %
  1311. (_exact_decimal_prefix, _inexact_normal_no_hashes,
  1312. _inexact_normal_no_hashes, _inexact_normal_no_hashes,
  1313. _delimiters), Number, '#pop'),
  1314. # Inexact without explicit #i
  1315. (r'(?i)(#d)?(%s([-+]%s?i)?|[-+]%s?i|%s@%s)(?=[%s])' %
  1316. (_inexact_real, _inexact_unsigned, _inexact_unsigned,
  1317. _inexact_real, _inexact_real, _delimiters), Number.Float,
  1318. '#pop'),
  1319. # The remaining extflonums
  1320. (r'(?i)(([-+]?%st[-+]?\d+)|[-+](inf|nan)\.t)(?=[%s])' %
  1321. (_inexact_simple, _delimiters), Number.Float, '#pop'),
  1322. # #b
  1323. (r'(?iu)(#[ei])?#b%s' % _symbol, Number.Bin, '#pop'),
  1324. # #o
  1325. (r'(?iu)(#[ei])?#o%s' % _symbol, Number.Oct, '#pop'),
  1326. # #x
  1327. (r'(?iu)(#[ei])?#x%s' % _symbol, Number.Hex, '#pop'),
  1328. # #i is always inexact, i.e. float
  1329. (r'(?iu)(#d)?#i%s' % _symbol, Number.Float, '#pop'),
  1330. # Strings and characters
  1331. (r'#?"', String.Double, ('#pop', 'string')),
  1332. (r'#<<(.+)\n(^(?!\1$).*$\n)*^\1$', String.Heredoc, '#pop'),
  1333. (r'#\\(u[\da-fA-F]{1,4}|U[\da-fA-F]{1,8})', String.Char, '#pop'),
  1334. (r'(?is)#\\([0-7]{3}|[a-z]+|.)', String.Char, '#pop'),
  1335. (r'(?s)#[pr]x#?"(\\?.)*?"', String.Regex, '#pop'),
  1336. # Constants
  1337. (r'#(true|false|[tTfF])', Name.Constant, '#pop'),
  1338. # Keyword argument names (e.g. #:keyword)
  1339. (r'#:%s' % _symbol, Keyword.Declaration, '#pop'),
  1340. # Reader extensions
  1341. (r'(#lang |#!)(\S+)',
  1342. bygroups(Keyword.Namespace, Name.Namespace)),
  1343. (r'#reader', Keyword.Namespace, 'quoted-datum'),
  1344. # Other syntax
  1345. (r"(?i)\.(?=[%s])|#c[is]|#['`]|#,@?" % _delimiters, Operator),
  1346. (r"'|#[s&]|#hash(eqv?)?|#\d*(?=%s)" % _opening_parenthesis,
  1347. Operator, ('#pop', 'quoted-datum'))
  1348. ],
  1349. 'datum*': [
  1350. (r'`|,@?', Operator),
  1351. (_symbol, String.Symbol, '#pop'),
  1352. (r'[|\\]', Error),
  1353. default('#pop')
  1354. ],
  1355. 'list': [
  1356. (_closing_parenthesis, Punctuation, '#pop')
  1357. ],
  1358. 'unquoted-datum': [
  1359. include('datum'),
  1360. (r'quote(?=[%s])' % _delimiters, Keyword,
  1361. ('#pop', 'quoted-datum')),
  1362. (r'`', Operator, ('#pop', 'quasiquoted-datum')),
  1363. (r'quasiquote(?=[%s])' % _delimiters, Keyword,
  1364. ('#pop', 'quasiquoted-datum')),
  1365. (_opening_parenthesis, Punctuation, ('#pop', 'unquoted-list')),
  1366. (words(_keywords, suffix='(?=[%s])' % _delimiters),
  1367. Keyword, '#pop'),
  1368. (words(_builtins, suffix='(?=[%s])' % _delimiters),
  1369. Name.Builtin, '#pop'),
  1370. (_symbol, Name, '#pop'),
  1371. include('datum*')
  1372. ],
  1373. 'unquoted-list': [
  1374. include('list'),
  1375. (r'(?!\Z)', Text, 'unquoted-datum')
  1376. ],
  1377. 'quasiquoted-datum': [
  1378. include('datum'),
  1379. (r',@?', Operator, ('#pop', 'unquoted-datum')),
  1380. (r'unquote(-splicing)?(?=[%s])' % _delimiters, Keyword,
  1381. ('#pop', 'unquoted-datum')),
  1382. (_opening_parenthesis, Punctuation, ('#pop', 'quasiquoted-list')),
  1383. include('datum*')
  1384. ],
  1385. 'quasiquoted-list': [
  1386. include('list'),
  1387. (r'(?!\Z)', Text, 'quasiquoted-datum')
  1388. ],
  1389. 'quoted-datum': [
  1390. include('datum'),
  1391. (_opening_parenthesis, Punctuation, ('#pop', 'quoted-list')),
  1392. include('datum*')
  1393. ],
  1394. 'quoted-list': [
  1395. include('list'),
  1396. (r'(?!\Z)', Text, 'quoted-datum')
  1397. ],
  1398. 'block-comment': [
  1399. (r'#\|', Comment.Multiline, '#push'),
  1400. (r'\|#', Comment.Multiline, '#pop'),
  1401. (r'[^#|]+|.', Comment.Multiline)
  1402. ],
  1403. 'string': [
  1404. (r'"', String.Double, '#pop'),
  1405. (r'(?s)\\([0-7]{1,3}|x[\da-fA-F]{1,2}|u[\da-fA-F]{1,4}|'
  1406. r'U[\da-fA-F]{1,8}|.)', String.Escape),
  1407. (r'[^\\"]+', String.Double)
  1408. ]
  1409. }
  1410. class NewLispLexer(RegexLexer):
  1411. """
  1412. For newLISP source code (version 10.3.0).
  1413. .. versionadded:: 1.5
  1414. """
  1415. name = 'NewLisp'
  1416. url = 'http://www.newlisp.org/'
  1417. aliases = ['newlisp']
  1418. filenames = ['*.lsp', '*.nl', '*.kif']
  1419. mimetypes = ['text/x-newlisp', 'application/x-newlisp']
  1420. flags = re.IGNORECASE | re.MULTILINE
  1421. # list of built-in functions for newLISP version 10.3
  1422. builtins = (
  1423. '^', '--', '-', ':', '!', '!=', '?', '@', '*', '/', '&', '%', '+', '++',
  1424. '<', '<<', '<=', '=', '>', '>=', '>>', '|', '~', '$', '$0', '$1', '$10',
  1425. '$11', '$12', '$13', '$14', '$15', '$2', '$3', '$4', '$5', '$6', '$7',
  1426. '$8', '$9', '$args', '$idx', '$it', '$main-args', 'abort', 'abs',
  1427. 'acos', 'acosh', 'add', 'address', 'amb', 'and', 'append-file',
  1428. 'append', 'apply', 'args', 'array-list', 'array?', 'array', 'asin',
  1429. 'asinh', 'assoc', 'atan', 'atan2', 'atanh', 'atom?', 'base64-dec',
  1430. 'base64-enc', 'bayes-query', 'bayes-train', 'begin',
  1431. 'beta', 'betai', 'bind', 'binomial', 'bits', 'callback',
  1432. 'case', 'catch', 'ceil', 'change-dir', 'char', 'chop', 'Class', 'clean',
  1433. 'close', 'command-event', 'cond', 'cons', 'constant',
  1434. 'context?', 'context', 'copy-file', 'copy', 'cos', 'cosh', 'count',
  1435. 'cpymem', 'crc32', 'crit-chi2', 'crit-z', 'current-line', 'curry',
  1436. 'date-list', 'date-parse', 'date-value', 'date', 'debug', 'dec',
  1437. 'def-new', 'default', 'define-macro', 'define',
  1438. 'delete-file', 'delete-url', 'delete', 'destroy', 'det', 'device',
  1439. 'difference', 'directory?', 'directory', 'div', 'do-until', 'do-while',
  1440. 'doargs', 'dolist', 'dostring', 'dotimes', 'dotree', 'dump', 'dup',
  1441. 'empty?', 'encrypt', 'ends-with', 'env', 'erf', 'error-event',
  1442. 'eval-string', 'eval', 'exec', 'exists', 'exit', 'exp', 'expand',
  1443. 'explode', 'extend', 'factor', 'fft', 'file-info', 'file?', 'filter',
  1444. 'find-all', 'find', 'first', 'flat', 'float?', 'float', 'floor', 'flt',
  1445. 'fn', 'for-all', 'for', 'fork', 'format', 'fv', 'gammai', 'gammaln',
  1446. 'gcd', 'get-char', 'get-float', 'get-int', 'get-long', 'get-string',
  1447. 'get-url', 'global?', 'global', 'if-not', 'if', 'ifft', 'import', 'inc',
  1448. 'index', 'inf?', 'int', 'integer?', 'integer', 'intersect', 'invert',
  1449. 'irr', 'join', 'lambda-macro', 'lambda?', 'lambda', 'last-error',
  1450. 'last', 'legal?', 'length', 'let', 'letex', 'letn',
  1451. 'list?', 'list', 'load', 'local', 'log', 'lookup',
  1452. 'lower-case', 'macro?', 'main-args', 'MAIN', 'make-dir', 'map', 'mat',
  1453. 'match', 'max', 'member', 'min', 'mod', 'module', 'mul', 'multiply',
  1454. 'NaN?', 'net-accept', 'net-close', 'net-connect', 'net-error',
  1455. 'net-eval', 'net-interface', 'net-ipv', 'net-listen', 'net-local',
  1456. 'net-lookup', 'net-packet', 'net-peek', 'net-peer', 'net-ping',
  1457. 'net-receive-from', 'net-receive-udp', 'net-receive', 'net-select',
  1458. 'net-send-to', 'net-send-udp', 'net-send', 'net-service',
  1459. 'net-sessions', 'new', 'nil?', 'nil', 'normal', 'not', 'now', 'nper',
  1460. 'npv', 'nth', 'null?', 'number?', 'open', 'or', 'ostype', 'pack',
  1461. 'parse-date', 'parse', 'peek', 'pipe', 'pmt', 'pop-assoc', 'pop',
  1462. 'post-url', 'pow', 'prefix', 'pretty-print', 'primitive?', 'print',
  1463. 'println', 'prob-chi2', 'prob-z', 'process', 'prompt-event',
  1464. 'protected?', 'push', 'put-url', 'pv', 'quote?', 'quote', 'rand',
  1465. 'random', 'randomize', 'read', 'read-char', 'read-expr', 'read-file',
  1466. 'read-key', 'read-line', 'read-utf8', 'reader-event',
  1467. 'real-path', 'receive', 'ref-all', 'ref', 'regex-comp', 'regex',
  1468. 'remove-dir', 'rename-file', 'replace', 'reset', 'rest', 'reverse',
  1469. 'rotate', 'round', 'save', 'search', 'seed', 'seek', 'select', 'self',
  1470. 'semaphore', 'send', 'sequence', 'series', 'set-locale', 'set-ref-all',
  1471. 'set-ref', 'set', 'setf', 'setq', 'sgn', 'share', 'signal', 'silent',
  1472. 'sin', 'sinh', 'sleep', 'slice', 'sort', 'source', 'spawn', 'sqrt',
  1473. 'starts-with', 'string?', 'string', 'sub', 'swap', 'sym', 'symbol?',
  1474. 'symbols', 'sync', 'sys-error', 'sys-info', 'tan', 'tanh', 'term',
  1475. 'throw-error', 'throw', 'time-of-day', 'time', 'timer', 'title-case',
  1476. 'trace-highlight', 'trace', 'transpose', 'Tree', 'trim', 'true?',
  1477. 'true', 'unicode', 'unify', 'unique', 'unless', 'unpack', 'until',
  1478. 'upper-case', 'utf8', 'utf8len', 'uuid', 'wait-pid', 'when', 'while',
  1479. 'write', 'write-char', 'write-file', 'write-line',
  1480. 'xfer-event', 'xml-error', 'xml-parse', 'xml-type-tags', 'zero?',
  1481. )
  1482. # valid names
  1483. valid_name = r'([\w!$%&*+.,/<=>?@^~|-])+|(\[.*?\])+'
  1484. tokens = {
  1485. 'root': [
  1486. # shebang
  1487. (r'#!(.*?)$', Comment.Preproc),
  1488. # comments starting with semicolon
  1489. (r';.*$', Comment.Single),
  1490. # comments starting with #
  1491. (r'#.*$', Comment.Single),
  1492. # whitespace
  1493. (r'\s+', Whitespace),
  1494. # strings, symbols and characters
  1495. (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
  1496. # braces
  1497. (r'\{', String, "bracestring"),
  1498. # [text] ... [/text] delimited strings
  1499. (r'\[text\]*', String, "tagstring"),
  1500. # 'special' operators...
  1501. (r"('|:)", Operator),
  1502. # highlight the builtins
  1503. (words(builtins, suffix=r'\b'),
  1504. Keyword),
  1505. # the remaining functions
  1506. (r'(?<=\()' + valid_name, Name.Variable),
  1507. # the remaining variables
  1508. (valid_name, String.Symbol),
  1509. # parentheses
  1510. (r'(\(|\))', Punctuation),
  1511. ],
  1512. # braced strings...
  1513. 'bracestring': [
  1514. (r'\{', String, "#push"),
  1515. (r'\}', String, "#pop"),
  1516. ('[^{}]+', String),
  1517. ],
  1518. # tagged [text]...[/text] delimited strings...
  1519. 'tagstring': [
  1520. (r'(?s)(.*?)(\[/text\])', String, '#pop'),
  1521. ],
  1522. }
  1523. class EmacsLispLexer(RegexLexer):
  1524. """
  1525. An ELisp lexer, parsing a stream and outputting the tokens
  1526. needed to highlight elisp code.
  1527. .. versionadded:: 2.1
  1528. """
  1529. name = 'EmacsLisp'
  1530. aliases = ['emacs-lisp', 'elisp', 'emacs']
  1531. filenames = ['*.el']
  1532. mimetypes = ['text/x-elisp', 'application/x-elisp']
  1533. flags = re.MULTILINE
  1534. # couple of useful regexes
  1535. # characters that are not macro-characters and can be used to begin a symbol
  1536. nonmacro = r'\\.|[\w!$%&*+-/<=>?@^{}~|]'
  1537. constituent = nonmacro + '|[#.:]'
  1538. terminated = r'(?=[ "()\]\'\n,;`])' # whitespace or terminating macro characters
  1539. # symbol token, reverse-engineered from hyperspec
  1540. # Take a deep breath...
  1541. symbol = r'((?:%s)(?:%s)*)' % (nonmacro, constituent)
  1542. macros = {
  1543. 'atomic-change-group', 'case', 'block', 'cl-block', 'cl-callf', 'cl-callf2',
  1544. 'cl-case', 'cl-decf', 'cl-declaim', 'cl-declare',
  1545. 'cl-define-compiler-macro', 'cl-defmacro', 'cl-defstruct',
  1546. 'cl-defsubst', 'cl-deftype', 'cl-defun', 'cl-destructuring-bind',
  1547. 'cl-do', 'cl-do*', 'cl-do-all-symbols', 'cl-do-symbols', 'cl-dolist',
  1548. 'cl-dotimes', 'cl-ecase', 'cl-etypecase', 'eval-when', 'cl-eval-when', 'cl-flet',
  1549. 'cl-flet*', 'cl-function', 'cl-incf', 'cl-labels', 'cl-letf',
  1550. 'cl-letf*', 'cl-load-time-value', 'cl-locally', 'cl-loop',
  1551. 'cl-macrolet', 'cl-multiple-value-bind', 'cl-multiple-value-setq',
  1552. 'cl-progv', 'cl-psetf', 'cl-psetq', 'cl-pushnew', 'cl-remf',
  1553. 'cl-return', 'cl-return-from', 'cl-rotatef', 'cl-shiftf',
  1554. 'cl-symbol-macrolet', 'cl-tagbody', 'cl-the', 'cl-typecase',
  1555. 'combine-after-change-calls', 'condition-case-unless-debug', 'decf',
  1556. 'declaim', 'declare', 'declare-function', 'def-edebug-spec',
  1557. 'defadvice', 'defclass', 'defcustom', 'defface', 'defgeneric',
  1558. 'defgroup', 'define-advice', 'define-alternatives',
  1559. 'define-compiler-macro', 'define-derived-mode', 'define-generic-mode',
  1560. 'define-global-minor-mode', 'define-globalized-minor-mode',
  1561. 'define-minor-mode', 'define-modify-macro',
  1562. 'define-obsolete-face-alias', 'define-obsolete-function-alias',
  1563. 'define-obsolete-variable-alias', 'define-setf-expander',
  1564. 'define-skeleton', 'defmacro', 'defmethod', 'defsetf', 'defstruct',
  1565. 'defsubst', 'deftheme', 'deftype', 'defun', 'defvar-local',
  1566. 'delay-mode-hooks', 'destructuring-bind', 'do', 'do*',
  1567. 'do-all-symbols', 'do-symbols', 'dolist', 'dont-compile', 'dotimes',
  1568. 'dotimes-with-progress-reporter', 'ecase', 'ert-deftest', 'etypecase',
  1569. 'eval-and-compile', 'eval-when-compile', 'flet', 'ignore-errors',
  1570. 'incf', 'labels', 'lambda', 'letrec', 'lexical-let', 'lexical-let*',
  1571. 'loop', 'multiple-value-bind', 'multiple-value-setq', 'noreturn',
  1572. 'oref', 'oref-default', 'oset', 'oset-default', 'pcase',
  1573. 'pcase-defmacro', 'pcase-dolist', 'pcase-exhaustive', 'pcase-let',
  1574. 'pcase-let*', 'pop', 'psetf', 'psetq', 'push', 'pushnew', 'remf',
  1575. 'return', 'rotatef', 'rx', 'save-match-data', 'save-selected-window',
  1576. 'save-window-excursion', 'setf', 'setq-local', 'shiftf',
  1577. 'track-mouse', 'typecase', 'unless', 'use-package', 'when',
  1578. 'while-no-input', 'with-case-table', 'with-category-table',
  1579. 'with-coding-priority', 'with-current-buffer', 'with-demoted-errors',
  1580. 'with-eval-after-load', 'with-file-modes', 'with-local-quit',
  1581. 'with-output-to-string', 'with-output-to-temp-buffer',
  1582. 'with-parsed-tramp-file-name', 'with-selected-frame',
  1583. 'with-selected-window', 'with-silent-modifications', 'with-slots',
  1584. 'with-syntax-table', 'with-temp-buffer', 'with-temp-file',
  1585. 'with-temp-message', 'with-timeout', 'with-tramp-connection-property',
  1586. 'with-tramp-file-property', 'with-tramp-progress-reporter',
  1587. 'with-wrapper-hook', 'load-time-value', 'locally', 'macrolet', 'progv',
  1588. 'return-from',
  1589. }
  1590. special_forms = {
  1591. 'and', 'catch', 'cond', 'condition-case', 'defconst', 'defvar',
  1592. 'function', 'if', 'interactive', 'let', 'let*', 'or', 'prog1',
  1593. 'prog2', 'progn', 'quote', 'save-current-buffer', 'save-excursion',
  1594. 'save-restriction', 'setq', 'setq-default', 'subr-arity',
  1595. 'unwind-protect', 'while',
  1596. }
  1597. builtin_function = {
  1598. '%', '*', '+', '-', '/', '/=', '1+', '1-', '<', '<=', '=', '>', '>=',
  1599. 'Snarf-documentation', 'abort-recursive-edit', 'abs',
  1600. 'accept-process-output', 'access-file', 'accessible-keymaps', 'acos',
  1601. 'active-minibuffer-window', 'add-face-text-property',
  1602. 'add-name-to-file', 'add-text-properties', 'all-completions',
  1603. 'append', 'apply', 'apropos-internal', 'aref', 'arrayp', 'aset',
  1604. 'ash', 'asin', 'assoc', 'assoc-string', 'assq', 'atan', 'atom',
  1605. 'autoload', 'autoload-do-load', 'backtrace', 'backtrace--locals',
  1606. 'backtrace-debug', 'backtrace-eval', 'backtrace-frame',
  1607. 'backward-char', 'backward-prefix-chars', 'barf-if-buffer-read-only',
  1608. 'base64-decode-region', 'base64-decode-string',
  1609. 'base64-encode-region', 'base64-encode-string', 'beginning-of-line',
  1610. 'bidi-find-overridden-directionality', 'bidi-resolved-levels',
  1611. 'bitmap-spec-p', 'bobp', 'bolp', 'bool-vector',
  1612. 'bool-vector-count-consecutive', 'bool-vector-count-population',
  1613. 'bool-vector-exclusive-or', 'bool-vector-intersection',
  1614. 'bool-vector-not', 'bool-vector-p', 'bool-vector-set-difference',
  1615. 'bool-vector-subsetp', 'bool-vector-union', 'boundp',
  1616. 'buffer-base-buffer', 'buffer-chars-modified-tick',
  1617. 'buffer-enable-undo', 'buffer-file-name', 'buffer-has-markers-at',
  1618. 'buffer-list', 'buffer-live-p', 'buffer-local-value',
  1619. 'buffer-local-variables', 'buffer-modified-p', 'buffer-modified-tick',
  1620. 'buffer-name', 'buffer-size', 'buffer-string', 'buffer-substring',
  1621. 'buffer-substring-no-properties', 'buffer-swap-text', 'bufferp',
  1622. 'bury-buffer-internal', 'byte-code', 'byte-code-function-p',
  1623. 'byte-to-position', 'byte-to-string', 'byteorder',
  1624. 'call-interactively', 'call-last-kbd-macro', 'call-process',
  1625. 'call-process-region', 'cancel-kbd-macro-events', 'capitalize',
  1626. 'capitalize-region', 'capitalize-word', 'car', 'car-less-than-car',
  1627. 'car-safe', 'case-table-p', 'category-docstring',
  1628. 'category-set-mnemonics', 'category-table', 'category-table-p',
  1629. 'ccl-execute', 'ccl-execute-on-string', 'ccl-program-p', 'cdr',
  1630. 'cdr-safe', 'ceiling', 'char-after', 'char-before',
  1631. 'char-category-set', 'char-charset', 'char-equal', 'char-or-string-p',
  1632. 'char-resolve-modifiers', 'char-syntax', 'char-table-extra-slot',
  1633. 'char-table-p', 'char-table-parent', 'char-table-range',
  1634. 'char-table-subtype', 'char-to-string', 'char-width', 'characterp',
  1635. 'charset-after', 'charset-id-internal', 'charset-plist',
  1636. 'charset-priority-list', 'charsetp', 'check-coding-system',
  1637. 'check-coding-systems-region', 'clear-buffer-auto-save-failure',
  1638. 'clear-charset-maps', 'clear-face-cache', 'clear-font-cache',
  1639. 'clear-image-cache', 'clear-string', 'clear-this-command-keys',
  1640. 'close-font', 'clrhash', 'coding-system-aliases',
  1641. 'coding-system-base', 'coding-system-eol-type', 'coding-system-p',
  1642. 'coding-system-plist', 'coding-system-priority-list',
  1643. 'coding-system-put', 'color-distance', 'color-gray-p',
  1644. 'color-supported-p', 'combine-after-change-execute',
  1645. 'command-error-default-function', 'command-remapping', 'commandp',
  1646. 'compare-buffer-substrings', 'compare-strings',
  1647. 'compare-window-configurations', 'completing-read',
  1648. 'compose-region-internal', 'compose-string-internal',
  1649. 'composition-get-gstring', 'compute-motion', 'concat', 'cons',
  1650. 'consp', 'constrain-to-field', 'continue-process',
  1651. 'controlling-tty-p', 'coordinates-in-window-p', 'copy-alist',
  1652. 'copy-category-table', 'copy-file', 'copy-hash-table', 'copy-keymap',
  1653. 'copy-marker', 'copy-sequence', 'copy-syntax-table', 'copysign',
  1654. 'cos', 'current-active-maps', 'current-bidi-paragraph-direction',
  1655. 'current-buffer', 'current-case-table', 'current-column',
  1656. 'current-global-map', 'current-idle-time', 'current-indentation',
  1657. 'current-input-mode', 'current-local-map', 'current-message',
  1658. 'current-minor-mode-maps', 'current-time', 'current-time-string',
  1659. 'current-time-zone', 'current-window-configuration',
  1660. 'cygwin-convert-file-name-from-windows',
  1661. 'cygwin-convert-file-name-to-windows', 'daemon-initialized',
  1662. 'daemonp', 'dbus--init-bus', 'dbus-get-unique-name',
  1663. 'dbus-message-internal', 'debug-timer-check', 'declare-equiv-charset',
  1664. 'decode-big5-char', 'decode-char', 'decode-coding-region',
  1665. 'decode-coding-string', 'decode-sjis-char', 'decode-time',
  1666. 'default-boundp', 'default-file-modes', 'default-printer-name',
  1667. 'default-toplevel-value', 'default-value', 'define-category',
  1668. 'define-charset-alias', 'define-charset-internal',
  1669. 'define-coding-system-alias', 'define-coding-system-internal',
  1670. 'define-fringe-bitmap', 'define-hash-table-test', 'define-key',
  1671. 'define-prefix-command', 'delete',
  1672. 'delete-all-overlays', 'delete-and-extract-region', 'delete-char',
  1673. 'delete-directory-internal', 'delete-field', 'delete-file',
  1674. 'delete-frame', 'delete-other-windows-internal', 'delete-overlay',
  1675. 'delete-process', 'delete-region', 'delete-terminal',
  1676. 'delete-window-internal', 'delq', 'describe-buffer-bindings',
  1677. 'describe-vector', 'destroy-fringe-bitmap', 'detect-coding-region',
  1678. 'detect-coding-string', 'ding', 'directory-file-name',
  1679. 'directory-files', 'directory-files-and-attributes', 'discard-input',
  1680. 'display-supports-face-attributes-p', 'do-auto-save', 'documentation',
  1681. 'documentation-property', 'downcase', 'downcase-region',
  1682. 'downcase-word', 'draw-string', 'dump-colors', 'dump-emacs',
  1683. 'dump-face', 'dump-frame-glyph-matrix', 'dump-glyph-matrix',
  1684. 'dump-glyph-row', 'dump-redisplay-history', 'dump-tool-bar-row',
  1685. 'elt', 'emacs-pid', 'encode-big5-char', 'encode-char',
  1686. 'encode-coding-region', 'encode-coding-string', 'encode-sjis-char',
  1687. 'encode-time', 'end-kbd-macro', 'end-of-line', 'eobp', 'eolp', 'eq',
  1688. 'eql', 'equal', 'equal-including-properties', 'erase-buffer',
  1689. 'error-message-string', 'eval', 'eval-buffer', 'eval-region',
  1690. 'event-convert-list', 'execute-kbd-macro', 'exit-recursive-edit',
  1691. 'exp', 'expand-file-name', 'expt', 'external-debugging-output',
  1692. 'face-attribute-relative-p', 'face-attributes-as-vector', 'face-font',
  1693. 'fboundp', 'fceiling', 'fetch-bytecode', 'ffloor',
  1694. 'field-beginning', 'field-end', 'field-string',
  1695. 'field-string-no-properties', 'file-accessible-directory-p',
  1696. 'file-acl', 'file-attributes', 'file-attributes-lessp',
  1697. 'file-directory-p', 'file-executable-p', 'file-exists-p',
  1698. 'file-locked-p', 'file-modes', 'file-name-absolute-p',
  1699. 'file-name-all-completions', 'file-name-as-directory',
  1700. 'file-name-completion', 'file-name-directory',
  1701. 'file-name-nondirectory', 'file-newer-than-file-p', 'file-readable-p',
  1702. 'file-regular-p', 'file-selinux-context', 'file-symlink-p',
  1703. 'file-system-info', 'file-system-info', 'file-writable-p',
  1704. 'fillarray', 'find-charset-region', 'find-charset-string',
  1705. 'find-coding-systems-region-internal', 'find-composition-internal',
  1706. 'find-file-name-handler', 'find-font', 'find-operation-coding-system',
  1707. 'float', 'float-time', 'floatp', 'floor', 'fmakunbound',
  1708. 'following-char', 'font-at', 'font-drive-otf', 'font-face-attributes',
  1709. 'font-family-list', 'font-get', 'font-get-glyphs',
  1710. 'font-get-system-font', 'font-get-system-normal-font', 'font-info',
  1711. 'font-match-p', 'font-otf-alternates', 'font-put',
  1712. 'font-shape-gstring', 'font-spec', 'font-variation-glyphs',
  1713. 'font-xlfd-name', 'fontp', 'fontset-font', 'fontset-info',
  1714. 'fontset-list', 'fontset-list-all', 'force-mode-line-update',
  1715. 'force-window-update', 'format', 'format-mode-line',
  1716. 'format-network-address', 'format-time-string', 'forward-char',
  1717. 'forward-comment', 'forward-line', 'forward-word',
  1718. 'frame-border-width', 'frame-bottom-divider-width',
  1719. 'frame-can-run-window-configuration-change-hook', 'frame-char-height',
  1720. 'frame-char-width', 'frame-face-alist', 'frame-first-window',
  1721. 'frame-focus', 'frame-font-cache', 'frame-fringe-width', 'frame-list',
  1722. 'frame-live-p', 'frame-or-buffer-changed-p', 'frame-parameter',
  1723. 'frame-parameters', 'frame-pixel-height', 'frame-pixel-width',
  1724. 'frame-pointer-visible-p', 'frame-right-divider-width',
  1725. 'frame-root-window', 'frame-scroll-bar-height',
  1726. 'frame-scroll-bar-width', 'frame-selected-window', 'frame-terminal',
  1727. 'frame-text-cols', 'frame-text-height', 'frame-text-lines',
  1728. 'frame-text-width', 'frame-total-cols', 'frame-total-lines',
  1729. 'frame-visible-p', 'framep', 'frexp', 'fringe-bitmaps-at-pos',
  1730. 'fround', 'fset', 'ftruncate', 'funcall', 'funcall-interactively',
  1731. 'function-equal', 'functionp', 'gap-position', 'gap-size',
  1732. 'garbage-collect', 'gc-status', 'generate-new-buffer-name', 'get',
  1733. 'get-buffer', 'get-buffer-create', 'get-buffer-process',
  1734. 'get-buffer-window', 'get-byte', 'get-char-property',
  1735. 'get-char-property-and-overlay', 'get-file-buffer', 'get-file-char',
  1736. 'get-internal-run-time', 'get-load-suffixes', 'get-pos-property',
  1737. 'get-process', 'get-screen-color', 'get-text-property',
  1738. 'get-unicode-property-internal', 'get-unused-category',
  1739. 'get-unused-iso-final-char', 'getenv-internal', 'gethash',
  1740. 'gfile-add-watch', 'gfile-rm-watch', 'global-key-binding',
  1741. 'gnutls-available-p', 'gnutls-boot', 'gnutls-bye', 'gnutls-deinit',
  1742. 'gnutls-error-fatalp', 'gnutls-error-string', 'gnutls-errorp',
  1743. 'gnutls-get-initstage', 'gnutls-peer-status',
  1744. 'gnutls-peer-status-warning-describe', 'goto-char', 'gpm-mouse-start',
  1745. 'gpm-mouse-stop', 'group-gid', 'group-real-gid',
  1746. 'handle-save-session', 'handle-switch-frame', 'hash-table-count',
  1747. 'hash-table-p', 'hash-table-rehash-size',
  1748. 'hash-table-rehash-threshold', 'hash-table-size', 'hash-table-test',
  1749. 'hash-table-weakness', 'iconify-frame', 'identity', 'image-flush',
  1750. 'image-mask-p', 'image-metadata', 'image-size', 'imagemagick-types',
  1751. 'imagep', 'indent-to', 'indirect-function', 'indirect-variable',
  1752. 'init-image-library', 'inotify-add-watch', 'inotify-rm-watch',
  1753. 'input-pending-p', 'insert', 'insert-and-inherit',
  1754. 'insert-before-markers', 'insert-before-markers-and-inherit',
  1755. 'insert-buffer-substring', 'insert-byte', 'insert-char',
  1756. 'insert-file-contents', 'insert-startup-screen', 'int86',
  1757. 'integer-or-marker-p', 'integerp', 'interactive-form', 'intern',
  1758. 'intern-soft', 'internal--track-mouse', 'internal-char-font',
  1759. 'internal-complete-buffer', 'internal-copy-lisp-face',
  1760. 'internal-default-process-filter',
  1761. 'internal-default-process-sentinel', 'internal-describe-syntax-value',
  1762. 'internal-event-symbol-parse-modifiers',
  1763. 'internal-face-x-get-resource', 'internal-get-lisp-face-attribute',
  1764. 'internal-lisp-face-attribute-values', 'internal-lisp-face-empty-p',
  1765. 'internal-lisp-face-equal-p', 'internal-lisp-face-p',
  1766. 'internal-make-lisp-face', 'internal-make-var-non-special',
  1767. 'internal-merge-in-global-face',
  1768. 'internal-set-alternative-font-family-alist',
  1769. 'internal-set-alternative-font-registry-alist',
  1770. 'internal-set-font-selection-order',
  1771. 'internal-set-lisp-face-attribute',
  1772. 'internal-set-lisp-face-attribute-from-resource',
  1773. 'internal-show-cursor', 'internal-show-cursor-p', 'interrupt-process',
  1774. 'invisible-p', 'invocation-directory', 'invocation-name', 'isnan',
  1775. 'iso-charset', 'key-binding', 'key-description',
  1776. 'keyboard-coding-system', 'keymap-parent', 'keymap-prompt', 'keymapp',
  1777. 'keywordp', 'kill-all-local-variables', 'kill-buffer', 'kill-emacs',
  1778. 'kill-local-variable', 'kill-process', 'last-nonminibuffer-frame',
  1779. 'lax-plist-get', 'lax-plist-put', 'ldexp', 'length',
  1780. 'libxml-parse-html-region', 'libxml-parse-xml-region',
  1781. 'line-beginning-position', 'line-end-position', 'line-pixel-height',
  1782. 'list', 'list-fonts', 'list-system-processes', 'listp', 'load',
  1783. 'load-average', 'local-key-binding', 'local-variable-if-set-p',
  1784. 'local-variable-p', 'locale-info', 'locate-file-internal',
  1785. 'lock-buffer', 'log', 'logand', 'logb', 'logior', 'lognot', 'logxor',
  1786. 'looking-at', 'lookup-image', 'lookup-image-map', 'lookup-key',
  1787. 'lower-frame', 'lsh', 'macroexpand', 'make-bool-vector',
  1788. 'make-byte-code', 'make-category-set', 'make-category-table',
  1789. 'make-char', 'make-char-table', 'make-directory-internal',
  1790. 'make-frame-invisible', 'make-frame-visible', 'make-hash-table',
  1791. 'make-indirect-buffer', 'make-keymap', 'make-list',
  1792. 'make-local-variable', 'make-marker', 'make-network-process',
  1793. 'make-overlay', 'make-serial-process', 'make-sparse-keymap',
  1794. 'make-string', 'make-symbol', 'make-symbolic-link', 'make-temp-name',
  1795. 'make-terminal-frame', 'make-variable-buffer-local',
  1796. 'make-variable-frame-local', 'make-vector', 'makunbound',
  1797. 'map-char-table', 'map-charset-chars', 'map-keymap',
  1798. 'map-keymap-internal', 'mapatoms', 'mapc', 'mapcar', 'mapconcat',
  1799. 'maphash', 'mark-marker', 'marker-buffer', 'marker-insertion-type',
  1800. 'marker-position', 'markerp', 'match-beginning', 'match-data',
  1801. 'match-end', 'matching-paren', 'max', 'max-char', 'md5', 'member',
  1802. 'memory-info', 'memory-limit', 'memory-use-counts', 'memq', 'memql',
  1803. 'menu-bar-menu-at-x-y', 'menu-or-popup-active-p',
  1804. 'menu-or-popup-active-p', 'merge-face-attribute', 'message',
  1805. 'message-box', 'message-or-box', 'min',
  1806. 'minibuffer-completion-contents', 'minibuffer-contents',
  1807. 'minibuffer-contents-no-properties', 'minibuffer-depth',
  1808. 'minibuffer-prompt', 'minibuffer-prompt-end',
  1809. 'minibuffer-selected-window', 'minibuffer-window', 'minibufferp',
  1810. 'minor-mode-key-binding', 'mod', 'modify-category-entry',
  1811. 'modify-frame-parameters', 'modify-syntax-entry',
  1812. 'mouse-pixel-position', 'mouse-position', 'move-overlay',
  1813. 'move-point-visually', 'move-to-column', 'move-to-window-line',
  1814. 'msdos-downcase-filename', 'msdos-long-file-names', 'msdos-memget',
  1815. 'msdos-memput', 'msdos-mouse-disable', 'msdos-mouse-enable',
  1816. 'msdos-mouse-init', 'msdos-mouse-p', 'msdos-remember-default-colors',
  1817. 'msdos-set-keyboard', 'msdos-set-mouse-buttons',
  1818. 'multibyte-char-to-unibyte', 'multibyte-string-p', 'narrow-to-region',
  1819. 'natnump', 'nconc', 'network-interface-info',
  1820. 'network-interface-list', 'new-fontset', 'newline-cache-check',
  1821. 'next-char-property-change', 'next-frame', 'next-overlay-change',
  1822. 'next-property-change', 'next-read-file-uses-dialog-p',
  1823. 'next-single-char-property-change', 'next-single-property-change',
  1824. 'next-window', 'nlistp', 'nreverse', 'nth', 'nthcdr', 'null',
  1825. 'number-or-marker-p', 'number-to-string', 'numberp',
  1826. 'open-dribble-file', 'open-font', 'open-termscript',
  1827. 'optimize-char-table', 'other-buffer', 'other-window-for-scrolling',
  1828. 'overlay-buffer', 'overlay-end', 'overlay-get', 'overlay-lists',
  1829. 'overlay-properties', 'overlay-put', 'overlay-recenter',
  1830. 'overlay-start', 'overlayp', 'overlays-at', 'overlays-in',
  1831. 'parse-partial-sexp', 'play-sound-internal', 'plist-get',
  1832. 'plist-member', 'plist-put', 'point', 'point-marker', 'point-max',
  1833. 'point-max-marker', 'point-min', 'point-min-marker',
  1834. 'pos-visible-in-window-p', 'position-bytes', 'posix-looking-at',
  1835. 'posix-search-backward', 'posix-search-forward', 'posix-string-match',
  1836. 'posn-at-point', 'posn-at-x-y', 'preceding-char',
  1837. 'prefix-numeric-value', 'previous-char-property-change',
  1838. 'previous-frame', 'previous-overlay-change',
  1839. 'previous-property-change', 'previous-single-char-property-change',
  1840. 'previous-single-property-change', 'previous-window', 'prin1',
  1841. 'prin1-to-string', 'princ', 'print', 'process-attributes',
  1842. 'process-buffer', 'process-coding-system', 'process-command',
  1843. 'process-connection', 'process-contact', 'process-datagram-address',
  1844. 'process-exit-status', 'process-filter', 'process-filter-multibyte-p',
  1845. 'process-id', 'process-inherit-coding-system-flag', 'process-list',
  1846. 'process-mark', 'process-name', 'process-plist',
  1847. 'process-query-on-exit-flag', 'process-running-child-p',
  1848. 'process-send-eof', 'process-send-region', 'process-send-string',
  1849. 'process-sentinel', 'process-status', 'process-tty-name',
  1850. 'process-type', 'processp', 'profiler-cpu-log',
  1851. 'profiler-cpu-running-p', 'profiler-cpu-start', 'profiler-cpu-stop',
  1852. 'profiler-memory-log', 'profiler-memory-running-p',
  1853. 'profiler-memory-start', 'profiler-memory-stop', 'propertize',
  1854. 'purecopy', 'put', 'put-text-property',
  1855. 'put-unicode-property-internal', 'puthash', 'query-font',
  1856. 'query-fontset', 'quit-process', 'raise-frame', 'random', 'rassoc',
  1857. 'rassq', 're-search-backward', 're-search-forward', 'read',
  1858. 'read-buffer', 'read-char', 'read-char-exclusive',
  1859. 'read-coding-system', 'read-command', 'read-event',
  1860. 'read-from-minibuffer', 'read-from-string', 'read-function',
  1861. 'read-key-sequence', 'read-key-sequence-vector',
  1862. 'read-no-blanks-input', 'read-non-nil-coding-system', 'read-string',
  1863. 'read-variable', 'recent-auto-save-p', 'recent-doskeys',
  1864. 'recent-keys', 'recenter', 'recursion-depth', 'recursive-edit',
  1865. 'redirect-debugging-output', 'redirect-frame-focus', 'redisplay',
  1866. 'redraw-display', 'redraw-frame', 'regexp-quote', 'region-beginning',
  1867. 'region-end', 'register-ccl-program', 'register-code-conversion-map',
  1868. 'remhash', 'remove-list-of-text-properties', 'remove-text-properties',
  1869. 'rename-buffer', 'rename-file', 'replace-match',
  1870. 'reset-this-command-lengths', 'resize-mini-window-internal',
  1871. 'restore-buffer-modified-p', 'resume-tty', 'reverse', 'round',
  1872. 'run-hook-with-args', 'run-hook-with-args-until-failure',
  1873. 'run-hook-with-args-until-success', 'run-hook-wrapped', 'run-hooks',
  1874. 'run-window-configuration-change-hook', 'run-window-scroll-functions',
  1875. 'safe-length', 'scan-lists', 'scan-sexps', 'scroll-down',
  1876. 'scroll-left', 'scroll-other-window', 'scroll-right', 'scroll-up',
  1877. 'search-backward', 'search-forward', 'secure-hash', 'select-frame',
  1878. 'select-window', 'selected-frame', 'selected-window',
  1879. 'self-insert-command', 'send-string-to-terminal', 'sequencep',
  1880. 'serial-process-configure', 'set', 'set-buffer',
  1881. 'set-buffer-auto-saved', 'set-buffer-major-mode',
  1882. 'set-buffer-modified-p', 'set-buffer-multibyte', 'set-case-table',
  1883. 'set-category-table', 'set-char-table-extra-slot',
  1884. 'set-char-table-parent', 'set-char-table-range', 'set-charset-plist',
  1885. 'set-charset-priority', 'set-coding-system-priority',
  1886. 'set-cursor-size', 'set-default', 'set-default-file-modes',
  1887. 'set-default-toplevel-value', 'set-file-acl', 'set-file-modes',
  1888. 'set-file-selinux-context', 'set-file-times', 'set-fontset-font',
  1889. 'set-frame-height', 'set-frame-position', 'set-frame-selected-window',
  1890. 'set-frame-size', 'set-frame-width', 'set-fringe-bitmap-face',
  1891. 'set-input-interrupt-mode', 'set-input-meta-mode', 'set-input-mode',
  1892. 'set-keyboard-coding-system-internal', 'set-keymap-parent',
  1893. 'set-marker', 'set-marker-insertion-type', 'set-match-data',
  1894. 'set-message-beep', 'set-minibuffer-window',
  1895. 'set-mouse-pixel-position', 'set-mouse-position',
  1896. 'set-network-process-option', 'set-output-flow-control',
  1897. 'set-process-buffer', 'set-process-coding-system',
  1898. 'set-process-datagram-address', 'set-process-filter',
  1899. 'set-process-filter-multibyte',
  1900. 'set-process-inherit-coding-system-flag', 'set-process-plist',
  1901. 'set-process-query-on-exit-flag', 'set-process-sentinel',
  1902. 'set-process-window-size', 'set-quit-char',
  1903. 'set-safe-terminal-coding-system-internal', 'set-screen-color',
  1904. 'set-standard-case-table', 'set-syntax-table',
  1905. 'set-terminal-coding-system-internal', 'set-terminal-local-value',
  1906. 'set-terminal-parameter', 'set-text-properties', 'set-time-zone-rule',
  1907. 'set-visited-file-modtime', 'set-window-buffer',
  1908. 'set-window-combination-limit', 'set-window-configuration',
  1909. 'set-window-dedicated-p', 'set-window-display-table',
  1910. 'set-window-fringes', 'set-window-hscroll', 'set-window-margins',
  1911. 'set-window-new-normal', 'set-window-new-pixel',
  1912. 'set-window-new-total', 'set-window-next-buffers',
  1913. 'set-window-parameter', 'set-window-point', 'set-window-prev-buffers',
  1914. 'set-window-redisplay-end-trigger', 'set-window-scroll-bars',
  1915. 'set-window-start', 'set-window-vscroll', 'setcar', 'setcdr',
  1916. 'setplist', 'show-face-resources', 'signal', 'signal-process', 'sin',
  1917. 'single-key-description', 'skip-chars-backward', 'skip-chars-forward',
  1918. 'skip-syntax-backward', 'skip-syntax-forward', 'sleep-for', 'sort',
  1919. 'sort-charsets', 'special-variable-p', 'split-char',
  1920. 'split-window-internal', 'sqrt', 'standard-case-table',
  1921. 'standard-category-table', 'standard-syntax-table', 'start-kbd-macro',
  1922. 'start-process', 'stop-process', 'store-kbd-macro-event', 'string',
  1923. 'string=', 'string<', 'string>', 'string-as-multibyte',
  1924. 'string-as-unibyte', 'string-bytes', 'string-collate-equalp',
  1925. 'string-collate-lessp', 'string-equal', 'string-greaterp',
  1926. 'string-lessp', 'string-make-multibyte', 'string-make-unibyte',
  1927. 'string-match', 'string-to-char', 'string-to-multibyte',
  1928. 'string-to-number', 'string-to-syntax', 'string-to-unibyte',
  1929. 'string-width', 'stringp', 'subr-name', 'subrp',
  1930. 'subst-char-in-region', 'substitute-command-keys',
  1931. 'substitute-in-file-name', 'substring', 'substring-no-properties',
  1932. 'suspend-emacs', 'suspend-tty', 'suspicious-object', 'sxhash',
  1933. 'symbol-function', 'symbol-name', 'symbol-plist', 'symbol-value',
  1934. 'symbolp', 'syntax-table', 'syntax-table-p', 'system-groups',
  1935. 'system-move-file-to-trash', 'system-name', 'system-users', 'tan',
  1936. 'terminal-coding-system', 'terminal-list', 'terminal-live-p',
  1937. 'terminal-local-value', 'terminal-name', 'terminal-parameter',
  1938. 'terminal-parameters', 'terpri', 'test-completion',
  1939. 'text-char-description', 'text-properties-at', 'text-property-any',
  1940. 'text-property-not-all', 'this-command-keys',
  1941. 'this-command-keys-vector', 'this-single-command-keys',
  1942. 'this-single-command-raw-keys', 'time-add', 'time-less-p',
  1943. 'time-subtract', 'tool-bar-get-system-style', 'tool-bar-height',
  1944. 'tool-bar-pixel-width', 'top-level', 'trace-redisplay',
  1945. 'trace-to-stderr', 'translate-region-internal', 'transpose-regions',
  1946. 'truncate', 'try-completion', 'tty-display-color-cells',
  1947. 'tty-display-color-p', 'tty-no-underline',
  1948. 'tty-suppress-bold-inverse-default-colors', 'tty-top-frame',
  1949. 'tty-type', 'type-of', 'undo-boundary', 'unencodable-char-position',
  1950. 'unhandled-file-name-directory', 'unibyte-char-to-multibyte',
  1951. 'unibyte-string', 'unicode-property-table-internal', 'unify-charset',
  1952. 'unintern', 'unix-sync', 'unlock-buffer', 'upcase', 'upcase-initials',
  1953. 'upcase-initials-region', 'upcase-region', 'upcase-word',
  1954. 'use-global-map', 'use-local-map', 'user-full-name',
  1955. 'user-login-name', 'user-real-login-name', 'user-real-uid',
  1956. 'user-uid', 'variable-binding-locus', 'vconcat', 'vector',
  1957. 'vector-or-char-table-p', 'vectorp', 'verify-visited-file-modtime',
  1958. 'vertical-motion', 'visible-frame-list', 'visited-file-modtime',
  1959. 'w16-get-clipboard-data', 'w16-selection-exists-p',
  1960. 'w16-set-clipboard-data', 'w32-battery-status',
  1961. 'w32-default-color-map', 'w32-define-rgb-color',
  1962. 'w32-display-monitor-attributes-list', 'w32-frame-menu-bar-size',
  1963. 'w32-frame-rect', 'w32-get-clipboard-data',
  1964. 'w32-get-codepage-charset', 'w32-get-console-codepage',
  1965. 'w32-get-console-output-codepage', 'w32-get-current-locale-id',
  1966. 'w32-get-default-locale-id', 'w32-get-keyboard-layout',
  1967. 'w32-get-locale-info', 'w32-get-valid-codepages',
  1968. 'w32-get-valid-keyboard-layouts', 'w32-get-valid-locale-ids',
  1969. 'w32-has-winsock', 'w32-long-file-name', 'w32-reconstruct-hot-key',
  1970. 'w32-register-hot-key', 'w32-registered-hot-keys',
  1971. 'w32-selection-exists-p', 'w32-send-sys-command',
  1972. 'w32-set-clipboard-data', 'w32-set-console-codepage',
  1973. 'w32-set-console-output-codepage', 'w32-set-current-locale',
  1974. 'w32-set-keyboard-layout', 'w32-set-process-priority',
  1975. 'w32-shell-execute', 'w32-short-file-name', 'w32-toggle-lock-key',
  1976. 'w32-unload-winsock', 'w32-unregister-hot-key', 'w32-window-exists-p',
  1977. 'w32notify-add-watch', 'w32notify-rm-watch',
  1978. 'waiting-for-user-input-p', 'where-is-internal', 'widen',
  1979. 'widget-apply', 'widget-get', 'widget-put',
  1980. 'window-absolute-pixel-edges', 'window-at', 'window-body-height',
  1981. 'window-body-width', 'window-bottom-divider-width', 'window-buffer',
  1982. 'window-combination-limit', 'window-configuration-frame',
  1983. 'window-configuration-p', 'window-dedicated-p',
  1984. 'window-display-table', 'window-edges', 'window-end', 'window-frame',
  1985. 'window-fringes', 'window-header-line-height', 'window-hscroll',
  1986. 'window-inside-absolute-pixel-edges', 'window-inside-edges',
  1987. 'window-inside-pixel-edges', 'window-left-child',
  1988. 'window-left-column', 'window-line-height', 'window-list',
  1989. 'window-list-1', 'window-live-p', 'window-margins',
  1990. 'window-minibuffer-p', 'window-mode-line-height', 'window-new-normal',
  1991. 'window-new-pixel', 'window-new-total', 'window-next-buffers',
  1992. 'window-next-sibling', 'window-normal-size', 'window-old-point',
  1993. 'window-parameter', 'window-parameters', 'window-parent',
  1994. 'window-pixel-edges', 'window-pixel-height', 'window-pixel-left',
  1995. 'window-pixel-top', 'window-pixel-width', 'window-point',
  1996. 'window-prev-buffers', 'window-prev-sibling',
  1997. 'window-redisplay-end-trigger', 'window-resize-apply',
  1998. 'window-resize-apply-total', 'window-right-divider-width',
  1999. 'window-scroll-bar-height', 'window-scroll-bar-width',
  2000. 'window-scroll-bars', 'window-start', 'window-system',
  2001. 'window-text-height', 'window-text-pixel-size', 'window-text-width',
  2002. 'window-top-child', 'window-top-line', 'window-total-height',
  2003. 'window-total-width', 'window-use-time', 'window-valid-p',
  2004. 'window-vscroll', 'windowp', 'write-char', 'write-region',
  2005. 'x-backspace-delete-keys-p', 'x-change-window-property',
  2006. 'x-change-window-property', 'x-close-connection',
  2007. 'x-close-connection', 'x-create-frame', 'x-create-frame',
  2008. 'x-delete-window-property', 'x-delete-window-property',
  2009. 'x-disown-selection-internal', 'x-display-backing-store',
  2010. 'x-display-backing-store', 'x-display-color-cells',
  2011. 'x-display-color-cells', 'x-display-grayscale-p',
  2012. 'x-display-grayscale-p', 'x-display-list', 'x-display-list',
  2013. 'x-display-mm-height', 'x-display-mm-height', 'x-display-mm-width',
  2014. 'x-display-mm-width', 'x-display-monitor-attributes-list',
  2015. 'x-display-pixel-height', 'x-display-pixel-height',
  2016. 'x-display-pixel-width', 'x-display-pixel-width', 'x-display-planes',
  2017. 'x-display-planes', 'x-display-save-under', 'x-display-save-under',
  2018. 'x-display-screens', 'x-display-screens', 'x-display-visual-class',
  2019. 'x-display-visual-class', 'x-family-fonts', 'x-file-dialog',
  2020. 'x-file-dialog', 'x-file-dialog', 'x-focus-frame', 'x-frame-geometry',
  2021. 'x-frame-geometry', 'x-get-atom-name', 'x-get-resource',
  2022. 'x-get-selection-internal', 'x-hide-tip', 'x-hide-tip',
  2023. 'x-list-fonts', 'x-load-color-file', 'x-menu-bar-open-internal',
  2024. 'x-menu-bar-open-internal', 'x-open-connection', 'x-open-connection',
  2025. 'x-own-selection-internal', 'x-parse-geometry', 'x-popup-dialog',
  2026. 'x-popup-menu', 'x-register-dnd-atom', 'x-select-font',
  2027. 'x-select-font', 'x-selection-exists-p', 'x-selection-owner-p',
  2028. 'x-send-client-message', 'x-server-max-request-size',
  2029. 'x-server-max-request-size', 'x-server-vendor', 'x-server-vendor',
  2030. 'x-server-version', 'x-server-version', 'x-show-tip', 'x-show-tip',
  2031. 'x-synchronize', 'x-synchronize', 'x-uses-old-gtk-dialog',
  2032. 'x-window-property', 'x-window-property', 'x-wm-set-size-hint',
  2033. 'xw-color-defined-p', 'xw-color-defined-p', 'xw-color-values',
  2034. 'xw-color-values', 'xw-display-color-p', 'xw-display-color-p',
  2035. 'yes-or-no-p', 'zlib-available-p', 'zlib-decompress-region',
  2036. 'forward-point',
  2037. }
  2038. builtin_function_highlighted = {
  2039. 'defvaralias', 'provide', 'require',
  2040. 'with-no-warnings', 'define-widget', 'with-electric-help',
  2041. 'throw', 'defalias', 'featurep'
  2042. }
  2043. lambda_list_keywords = {
  2044. '&allow-other-keys', '&aux', '&body', '&environment', '&key', '&optional',
  2045. '&rest', '&whole',
  2046. }
  2047. error_keywords = {
  2048. 'cl-assert', 'cl-check-type', 'error', 'signal',
  2049. 'user-error', 'warn',
  2050. }
  2051. def get_tokens_unprocessed(self, text):
  2052. stack = ['root']
  2053. for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
  2054. if token is Name.Variable:
  2055. if value in EmacsLispLexer.builtin_function:
  2056. yield index, Name.Function, value
  2057. continue
  2058. if value in EmacsLispLexer.special_forms:
  2059. yield index, Keyword, value
  2060. continue
  2061. if value in EmacsLispLexer.error_keywords:
  2062. yield index, Name.Exception, value
  2063. continue
  2064. if value in EmacsLispLexer.builtin_function_highlighted:
  2065. yield index, Name.Builtin, value
  2066. continue
  2067. if value in EmacsLispLexer.macros:
  2068. yield index, Name.Builtin, value
  2069. continue
  2070. if value in EmacsLispLexer.lambda_list_keywords:
  2071. yield index, Keyword.Pseudo, value
  2072. continue
  2073. yield index, token, value
  2074. tokens = {
  2075. 'root': [
  2076. default('body'),
  2077. ],
  2078. 'body': [
  2079. # whitespace
  2080. (r'\s+', Whitespace),
  2081. # single-line comment
  2082. (r';.*$', Comment.Single),
  2083. # strings and characters
  2084. (r'"', String, 'string'),
  2085. (r'\?([^\\]|\\.)', String.Char),
  2086. # quoting
  2087. (r":" + symbol, Name.Builtin),
  2088. (r"::" + symbol, String.Symbol),
  2089. (r"'" + symbol, String.Symbol),
  2090. (r"'", Operator),
  2091. (r"`", Operator),
  2092. # decimal numbers
  2093. (r'[-+]?\d+\.?' + terminated, Number.Integer),
  2094. (r'[-+]?\d+/\d+' + terminated, Number),
  2095. (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' +
  2096. terminated, Number.Float),
  2097. # vectors
  2098. (r'\[|\]', Punctuation),
  2099. # uninterned symbol
  2100. (r'#:' + symbol, String.Symbol),
  2101. # read syntax for char tables
  2102. (r'#\^\^?', Operator),
  2103. # function shorthand
  2104. (r'#\'', Name.Function),
  2105. # binary rational
  2106. (r'#[bB][+-]?[01]+(/[01]+)?', Number.Bin),
  2107. # octal rational
  2108. (r'#[oO][+-]?[0-7]+(/[0-7]+)?', Number.Oct),
  2109. # hex rational
  2110. (r'#[xX][+-]?[0-9a-fA-F]+(/[0-9a-fA-F]+)?', Number.Hex),
  2111. # radix rational
  2112. (r'#\d+r[+-]?[0-9a-zA-Z]+(/[0-9a-zA-Z]+)?', Number),
  2113. # reference
  2114. (r'#\d+=', Operator),
  2115. (r'#\d+#', Operator),
  2116. # special operators that should have been parsed already
  2117. (r'(,@|,|\.|:)', Operator),
  2118. # special constants
  2119. (r'(t|nil)' + terminated, Name.Constant),
  2120. # functions and variables
  2121. (r'\*' + symbol + r'\*', Name.Variable.Global),
  2122. (symbol, Name.Variable),
  2123. # parentheses
  2124. (r'#\(', Operator, 'body'),
  2125. (r'\(', Punctuation, 'body'),
  2126. (r'\)', Punctuation, '#pop'),
  2127. ],
  2128. 'string': [
  2129. (r'[^"\\`]+', String),
  2130. (r'`%s\'' % symbol, String.Symbol),
  2131. (r'`', String),
  2132. (r'\\.', String),
  2133. (r'\\\n', String),
  2134. (r'"', String, '#pop'),
  2135. ],
  2136. }
  2137. class ShenLexer(RegexLexer):
  2138. """
  2139. Lexer for Shen source code.
  2140. .. versionadded:: 2.1
  2141. """
  2142. name = 'Shen'
  2143. url = 'http://shenlanguage.org/'
  2144. aliases = ['shen']
  2145. filenames = ['*.shen']
  2146. mimetypes = ['text/x-shen', 'application/x-shen']
  2147. DECLARATIONS = (
  2148. 'datatype', 'define', 'defmacro', 'defprolog', 'defcc',
  2149. 'synonyms', 'declare', 'package', 'type', 'function',
  2150. )
  2151. SPECIAL_FORMS = (
  2152. 'lambda', 'get', 'let', 'if', 'cases', 'cond', 'put', 'time', 'freeze',
  2153. 'value', 'load', '$', 'protect', 'or', 'and', 'not', 'do', 'output',
  2154. 'prolog?', 'trap-error', 'error', 'make-string', '/.', 'set', '@p',
  2155. '@s', '@v',
  2156. )
  2157. BUILTINS = (
  2158. '==', '=', '*', '+', '-', '/', '<', '>', '>=', '<=', '<-address',
  2159. '<-vector', 'abort', 'absvector', 'absvector?', 'address->', 'adjoin',
  2160. 'append', 'arity', 'assoc', 'bind', 'boolean?', 'bound?', 'call', 'cd',
  2161. 'close', 'cn', 'compile', 'concat', 'cons', 'cons?', 'cut', 'destroy',
  2162. 'difference', 'element?', 'empty?', 'enable-type-theory',
  2163. 'error-to-string', 'eval', 'eval-kl', 'exception', 'explode', 'external',
  2164. 'fail', 'fail-if', 'file', 'findall', 'fix', 'fst', 'fwhen', 'gensym',
  2165. 'get-time', 'hash', 'hd', 'hdstr', 'hdv', 'head', 'identical',
  2166. 'implementation', 'in', 'include', 'include-all-but', 'inferences',
  2167. 'input', 'input+', 'integer?', 'intern', 'intersection', 'is', 'kill',
  2168. 'language', 'length', 'limit', 'lineread', 'loaded', 'macro', 'macroexpand',
  2169. 'map', 'mapcan', 'maxinferences', 'mode', 'n->string', 'nl', 'nth', 'null',
  2170. 'number?', 'occurrences', 'occurs-check', 'open', 'os', 'out', 'port',
  2171. 'porters', 'pos', 'pr', 'preclude', 'preclude-all-but', 'print', 'profile',
  2172. 'profile-results', 'ps', 'quit', 'read', 'read+', 'read-byte', 'read-file',
  2173. 'read-file-as-bytelist', 'read-file-as-string', 'read-from-string',
  2174. 'release', 'remove', 'return', 'reverse', 'run', 'save', 'set',
  2175. 'simple-error', 'snd', 'specialise', 'spy', 'step', 'stinput', 'stoutput',
  2176. 'str', 'string->n', 'string->symbol', 'string?', 'subst', 'symbol?',
  2177. 'systemf', 'tail', 'tc', 'tc?', 'thaw', 'tl', 'tlstr', 'tlv', 'track',
  2178. 'tuple?', 'undefmacro', 'unify', 'unify!', 'union', 'unprofile',
  2179. 'unspecialise', 'untrack', 'variable?', 'vector', 'vector->', 'vector?',
  2180. 'verified', 'version', 'warn', 'when', 'write-byte', 'write-to-file',
  2181. 'y-or-n?',
  2182. )
  2183. BUILTINS_ANYWHERE = ('where', 'skip', '>>', '_', '!', '<e>', '<!>')
  2184. MAPPINGS = {s: Keyword for s in DECLARATIONS}
  2185. MAPPINGS.update((s, Name.Builtin) for s in BUILTINS)
  2186. MAPPINGS.update((s, Keyword) for s in SPECIAL_FORMS)
  2187. valid_symbol_chars = r'[\w!$%*+,<=>?/.\'@&#:-]'
  2188. valid_name = '%s+' % valid_symbol_chars
  2189. symbol_name = r'[a-z!$%%*+,<=>?/.\'@&#_-]%s*' % valid_symbol_chars
  2190. variable = r'[A-Z]%s*' % valid_symbol_chars
  2191. tokens = {
  2192. 'string': [
  2193. (r'"', String, '#pop'),
  2194. (r'c#\d{1,3};', String.Escape),
  2195. (r'~[ARS%]', String.Interpol),
  2196. (r'(?s).', String),
  2197. ],
  2198. 'root': [
  2199. (r'(?s)\\\*.*?\*\\', Comment.Multiline), # \* ... *\
  2200. (r'\\\\.*', Comment.Single), # \\ ...
  2201. (r'\s+', Whitespace),
  2202. (r'_{5,}', Punctuation),
  2203. (r'={5,}', Punctuation),
  2204. (r'(;|:=|\||--?>|<--?)', Punctuation),
  2205. (r'(:-|:|\{|\})', Literal),
  2206. (r'[+-]*\d*\.\d+(e[+-]?\d+)?', Number.Float),
  2207. (r'[+-]*\d+', Number.Integer),
  2208. (r'"', String, 'string'),
  2209. (variable, Name.Variable),
  2210. (r'(true|false|<>|\[\])', Keyword.Pseudo),
  2211. (symbol_name, Literal),
  2212. (r'(\[|\]|\(|\))', Punctuation),
  2213. ],
  2214. }
  2215. def get_tokens_unprocessed(self, text):
  2216. tokens = RegexLexer.get_tokens_unprocessed(self, text)
  2217. tokens = self._process_symbols(tokens)
  2218. tokens = self._process_declarations(tokens)
  2219. return tokens
  2220. def _relevant(self, token):
  2221. return token not in (Text, Whitespace, Comment.Single, Comment.Multiline)
  2222. def _process_declarations(self, tokens):
  2223. opening_paren = False
  2224. for index, token, value in tokens:
  2225. yield index, token, value
  2226. if self._relevant(token):
  2227. if opening_paren and token == Keyword and value in self.DECLARATIONS:
  2228. declaration = value
  2229. yield from self._process_declaration(declaration, tokens)
  2230. opening_paren = value == '(' and token == Punctuation
  2231. def _process_symbols(self, tokens):
  2232. opening_paren = False
  2233. for index, token, value in tokens:
  2234. if opening_paren and token in (Literal, Name.Variable):
  2235. token = self.MAPPINGS.get(value, Name.Function)
  2236. elif token == Literal and value in self.BUILTINS_ANYWHERE:
  2237. token = Name.Builtin
  2238. opening_paren = value == '(' and token == Punctuation
  2239. yield index, token, value
  2240. def _process_declaration(self, declaration, tokens):
  2241. for index, token, value in tokens:
  2242. if self._relevant(token):
  2243. break
  2244. yield index, token, value
  2245. if declaration == 'datatype':
  2246. prev_was_colon = False
  2247. token = Keyword.Type if token == Literal else token
  2248. yield index, token, value
  2249. for index, token, value in tokens:
  2250. if prev_was_colon and token == Literal:
  2251. token = Keyword.Type
  2252. yield index, token, value
  2253. if self._relevant(token):
  2254. prev_was_colon = token == Literal and value == ':'
  2255. elif declaration == 'package':
  2256. token = Name.Namespace if token == Literal else token
  2257. yield index, token, value
  2258. elif declaration == 'define':
  2259. token = Name.Function if token == Literal else token
  2260. yield index, token, value
  2261. for index, token, value in tokens:
  2262. if self._relevant(token):
  2263. break
  2264. yield index, token, value
  2265. if value == '{' and token == Literal:
  2266. yield index, Punctuation, value
  2267. for index, token, value in self._process_signature(tokens):
  2268. yield index, token, value
  2269. else:
  2270. yield index, token, value
  2271. else:
  2272. token = Name.Function if token == Literal else token
  2273. yield index, token, value
  2274. return
  2275. def _process_signature(self, tokens):
  2276. for index, token, value in tokens:
  2277. if token == Literal and value == '}':
  2278. yield index, Punctuation, value
  2279. return
  2280. elif token in (Literal, Name.Function):
  2281. token = Name.Variable if value.istitle() else Keyword.Type
  2282. yield index, token, value
  2283. class CPSALexer(RegexLexer):
  2284. """
  2285. A CPSA lexer based on the CPSA language as of version 2.2.12
  2286. .. versionadded:: 2.1
  2287. """
  2288. name = 'CPSA'
  2289. aliases = ['cpsa']
  2290. filenames = ['*.cpsa']
  2291. mimetypes = []
  2292. # list of known keywords and builtins taken form vim 6.4 scheme.vim
  2293. # syntax file.
  2294. _keywords = (
  2295. 'herald', 'vars', 'defmacro', 'include', 'defprotocol', 'defrole',
  2296. 'defskeleton', 'defstrand', 'deflistener', 'non-orig', 'uniq-orig',
  2297. 'pen-non-orig', 'precedes', 'trace', 'send', 'recv', 'name', 'text',
  2298. 'skey', 'akey', 'data', 'mesg',
  2299. )
  2300. _builtins = (
  2301. 'cat', 'enc', 'hash', 'privk', 'pubk', 'invk', 'ltk', 'gen', 'exp',
  2302. )
  2303. # valid names for identifiers
  2304. # well, names can only not consist fully of numbers
  2305. # but this should be good enough for now
  2306. valid_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
  2307. tokens = {
  2308. 'root': [
  2309. # the comments - always starting with semicolon
  2310. # and going to the end of the line
  2311. (r';.*$', Comment.Single),
  2312. # whitespaces - usually not relevant
  2313. (r'\s+', Whitespace),
  2314. # numbers
  2315. (r'-?\d+\.\d+', Number.Float),
  2316. (r'-?\d+', Number.Integer),
  2317. # support for uncommon kinds of numbers -
  2318. # have to figure out what the characters mean
  2319. # (r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
  2320. # strings, symbols and characters
  2321. (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
  2322. (r"'" + valid_name, String.Symbol),
  2323. (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char),
  2324. # constants
  2325. (r'(#t|#f)', Name.Constant),
  2326. # special operators
  2327. (r"('|#|`|,@|,|\.)", Operator),
  2328. # highlight the keywords
  2329. (words(_keywords, suffix=r'\b'), Keyword),
  2330. # first variable in a quoted string like
  2331. # '(this is syntactic sugar)
  2332. (r"(?<='\()" + valid_name, Name.Variable),
  2333. (r"(?<=#\()" + valid_name, Name.Variable),
  2334. # highlight the builtins
  2335. (words(_builtins, prefix=r'(?<=\()', suffix=r'\b'), Name.Builtin),
  2336. # the remaining functions
  2337. (r'(?<=\()' + valid_name, Name.Function),
  2338. # find the remaining variables
  2339. (valid_name, Name.Variable),
  2340. # the famous parentheses!
  2341. (r'(\(|\))', Punctuation),
  2342. (r'(\[|\])', Punctuation),
  2343. ],
  2344. }
  2345. class XtlangLexer(RegexLexer):
  2346. """An xtlang lexer for the Extempore programming environment.
  2347. This is a mixture of Scheme and xtlang, really. Keyword lists are
  2348. taken from the Extempore Emacs mode
  2349. (https://github.com/extemporelang/extempore-emacs-mode)
  2350. .. versionadded:: 2.2
  2351. """
  2352. name = 'xtlang'
  2353. url = 'http://extempore.moso.com.au'
  2354. aliases = ['extempore']
  2355. filenames = ['*.xtm']
  2356. mimetypes = []
  2357. common_keywords = (
  2358. 'lambda', 'define', 'if', 'else', 'cond', 'and',
  2359. 'or', 'let', 'begin', 'set!', 'map', 'for-each',
  2360. )
  2361. scheme_keywords = (
  2362. 'do', 'delay', 'quasiquote', 'unquote', 'unquote-splicing', 'eval',
  2363. 'case', 'let*', 'letrec', 'quote',
  2364. )
  2365. xtlang_bind_keywords = (
  2366. 'bind-func', 'bind-val', 'bind-lib', 'bind-type', 'bind-alias',
  2367. 'bind-poly', 'bind-dylib', 'bind-lib-func', 'bind-lib-val',
  2368. )
  2369. xtlang_keywords = (
  2370. 'letz', 'memzone', 'cast', 'convert', 'dotimes', 'doloop',
  2371. )
  2372. common_functions = (
  2373. '*', '+', '-', '/', '<', '<=', '=', '>', '>=', '%', 'abs', 'acos',
  2374. 'angle', 'append', 'apply', 'asin', 'assoc', 'assq', 'assv',
  2375. 'atan', 'boolean?', 'caaaar', 'caaadr', 'caaar', 'caadar',
  2376. 'caaddr', 'caadr', 'caar', 'cadaar', 'cadadr', 'cadar',
  2377. 'caddar', 'cadddr', 'caddr', 'cadr', 'car', 'cdaaar',
  2378. 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar',
  2379. 'cddaar', 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr',
  2380. 'cddr', 'cdr', 'ceiling', 'cons', 'cos', 'floor', 'length',
  2381. 'list', 'log', 'max', 'member', 'min', 'modulo', 'not',
  2382. 'reverse', 'round', 'sin', 'sqrt', 'substring', 'tan',
  2383. 'println', 'random', 'null?', 'callback', 'now',
  2384. )
  2385. scheme_functions = (
  2386. 'call-with-current-continuation', 'call-with-input-file',
  2387. 'call-with-output-file', 'call-with-values', 'call/cc',
  2388. 'char->integer', 'char-alphabetic?', 'char-ci<=?', 'char-ci<?',
  2389. 'char-ci=?', 'char-ci>=?', 'char-ci>?', 'char-downcase',
  2390. 'char-lower-case?', 'char-numeric?', 'char-ready?',
  2391. 'char-upcase', 'char-upper-case?', 'char-whitespace?',
  2392. 'char<=?', 'char<?', 'char=?', 'char>=?', 'char>?', 'char?',
  2393. 'close-input-port', 'close-output-port', 'complex?',
  2394. 'current-input-port', 'current-output-port', 'denominator',
  2395. 'display', 'dynamic-wind', 'eof-object?', 'eq?', 'equal?',
  2396. 'eqv?', 'even?', 'exact->inexact', 'exact?', 'exp', 'expt',
  2397. 'force', 'gcd', 'imag-part', 'inexact->exact', 'inexact?',
  2398. 'input-port?', 'integer->char', 'integer?',
  2399. 'interaction-environment', 'lcm', 'list->string',
  2400. 'list->vector', 'list-ref', 'list-tail', 'list?', 'load',
  2401. 'magnitude', 'make-polar', 'make-rectangular', 'make-string',
  2402. 'make-vector', 'memq', 'memv', 'negative?', 'newline',
  2403. 'null-environment', 'number->string', 'number?',
  2404. 'numerator', 'odd?', 'open-input-file', 'open-output-file',
  2405. 'output-port?', 'pair?', 'peek-char', 'port?', 'positive?',
  2406. 'procedure?', 'quotient', 'rational?', 'rationalize', 'read',
  2407. 'read-char', 'real-part', 'real?',
  2408. 'remainder', 'scheme-report-environment', 'set-car!', 'set-cdr!',
  2409. 'string', 'string->list', 'string->number', 'string->symbol',
  2410. 'string-append', 'string-ci<=?', 'string-ci<?', 'string-ci=?',
  2411. 'string-ci>=?', 'string-ci>?', 'string-copy', 'string-fill!',
  2412. 'string-length', 'string-ref', 'string-set!', 'string<=?',
  2413. 'string<?', 'string=?', 'string>=?', 'string>?', 'string?',
  2414. 'symbol->string', 'symbol?', 'transcript-off', 'transcript-on',
  2415. 'truncate', 'values', 'vector', 'vector->list', 'vector-fill!',
  2416. 'vector-length', 'vector?',
  2417. 'with-input-from-file', 'with-output-to-file', 'write',
  2418. 'write-char', 'zero?',
  2419. )
  2420. xtlang_functions = (
  2421. 'toString', 'afill!', 'pfill!', 'tfill!', 'tbind', 'vfill!',
  2422. 'array-fill!', 'pointer-fill!', 'tuple-fill!', 'vector-fill!', 'free',
  2423. 'array', 'tuple', 'list', '~', 'cset!', 'cref', '&', 'bor',
  2424. 'ang-names', '<<', '>>', 'nil', 'printf', 'sprintf', 'null', 'now',
  2425. 'pset!', 'pref-ptr', 'vset!', 'vref', 'aset!', 'aref', 'aref-ptr',
  2426. 'tset!', 'tref', 'tref-ptr', 'salloc', 'halloc', 'zalloc', 'alloc',
  2427. 'schedule', 'exp', 'log', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan',
  2428. 'sqrt', 'expt', 'floor', 'ceiling', 'truncate', 'round',
  2429. 'llvm_printf', 'push_zone', 'pop_zone', 'memzone', 'callback',
  2430. 'llvm_sprintf', 'make-array', 'array-set!', 'array-ref',
  2431. 'array-ref-ptr', 'pointer-set!', 'pointer-ref', 'pointer-ref-ptr',
  2432. 'stack-alloc', 'heap-alloc', 'zone-alloc', 'make-tuple', 'tuple-set!',
  2433. 'tuple-ref', 'tuple-ref-ptr', 'closure-set!', 'closure-ref', 'pref',
  2434. 'pdref', 'impc_null', 'bitcast', 'void', 'ifret', 'ret->', 'clrun->',
  2435. 'make-env-zone', 'make-env', '<>', 'dtof', 'ftod', 'i1tof',
  2436. 'i1tod', 'i1toi8', 'i1toi32', 'i1toi64', 'i8tof', 'i8tod',
  2437. 'i8toi1', 'i8toi32', 'i8toi64', 'i32tof', 'i32tod', 'i32toi1',
  2438. 'i32toi8', 'i32toi64', 'i64tof', 'i64tod', 'i64toi1',
  2439. 'i64toi8', 'i64toi32',
  2440. )
  2441. # valid names for Scheme identifiers (names cannot consist fully
  2442. # of numbers, but this should be good enough for now)
  2443. valid_scheme_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
  2444. # valid characters in xtlang names & types
  2445. valid_xtlang_name = r'[\w.!-]+'
  2446. valid_xtlang_type = r'[]{}[\w<>,*/|!-]+'
  2447. tokens = {
  2448. # keep track of when we're exiting the xtlang form
  2449. 'xtlang': [
  2450. (r'\(', Punctuation, '#push'),
  2451. (r'\)', Punctuation, '#pop'),
  2452. (r'(?<=bind-func\s)' + valid_xtlang_name, Name.Function),
  2453. (r'(?<=bind-val\s)' + valid_xtlang_name, Name.Function),
  2454. (r'(?<=bind-type\s)' + valid_xtlang_name, Name.Function),
  2455. (r'(?<=bind-alias\s)' + valid_xtlang_name, Name.Function),
  2456. (r'(?<=bind-poly\s)' + valid_xtlang_name, Name.Function),
  2457. (r'(?<=bind-lib\s)' + valid_xtlang_name, Name.Function),
  2458. (r'(?<=bind-dylib\s)' + valid_xtlang_name, Name.Function),
  2459. (r'(?<=bind-lib-func\s)' + valid_xtlang_name, Name.Function),
  2460. (r'(?<=bind-lib-val\s)' + valid_xtlang_name, Name.Function),
  2461. # type annotations
  2462. (r':' + valid_xtlang_type, Keyword.Type),
  2463. # types
  2464. (r'(<' + valid_xtlang_type + r'>|\|' + valid_xtlang_type + r'\||/' +
  2465. valid_xtlang_type + r'/|' + valid_xtlang_type + r'\*)\**',
  2466. Keyword.Type),
  2467. # keywords
  2468. (words(xtlang_keywords, prefix=r'(?<=\()'), Keyword),
  2469. # builtins
  2470. (words(xtlang_functions, prefix=r'(?<=\()'), Name.Function),
  2471. include('common'),
  2472. # variables
  2473. (valid_xtlang_name, Name.Variable),
  2474. ],
  2475. 'scheme': [
  2476. # quoted symbols
  2477. (r"'" + valid_scheme_name, String.Symbol),
  2478. # char literals
  2479. (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char),
  2480. # special operators
  2481. (r"('|#|`|,@|,|\.)", Operator),
  2482. # keywords
  2483. (words(scheme_keywords, prefix=r'(?<=\()'), Keyword),
  2484. # builtins
  2485. (words(scheme_functions, prefix=r'(?<=\()'), Name.Function),
  2486. include('common'),
  2487. # variables
  2488. (valid_scheme_name, Name.Variable),
  2489. ],
  2490. # common to both xtlang and Scheme
  2491. 'common': [
  2492. # comments
  2493. (r';.*$', Comment.Single),
  2494. # whitespaces - usually not relevant
  2495. (r'\s+', Whitespace),
  2496. # numbers
  2497. (r'-?\d+\.\d+', Number.Float),
  2498. (r'-?\d+', Number.Integer),
  2499. # binary/oct/hex literals
  2500. (r'(#b|#o|#x)[\d.]+', Number),
  2501. # strings
  2502. (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
  2503. # true/false constants
  2504. (r'(#t|#f)', Name.Constant),
  2505. # keywords
  2506. (words(common_keywords, prefix=r'(?<=\()'), Keyword),
  2507. # builtins
  2508. (words(common_functions, prefix=r'(?<=\()'), Name.Function),
  2509. # the famous parentheses!
  2510. (r'(\(|\))', Punctuation),
  2511. ],
  2512. 'root': [
  2513. # go into xtlang mode
  2514. (words(xtlang_bind_keywords, prefix=r'(?<=\()', suffix=r'\b'),
  2515. Keyword, 'xtlang'),
  2516. include('scheme')
  2517. ],
  2518. }
  2519. class FennelLexer(RegexLexer):
  2520. """A lexer for the Fennel programming language.
  2521. Fennel compiles to Lua, so all the Lua builtins are recognized as well
  2522. as the special forms that are particular to the Fennel compiler.
  2523. .. versionadded:: 2.3
  2524. """
  2525. name = 'Fennel'
  2526. url = 'https://fennel-lang.org'
  2527. aliases = ['fennel', 'fnl']
  2528. filenames = ['*.fnl']
  2529. # this list is current as of Fennel version 0.10.0.
  2530. special_forms = (
  2531. '#', '%', '*', '+', '-', '->', '->>', '-?>', '-?>>', '.', '..',
  2532. '/', '//', ':', '<', '<=', '=', '>', '>=', '?.', '^', 'accumulate',
  2533. 'and', 'band', 'bnot', 'bor', 'bxor', 'collect', 'comment', 'do', 'doc',
  2534. 'doto', 'each', 'eval-compiler', 'for', 'hashfn', 'icollect', 'if',
  2535. 'import-macros', 'include', 'length', 'let', 'lshift', 'lua',
  2536. 'macrodebug', 'match', 'not', 'not=', 'or', 'partial', 'pick-args',
  2537. 'pick-values', 'quote', 'require-macros', 'rshift', 'set',
  2538. 'set-forcibly!', 'tset', 'values', 'when', 'while', 'with-open', '~='
  2539. )
  2540. declarations = (
  2541. 'fn', 'global', 'lambda', 'local', 'macro', 'macros', 'var', 'λ'
  2542. )
  2543. builtins = (
  2544. '_G', '_VERSION', 'arg', 'assert', 'bit32', 'collectgarbage',
  2545. 'coroutine', 'debug', 'dofile', 'error', 'getfenv',
  2546. 'getmetatable', 'io', 'ipairs', 'load', 'loadfile', 'loadstring',
  2547. 'math', 'next', 'os', 'package', 'pairs', 'pcall', 'print',
  2548. 'rawequal', 'rawget', 'rawlen', 'rawset', 'require', 'select',
  2549. 'setfenv', 'setmetatable', 'string', 'table', 'tonumber',
  2550. 'tostring', 'type', 'unpack', 'xpcall'
  2551. )
  2552. # based on the scheme definition, but disallowing leading digits and
  2553. # commas, and @ is not allowed.
  2554. valid_name = r'[a-zA-Z_!$%&*+/:<=>?^~|-][\w!$%&*+/:<=>?^~|\.-]*'
  2555. tokens = {
  2556. 'root': [
  2557. # the only comment form is a semicolon; goes to the end of the line
  2558. (r';.*$', Comment.Single),
  2559. (r',+', Text),
  2560. (r'\s+', Whitespace),
  2561. (r'-?\d+\.\d+', Number.Float),
  2562. (r'-?\d+', Number.Integer),
  2563. (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
  2564. (r'(true|false|nil)', Name.Constant),
  2565. # these are technically strings, but it's worth visually
  2566. # distinguishing them because their intent is different
  2567. # from regular strings.
  2568. (r':' + valid_name, String.Symbol),
  2569. # special forms are keywords
  2570. (words(special_forms, suffix=' '), Keyword),
  2571. # these are ... even more special!
  2572. (words(declarations, suffix=' '), Keyword.Declaration),
  2573. # lua standard library are builtins
  2574. (words(builtins, suffix=' '), Name.Builtin),
  2575. # special-case the vararg symbol
  2576. (r'\.\.\.', Name.Variable),
  2577. # regular identifiers
  2578. (valid_name, Name.Variable),
  2579. # all your normal paired delimiters for your programming enjoyment
  2580. (r'(\(|\))', Punctuation),
  2581. (r'(\[|\])', Punctuation),
  2582. (r'(\{|\})', Punctuation),
  2583. # the # symbol is shorthand for a lambda function
  2584. (r'#', Punctuation),
  2585. ]
  2586. }