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.

53 lines
1.1 KiB

  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_path ["->" name] _NL -> import
  10. | "%import" import_path name_list _NL -> multi_import
  11. | "%declare" name+ -> declare
  12. !import_path: "."? name ("." name)*
  13. name_list: "(" name ("," name)* ")"
  14. ?expansions: alias (_VBAR alias)*
  15. ?alias: expansion ["->" RULE]
  16. ?expansion: expr*
  17. ?expr: atom [OP | "~" NUMBER [".." NUMBER]]
  18. ?atom: "(" expansions ")"
  19. | "[" expansions "]" -> maybe
  20. | STRING ".." STRING -> literal_range
  21. | name
  22. | (REGEXP | STRING) -> literal
  23. name: RULE
  24. | TOKEN
  25. _VBAR: _NL? "|"
  26. OP: /[+*]|[?](?![a-z])/
  27. RULE: /!?[_?]?[a-z][_a-z0-9]*/
  28. TOKEN: /_?[A-Z][_A-Z0-9]*/
  29. STRING: _STRING "i"?
  30. REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/\n])*?\/[imslux]*/
  31. _NL: /(\r?\n)+\s*/
  32. %import common.ESCAPED_STRING -> _STRING
  33. %import common.INT -> NUMBER
  34. %import common.WS_INLINE
  35. COMMENT: "//" /[^\n]/*
  36. %ignore WS_INLINE
  37. %ignore COMMENT