Merge pull request #918 from quantified-uncertainty/squiggle-record-syntax
the last property of a record can have a following comma
This commit is contained in:
commit
b23dbc1c8b
|
@ -27,6 +27,15 @@ describe("eval", () => {
|
|||
test("index", () => expectEvalToBe("r = {a: 1}; r.a", "Ok(1)"))
|
||||
test("index", () => expectEvalToBe("r = {a: 1}; r.b", "Error(Record property not found: b)"))
|
||||
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", () => {
|
||||
|
|
|
@ -277,9 +277,13 @@ arrayConstructor 'array'
|
|||
{ return [head, ...tail]; }
|
||||
|
||||
recordConstructor 'record'
|
||||
= '{' _nl args:array_recordArguments _nl '}'
|
||||
= '{' _nl args:array_recordArguments _nl end_of_record
|
||||
{ return h.constructRecord(args); }
|
||||
|
||||
end_of_record
|
||||
= '}'
|
||||
/ ',' _nl '}'
|
||||
|
||||
array_recordArguments
|
||||
= head:keyValuePair tail:(_ ',' _nl @keyValuePair)*
|
||||
{ return [head, ...tail]; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user