basic records support
All checks were successful
/ test (push) Successful in 50s

This commit is contained in:
Neemek 2026-08-17 17:08:24 +02:00
parent db3a3e29eb
commit 42fa039daf
11 changed files with 522 additions and 138 deletions

View file

@ -29,6 +29,7 @@ const (
NilNodeType
ListNodeType
TupleNodeType
RecordNodeType
BinaryNodeType
UnaryNodeType
BlockNodeType
@ -93,6 +94,8 @@ func (n NodeType) String() string {
return "Alias"
case IndexNodeType:
return "Index"
case RecordNodeType:
return "Record"
}
return "Invalid Node Type"
}
@ -237,6 +240,36 @@ func (n TupleNode) Bounds() (Pos, Pos) {
return n.start, n.end
}
type RecordNode struct {
entries map[string]Node
start Pos
end Pos
}
func (n RecordNode) Type() NodeType {
return RecordNodeType
}
func (n RecordNode) String() string {
sb := strings.Builder{}
sb.WriteString("(")
for name, item := range n.entries {
sb.WriteString(name)
sb.WriteString(": ")
sb.WriteString(item.String())
sb.WriteString(",")
}
sb.WriteString(")")
return sb.String()
}
func (n RecordNode) Bounds() (Pos, Pos) {
return n.start, n.end
}
type AccessNode struct {
source Node
property *Token
@ -269,6 +302,8 @@ func (n BinaryOperation) String() string {
return "multiply"
case BinaryDivision:
return "divide"
case BinaryModulo:
return "modulo"
case BinaryEquality:
return "equality"
case BinaryInequality: