From dd5bbae055fd34ce2e12ef63f8a261c6b15dc83e Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 21 Oct 2026 05:43:35 +0000 Subject: feat(parser): parse TEMPLATE declarations, template ids and parameter packs Co-Authored-By: Claude Opus 5.5 --- tests/i/template-unused/case.json | 1 + tests/i/template-unused/expected.txt | 1 + tests/i/template-unused/lib.cps | 48 ++++++++++++++++++++++++++++++++++++ tests/i/template-unused/notes.md | 5 ++++ tests/i/template-unused/program.cps | 2 ++ 5 files changed, 57 insertions(+) create mode 100644 tests/i/template-unused/case.json create mode 100644 tests/i/template-unused/expected.txt create mode 100644 tests/i/template-unused/lib.cps create mode 100644 tests/i/template-unused/notes.md create mode 100644 tests/i/template-unused/program.cps (limited to 'tests/i') diff --git a/tests/i/template-unused/case.json b/tests/i/template-unused/case.json new file mode 100644 index 0000000..3415f39 --- /dev/null +++ b/tests/i/template-unused/case.json @@ -0,0 +1 @@ +{"sources": ["program.cps", "lib.cps"]} diff --git a/tests/i/template-unused/expected.txt b/tests/i/template-unused/expected.txt new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/i/template-unused/expected.txt @@ -0,0 +1 @@ +7 diff --git a/tests/i/template-unused/lib.cps b/tests/i/template-unused/lib.cps new file mode 100644 index 0000000..3de8ac3 --- /dev/null +++ b/tests/i/template-unused/lib.cps @@ -0,0 +1,48 @@ +TEMPLATE +FUNCTION Identity(Value : T) RETURNS T + IF Value < Value THEN + RETURN (T)Value + ENDIF + RETURN Value +ENDFUNCTION + +TEMPLATE +OVERLOAD PROCEDURE Visit(First : T, Others : Rest...) + OUTPUT Identity(First) + CALL Visit(Others...) + Visit>>(Others...) +ENDPROCEDURE + +TEMPLATE +CLASS Box + PRIVATE Value : T + PUBLIC PROCEDURE NEW(V : T) + Value <- V + ENDPROCEDURE + PUBLIC FUNCTION Get() RETURNS T + RETURN Value + ENDFUNCTION + PUBLIC FUNCTION AsBox(V : Box) RETURNS Box + RETURN (Box)V + ENDFUNCTION +ENDCLASS + +TEMPLATE +CLASS Pair + Left : A + Right : B +ENDCLASS + +TEMPLATE +CLASS Bundle + PUBLIC PROCEDURE Send(Values : Rest...) + CALL Visit(Values...) + ENDPROCEDURE +ENDCLASS + +TEMPLATE +PROCEDURE NestedTypes(Value : Box>) + DECLARE Other : Box> + Other <- NEW Box>() + Value <- (Box>)Value +ENDPROCEDURE diff --git a/tests/i/template-unused/notes.md b/tests/i/template-unused/notes.md new file mode 100644 index 0000000..c3ff7fd --- /dev/null +++ b/tests/i/template-unused/notes.md @@ -0,0 +1,5 @@ +# template-unused + +Human review: pending. Expected output was independently traced by AI, not captured from cpsc. + +Basis: TEMPLATE is a project extension. The library holds unused function, class and variadic templates, including casts, nested type ids, explicit calls and pack forwarding. Their bodies are parsed without being emitted or counted as top-level code. The entry unit prints INTEGER 7. diff --git a/tests/i/template-unused/program.cps b/tests/i/template-unused/program.cps new file mode 100644 index 0000000..d8b89a2 --- /dev/null +++ b/tests/i/template-unused/program.cps @@ -0,0 +1,2 @@ +INCLUDE "lib.cps" +OUTPUT 7 -- cgit v1.3.1-4-g156e