parser: add initial Parser emitting non-whitespace tokens

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-31 00:11:33 +00:00
parent a15deb7e42
commit 1090a374f0
7 changed files with 252 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package parser
//go:generate go run golang.org/x/tools/cmd/stringer -type=TokenType
// A TokenType is a type of Token
type TokenType uint
const (
// TokenUnknown represents a Token that hasn't been identified
TokenUnknown TokenType = iota
// TokenSectionStart indicates the opening marker of a section declaration.
// The left squared bracket.
TokenSectionStart
// TokenSectionEnd indicates the closing marker of a section declaration.
// The right squared bracket.
TokenSectionEnd
// TokenSectionName represents the section name between the squared brackets
TokenSectionName
// TokenSectionSubname represents a secondary name in the section represented
// between quotes after the section name.
// e.g.
// [section_name "section_subname"]
TokenSectionSubname
// TokenComment represents a comment, including the initial ';' or '#' until
// the end of the line.
TokenComment
// TokenFieldKey represents a field name in a `key = value` entry
TokenFieldKey
// TokenFieldValue represents a field value in a `key = value` entry
TokenFieldValue
)