From 4875633acf4701705b9b3b014eb7d94268b897c2 Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Sat, 23 Oct 2021 19:03:27 +0200 Subject: Change parser --- tests/typ/code/array.typ | 2 +- tests/typ/code/call.typ | 2 +- tests/typ/code/dict.typ | 2 +- tests/typ/code/import.typ | 3 ++- tests/typ/code/spread.typ | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/typ/code') diff --git a/tests/typ/code/array.typ b/tests/typ/code/array.typ index df37dd45..44b8b597 100644 --- a/tests/typ/code/array.typ +++ b/tests/typ/code/array.typ @@ -72,7 +72,7 @@ {(,1)} // Missing expression makes named pair incomplete, making this an empty array. -// Error: 5 expected expression +// Error: 3-5 expected expression, found named pair {(a:)} // Named pair after this is already identified as an array. diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ index 2c16af1c..95d75595 100644 --- a/tests/typ/code/call.typ +++ b/tests/typ/code/call.typ @@ -72,7 +72,7 @@ // Error: 10-12 expected expression, found end of block comment #func(a:1*/) -// Error: 8 expected comma +// Error: 9 expected comma #func(1 2) // Error: 7-8 expected identifier diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index b369b8b6..757759ac 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -42,7 +42,7 @@ // Identified as dictionary due to initial colon. // Error: 4-5 expected named pair, found expression -// Error: 5 expected comma +// Error: 6 expected comma // Error: 12-16 expected identifier // Error: 17-18 expected expression, found colon {(:1 b:"", true::)} diff --git a/tests/typ/code/import.typ b/tests/typ/code/import.typ index bc96e80c..1fa8f205 100644 --- a/tests/typ/code/import.typ +++ b/tests/typ/code/import.typ @@ -79,7 +79,7 @@ This is never reached. // Error: 22 expected keyword `from` #import afrom, "b", c -// Error: 8 expected import items +// Error: 9 expected import items #import from "target.typ" // Error: 9-10 expected expression, found assignment operator @@ -114,4 +114,5 @@ This is never reached. // An item after a star. // Should output `, a from "target.typ"`. // Error: 10 expected keyword `from` +// Error: 10 expected semicolon or line break #import *, a from "target.typ" diff --git a/tests/typ/code/spread.typ b/tests/typ/code/spread.typ index 8a9491d0..41e790a4 100644 --- a/tests/typ/code/spread.typ +++ b/tests/typ/code/spread.typ @@ -62,7 +62,7 @@ #min(.."nope") --- -// Error: 10-14 expected identifier +// Error: 8-14 expected identifier #let f(..true) = none --- @@ -70,9 +70,9 @@ #let f(..a, ..b) = none --- -// Error: 5-6 spreading is not allowed here +// Error: 3-6 spreading is not allowed here {(..x)} --- -// Error: 11-17 spreading is not allowed here +// Error: 9-17 spreading is not allowed here {(1, 2, ..(1, 2))} -- cgit v1.2.3 From 5c952d56d0d602a1dbcf85210ae30fa402219fca Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Thu, 4 Nov 2021 19:36:32 +0100 Subject: New error handling --- tests/typ/code/let.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/typ/code') diff --git a/tests/typ/code/let.typ b/tests/typ/code/let.typ index 3f3f9d35..cd7531b7 100644 --- a/tests/typ/code/let.typ +++ b/tests/typ/code/let.typ @@ -56,7 +56,7 @@ Three #let v4 = 4 Four // Terminated by semicolon even though we are in a paren group. -// Error: 19 expected expression +// Error: 18 expected expression // Error: 19 expected closing paren #let v5 = (1, 2 + ; Five -- cgit v1.2.3 From 515fe89c5ea94e6bcdcfe387d006776d31ad3646 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 5 Nov 2021 13:21:39 +0100 Subject: Style changes Co-Authored-By: Martin --- tests/typ/code/import.typ | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/typ/code') diff --git a/tests/typ/code/import.typ b/tests/typ/code/import.typ index 1fa8f205..683bb52a 100644 --- a/tests/typ/code/import.typ +++ b/tests/typ/code/import.typ @@ -114,5 +114,4 @@ This is never reached. // An item after a star. // Should output `, a from "target.typ"`. // Error: 10 expected keyword `from` -// Error: 10 expected semicolon or line break #import *, a from "target.typ" -- cgit v1.2.3 From 75fffc1f9b6ef8bf258b2b1845a4ba74a0f5f2c1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 7 Nov 2021 23:31:42 +0100 Subject: Fine-grained capturing --- tests/typ/code/closure.typ | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests/typ/code') diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ index 3b8b4261..14e74e7e 100644 --- a/tests/typ/code/closure.typ +++ b/tests/typ/code/closure.typ @@ -56,6 +56,52 @@ test(f(), 3) } +--- +// Import bindings. +{ + let b = "target.typ" + let f() = { + import b from b + b + } + test(f(), 1) +} + +--- +// For loop bindings. +{ + let v = (1, 2, 3) + let s = 0 + let f() = { + for v in v { s += v } + } + f() + test(s, 6) +} + +--- +// Let + closure bindings. +{ + let g = "hi" + let f() = { + let g() = "bye" + g() + } + test(f(), "bye") +} + +--- +// Parameter bindings. +{ + let x = 5 + let g() = { + let f(x, y: x) = x + y + f + } + + test(g()(8), 13) +} + --- // Don't leak environment. { -- cgit v1.2.3 From 38c5c362419c5eee7a4fdc0b43d3a9dfb339a6d2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 8 Nov 2021 12:13:32 +0100 Subject: Final touches --- tests/typ/code/array.typ | 2 +- tests/typ/code/call.typ | 2 +- tests/typ/code/dict.typ | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/typ/code') diff --git a/tests/typ/code/array.typ b/tests/typ/code/array.typ index 44b8b597..df37dd45 100644 --- a/tests/typ/code/array.typ +++ b/tests/typ/code/array.typ @@ -72,7 +72,7 @@ {(,1)} // Missing expression makes named pair incomplete, making this an empty array. -// Error: 3-5 expected expression, found named pair +// Error: 5 expected expression {(a:)} // Named pair after this is already identified as an array. diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ index 95d75595..2c16af1c 100644 --- a/tests/typ/code/call.typ +++ b/tests/typ/code/call.typ @@ -72,7 +72,7 @@ // Error: 10-12 expected expression, found end of block comment #func(a:1*/) -// Error: 9 expected comma +// Error: 8 expected comma #func(1 2) // Error: 7-8 expected identifier diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index 757759ac..b369b8b6 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -42,7 +42,7 @@ // Identified as dictionary due to initial colon. // Error: 4-5 expected named pair, found expression -// Error: 6 expected comma +// Error: 5 expected comma // Error: 12-16 expected identifier // Error: 17-18 expected expression, found colon {(:1 b:"", true::)} -- cgit v1.2.3