diff options
author | Richard Burke <rich.g.burke@gmail.com> | 2019-01-06 10:55:05 +0000 |
---|---|---|
committer | Richard Burke <rich.g.burke@gmail.com> | 2019-01-06 10:55:05 +0000 |
commit | 227d870e7e6dd72d4a4b7b3bbcb5942d382c3445 (patch) | |
tree | da105e2371e96029f26d4e0941d3a3ff9f0b80b4 | |
parent | d44b041d4cb73ea5b50e89dae34636da67c7742c (diff) |
Only raw closing brace finishes command body
-rw-r--r-- | cmd/grv/config_parse.go | 4 | ||||
-rw-r--r-- | cmd/grv/config_parse_test.go | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cmd/grv/config_parse.go b/cmd/grv/config_parse.go index 4ec0cd5..78cc507 100644 --- a/cmd/grv/config_parse.go +++ b/cmd/grv/config_parse.go @@ -524,7 +524,7 @@ func parseDefCommand(parser *ConfigParser) (tokens []*ConfigToken, err error) { return } else if err = openingBraceToken.err; err != nil { return - } else if openingBraceToken.tokenType != CtkWord || openingBraceToken.value != openingBrace { + } else if openingBraceToken.tokenType != CtkWord || openingBraceToken.rawValue != openingBrace { return tokens, parser.generateParseError(openingBraceToken, "Expected %v but found %v", openingBrace, openingBraceToken.value) } @@ -549,7 +549,7 @@ func parseDefCommand(parser *ConfigParser) (tokens []*ConfigToken, err error) { case CtkWord: if token.value == defCommand && wordsSinceTerminator == 0 { closingBracesRemaining++ - } else if token.value == closingBrace { + } else if token.rawValue == closingBrace { closingBracesRemaining-- } diff --git a/cmd/grv/config_parse_test.go b/cmd/grv/config_parse_test.go index 629a1cb..50bbd6e 100644 --- a/cmd/grv/config_parse_test.go +++ b/cmd/grv/config_parse_test.go @@ -432,6 +432,13 @@ func TestParseSingleCommand(t *testing.T) { functionBody: " addtab Main ", }, }, + { + input: "def\n myFunc \n{ addtab \"}\" }", + expectedCommand: &DefCommandValues{ + commandName: "myFunc", + functionBody: " addtab \"}\" ", + }, + }, } for _, singleCommandTest := range singleCommandTests { |