the last property of a record can have a following comma
This commit is contained in:
parent
d9aef8d9c1
commit
4c21aa902e
|
@ -27,6 +27,15 @@ describe("eval", () => {
|
||||||
test("index", () => expectEvalToBe("r = {a: 1}; r.a", "Ok(1)"))
|
test("index", () => expectEvalToBe("r = {a: 1}; r.a", "Ok(1)"))
|
||||||
test("index", () => expectEvalToBe("r = {a: 1}; r.b", "Error(Record property not found: b)"))
|
test("index", () => expectEvalToBe("r = {a: 1}; r.b", "Error(Record property not found: b)"))
|
||||||
testEvalError("{a: 1}.b") // invalid syntax
|
testEvalError("{a: 1}.b") // invalid syntax
|
||||||
|
test("always the same property ending", () =>
|
||||||
|
expectEvalToBe(
|
||||||
|
`{
|
||||||
|
a: 1,
|
||||||
|
b: 2,
|
||||||
|
}`,
|
||||||
|
"Ok({a: 1,b: 2})",
|
||||||
|
)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("multi-line", () => {
|
describe("multi-line", () => {
|
||||||
|
|
|
@ -277,9 +277,13 @@ arrayConstructor 'array'
|
||||||
{ return [head, ...tail]; }
|
{ return [head, ...tail]; }
|
||||||
|
|
||||||
recordConstructor 'record'
|
recordConstructor 'record'
|
||||||
= '{' _nl args:array_recordArguments _nl '}'
|
= '{' _nl args:array_recordArguments _nl end_of_record
|
||||||
{ return h.constructRecord(args); }
|
{ return h.constructRecord(args); }
|
||||||
|
|
||||||
|
end_of_record
|
||||||
|
= '}'
|
||||||
|
/ ',' _nl '}'
|
||||||
|
|
||||||
array_recordArguments
|
array_recordArguments
|
||||||
= head:keyValuePair tail:(_ ',' _nl @keyValuePair)*
|
= head:keyValuePair tail:(_ ',' _nl @keyValuePair)*
|
||||||
{ return [head, ...tail]; }
|
{ return [head, ...tail]; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user