Source File
ini_parser.go
Belonging Package
github.com/aws/aws-sdk-go/internal/ini
package ini
import (
)
const (
var parseTable = map[ASTKind]map[TokenType]int{
ASTKindStart: map[TokenType]int{
TokenLit: StatementState,
TokenSep: OpenScopeState,
TokenWS: SkipTokenState,
TokenNL: SkipTokenState,
TokenComment: CommentState,
TokenNone: TerminalState,
},
ASTKindCommentStatement: map[TokenType]int{
TokenLit: StatementState,
TokenSep: OpenScopeState,
TokenWS: SkipTokenState,
TokenNL: SkipTokenState,
TokenComment: CommentState,
TokenNone: MarkCompleteState,
},
ASTKindExpr: map[TokenType]int{
TokenOp: StatementPrimeState,
TokenLit: ValueState,
TokenSep: OpenScopeState,
TokenWS: ValueState,
TokenNL: SkipState,
TokenComment: CommentState,
TokenNone: MarkCompleteState,
},
ASTKindEqualExpr: map[TokenType]int{
TokenLit: ValueState,
TokenWS: SkipTokenState,
TokenNL: SkipState,
},
ASTKindStatement: map[TokenType]int{
TokenLit: SectionState,
TokenSep: CloseScopeState,
TokenWS: SkipTokenState,
TokenNL: SkipTokenState,
TokenComment: CommentState,
TokenNone: MarkCompleteState,
},
ASTKindExprStatement: map[TokenType]int{
TokenLit: ValueState,
TokenSep: OpenScopeState,
TokenOp: ValueState,
TokenWS: ValueState,
TokenNL: MarkCompleteState,
TokenComment: CommentState,
TokenNone: TerminalState,
TokenComma: SkipState,
},
ASTKindSectionStatement: map[TokenType]int{
TokenLit: SectionState,
TokenOp: SectionState,
TokenSep: CloseScopeState,
TokenWS: SectionState,
TokenNL: SkipTokenState,
},
ASTKindCompletedSectionStatement: map[TokenType]int{
TokenWS: SkipTokenState,
TokenNL: SkipTokenState,
TokenLit: StatementState,
TokenSep: OpenScopeState,
TokenComment: CommentState,
TokenNone: MarkCompleteState,
},
ASTKindSkipStatement: map[TokenType]int{
TokenLit: StatementState,
TokenSep: OpenScopeState,
TokenWS: SkipTokenState,
TokenNL: SkipTokenState,
TokenComment: CommentState,
TokenNone: TerminalState,
},
}
= emptyToken
} else {
= [0]
}
:= parseTable[.Kind][.Type()]
if len() == 0 {
break
= SkipTokenState
}
switch {
if .Kind != ASTKindStart {
.MarkComplete()
}
break
.Push()
case StatementState:
if .Kind != ASTKindStart {
.MarkComplete()
}
:= newExpression()
.Push()
case StatementPrimeState:
if .Type() != TokenOp {
.MarkComplete()
continue
}
if .Kind != ASTKindExpr {
return nil, NewParseError(
fmt.Sprintf("invalid expression: expected Expr type, but found %T type", ),
)
}
= trimSpaces()
:= newEqualExpr(, )
.Push()
switch .Kind {
.AppendChild(newExpression())
.Push(newExprStatement())
case ASTKindExpr:
.Root.raw = append(.Root.raw, .Raw()...)
.Push()
case ASTKindExprStatement:
:= .GetRoot()
:= .GetChildren()
if len() == 0 {
return nil, NewParseError(
fmt.Sprintf("invalid expression: AST contains no children %s", .Kind),
)
}
:= [len()-1]
if .Root.ValueType != QuotedStringType {
.Root.ValueType = StringType
.Root.raw = append(.Root.raw, .Raw()...)
}
[len()-1] =
.SetChildren()
.Push()
}
case OpenScopeState:
if !runeCompare(.Raw(), openBrace) {
return nil, NewParseError("expected '['")
if .Kind != ASTKindStart {
.MarkComplete()
}
:= newStatement()
.Push()
case CloseScopeState:
if !runeCompare(.Raw(), closeBrace) {
return nil, NewParseError("expected ']'")
}
= trimSpaces()
.Push(newCompletedSectionStatement())
case SectionState:
var AST
switch .Kind {
= newSectionStatement()
case ASTKindSectionStatement:
.Root.raw = append(.Root.raw, .Raw()...)
=
default:
return nil, NewParseError(
fmt.Sprintf("invalid statement: expected statement: %v", .Kind),
)
}
.Push()
case MarkCompleteState:
if .Kind != ASTKindStart {
.MarkComplete()
}
if .Len() == 0 {
.Push()
}
case SkipState:
.Push(newSkipStatement())
.Skip()
case CommentState:
if .Kind == ASTKindStart {
.Push()
} else {
.MarkComplete()
}
:= newCommentStatement()
.Push()
default:
return nil, NewParseError(
fmt.Sprintf("invalid state with ASTKind %v and TokenType %v",
, .Type()))
}
if len() > 0 {
= [1:]
}
}
if .top > 1 {
return nil, NewParseError(fmt.Sprintf("incomplete ini expression"))
}
![]() |
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. |