From a3335110dc4f1283cf1680e273cc9775b7e8c8ac Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 20 Oct 2026 11:42:45 +0000 Subject: feat(lexer): add C_STRING literal suffix Co-Authored-By: Claude Opus 5.5 --- tests/i/c-string-literals/case.json | 1 + tests/i/c-string-literals/expected.txt | 4 ++++ tests/i/c-string-literals/notes.md | 5 +++++ tests/i/c-string-literals/program.cps | 13 +++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 tests/i/c-string-literals/case.json create mode 100644 tests/i/c-string-literals/expected.txt create mode 100644 tests/i/c-string-literals/notes.md create mode 100644 tests/i/c-string-literals/program.cps (limited to 'tests') diff --git a/tests/i/c-string-literals/case.json b/tests/i/c-string-literals/case.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/i/c-string-literals/case.json @@ -0,0 +1 @@ +{} diff --git a/tests/i/c-string-literals/expected.txt b/tests/i/c-string-literals/expected.txt new file mode 100644 index 0000000..2255027 --- /dev/null +++ b/tests/i/c-string-literals/expected.txt @@ -0,0 +1,4 @@ +quote:" slash:\ +AB +0 +1:2 diff --git a/tests/i/c-string-literals/notes.md b/tests/i/c-string-literals/notes.md new file mode 100644 index 0000000..a469ce1 --- /dev/null +++ b/tests/i/c-string-literals/notes.md @@ -0,0 +1,5 @@ +# C string literals + +Human review: pending. Expectations follow the literal bytes and declared overloads. + +The adjacent uppercase C suffix produces C_STRING. Escapes use the ordinary lexer rules. Explicit STRING casts preserve the text; an empty C string has length zero after conversion. Overload selection distinguishes STRING from C_STRING. diff --git a/tests/i/c-string-literals/program.cps b/tests/i/c-string-literals/program.cps new file mode 100644 index 0000000..ac2f7b0 --- /dev/null +++ b/tests/i/c-string-literals/program.cps @@ -0,0 +1,13 @@ +DECLARE Text : C_STRING +Text <- "quote:\" slash:\\"C +OUTPUT (STRING)Text +OUTPUT (STRING)"\101\x42"C +CONSTANT Empty = ""C +OUTPUT LENGTH((STRING)Empty) +OVERLOAD FUNCTION Kind(Text : STRING) RETURNS INTEGER + RETURN 1 +ENDFUNCTION +OVERLOAD FUNCTION Kind(Text : C_STRING) RETURNS INTEGER + RETURN 2 +ENDFUNCTION +OUTPUT Kind("text"), ":", Kind("text"C) -- cgit v1.3.1-4-g156e