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.
 
 

60 line
1.4 KiB

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