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/iii/template-header-errors/case.json | 36 +++++++++++++++++++++++++ tests/iii/template-header-errors/program.cps | 39 ++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 tests/iii/template-header-errors/case.json create mode 100644 tests/iii/template-header-errors/program.cps (limited to 'tests/iii/template-header-errors') diff --git a/tests/iii/template-header-errors/case.json b/tests/iii/template-header-errors/case.json new file mode 100644 index 0000000..f74cc0d --- /dev/null +++ b/tests/iii/template-header-errors/case.json @@ -0,0 +1,36 @@ +{ + "errors": [ + { + "reason": "Duplicate template parameter", + "line": 1 + }, + { + "reason": "template parameter pack must be last", + "line": 6 + }, + { + "reason": "only one parameter pack", + "line": 10 + }, + { + "reason": "TEMPLATE cannot prefix TYPE", + "line": 14 + }, + { + "reason": "Operator templates are not supported", + "line": 17 + }, + { + "reason": "TEMPLATE declarations are only allowed at top level", + "line": 23 + }, + { + "reason": "TEMPLATE declarations are only allowed at top level", + "line": 30 + }, + { + "reason": "Expected '<' after TEMPLATE", + "line": 35 + } + ] +} diff --git a/tests/iii/template-header-errors/program.cps b/tests/iii/template-header-errors/program.cps new file mode 100644 index 0000000..73c34a2 --- /dev/null +++ b/tests/iii/template-header-errors/program.cps @@ -0,0 +1,39 @@ +TEMPLATE +FUNCTION Duplicate(Value : T) RETURNS T + RETURN Value +ENDFUNCTION + +TEMPLATE +PROCEDURE NotLast() +ENDPROCEDURE + +TEMPLATE +PROCEDURE TwoPacks() +ENDPROCEDURE + +TEMPLATE +TYPE Alias = ^T + +TEMPLATE +OVERLOAD FUNCTION OPERATOR+(Value : T) RETURNS T + RETURN Value +ENDFUNCTION + +IF TRUE THEN + TEMPLATE + PROCEDURE Nested(Value : T) + OUTPUT 99 + ENDPROCEDURE +ENDIF + +CLASS Outer + TEMPLATE + PROCEDURE Member(Value : T) + ENDPROCEDURE +ENDCLASS + +TEMPLATE <> +PROCEDURE Empty() +ENDPROCEDURE + +OUTPUT 0 -- cgit v1.3.1-4-g156e