Give jetc a dedicated, fully inert <comment> handler at compile time

<comment> had no special-case in jetc's compiler at all - it fell
through to parseFallback(), the generic unknown-tag path, which hunts
for a tag's own closing tag via scanBody()/skipQuotedValue(), the same
quote-aware, backslash-escape-interpreting scanning real Jet attribute
syntax needs. A comment containing an explanatory " sequence (a JSON
example in prose, say) or a literal <else>/<if>-looking word - both
already confirmed, separately, to corrupt jetc when they turn up
inside a JS // comment - hit the exact same corruption here too, just
triggered from inside a <comment> block instead.

Added skipCommentTag(), which only tracks same-tag-name nesting depth
via the existing case-insensitive matchTagOpen/matchTagClose and
otherwise ignores every character - no quote tracking, no other-tag
recognition, nothing a comment's own body could ever trip over. Wired
into parseNodes() alongside the other recognized top-level tags;
unlike those, it pushes no node at all; the comment contributes
nothing to the compiled output, matching the runtime interpreters own
__comment behavior but now safe at compile time too.

Verified directly: a scratch .jet with five <comment> blocks (plain,
a bare quote, a backslash-quote JSON example, literal <else>/<if>
text, and nested comments with their own quotes) all compiled clean
and left zero trace in the generated code, with the <if> immediately
following them compiling correctly too - confirming nothing after a
tricky comment gets corrupted either.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Brad ArantandClaude Sonnet 5 committed 2026-10-10 16:49:53 +00:00
1 parent b8f7793773
commit 867ace3cb3
2 files changed
+52

No files matched your search

+9
View File
@@ -61,6 +61,15 @@ namespace jetc {
void skipQuotedValue(size_t &p);
void skipEmbeddedTag(size_t &p);
// <comment>...</comment> must be fully inert regardless of what's
// inside it - unlike the generic parseFallback/scanBody path this
// tag used to fall through to (which applies the same quote/
// backslash-escape and nested-tag scanning real Jet syntax needs),
// this tracks only same-tag-name nesting depth via matchTagOpen/
// matchTagClose and otherwise ignores every character. See its own
// definition for the quote-corruption bug this specifically closes.
void skipCommentTag(size_t &p);
std::map<std::string, std::string> parseAttrs(bool &hasContainer);
// Scans forward from bodyStart (just after the opening tag's '>') for