Browse Source

Merge pull request #28 from brettlangdon/bug/empty.string

Allow empty string values
pull/30/head v0.1.7
Brett Langdon 10 years ago
parent
commit
0b2bf8e484
3 changed files with 7 additions and 0 deletions
  1. +2
    -0
      forge_test.go
  2. +4
    -0
      scanner.go
  3. +1
    -0
      test.cfg

+ 2
- 0
forge_test.go View File

@ -16,6 +16,7 @@ primary {
string = "primary string value";
string_with_quote = "some \"quoted\" str\\ing";
single = 'hello world';
empty = '';
single_with_quote = '\'hello\' "world"';
# Semicolons are optional
@ -70,6 +71,7 @@ func assertDirectives(values map[string]interface{}, t *testing.T) {
assertEqual(primary["string"], "primary string value", t)
assertEqual(primary["string_with_quote"], "some \"quoted\" str\\ing", t)
assertEqual(primary["single"], "hello world", t)
assertEqual(primary["empty"], "", t)
assertEqual(primary["single_with_quote"], "'hello' \"world\"", t)
assertEqual(primary["integer500"], int64(500), t)
assertEqual(primary["float"], float64(80.80), t)


+ 4
- 0
scanner.go View File

@ -123,6 +123,10 @@ func (scanner *Scanner) parseNumber(negative bool) {
func (scanner *Scanner) parseString(delimiter rune) {
scanner.curTok.ID = token.STRING
scanner.curTok.Literal = ""
if scanner.curCh == delimiter {
scanner.readRune()
return
}
// Whether or not we are trying to escape a character
escape := false


+ 1
- 0
test.cfg View File

@ -5,6 +5,7 @@ primary {
string = "primary string value";
string_with_quote = "some \"quoted\" str\\ing";
single = 'hello world';
empty = '';
single_with_quote = '\'hello\' "world"';
# Semicolons are optional


Loading…
Cancel
Save