feat: implement gomark parsers

This commit is contained in:
Steven
2023-12-13 21:00:13 +08:00
parent 2d9c5d16e1
commit 453707d18c
28 changed files with 625 additions and 209 deletions

View File

@ -4,7 +4,7 @@ type TokenType = string
const (
Underline TokenType = "_"
Star TokenType = "*"
Asterisk TokenType = "*"
Hash TokenType = "#"
Backtick TokenType = "`"
LeftSquareBracket TokenType = "["
@ -12,6 +12,9 @@ const (
LeftParenthesis TokenType = "("
RightParenthesis TokenType = ")"
ExclamationMark TokenType = "!"
Tilde TokenType = "~"
Dash TokenType = "-"
GreaterThan TokenType = ">"
Newline TokenType = "\n"
Space TokenType = " "
)
@ -39,7 +42,7 @@ func Tokenize(text string) []*Token {
case '_':
tokens = append(tokens, NewToken(Underline, "_"))
case '*':
tokens = append(tokens, NewToken(Star, "*"))
tokens = append(tokens, NewToken(Asterisk, "*"))
case '#':
tokens = append(tokens, NewToken(Hash, "#"))
case '`':
@ -54,6 +57,12 @@ func Tokenize(text string) []*Token {
tokens = append(tokens, NewToken(RightParenthesis, ")"))
case '!':
tokens = append(tokens, NewToken(ExclamationMark, "!"))
case '~':
tokens = append(tokens, NewToken(Tilde, "~"))
case '-':
tokens = append(tokens, NewToken(Dash, "-"))
case '>':
tokens = append(tokens, NewToken(GreaterThan, ">"))
case '\n':
tokens = append(tokens, NewToken(Newline, "\n"))
case ' ':