Browse Source

Merge pull request #26 from brettlangdon/dev/number.identifiers.sqwished

Allow integers in identifiers
pull/28/head v0.1.6
Brett Langdon 10 years ago
parent
commit
236b7cba2e
4 changed files with 5 additions and 5 deletions
  1. +1
    -1
      forge.go
  2. +2
    -2
      forge_test.go
  3. +1
    -1
      scanner.go
  4. +1
    -1
      test.cfg

+ 1
- 1
forge.go View File

@ -32,7 +32,7 @@
//
// Config file format:
//
// IDENTIFIER: [_a-zA-Z]+
// IDENTIFIER: [_a-zA-Z]([_a-zA-Z0-9]+)?
// NUMBERS: [0-9]+
// END: ';' | '\n'
//


+ 2
- 2
forge_test.go View File

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


+ 1
- 1
scanner.go View File

@ -85,7 +85,7 @@ func (scanner *Scanner) parseIdentifier() {
scanner.curTok.Literal = string(scanner.curCh)
for {
scanner.readRune()
if !isLetter(scanner.curCh) && scanner.curCh != '_' {
if !isLetter(scanner.curCh) && !isDigit(scanner.curCh) && scanner.curCh != '_' {
break
}
scanner.curTok.Literal += string(scanner.curCh)


+ 1
- 1
test.cfg View File

@ -8,7 +8,7 @@ primary {
single_with_quote = '\'hello\' "world"';
# Semicolons are optional
integer = 500
integer500 = 500
float = 80.80
negative = -50
boolean = true


Loading…
Cancel
Save