prism-gdscript.js 1.2 KB

123456789101112131415161718192021222324252627
  1. Prism.languages.gdscript = {
  2. 'comment': /#.*/,
  3. 'string': {
  4. pattern: /@?(?:("|')(?:(?!\1)[^\n\\]|\\[\s\S])*\1(?!"|')|"""(?:[^\\]|\\[\s\S])*?""")/,
  5. greedy: true
  6. },
  7. 'class-name': {
  8. // class_name Foo, extends Bar, class InnerClass
  9. // export(int) var baz, export(int, 0) var i
  10. // as Node
  11. // const FOO: int = 9, var bar: bool = true
  12. // func add(reference: Item, amount: int) -> Item:
  13. pattern: /(^(?:class|class_name|extends)[ \t]+|^export\([ \t]*|\bas[ \t]+|(?:\b(?:const|var)[ \t]|[,(])[ \t]*\w+[ \t]*:[ \t]*|->[ \t]*)[a-zA-Z_]\w*/m,
  14. lookbehind: true
  15. },
  16. 'keyword': /\b(?:and|as|assert|break|breakpoint|class|class_name|const|continue|elif|else|enum|export|extends|for|func|if|in|is|master|mastersync|match|not|null|onready|or|pass|preload|puppet|puppetsync|remote|remotesync|return|self|setget|signal|static|tool|var|while|yield)\b/,
  17. 'function': /\b[a-z_]\w*(?=[ \t]*\()/i,
  18. 'variable': /\$\w+/,
  19. 'number': [
  20. /\b0b[01_]+\b|\b0x[\da-fA-F_]+\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.[\d_]+)(?:e[+-]?[\d_]+)?\b/,
  21. /\b(?:INF|NAN|PI|TAU)\b/
  22. ],
  23. 'constant': /\b[A-Z][A-Z_\d]*\b/,
  24. 'boolean': /\b(?:false|true)\b/,
  25. 'operator': /->|:=|&&|\|\||<<|>>|[-+*/%&|!<>=]=?|[~^]/,
  26. 'punctuation': /[.:,;()[\]{}]/
  27. };