fix: make named member prefix optional in tuple values
- Allow parsing tuple values with or without name prefixes - Supports both [x: 10; y: 20] and [10; 20] formats - Useful for CSV data where names are schema-only metadata Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Vendored
+5
-3
@@ -295,10 +295,12 @@ var ValueParser = class {
|
||||
const elementSchema = schema.elements[i];
|
||||
if (elementSchema.name) {
|
||||
this.skipWhitespace();
|
||||
if (!this.consumeStr(`${elementSchema.name}:`)) {
|
||||
throw new ParseError(`Expected ${elementSchema.name}:`, this.pos);
|
||||
}
|
||||
const savedPos = this.pos;
|
||||
if (this.consumeStr(`${elementSchema.name}:`)) {
|
||||
this.skipWhitespace();
|
||||
} else {
|
||||
this.pos = savedPos;
|
||||
}
|
||||
}
|
||||
result.push(this.parseValue(elementSchema.schema, false));
|
||||
this.skipWhitespace();
|
||||
|
||||
Vendored
+5
-3
@@ -261,10 +261,12 @@ var ValueParser = class {
|
||||
const elementSchema = schema.elements[i];
|
||||
if (elementSchema.name) {
|
||||
this.skipWhitespace();
|
||||
if (!this.consumeStr(`${elementSchema.name}:`)) {
|
||||
throw new ParseError(`Expected ${elementSchema.name}:`, this.pos);
|
||||
}
|
||||
const savedPos = this.pos;
|
||||
if (this.consumeStr(`${elementSchema.name}:`)) {
|
||||
this.skipWhitespace();
|
||||
} else {
|
||||
this.pos = savedPos;
|
||||
}
|
||||
}
|
||||
result.push(this.parseValue(elementSchema.schema, false));
|
||||
this.skipWhitespace();
|
||||
|
||||
Vendored
+5
-3
@@ -288,10 +288,12 @@ var ValueParser = class {
|
||||
const elementSchema = schema.elements[i];
|
||||
if (elementSchema.name) {
|
||||
this.skipWhitespace();
|
||||
if (!this.consumeStr(`${elementSchema.name}:`)) {
|
||||
throw new ParseError(`Expected ${elementSchema.name}:`, this.pos);
|
||||
}
|
||||
const savedPos = this.pos;
|
||||
if (this.consumeStr(`${elementSchema.name}:`)) {
|
||||
this.skipWhitespace();
|
||||
} else {
|
||||
this.pos = savedPos;
|
||||
}
|
||||
}
|
||||
result.push(this.parseValue(elementSchema.schema, false));
|
||||
this.skipWhitespace();
|
||||
|
||||
Vendored
+5
-3
@@ -258,10 +258,12 @@ var ValueParser = class {
|
||||
const elementSchema = schema.elements[i];
|
||||
if (elementSchema.name) {
|
||||
this.skipWhitespace();
|
||||
if (!this.consumeStr(`${elementSchema.name}:`)) {
|
||||
throw new ParseError(`Expected ${elementSchema.name}:`, this.pos);
|
||||
}
|
||||
const savedPos = this.pos;
|
||||
if (this.consumeStr(`${elementSchema.name}:`)) {
|
||||
this.skipWhitespace();
|
||||
} else {
|
||||
this.pos = savedPos;
|
||||
}
|
||||
}
|
||||
result.push(this.parseValue(elementSchema.schema, false));
|
||||
this.skipWhitespace();
|
||||
|
||||
+7
-3
@@ -116,12 +116,16 @@ class ValueParser {
|
||||
this.skipWhitespace();
|
||||
const elementSchema = schema.elements[i];
|
||||
|
||||
// Try to consume optional name prefix (e.g., "current:")
|
||||
if (elementSchema.name) {
|
||||
this.skipWhitespace();
|
||||
if (!this.consumeStr(`${elementSchema.name}:`)) {
|
||||
throw new ParseError(`Expected ${elementSchema.name}:`, this.pos);
|
||||
}
|
||||
const savedPos = this.pos;
|
||||
if (this.consumeStr(`${elementSchema.name}:`)) {
|
||||
this.skipWhitespace();
|
||||
} else {
|
||||
// Name not found, reset position and continue without name
|
||||
this.pos = savedPos;
|
||||
}
|
||||
}
|
||||
|
||||
result.push(this.parseValue(elementSchema.schema, false));
|
||||
|
||||
Reference in New Issue
Block a user