expr.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package ast
  2. type Expr interface {
  3. PositionHolder
  4. exprMarker()
  5. }
  6. type ExprBase struct {
  7. Node
  8. }
  9. func (expr *ExprBase) exprMarker() {}
  10. /* ConstExprs {{{ */
  11. type ConstExpr interface {
  12. Expr
  13. constExprMarker()
  14. }
  15. type ConstExprBase struct {
  16. ExprBase
  17. }
  18. func (expr *ConstExprBase) constExprMarker() {}
  19. type TrueExpr struct {
  20. ConstExprBase
  21. }
  22. type FalseExpr struct {
  23. ConstExprBase
  24. }
  25. type NilExpr struct {
  26. ConstExprBase
  27. }
  28. type NumberExpr struct {
  29. ConstExprBase
  30. Value string
  31. }
  32. type StringExpr struct {
  33. ConstExprBase
  34. Value string
  35. }
  36. /* ConstExprs }}} */
  37. type Comma3Expr struct {
  38. ExprBase
  39. AdjustRet bool
  40. }
  41. type IdentExpr struct {
  42. ExprBase
  43. Value string
  44. }
  45. type AttrGetExpr struct {
  46. ExprBase
  47. Object Expr
  48. Key Expr
  49. }
  50. type TableExpr struct {
  51. ExprBase
  52. Fields []*Field
  53. }
  54. type FuncCallExpr struct {
  55. ExprBase
  56. Func Expr
  57. Receiver Expr
  58. Method string
  59. Args []Expr
  60. AdjustRet bool
  61. }
  62. type LogicalOpExpr struct {
  63. ExprBase
  64. Operator string
  65. Lhs Expr
  66. Rhs Expr
  67. }
  68. type RelationalOpExpr struct {
  69. ExprBase
  70. Operator string
  71. Lhs Expr
  72. Rhs Expr
  73. }
  74. type StringConcatOpExpr struct {
  75. ExprBase
  76. Lhs Expr
  77. Rhs Expr
  78. }
  79. type ArithmeticOpExpr struct {
  80. ExprBase
  81. Operator string
  82. Lhs Expr
  83. Rhs Expr
  84. }
  85. type UnaryMinusOpExpr struct {
  86. ExprBase
  87. Expr Expr
  88. }
  89. type UnaryNotOpExpr struct {
  90. ExprBase
  91. Expr Expr
  92. }
  93. type UnaryLenOpExpr struct {
  94. ExprBase
  95. Expr Expr
  96. }
  97. type FunctionExpr struct {
  98. ExprBase
  99. ParList *ParList
  100. Stmts []Stmt
  101. }