diff --git a/README.md b/README.md index 1123ee4..b629f7b 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,27 @@ funky keys unless there is a good reason to use them. ``` +### Conversion caveats + +Given the current implementation, *most* values are represented exactly the way +they are spelled out in the input file after they're queried for. The following +value notations will be converted to a different notation related to the +backing Go type: + +```txt +1_000 => 1000 # Underscores are not retained. +0xFFFF => 65535 # Hexadecimal is converted to decimal. +0o755 => 493 # Octal is converted to decimal. +0b1111_1111 => 255 # Binary is converted to decimal. ++100 => 100 # The plus sign is dropped. +5e-3 => 0.005 # The exponential notation is not kept. + +# Other relevant notations like date, time, date-time, with and without the +# offset, inf, nan, negative numbers, stay the way they're written in the +# input file. +``` + + ### Multiline query with bare strings Here is a dummy configuration file in TOML found on the web for Gitlab diff --git a/internal/lexer/lexer.go b/internal/lexer/lexer.go index 7f81945..a69f391 100644 --- a/internal/lexer/lexer.go +++ b/internal/lexer/lexer.go @@ -157,10 +157,7 @@ func (l *Lexer) scanBareString() bool { t := l.buffer[l.offset] start := l.offset l.advance() - for { - if l.offset > len(l.buffer)-1 { - break - } + for l.offset <= len(l.buffer)-1 { t = l.buffer[l.offset] if !isBareChar(t.Rune) { break @@ -180,10 +177,9 @@ func (l *Lexer) scanString() bool { l.advance() for { if l.offset > len(l.buffer)-1 { - // NOTE: This error is reported because the string goes - // past the buffer without encountering the matching - // quote character that should terminate the quoted - // string. + // NOTE: This error is reported because the string goes past the + // buffer without encountering the matching quote character that + // should terminate the quoted string. l.setToken(Undefined, start, l.offset+1) l.pushErr(ErrUnterminatedString) return false @@ -206,10 +202,7 @@ func (l *Lexer) scanInteger() bool { t := l.buffer[l.offset] start := l.offset l.advance() - for { - if l.offset > len(l.buffer)-1 { - break - } + for l.offset <= len(l.buffer)-1 { t = l.buffer[l.offset] if !isDigit(t.Rune) { break @@ -224,10 +217,7 @@ func (l *Lexer) scanWhitespace() bool { t := l.buffer[l.offset] start := l.offset l.advance() - for { - if l.offset > len(l.buffer)-1 { - break - } + for l.offset <= len(l.buffer)-1 { l.resetLineOffsetOnLineBreak(t.Rune) t = l.buffer[l.offset] if !isWhitespace(t.Rune) {