prism-bison.js 982 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. Prism.languages.bison = Prism.languages.extend('c', {});
  2. Prism.languages.insertBefore('bison', 'comment', {
  3. 'bison': {
  4. // This should match all the beginning of the file
  5. // including the prologue(s), the bison declarations and
  6. // the grammar rules.
  7. pattern: /^(?:[^%]|%(?!%))*%%[\s\S]*?%%/,
  8. inside: {
  9. 'c': {
  10. // Allow for one level of nested braces
  11. pattern: /%\{[\s\S]*?%\}|\{(?:\{[^}]*\}|[^{}])*\}/,
  12. inside: {
  13. 'delimiter': {
  14. pattern: /^%?\{|%?\}$/,
  15. alias: 'punctuation'
  16. },
  17. 'bison-variable': {
  18. pattern: /[$@](?:<[^\s>]+>)?[\w$]+/,
  19. alias: 'variable',
  20. inside: {
  21. 'punctuation': /<|>/
  22. }
  23. },
  24. rest: Prism.languages.c
  25. }
  26. },
  27. 'comment': Prism.languages.c.comment,
  28. 'string': Prism.languages.c.string,
  29. 'property': /\S+(?=:)/,
  30. 'keyword': /%\w+/,
  31. 'number': {
  32. pattern: /(^|[^@])\b(?:0x[\da-f]+|\d+)/i,
  33. lookbehind: true
  34. },
  35. 'punctuation': /%[%?]|[|:;\[\]<>]/
  36. }
  37. }
  38. });