This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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