From 4417b9fe9a223aff00c2ef277d74606b0859004c Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 18 Jul 2021 17:09:52 +0900 Subject: Add token positions to an AST --- spec/lexer.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'spec/lexer.go') diff --git a/spec/lexer.go b/spec/lexer.go index 3a5a914..83b1a93 100644 --- a/spec/lexer.go +++ b/spec/lexer.go @@ -34,12 +34,12 @@ const ( tokenKindInvalid = tokenKind("invalid") ) -type position struct { +type Position struct { row int } -func newPosition(row int) position { - return position{ +func newPosition(row int) Position { + return Position{ row: row, } } @@ -48,17 +48,17 @@ type token struct { kind tokenKind text string num int - pos position + pos Position } -func newSymbolToken(kind tokenKind, pos position) *token { +func newSymbolToken(kind tokenKind, pos Position) *token { return &token{ kind: kind, pos: pos, } } -func newIDToken(text string, pos position) *token { +func newIDToken(text string, pos Position) *token { return &token{ kind: tokenKindID, text: text, @@ -66,7 +66,7 @@ func newIDToken(text string, pos position) *token { } } -func newTerminalPatternToken(text string, pos position) *token { +func newTerminalPatternToken(text string, pos Position) *token { return &token{ kind: tokenKindTerminalPattern, text: text, @@ -74,7 +74,7 @@ func newTerminalPatternToken(text string, pos position) *token { } } -func newPositionToken(num int, pos position) *token { +func newPositionToken(num int, pos Position) *token { return &token{ kind: tokenKindPosition, num: num, -- cgit v1.2.3