Source File
read.go
Belonging Package
github.com/go-git/gcfg
func ( string) string {
, , := make([]rune, 0, len()), false, false
for , := range {
if {
, := unescape[]
switch {
case :
= append(, )
fallthrough
case ! && == '\n':
= false
continue
}
panic("invalid escape sequence")
}
switch {
case '"':
= !
case '\\':
= true
default:
= append(, )
}
}
if {
panic("missing end quote")
}
if {
panic("invalid escape sequence")
}
return string()
}
func ( *warnings.Collector, func(string, string, string, string, bool) error,
var scanner.Scanner
var scanner.ErrorList
.Init(, , func( token.Position, string) { .Add(, ) }, 0)
, := "", ""
, , := .Scan()
:= func( string) error {
return fmt.Errorf("%s: %s", .Position(), )
}
for {
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
switch {
case token.EOF:
return nil
case token.EOL, token.COMMENT:
, , = .Scan()
case token.LBRACK:
, , = .Scan()
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
if != token.IDENT {
if := .Collect(("expected section name")); != nil {
return
}
}
, = , ""
, , = .Scan()
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
if == token.STRING {
= unquote()
if == "" {
if := .Collect(("empty subsection name")); != nil {
return
}
}
, , = .Scan()
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
}
if != token.RBRACK {
if == "" {
if := .Collect(("expected subsection name or right bracket")); != nil {
return
}
}
if := .Collect(("expected right bracket")); != nil {
return
}
}
, , = .Scan()
if != token.EOL && != token.EOF && != token.COMMENT {
if := .Collect(("expected EOL, EOF, or comment")); != nil {
return
}
:= .Collect((, , "", "", true))
if != nil {
return
}
case token.IDENT:
if == "" {
if := .Collect(("expected section header")); != nil {
return
}
}
:=
, , = .Scan()
if .Len() > 0 {
return .Err()
}
, := == token.EOF || == token.EOL || == token.COMMENT, ""
if ! {
if != token.ASSIGN {
if := .Collect(("expected '='")); != nil {
return
}
}
, , = .Scan()
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
if != token.STRING {
if := .Collect(("expected value")); != nil {
return
}
}
= unquote()
, , = .Scan()
if .Len() > 0 {
if := .Collect(.Err()); != nil {
return
}
}
if != token.EOL && != token.EOF && != token.COMMENT {
if := .Collect(("expected EOL, EOF, or comment")); != nil {
return
}
}
}
:= .Collect((, , , , ))
if != nil {
return
}
default:
if == "" {
if := .Collect(("expected section header")); != nil {
return
}
}
if := .Collect(("expected section header or variable declaration")); != nil {
return
}
}
}
panic("never reached")
}
func ( interface{}, *token.FileSet, *token.File,
:= warnings.NewCollector(isFatal)
:= func( string, string, string, string, bool) error {
return set(, , , , , , , false)
}
:= read(, , , , )
if != nil {
return
}
:= func( string, string, string, string, bool) error {
return set(, , , , , , , true)
}
= read(, , , , )
if != nil {
return
}
return .Done()
}
![]() |
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. |