diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-02-24 23:05:54 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-02-25 00:39:23 +0900 |
commit | 0d4795245765669f4c7aa033e988833d5f78c9a3 (patch) | |
tree | d6d50edfb57a19b1a4664edc583d9a2f2db12dd4 /compiler/ast.go | |
parent | Add range expression (diff) | |
download | tre-0d4795245765669f4c7aa033e988833d5f78c9a3.tar.gz tre-0d4795245765669f4c7aa033e988833d5f78c9a3.tar.xz |
Refactoring
* Remove token field from symbolNode
* Simplify notation of nested nodes
* Simplify arguments of newSymbolNode()
Diffstat (limited to 'compiler/ast.go')
-rw-r--r-- | compiler/ast.go | 19 |
1 files changed, 8 insertions, 11 deletions
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, } } |