Fixes #32 : Ensure keys are correctly parsed

This commit is contained in:
Thomas Pelletier
2014-12-06 14:16:42 +01:00
parent 543444f747
commit 2f2f28631b
4 changed files with 20 additions and 15 deletions
+5 -2
View File
@@ -138,7 +138,7 @@ func (l *tomlLexer) lexVoid() tomlLexStateFn {
return l.lexRvalue
}
if isKeyChar(next) {
if isKeyStartChar(next) {
return l.lexKey
}
@@ -250,7 +250,10 @@ func (l *tomlLexer) lexComma() tomlLexStateFn {
func (l *tomlLexer) lexKey() tomlLexStateFn {
l.ignore()
for isKeyChar(l.next()) {
for r := l.next(); isKeyChar(r); r = l.next() {
if (r == '#') {
return l.errorf("keys cannot contain # character")
}
}
l.backup()
l.emit(tokenKey)