Enhance template parser to handle C++ comments and refactor preprocessing logic
- Updated parser to correctly interpret C++ `//` and `/* ... */` comments within template code. - Split preprocessing implementation into separate files for better organization. - Added regression test for comment parsing in templates. - Adjusted CSS styles for improved layout and readability in documentation.
This commit is contained in:
@@ -33,6 +33,7 @@ RENDER(Request& context)
|
||||
<div class="grid-heading">Data Types & Parsing</div>
|
||||
<? render_card("dtree.uce", "DTree", "Dynamic hierarchical data tree"); ?>
|
||||
<? render_card("json.uce", "JSON", "Parse and encode JSON data"); ?>
|
||||
<? render_card("preprocessor-comments.uce", "Preprocessor Comments", "Regression coverage for comment parsing in templates"); ?>
|
||||
<? render_card("string.uce", "String", "String operations"); ?>
|
||||
<? render_card("str_replace.uce", "String Replace", "Search and replace in strings"); ?>
|
||||
<? render_card("utf8.uce", "UTF-8", "Unicode string handling"); ?>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
RENDER(Request& context)
|
||||
{
|
||||
// Regression: this comment contains <> and an apostrophe that shouldn't start a literal block: <>
|
||||
String outer_status = "outer parser ok";
|
||||
|
||||
<>
|
||||
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
|
||||
<h1>
|
||||
<a href="index.uce">UCE Test</a>:
|
||||
Preprocessor Comments
|
||||
</h1>
|
||||
|
||||
<p>This page exists to prove the template parser ignores quotes and template markers that appear inside C++ comments.</p>
|
||||
|
||||
<?
|
||||
// Regression: this comment's apostrophe must not swallow the later ?> marker.
|
||||
String inline_status = "inline comment ok";
|
||||
?>
|
||||
|
||||
<?
|
||||
/*
|
||||
Regression: block comments may contain "quotes", apostrophe's, and <> markers
|
||||
without confusing the parser or the generated .cpp output.
|
||||
*/
|
||||
String block_status = "block comment ok";
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<li>Outer code scan: <code><?= outer_status ?></code></li>
|
||||
<li>Markup code island with // comment: <code><?= inline_status ?></code></li>
|
||||
<li>Markup code island with /* */ comment: <code><?= block_status ?></code></li>
|
||||
</ul>
|
||||
|
||||
<details>
|
||||
<summary>Request Parameters</summary>
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
</details>
|
||||
</>
|
||||
}
|
||||
+4
-4
@@ -2,12 +2,12 @@
|
||||
Color palette: deep blue gradient · warm gold accents · frosted glass surfaces */
|
||||
|
||||
:root {
|
||||
--bg: #0b1d4e;
|
||||
--bg-grad: linear-gradient(168deg, #0f2462 0%, #0b1d4e 40%, #091840 100%);
|
||||
--bg: #113399;
|
||||
--bg-grad: linear-gradient(168deg, #1a3daa 0%, #113399 40%, #0d2880 100%);
|
||||
--bg-surface: rgba(255, 255, 255, 0.05);
|
||||
--bg-surface-hover: rgba(255, 255, 255, 0.09);
|
||||
--bg-inset: rgba(0, 0, 0, 0.3);
|
||||
--bg-code: rgba(0, 0, 0, 0.32);
|
||||
--bg-inset: rgba(0, 0, 0, 0.28);
|
||||
--bg-code: rgba(0, 0, 0, 0.3);
|
||||
--text: #dfe5f2;
|
||||
--text-dim: rgba(200, 210, 235, 0.6);
|
||||
--text-muted: rgba(200, 210, 235, 0.35);
|
||||
|
||||
Reference in New Issue
Block a user