This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
980 B

  1. start: (_item | _NL)*
  2. _item: rule
  3. | token
  4. | statement
  5. rule: RULE priority? ":" expansions _NL
  6. token: TOKEN priority? ":" expansions _NL
  7. priority: "." NUMBER
  8. statement: "%ignore" expansions _NL -> ignore
  9. | "%import" import_args ["->" TOKEN] _NL -> import
  10. import_args: name ("." name)*
  11. ?expansions: alias (_VBAR alias)*
  12. ?alias: expansion ["->" RULE]
  13. ?expansion: expr*
  14. ?expr: atom [OP | "~" NUMBER [".." NUMBER]]
  15. ?atom: "(" expansions ")"
  16. | "[" expansions "]" -> maybe
  17. | STRING ".." STRING -> literal_range
  18. | name
  19. | (REGEXP | STRING) -> literal
  20. name: RULE
  21. | TOKEN
  22. _VBAR: _NL? "|"
  23. OP: /[+*][?]?|[?](?![a-z])/
  24. RULE: /!?[_?]?[a-z][_a-z0-9]*/
  25. TOKEN: /_?[A-Z][_A-Z0-9]*/
  26. STRING: _STRING "i"?
  27. REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/\n])*?\/[imslux]*/
  28. _NL: /(\r?\n)+\s*/
  29. %import common.ESCAPED_STRING -> _STRING
  30. %import common.INT -> NUMBER
  31. %import common.WS_INLINE
  32. COMMENT: "//" /[^\n]/*
  33. %ignore WS_INLINE
  34. %ignore COMMENT