diff --git a/parse/lex/lex.go b/parse/lex/lex.go index 03674e1..828afc2 100644 --- a/parse/lex/lex.go +++ b/parse/lex/lex.go @@ -16,8 +16,8 @@ type TokenType int const ( BareString TokenType = iota QuotedString - OpenParen - CloseParen + Open + Close Err eof ) @@ -162,9 +162,17 @@ func lexWhitespace(l *Lexer) lexerFunc { case '"': return lexQuotedString case '(': - l.emit(OpenParen) + l.emit(Open) case ')': - l.emit(CloseParen) + l.emit(Close) + case '[': + l.emit(Open) + case ']': + l.emit(Close) + case '{': + l.emit(Open) + case '}': + l.emit(Close) default: return lexBareString } diff --git a/parse/lex/lex_test.go b/parse/lex/lex_test.go index 7042953..a84b4e9 100644 --- a/parse/lex/lex_test.go +++ b/parse/lex/lex_test.go @@ -19,21 +19,21 @@ func TestLexer(t *T) { "\"foo\nbar\" baz": {{QuotedString, "\"foo\nbar\""}, {BareString, "baz"}, {eof, ""}}, - "( foo bar ) baz": {{OpenParen, "("}, + "( foo bar ) baz": {{Open, "("}, {BareString, "foo"}, {BareString, "bar"}, - {CloseParen, ")"}, + {Close, ")"}, {BareString, "baz"}, {eof, ""}}, - "((foo-bar))": {{OpenParen, "("}, - {OpenParen, "("}, + "((foo-bar))": {{Open, "("}, + {Open, "("}, {BareString, "foo-bar"}, - {CloseParen, ")"}, - {CloseParen, ")"}, + {Close, ")"}, + {Close, ")"}, {eof, ""}}, - "(\"foo\nbar\")": {{OpenParen, "("}, + "(\"foo\nbar\")": {{Open, "("}, {QuotedString, "\"foo\nbar\""}, - {CloseParen, ")"}, + {Close, ")"}, {eof, ""}}, }