| 1 | package internalscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 5 | "mathscip-go gomod github.com/golang/go/src go1.25 math/" |
| 6 | "strconvscip-go gomod github.com/golang/go/src go1.25 strconv/" |
| 7 | "stringsscip-go gomod github.com/golang/go/src go1.25 strings/" |
| 8 | ) |
| 9 | |
| 10 | // Parser parses KDL tokens into a Document. |
| 11 | type Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser# struct { |
| 12 | tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok. *Tokenizerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer# |
| 13 | } |
| 14 | |
| 15 | // Parse parses the given KDL input and returns a Document. |
| 16 | func Parsescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parse().(input string) (*Documentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#, error) { |
| 17 | tok := NewTokenizerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/NewTokenizer().(input) |
| 18 | |
| 19 | // Check for version marker: /- kdl-version N |
| 20 | p := &Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#{tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok.: tok} |
| 21 | if err := p.detectVersionMarkerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#detectVersionMarker().(input); err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | |
| 25 | return p.parseDocumentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseDocument().() |
| 26 | } |
| 27 | |
| 28 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) detectVersionMarkerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#detectVersionMarker().(input string) error { |
| 29 | trimmed := stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25 strings/TrimSpace().(input) |
| 30 | if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(trimmed, "/- kdl-version ") { |
| 31 | rest := stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(trimmed, "/- kdl-version ") |
| 32 | if len(rest) > 0 { |
| 33 | // Extract the version number (up to next whitespace or newline) |
| 34 | verStr := rest |
| 35 | if idx := stringsscip-go gomod github.com/golang/go/src go1.25 strings/.IndexAnyscip-go gomod github.com/golang/go/src go1.25 strings/IndexAny().(verStr, " \t\n\r"); idx >= 0 { |
| 36 | verStr = verStr[:idx] |
| 37 | } |
| 38 | switch verStr { |
| 39 | case "1": |
| 40 | p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..Versionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#Version. = Version1scip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Version1. |
| 41 | case "2": |
| 42 | p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..Versionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#Version. = Version2scip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Version2. |
| 43 | default: |
| 44 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: unsupported version %q in version marker", verStr) |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseDocumentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseDocument().() (*Documentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#, error) { |
| 52 | doc := &Documentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#{} |
| 53 | |
| 54 | for { |
| 55 | p.skipNewlinesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipNewlines().() |
| 56 | |
| 57 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 58 | if err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | |
| 62 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenEOFscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenEOF. { |
| 63 | break |
| 64 | } |
| 65 | |
| 66 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenCloseBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseBrace. { |
| 67 | break |
| 68 | } |
| 69 | |
| 70 | // Check for slashdash before node |
| 71 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSlashDashscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSlashDash. { |
| 72 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | // Skip the next node |
| 76 | _, err := p.parseNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseNode().() |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | continue |
| 81 | } |
| 82 | |
| 83 | node, err := p.parseNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseNode().() |
| 84 | if err != nil { |
| 85 | return nil, err |
| 86 | } |
| 87 | if node != nil { |
| 88 | doc.Nodesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#Nodes. = append(doc.Nodesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#Nodes., node) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return doc, nil |
| 93 | } |
| 94 | |
| 95 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseNode().() (*Nodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#, error) { |
| 96 | p.skipNewlinesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipNewlines().() |
| 97 | |
| 98 | node := &Nodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#{} |
| 99 | |
| 100 | // Optional type annotation |
| 101 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenParenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenParen. { |
| 106 | typeAnn, err := p.parseTypeAnnotationscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseTypeAnnotation().() |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | node.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Type. = typeAnn |
| 111 | } |
| 112 | |
| 113 | // Node name |
| 114 | nameTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 115 | if err != nil { |
| 116 | return nil, err |
| 117 | } |
| 118 | |
| 119 | switch nameTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. { |
| 120 | case TokenIdentifierscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenIdentifier., TokenQuotedStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenQuotedString., TokenRawStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenRawString.: |
| 121 | node.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Name. = nameTok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 122 | default: |
| 123 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected node name, got %v at line %d, col %d", nameTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., nameTok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., nameTok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 124 | } |
| 125 | |
| 126 | // Parse entries (arguments and properties) and optional children |
| 127 | if err := p.parseNodeEntriesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseNodeEntries().(node); err != nil { |
| 128 | return nil, err |
| 129 | } |
| 130 | |
| 131 | return node, nil |
| 132 | } |
| 133 | |
| 134 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseNodeEntriesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseNodeEntries().(node *Nodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#) error { |
| 135 | for { |
| 136 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 137 | if err != nil { |
| 138 | return err |
| 139 | } |
| 140 | |
| 141 | // Node terminators |
| 142 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenNewlinescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNewline. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSemicolonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSemicolon. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenEOFscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenEOF. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenCloseBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseBrace. { |
| 143 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSemicolonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSemicolon. { |
| 144 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 145 | return err |
| 146 | } |
| 147 | } |
| 148 | return nil |
| 149 | } |
| 150 | |
| 151 | // Children block |
| 152 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenBrace. { |
| 153 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 154 | return err |
| 155 | } |
| 156 | children, err := p.parseDocumentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseDocument().() |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | node.Childrenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Children. = children.Nodesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Document#Nodes. |
| 161 | |
| 162 | // Expect closing brace |
| 163 | p.skipNewlinesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipNewlines().() |
| 164 | closeTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | if closeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenCloseBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseBrace. { |
| 169 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected '}', got %v at line %d, col %d", closeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., closeTok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., closeTok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 170 | } |
| 171 | |
| 172 | // After children block, node must end |
| 173 | return p.expectNodeEndscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#expectNodeEnd().() |
| 174 | } |
| 175 | |
| 176 | // Slashdash before entry |
| 177 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSlashDashscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSlashDash. { |
| 178 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 179 | return err |
| 180 | } |
| 181 | |
| 182 | // Peek what follows to know if we're slashdashing an arg, prop, or children |
| 183 | next, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 184 | if err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | if next.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenBrace. { |
| 189 | // Slashdash children |
| 190 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 191 | return err |
| 192 | } |
| 193 | if _, err := p.parseDocumentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseDocument().(); err != nil { |
| 194 | return err |
| 195 | } |
| 196 | p.skipNewlinesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipNewlines().() |
| 197 | closeTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 198 | if err != nil { |
| 199 | return err |
| 200 | } |
| 201 | if closeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenCloseBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseBrace. { |
| 202 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected '}' after slashdashed children") |
| 203 | } |
| 204 | continue |
| 205 | } |
| 206 | |
| 207 | // Slashdash an entry (arg or prop) — parse and discard |
| 208 | if err := p.skipEntryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipEntry().(); err != nil { |
| 209 | return err |
| 210 | } |
| 211 | continue |
| 212 | } |
| 213 | |
| 214 | // Try to parse as property or argument |
| 215 | if err := p.parseEntryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseEntry().(node); err != nil { |
| 216 | return err |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseEntryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseEntry().(node *Nodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#) error { |
| 222 | // Check for type annotation |
| 223 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 224 | if err != nil { |
| 225 | return err |
| 226 | } |
| 227 | |
| 228 | typeAnn := "" |
| 229 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenParenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenParen. { |
| 230 | typeAnn, err = p.parseTypeAnnotationscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseTypeAnnotation().() |
| 231 | if err != nil { |
| 232 | return err |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | // Read the value/name token |
| 237 | valTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 238 | if err != nil { |
| 239 | return err |
| 240 | } |
| 241 | |
| 242 | // Check if this is a property (identifier/string followed by =) |
| 243 | if (valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenIdentifierscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenIdentifier. || valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenQuotedStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenQuotedString. || valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenRawStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenRawString.) && typeAnn == "" { |
| 244 | next, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | if next.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenEqualsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenEquals. { |
| 249 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 250 | return err |
| 251 | } |
| 252 | val, err := p.parseValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseValue().() |
| 253 | if err != nil { |
| 254 | return err |
| 255 | } |
| 256 | node.Propertiesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Properties. = append(node.Propertiesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Properties., &Propertyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Property#{ |
| 257 | Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Property#Key.: valTok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., |
| 258 | Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Property#Value.: val, |
| 259 | }) |
| 260 | return nil |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // It's an argument |
| 265 | val, err := tokenToValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/tokenToValue().(valTok, typeAnn) |
| 266 | if err != nil { |
| 267 | return err |
| 268 | } |
| 269 | node.Argumentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Arguments. = append(node.Argumentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Node#Arguments., val) |
| 270 | return nil |
| 271 | } |
| 272 | |
| 273 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) skipEntryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipEntry().() error { |
| 274 | // Check for type annotation |
| 275 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 276 | if err != nil { |
| 277 | return err |
| 278 | } |
| 279 | |
| 280 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenParenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenParen. { |
| 281 | if _, err := p.parseTypeAnnotationscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseTypeAnnotation().(); err != nil { |
| 282 | return err |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Read the value/name token |
| 287 | valTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 288 | if err != nil { |
| 289 | return err |
| 290 | } |
| 291 | |
| 292 | // Check for property (name = value) |
| 293 | if valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenIdentifierscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenIdentifier. || valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenQuotedStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenQuotedString. || valTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenRawStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenRawString. { |
| 294 | next, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 295 | if err != nil { |
| 296 | return err |
| 297 | } |
| 298 | if next.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenEqualsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenEquals. { |
| 299 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 300 | return err |
| 301 | } |
| 302 | if _, err := p.parseValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseValue().(); err != nil { |
| 303 | return err |
| 304 | } |
| 305 | return nil |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | return nil |
| 310 | } |
| 311 | |
| 312 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseValue().() (*Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#, error) { |
| 313 | // Check for type annotation |
| 314 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 315 | if err != nil { |
| 316 | return nil, err |
| 317 | } |
| 318 | |
| 319 | typeAnn := "" |
| 320 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenOpenParenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOpenParen. { |
| 321 | typeAnn, err = p.parseTypeAnnotationscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseTypeAnnotation().() |
| 322 | if err != nil { |
| 323 | return nil, err |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | valTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 328 | if err != nil { |
| 329 | return nil, err |
| 330 | } |
| 331 | |
| 332 | return tokenToValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/tokenToValue().(valTok, typeAnn) |
| 333 | } |
| 334 | |
| 335 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) parseTypeAnnotationscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#parseTypeAnnotation().() (string, error) { |
| 336 | // Consume ( |
| 337 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 338 | return "", err |
| 339 | } |
| 340 | |
| 341 | // Read the type name |
| 342 | typeTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 343 | if err != nil { |
| 344 | return "", err |
| 345 | } |
| 346 | if typeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenIdentifierscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenIdentifier. && typeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenQuotedStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenQuotedString. { |
| 347 | return "", fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected type name, got %v at line %d, col %d", typeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., typeTok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., typeTok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 348 | } |
| 349 | |
| 350 | // Consume ) |
| 351 | closeTok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 352 | if err != nil { |
| 353 | return "", err |
| 354 | } |
| 355 | if closeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenCloseParenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseParen. { |
| 356 | return "", fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected ')', got %v at line %d, col %d", closeTok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., closeTok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., closeTok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 357 | } |
| 358 | |
| 359 | return typeTok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., nil |
| 360 | } |
| 361 | |
| 362 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) expectNodeEndscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#expectNodeEnd().() error { |
| 363 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 364 | if err != nil { |
| 365 | return err |
| 366 | } |
| 367 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenNewlinescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNewline. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSemicolonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSemicolon. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenEOFscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenEOF. || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenCloseBracescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenCloseBrace. { |
| 368 | if tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. == TokenSemicolonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenSemicolon. { |
| 369 | if _, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().(); err != nil { |
| 370 | return err |
| 371 | } |
| 372 | } |
| 373 | return nil |
| 374 | } |
| 375 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: expected node terminator, got %v at line %d, col %d", tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., tok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., tok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 376 | } |
| 377 | |
| 378 | func (p *Parserscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#) skipNewlinesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#skipNewlines().() { |
| 379 | for { |
| 380 | tok, err := p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..PeekTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#PeekToken().() |
| 381 | if err != nil || tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. != TokenNewlinescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNewline. { |
| 382 | return |
| 383 | } |
| 384 | _, _ = p.tokscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Parser#tok..NextTokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Tokenizer#NextToken().() |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | func tokenToValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/tokenToValue().(tok Tokenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#, typeAnn string) (*Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#, error) { |
| 389 | v := &Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#{Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Type.: typeAnn} |
| 390 | |
| 391 | switch tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type. { |
| 392 | case TokenQuotedStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenQuotedString., TokenRawStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenRawString., TokenMultiLineStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenMultiLineString.: |
| 393 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 394 | case TokenIntegerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenInteger.: |
| 395 | n, err := strconvscip-go gomod github.com/golang/go/src go1.25 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.25 strconv/ParseInt().(tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., 10, 64) |
| 396 | if err != nil { |
| 397 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: invalid integer %q: %w", tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., err) |
| 398 | } |
| 399 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = n |
| 400 | case TokenFloatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenFloat.: |
| 401 | n, err := strconvscip-go gomod github.com/golang/go/src go1.25 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.25 strconv/ParseFloat().(tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., 64) |
| 402 | if err != nil { |
| 403 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: invalid float %q: %w", tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., err) |
| 404 | } |
| 405 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = n |
| 406 | case TokenHexIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenHexInt.: |
| 407 | s := tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 408 | neg := false |
| 409 | if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "-") { |
| 410 | neg = true |
| 411 | s = s[1:] |
| 412 | } else if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "+") { |
| 413 | s = s[1:] |
| 414 | } |
| 415 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0x") |
| 416 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0X") |
| 417 | n, err := strconvscip-go gomod github.com/golang/go/src go1.25 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.25 strconv/ParseInt().(s, 16, 64) |
| 418 | if err != nil { |
| 419 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: invalid hex integer %q: %w", tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., err) |
| 420 | } |
| 421 | if neg { |
| 422 | n = -n |
| 423 | } |
| 424 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = n |
| 425 | case TokenOctalIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenOctalInt.: |
| 426 | s := tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 427 | neg := false |
| 428 | if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "-") { |
| 429 | neg = true |
| 430 | s = s[1:] |
| 431 | } else if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "+") { |
| 432 | s = s[1:] |
| 433 | } |
| 434 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0o") |
| 435 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0O") |
| 436 | n, err := strconvscip-go gomod github.com/golang/go/src go1.25 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.25 strconv/ParseInt().(s, 8, 64) |
| 437 | if err != nil { |
| 438 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: invalid octal integer %q: %w", tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., err) |
| 439 | } |
| 440 | if neg { |
| 441 | n = -n |
| 442 | } |
| 443 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = n |
| 444 | case TokenBinaryIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenBinaryInt.: |
| 445 | s := tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 446 | neg := false |
| 447 | if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "-") { |
| 448 | neg = true |
| 449 | s = s[1:] |
| 450 | } else if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(s, "+") { |
| 451 | s = s[1:] |
| 452 | } |
| 453 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0b") |
| 454 | s = stringsscip-go gomod github.com/golang/go/src go1.25 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25 strings/TrimPrefix().(s, "0B") |
| 455 | n, err := strconvscip-go gomod github.com/golang/go/src go1.25 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.25 strconv/ParseInt().(s, 2, 64) |
| 456 | if err != nil { |
| 457 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: invalid binary integer %q: %w", tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value., err) |
| 458 | } |
| 459 | if neg { |
| 460 | n = -n |
| 461 | } |
| 462 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = n |
| 463 | case TokenTruescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenTrue.: |
| 464 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = true |
| 465 | case TokenFalsescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenFalse.: |
| 466 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = false |
| 467 | case TokenNullscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNull.: |
| 468 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = nil |
| 469 | case TokenInfscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenInf.: |
| 470 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = mathscip-go gomod github.com/golang/go/src go1.25 math/.Infscip-go gomod github.com/golang/go/src go1.25 math/Inf().(1) |
| 471 | case TokenNegInfscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNegInf.: |
| 472 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = mathscip-go gomod github.com/golang/go/src go1.25 math/.Infscip-go gomod github.com/golang/go/src go1.25 math/Inf().(-1) |
| 473 | case TokenNaNscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenNaN.: |
| 474 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = mathscip-go gomod github.com/golang/go/src go1.25 math/.NaNscip-go gomod github.com/golang/go/src go1.25 math/NaN().() |
| 475 | case TokenIdentifierscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/TokenIdentifier.: |
| 476 | // Bare identifier used as a value — treat as string |
| 477 | v.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Value#Value. = tok.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Value. |
| 478 | default: |
| 479 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("kdl: unexpected token %v for value at line %d, col %d", tok.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Type., tok.Linescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Line., tok.Colscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl/internal`/Token#Col.) |
| 480 | } |
| 481 | |
| 482 | return v, nil |
| 483 | } |