erlang-repl.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Language: Erlang REPL
  3. Author: Sergey Ignatov <sergey@ignatov.spb.su>
  4. Website: https://www.erlang.org
  5. Category: functional
  6. */
  7. /** @type LanguageFn */
  8. function erlangRepl(hljs) {
  9. const regex = hljs.regex;
  10. return {
  11. name: 'Erlang REPL',
  12. keywords: {
  13. built_in:
  14. 'spawn spawn_link self',
  15. keyword:
  16. 'after and andalso|10 band begin bnot bor bsl bsr bxor case catch cond div end fun if '
  17. + 'let not of or orelse|10 query receive rem try when xor'
  18. },
  19. contains: [
  20. {
  21. className: 'meta.prompt',
  22. begin: '^[0-9]+> ',
  23. relevance: 10
  24. },
  25. hljs.COMMENT('%', '$'),
  26. {
  27. className: 'number',
  28. begin: '\\b(\\d+(_\\d+)*#[a-fA-F0-9]+(_[a-fA-F0-9]+)*|\\d+(_\\d+)*(\\.\\d+(_\\d+)*)?([eE][-+]?\\d+)?)',
  29. relevance: 0
  30. },
  31. hljs.APOS_STRING_MODE,
  32. hljs.QUOTE_STRING_MODE,
  33. { begin: regex.concat(
  34. /\?(::)?/,
  35. /([A-Z]\w*)/, // at least one identifier
  36. /((::)[A-Z]\w*)*/ // perhaps more
  37. ) },
  38. { begin: '->' },
  39. { begin: 'ok' },
  40. { begin: '!' },
  41. {
  42. begin: '(\\b[a-z\'][a-zA-Z0-9_\']*:[a-z\'][a-zA-Z0-9_\']*)|(\\b[a-z\'][a-zA-Z0-9_\']*)',
  43. relevance: 0
  44. },
  45. {
  46. begin: '[A-Z][a-zA-Z0-9_\']*',
  47. relevance: 0
  48. }
  49. ]
  50. };
  51. }
  52. export { erlangRepl as default };