aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-03-29 01:43:36 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-03-29 01:45:08 +0900
commit4d2a389c0ea605413d1cc89ae35f2a3aaa293072 (patch)
tree6b6a5fe98f2a27a38cdbc569706e43970fbc05e5 /spec/lexer.go
parentAdd label notation (diff)
downloadurubu-4d2a389c0ea605413d1cc89ae35f2a3aaa293072.tar.gz
urubu-4d2a389c0ea605413d1cc89ae35f2a3aaa293072.tar.xz
Use IDs and labels as parameters of an #ast directive instead of symbol positions
Diffstat (limited to 'spec/lexer.go')
-rw-r--r--spec/lexer.go25
1 files changed, 0 insertions, 25 deletions
diff --git a/spec/lexer.go b/spec/lexer.go
index 51791be..6e9279d 100644
--- a/spec/lexer.go
+++ b/spec/lexer.go
@@ -7,7 +7,6 @@ import (
_ "embed"
"fmt"
"io"
- "strconv"
"strings"
verr "github.com/nihei9/vartan/error"
@@ -25,7 +24,6 @@ const (
tokenKindSemicolon = tokenKind(";")
tokenKindLabelMarker = tokenKind("@")
tokenKindDirectiveMarker = tokenKind("#")
- tokenKindPosition = tokenKind("$")
tokenKindExpantion = tokenKind("...")
tokenKindMetaDataMarker = tokenKind("%")
tokenKindNewline = tokenKind("newline")
@@ -48,7 +46,6 @@ func newPosition(row, col int) Position {
type token struct {
kind tokenKind
text string
- num int
pos Position
}
@@ -83,14 +80,6 @@ func newStringLiteralToken(text string, pos Position) *token {
}
}
-func newPositionToken(num int, pos Position) *token {
- return &token{
- kind: tokenKindPosition,
- num: num,
- pos: pos,
- }
-}
-
func newEOFToken() *token {
return &token{
kind: tokenKindEOF,
@@ -274,20 +263,6 @@ func (l *lexer) lexAndSkipWSs() (*token, error) {
return newSymbolToken(tokenKindLabelMarker, newPosition(tok.Row+1, tok.Col+1)), nil
case KindIDDirectiveMarker:
return newSymbolToken(tokenKindDirectiveMarker, newPosition(tok.Row+1, tok.Col+1)), nil
- case KindIDPosition:
- // Remove '$' character and convert to an integer.
- num, err := strconv.Atoi(string(tok.Lexeme)[1:])
- if err != nil {
- return nil, err
- }
- if num == 0 {
- return nil, &verr.SpecError{
- Cause: synErrZeroPos,
- Row: tok.Row + 1,
- Col: tok.Col + 1,
- }
- }
- return newPositionToken(num, newPosition(tok.Row+1, tok.Col+1)), nil
case KindIDExpansion:
return newSymbolToken(tokenKindExpantion, newPosition(tok.Row+1, tok.Col+1)), nil
case KindIDMetadataMarker: