about summary refs log tree commit diff
path: root/pkg/lang/ast
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-07-28 21:18:09 +0000
committerMel <einebeere@gmail.com>2022-07-28 21:18:09 +0000
commit895120776a0ae4dd121029f1730d29ca886e201e (patch)
tree98e4771fd83ec88d559de95f058f724747405f1a /pkg/lang/ast
parentd79973cb9df8660fe89810507557f5ba86256f30 (diff)
downloadjinx-895120776a0ae4dd121029f1730d29ca886e201e.tar.zst
jinx-895120776a0ae4dd121029f1730d29ca886e201e.zip
Fix nested stacked exprs and parse members
Diffstat (limited to 'pkg/lang/ast')
-rw-r--r--pkg/lang/ast/expr.go6
-rw-r--r--pkg/lang/ast/op.go8
2 files changed, 6 insertions, 8 deletions
diff --git a/pkg/lang/ast/expr.go b/pkg/lang/ast/expr.go
index b0ed599..aceed18 100644
--- a/pkg/lang/ast/expr.go
+++ b/pkg/lang/ast/expr.go
@@ -11,6 +11,7 @@ const (
 	ExprKindUnary
 	ExprKindCall
 	ExprKindSubscription
+	ExprKindMember
 
 	ExprKindGroup
 	ExprKindFnLit
@@ -57,6 +58,11 @@ type ExprSubscription struct {
 	Key Expr
 }
 
+type ExprMember struct {
+	Obj Expr
+	Key IdentNode
+}
+
 type ExprGroup struct {
 	Value Expr
 }
diff --git a/pkg/lang/ast/op.go b/pkg/lang/ast/op.go
index 063a309..6f48e0c 100644
--- a/pkg/lang/ast/op.go
+++ b/pkg/lang/ast/op.go
@@ -21,8 +21,6 @@ const (
 	BinOpLte
 	BinOpGt
 	BinOpGte
-
-	BinOpDot
 )
 
 func BinOpFromToken(tok token.Token) (BinOp, bool) {
@@ -52,8 +50,6 @@ func BinOpFromToken(tok token.Token) (BinOp, bool) {
 		op = BinOpGt
 	case token.Gte:
 		op = BinOpGte
-	case token.Dot:
-		op = BinOpDot
 	default:
 		return 0, false
 	}
@@ -71,8 +67,6 @@ func (op BinOp) Precedence() int {
 		return 3
 	case BinOpStar, BinOpSlash, BinOpPercent:
 		return 4
-	case BinOpDot:
-		return 5
 
 	default:
 		panic(fmt.Sprintf("unknown binary operator: %d", op))
@@ -94,8 +88,6 @@ func (op BinOp) Associativity() Associativity {
 		return AssociativityRight
 	case BinOpEq, BinOpNeq, BinOpLt, BinOpLte, BinOpGt, BinOpGte:
 		return AssociativityLeft
-	case BinOpDot:
-		return AssociativityLeft
 	default:
 		panic(fmt.Sprintf("unknown binary operator: %d", op))
 	}