brainfuck.js 875 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Language: Brainfuck
  3. Author: Evgeny Stepanischev <imbolk@gmail.com>
  4. Website: https://esolangs.org/wiki/Brainfuck
  5. */
  6. /** @type LanguageFn */
  7. function brainfuck(hljs) {
  8. const LITERAL = {
  9. className: 'literal',
  10. begin: /[+-]/,
  11. relevance: 0
  12. };
  13. return {
  14. name: 'Brainfuck',
  15. aliases: ['bf'],
  16. contains: [
  17. hljs.COMMENT(
  18. '[^\\[\\]\\.,\\+\\-<> \r\n]',
  19. '[\\[\\]\\.,\\+\\-<> \r\n]',
  20. {
  21. returnEnd: true,
  22. relevance: 0
  23. }
  24. ),
  25. {
  26. className: 'title',
  27. begin: '[\\[\\]]',
  28. relevance: 0
  29. },
  30. {
  31. className: 'string',
  32. begin: '[\\.,]',
  33. relevance: 0
  34. },
  35. {
  36. // this mode works as the only relevance counter
  37. begin: /(?:\+\+|--)/,
  38. contains: [LITERAL]
  39. },
  40. LITERAL
  41. ]
  42. };
  43. }
  44. module.exports = brainfuck;