lisp.py 141 KB

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