prism-magma.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. Prism.languages.magma = {
  2. 'output': {
  3. pattern: /^(>.*(?:\r(?:\n|(?!\n))|\n))(?!>)(?:.+|(?:\r(?:\n|(?!\n))|\n)(?!>).*)(?:(?:\r(?:\n|(?!\n))|\n)(?!>).*)*/m,
  4. lookbehind: true,
  5. greedy: true
  6. },
  7. 'comment': {
  8. pattern: /\/\/.*|\/\*[\s\S]*?\*\//,
  9. greedy: true
  10. },
  11. 'string': {
  12. pattern: /(^|[^\\"])"(?:[^\r\n\\"]|\\.)*"/,
  13. lookbehind: true,
  14. greedy: true
  15. },
  16. // http://magma.maths.usyd.edu.au/magma/handbook/text/82
  17. 'keyword': /\b(?:_|adj|and|assert|assert2|assert3|assigned|break|by|case|cat|catch|clear|cmpeq|cmpne|continue|declare|default|delete|diff|div|do|elif|else|end|eq|error|eval|exists|exit|for|forall|forward|fprintf|freeze|function|ge|gt|if|iload|import|in|intrinsic|is|join|le|load|local|lt|meet|mod|ne|not|notadj|notin|notsubset|or|print|printf|procedure|quit|random|read|readi|repeat|require|requirege|requirerange|restore|return|save|sdiff|select|subset|then|time|to|try|until|vprint|vprintf|vtime|when|where|while|xor)\b/,
  18. 'boolean': /\b(?:false|true)\b/,
  19. 'generator': {
  20. pattern: /\b[a-z_]\w*(?=\s*<)/i,
  21. alias: 'class-name'
  22. },
  23. 'function': /\b[a-z_]\w*(?=\s*\()/i,
  24. 'number': {
  25. pattern: /(^|[^\w.]|\.\.)(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:_[a-z]?)?(?=$|[^\w.]|\.\.)/,
  26. lookbehind: true
  27. },
  28. 'operator': /->|[-+*/^~!|#=]|:=|\.\./,
  29. 'punctuation': /[()[\]{}<>,;.:]/
  30. };