PatternGrammar.txt 793 B

12345678910111213141516171819202122232425262728
  1. # Copyright 2006 Google, Inc. All Rights Reserved.
  2. # Licensed to PSF under a Contributor Agreement.
  3. # A grammar to describe tree matching patterns.
  4. # Not shown here:
  5. # - 'TOKEN' stands for any token (leaf node)
  6. # - 'any' stands for any node (leaf or interior)
  7. # With 'any' we can still specify the sub-structure.
  8. # The start symbol is 'Matcher'.
  9. Matcher: Alternatives ENDMARKER
  10. Alternatives: Alternative ('|' Alternative)*
  11. Alternative: (Unit | NegatedUnit)+
  12. Unit: [NAME '='] ( STRING [Repeater]
  13. | NAME [Details] [Repeater]
  14. | '(' Alternatives ')' [Repeater]
  15. | '[' Alternatives ']'
  16. )
  17. NegatedUnit: 'not' (STRING | NAME [Details] | '(' Alternatives ')')
  18. Repeater: '*' | '+' | '{' NUMBER [',' NUMBER] '}'
  19. Details: '<' Alternatives '>'