action.go 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Code generated by gocc; DO NOT EDIT.
  2. package parser
  3. import (
  4. "fmt"
  5. )
  6. type action interface {
  7. act()
  8. String() string
  9. }
  10. type (
  11. accept bool
  12. shift int // value is next state index
  13. reduce int // value is production index
  14. )
  15. func (this accept) act() {}
  16. func (this shift) act() {}
  17. func (this reduce) act() {}
  18. func (this accept) Equal(that action) bool {
  19. if _, ok := that.(accept); ok {
  20. return true
  21. }
  22. return false
  23. }
  24. func (this reduce) Equal(that action) bool {
  25. that1, ok := that.(reduce)
  26. if !ok {
  27. return false
  28. }
  29. return this == that1
  30. }
  31. func (this shift) Equal(that action) bool {
  32. that1, ok := that.(shift)
  33. if !ok {
  34. return false
  35. }
  36. return this == that1
  37. }
  38. func (this accept) String() string { return "accept(0)" }
  39. func (this shift) String() string { return fmt.Sprintf("shift:%d", this) }
  40. func (this reduce) String() string {
  41. return fmt.Sprintf("reduce:%d(%s)", this, productionsTable[this].String)
  42. }