ebnf.js 875 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. module.exports = function(hljs) {
  2. var commentMode = hljs.COMMENT(/\(\*/, /\*\)/);
  3. var nonTerminalMode = {
  4. className: "attribute",
  5. begin: /^[ ]*[a-zA-Z][a-zA-Z-_]*([\s-_]+[a-zA-Z][a-zA-Z]*)*/
  6. };
  7. var specialSequenceMode = {
  8. className: "meta",
  9. begin: /\?.*\?/
  10. };
  11. var ruleBodyMode = {
  12. begin: /=/, end: /[.;]/,
  13. contains: [
  14. commentMode,
  15. specialSequenceMode,
  16. {
  17. // terminals
  18. className: 'string',
  19. variants: [
  20. hljs.APOS_STRING_MODE,
  21. hljs.QUOTE_STRING_MODE,
  22. {begin: '`', end: '`'},
  23. ]
  24. },
  25. ]
  26. };
  27. return {
  28. illegal: /\S/,
  29. contains: [
  30. commentMode,
  31. nonTerminalMode,
  32. ruleBodyMode
  33. ]
  34. };
  35. };