diff options
| author | Bobby <[email protected]> | 2024-03-29 20:19:31 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-03-29 20:19:31 +0000 |
| commit | cf6dd4b0e5efa1f8041d5570497a5228c737c454 (patch) | |
| tree | c15fa426e3a2c74ff6aa5261452ebadfbb3e0fed /parser/parser.go | |
| parent | c6a3c37f268ba3189a4902b852121e979c70817f (diff) | |
| download | mana-cf6dd4b0e5efa1f8041d5570497a5228c737c454.tar.xz mana-cf6dd4b0e5efa1f8041d5570497a5228c737c454.zip | |
Strings
Diffstat (limited to 'parser/parser.go')
| -rw-r--r-- | parser/parser.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/parser/parser.go b/parser/parser.go index 3fe3d9f..6ca88b3 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -71,6 +71,7 @@ func New(l *lexer.Lexer) *Parser { p.registerPrefix(tokens.IF, p.parseIfExpression) p.registerPrefix(tokens.FUNCTION, p.parseFunctionLiteral) p.registerPrefix(tokens.LPAREN, p.parseGroupedExpression) + p.registerPrefix(tokens.STRING, p.parseStringLiteral) // Initialize the infix parse functions. p.infixParseFns = make(map[tokens.TokenType]infixParseFn) @@ -436,6 +437,13 @@ func (p *Parser) parseCallArguments() []ast.Expression { return args } +func (p *Parser) parseStringLiteral() ast.Expression { + return &ast.StringLiteral{ + Token: p.curToken, + Value: p.curToken.Literal, + } +} + // curTokenIs returns true if the current token is of the given type. func (p *Parser) curTokenIs(t tokens.TokenType) bool { return p.curToken.Type == t |
