diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 05:43:35 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 05:43:35 +0000 |
| commit | dd5bbae055fd34ce2e12ef63f8a261c6b15dc83e (patch) | |
| tree | 757e367daacf92c50148eb42d7bda97ba33ed3fb /tests/i/template-unused/lib.cps | |
| parent | c682f983b0dce3acba76d1f08719a26b9c52c5ec (diff) | |
feat(parser): parse TEMPLATE declarations, template ids and parameter packs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/template-unused/lib.cps')
| -rw-r--r-- | tests/i/template-unused/lib.cps | 48 |
1 files changed, 48 insertions, 0 deletions
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 <T> +FUNCTION Identity(Value : T) RETURNS T + IF Value < Value THEN + RETURN (T)Value + ENDIF + RETURN Value +ENDFUNCTION + +TEMPLATE <T, Rest...> +OVERLOAD PROCEDURE Visit(First : T, Others : Rest...) + OUTPUT Identity<T>(First) + CALL Visit<Rest...>(Others...) + Visit<Box<Pair<INTEGER,REAL>>>(Others...) +ENDPROCEDURE + +TEMPLATE <T> +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<T>) RETURNS Box<T> + RETURN (Box<T>)V + ENDFUNCTION +ENDCLASS + +TEMPLATE <A, B> +CLASS Pair + Left : A + Right : B +ENDCLASS + +TEMPLATE <T, Rest...> +CLASS Bundle + PUBLIC PROCEDURE Send(Values : Rest...) + CALL Visit(Values...) + ENDPROCEDURE +ENDCLASS + +TEMPLATE <T> +PROCEDURE NestedTypes(Value : Box<Box<T>>) + DECLARE Other : Box<Pair<T,REAL>> + Other <- NEW Box<Pair<T,REAL>>() + Value <- (Box<Box<T>>)Value +ENDPROCEDURE |
