Source code of Windows XP (NT5)
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.

23 lines
436 B

  1. #
  2. # clean_y.awk - given an awk grammar, produce a cleaned listing
  3. # of just the grammar, without the actions.
  4. #
  5. # usage:
  6. #
  7. # gawk -f clean_y.awk grammar.y >grammar.out
  8. #
  9. BEGIN { in_body=0
  10. in_brackets=0
  11. }
  12. /%%/ { in_body=1-in_body }
  13. ($1=="{") && (in_body==1) {
  14. in_brackets++
  15. }
  16. (in_body==1) && (in_brackets==0)
  17. ($1=="};") && (in_body==1) {
  18. in_brackets--
  19. }
  20. ($1=="}") && (in_body==1) {
  21. in_brackets--
  22. }
  23. END {}