Source File
literal_tokens.go
Belonging Package
github.com/aws/aws-sdk-go/internal/ini
package ini
import (
)
var (
runesTrue = []rune("true")
runesFalse = []rune("false")
)
var literalValues = [][]rune{
runesTrue,
runesFalse,
}
func ( []rune) bool {
for , := range literalValues {
if isLitValue(, ) {
return true
}
}
return false
}
func (, []rune) bool {
if len() < len() {
return false
}
for := 0; < len(); ++ {
if [] != [] {
return false
}
}
return true
}
func ( []rune) bool {
:= 0
:= numberHelper{}
:= false
for := 0; < len(); ++ {
++
switch [] {
case '-':
if .IsNegative() || != 1 {
return false
}
.Determine([])
= true
continue
case 'e', 'E':
if := .Determine([]); != nil {
return false
}
= 0
= true
continue
case 'b':
if .numberFormat == hex {
break
}
fallthrough
case 'o', 'x':
= true
if == 0 {
return false
}
fallthrough
case '.':
if := .Determine([]); != nil {
return false
}
= true
continue
}
if > 0 && (isNewline([:]) || isWhitespace([])) {
return !
}
if !.CorrectByte([]) {
return false
}
= false
}
return !
}
func ( []rune) (bool, int, error) {
type ValueType int
func ( ValueType) () string {
switch {
case NoneType:
return "NONE"
case DecimalType:
return "FLOAT"
case IntegerType:
return "INT"
case StringType:
return "STRING"
case BoolType:
return "BOOL"
}
return ""
}
const (
NoneType = ValueType(iota)
DecimalType
IntegerType
StringType
QuotedStringType
BoolType
)
type Value struct {
Type ValueType
raw []rune
integer int64
decimal float64
boolean bool
str string
}
func ( ValueType, int, []rune) (Value, error) {
:= Value{
Type: ,
raw: ,
}
var error
switch {
case DecimalType:
.decimal, = strconv.ParseFloat(string(), 64)
case IntegerType:
if != 10 {
= [2:]
}
.integer, = strconv.ParseInt(string(), , 64)
case StringType:
.str = string()
case QuotedStringType:
.str = string([1 : len()-1])
case BoolType:
.boolean = runeCompare(.raw, runesTrue)
}
func ( *Value) ( Token) {
:= .Raw()
if .Type != QuotedStringType {
.Type = StringType
= .raw[1 : len(.raw)-1]
}
if .Type() != TokenLit {
.raw = append(.raw, .Raw()...)
} else {
.raw = append(.raw, ...)
}
}
func ( Value) () string {
switch .Type {
case DecimalType:
return fmt.Sprintf("decimal: %f", .decimal)
case IntegerType:
return fmt.Sprintf("integer: %d", .integer)
case StringType:
return fmt.Sprintf("string: %s", string(.raw))
case QuotedStringType:
return fmt.Sprintf("quoted string: %s", string(.raw))
case BoolType:
return fmt.Sprintf("bool: %t", .boolean)
default:
return "union not set"
}
}
func ( []rune) (Token, int, error) {
:= 0
var error
:= Token{}
if [0] == '"' {
, = getStringValue()
if != nil {
return , ,
}
= newToken(TokenLit, [:], QuotedStringType)
} else if isNumberValue() {
var int
, , = getNumericalValue()
if != nil {
return , 0,
}
:= [:]
:= IntegerType
if contains(, '.') || hasExponent() {
= DecimalType
}
= newToken(TokenLit, , )
.base =
} else if isBoolValue() {
, = getBoolValue()
= newToken(TokenLit, [:], BoolType)
} else {
, = getValue()
= newToken(TokenLit, [:], StringType)
}
return , ,
}
func ( Value) () string {
switch .Type {
case StringType:
return strings.TrimFunc(string(.raw), isTrimmable)
return string(removeEscapedCharacters(.raw[1 : len(.raw)-1]))
default:
return strings.TrimFunc(string(.raw), isTrimmable)
}
}
func ( []rune, rune) bool {
for := 0; < len(); ++ {
if [] == {
return true
}
}
return false
}
func ( []rune, []rune) bool {
if len() != len() {
return false
}
for := 0; < len(); ++ {
if [] != [] {
return false
}
}
return true
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |