From 0d4795245765669f4c7aa033e988833d5f78c9a3 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Wed, 24 Feb 2021 23:05:54 +0900 Subject: Refactoring * Remove token field from symbolNode * Simplify notation of nested nodes * Simplify arguments of newSymbolNode() --- compiler/ast.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'compiler/ast.go') diff --git a/compiler/ast.go b/compiler/ast.go index e4609ac..f0181f5 100644 --- a/compiler/ast.go +++ b/compiler/ast.go @@ -138,34 +138,31 @@ type astNode interface { type symbolNode struct { byteRange - token *token - pos symbolPosition + pos symbolPosition } -func newSymbolNode(tok *token, value byte, pos symbolPosition) *symbolNode { +func newSymbolNode(value byte) *symbolNode { return &symbolNode{ byteRange: byteRange{ from: value, to: value, }, - token: tok, - pos: pos, + pos: symbolPositionNil, } } -func newRangeSymbolNode(tok *token, from, to byte, pos symbolPosition) *symbolNode { +func newRangeSymbolNode(from, to byte) *symbolNode { return &symbolNode{ byteRange: byteRange{ from: from, to: to, }, - token: tok, - pos: pos, + pos: symbolPositionNil, } } func (n *symbolNode) String() string { - return fmt.Sprintf("{type: symbol, value: %v - %v, token char: %v, pos: %v}", n.from, n.to, string(n.token.char), n.pos) + return fmt.Sprintf("{type: symbol, value: %v - %v, pos: %v}", n.from, n.to, n.pos) } func (n *symbolNode) children() (astNode, astNode) { @@ -193,10 +190,10 @@ type endMarkerNode struct { pos symbolPosition } -func newEndMarkerNode(id int, pos symbolPosition) *endMarkerNode { +func newEndMarkerNode(id int) *endMarkerNode { return &endMarkerNode{ id: id, - pos: pos, + pos: symbolPositionNil, } } -- cgit v1.2.3