prism-rego.js 764 B

123456789101112131415161718192021222324252627282930
  1. // https://www.openpolicyagent.org/docs/latest/policy-reference/
  2. Prism.languages.rego = {
  3. 'comment': /#.*/,
  4. 'property': {
  5. pattern: /(^|[^\\.])(?:"(?:\\.|[^\\"\r\n])*"|`[^`]*`|\b[a-z_]\w*\b)(?=\s*:(?!=))/i,
  6. lookbehind: true,
  7. greedy: true
  8. },
  9. 'string': {
  10. pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"|`[^`]*`/,
  11. lookbehind: true,
  12. greedy: true
  13. },
  14. 'keyword': /\b(?:as|default|else|import|not|null|package|set(?=\s*\()|some|with)\b/,
  15. 'boolean': /\b(?:false|true)\b/,
  16. 'function': {
  17. pattern: /\b[a-z_]\w*\b(?:\s*\.\s*\b[a-z_]\w*\b)*(?=\s*\()/i,
  18. inside: {
  19. 'namespace': /\b\w+\b(?=\s*\.)/,
  20. 'punctuation': /\./
  21. }
  22. },
  23. 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
  24. 'operator': /[-+*/%|&]|[<>:=]=?|!=|\b_\b/,
  25. 'punctuation': /[,;.\[\]{}()]/
  26. };