()
| 1089 | } |
| 1090 | |
| 1091 | func (p *Parser) parseJSONOption() (*JSONOption, error) { |
| 1092 | switch { |
| 1093 | case p.tryConsumeKeywords(KeywordSkip): |
| 1094 | if p.tryConsumeKeywords(KeywordRegexp) { |
| 1095 | regex, err := p.parseString(p.Pos()) |
| 1096 | if err != nil { |
| 1097 | return nil, err |
| 1098 | } |
| 1099 | return &JSONOption{ |
| 1100 | SkipRegex: regex, |
| 1101 | }, nil |
| 1102 | } |
| 1103 | jsonPath, err := p.parseJSONPath() |
| 1104 | if err != nil { |
| 1105 | return nil, err |
| 1106 | } |
| 1107 | return &JSONOption{ |
| 1108 | SkipPath: jsonPath, |
| 1109 | }, nil |
| 1110 | case p.matchTokenKind(TokenKindIdent): |
| 1111 | // Could be max_dynamic_* option OR a type hint like: a.b String |
| 1112 | // Lookahead to see if there's an '=' following the identifier path (max_dynamic_*) |
| 1113 | // or if it's a path followed by a ColumnType. |
| 1114 | // We'll parse a JSONPath first, then decide. |
| 1115 | // Save lexer state by consuming as path greedily using existing helpers. |
| 1116 | // Try: if single ident and next is '=' -> max_dynamic_*; else treat as path + type |
| 1117 | |
| 1118 | // Peek next token after current ident without consuming type; we need to |
| 1119 | // attempt to parse as max_dynamic_* first as it's existing behavior for a single ident. |
| 1120 | // To support dotted paths, we need to capture path, then if '=' exists, it's option; otherwise parse type. |
| 1121 | path, err := p.parseJSONPath() |
| 1122 | if err != nil { |
| 1123 | return nil, err |
| 1124 | } |
| 1125 | if p.tryConsumeTokenKind(TokenKindSingleEQ) != nil { |
| 1126 | // This is a max_dynamic_* option; only valid when path is a single ident of that name |
| 1127 | // Reconstruct handling similar to parseJSONMaxDynamicOptions but we already consumed ident and '=' |
| 1128 | // Determine which option based on the first ident name |
| 1129 | if len(path.Idents) != 1 { |
| 1130 | return nil, fmt.Errorf("unexpected token kind: %s", p.lastTokenKind()) |
| 1131 | } |
| 1132 | name := path.Idents[0].Name |
| 1133 | switch name { |
| 1134 | case "max_dynamic_types": |
| 1135 | number, err := p.parseNumber(p.Pos()) |
| 1136 | if err != nil { |
| 1137 | return nil, err |
| 1138 | } |
| 1139 | return &JSONOption{MaxDynamicTypes: number}, nil |
| 1140 | case "max_dynamic_paths": |
| 1141 | number, err := p.parseNumber(p.Pos()) |
| 1142 | if err != nil { |
| 1143 | return nil, err |
| 1144 | } |
| 1145 | return &JSONOption{MaxDynamicPaths: number}, nil |
| 1146 | default: |
| 1147 | return nil, fmt.Errorf("unexpected token kind: %s", p.lastTokenKind()) |
| 1148 | } |
no test coverage detected