<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hashtag # in a string causing EOF?]]></title><description><![CDATA[<p dir="auto">since when having an <code>#</code> in a string causes compilation error? And why can't we escape it with <code>\#</code></p>
<pre><code>inline function initMidiCbs()
{
    local ccList = [];

    for (i=0; i&lt;128; i++)
        ccList[i] = "#" + i; // error: Unexpected EOF in string constant
}
</code></pre>
]]></description><link>https://forum.hise.audio/topic/14899/hashtag-in-a-string-causing-eof</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 18:33:33 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/14899.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 03 Jul 2026 13:38:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 17:13:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> btw, HISE automatically uses the correct path separator if you use the File/FileSystem APIs.</p>
]]></description><link>https://forum.hise.audio/post/121769</link><guid isPermaLink="true">https://forum.hise.audio/post/121769</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 17:13:58 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 17:13:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> Aha now it makes sense</p>
]]></description><link>https://forum.hise.audio/post/121768</link><guid isPermaLink="true">https://forum.hise.audio/post/121768</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 17:13:30 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 17:11:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/12">@David-Healey</a> because I had this in the same script</p>
<pre><code>const var PATH_SEPARATOR = Engine.getOS() == "OSX" ? "/" : "\\"; // last " is escaped

const var someStringWithHashtag = "#"; // the first " closes the above line, so # is in the wild...
</code></pre>
<p dir="auto">and the parser sees the second <code>\</code> as an escape for the next char, which is <code>"</code>, hence messing the double quotes count.<br />
Ii is not seen as an error until the parser sees a <code>#</code> which instead of being taken as string, is taken as a preprocessor call.</p>
]]></description><link>https://forum.hise.audio/post/121767</link><guid isPermaLink="true">https://forum.hise.audio/post/121767</guid><dc:creator><![CDATA[ustk]]></dc:creator><pubDate>Fri, 03 Jul 2026 17:11:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:41:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> So why did the example in your first post fail?</p>
]]></description><link>https://forum.hise.audio/post/121761</link><guid isPermaLink="true">https://forum.hise.audio/post/121761</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:41:19 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:29:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/12">@David-Healey</a> Claude found it's a parsing issue with double backslash escape that de-sync the parsing:</p>
<pre><code>const var PATH_SEPARATOR = Engine.getOS() == "OSX" ? "/" : "\\";
</code></pre>
<p dir="auto">That <code>"\\"</code> is a perfectly valid HISEScript string (one escaped backslash). But HISE preprocesses every script through the SNEX preprocessor before the JS compiler sees it, and that preprocessor has a buggy string scanner (<code>snex_jit_PreProcessor.cpp:594</code>):</p>
<pre><code>// it only treats a backslash as an escape when the NEXT char is the quote:
if (*start == '\\' &amp;&amp; *(start + 1) == quoteChar) { start += 2; continue; }
</code></pre>
<p dir="auto">Walking <code>"\\"</code>: it reads the first <code>\</code>, then sees the second <code>\</code> sitting right before the closing <code>"</code> and concludes the <code>"</code> is an escaped quote — so it keeps scanning past the end of the string, swallowing text until the next <code>"</code> somewhere later. From that point on, the preprocessor's idea of "inside a string / outside a string" is inverted for the rest of the file.</p>
<p dir="auto">Why single quotes fix it, and why it's specific to this script:</p>
<ul>
<li>Line 4's trap flips quote-phase for everything after it. Approaching line 443, the preprocessor wrongly believes it's inside a string.</li>
<li>With <code>'#'</code>: the ' and <code>#</code> are just harmless characters inside that (phantom) string → no problem.</li>
<li>With <code>"#"</code>: the first " closes the phantom string → the preprocessor is now "outside" → it sees a bare <code>#</code>, which it treats as a preprocessor directive marker (<code>#define</code>/<code>#if</code>/…). It grabs <code>#" + i;</code>, fails to match a directive, blanks the block, and the mangled leftover reaches the JS tokenizer → its JSON-based string parser hits EOF mid-string → "Unexpected EOF in string constant".</li>
<li>It's confined to this file because the preprocessor runs per-file, and this is the file that contains both the <code>"\\"</code> trap and a <code>#</code>.</li>
</ul>
<p dir="auto">I proved it: replacing line 4's <code>"\\"</code> with the equivalent <code>"\u005C"</code> (same backslash, but no <code>\\</code> right before the quote) makes the <code>"#"</code> version compile with zero errors.</p>
<p dir="auto"><strong>Fix options</strong><br />
Recommended — remove the landmine. Change line 4 to a form that doesn't put <code>\\</code> against the closing quote, then <code>#</code> works anywhere (double-quoted included):</p>
<pre><code>const var PATH_SEPARATOR = Engine.getOS() == "OSX" ? "/" : "\u005C"; // backslash; avoids preprocessor quote-desync
</code></pre>
]]></description><link>https://forum.hise.audio/post/121760</link><guid isPermaLink="true">https://forum.hise.audio/post/121760</guid><dc:creator><![CDATA[ustk]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:29:33 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:09:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> Might have added in some hidden characters</p>
]]></description><link>https://forum.hise.audio/post/121759</link><guid isPermaLink="true">https://forum.hise.audio/post/121759</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:09:36 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:08:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/12">@David-Healey</a> I probably did... or Claude did once or twice</p>
]]></description><link>https://forum.hise.audio/post/121758</link><guid isPermaLink="true">https://forum.hise.audio/post/121758</guid><dc:creator><![CDATA[ustk]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:08:51 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:05:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> Did you edit the script in an external editor?</p>
]]></description><link>https://forum.hise.audio/post/121757</link><guid isPermaLink="true">https://forum.hise.audio/post/121757</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:05:40 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 14:04:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/12">@David-Healey</a> Mmmm... That is very very strange. It effectively works on a new project on both mac and win but not in my current big project, and only in a specific place in code...<br />
This reminds me of a missing <code>"</code> issue I heard of around here... Investigating...</p>
]]></description><link>https://forum.hise.audio/post/121756</link><guid isPermaLink="true">https://forum.hise.audio/post/121756</guid><dc:creator><![CDATA[ustk]]></dc:creator><pubDate>Fri, 03 Jul 2026 14:04:51 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 13:43:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/449">@ustk</a> No error here</p>
<pre><code>HiseSnippet 773.3ocsUstSZDDEdFj0TnWRMoO.Sr+Aql5BBVoTSsxkVREkTTSSLFyvryJSbYlMyNXkzz249FzdlcQ.qDuPRme.64x2Le6Y9NmssVw3QQJMBm8vggbD9YNcFJM8p1iJjnl0P3W3zhFY3ZRhqcGFRih3dHLdgOacfyjFEu98G2kFPkL9DWHzwJAiumnuvLwa3NeUDDzf5wOTzeprKtSSlRVUEnF.7YAGWTHkcA8b99TaZobPegF0CgeiS9h48bKUpKuPYe2M4ta3R8cKVfVtaYuhk3k4tdaUfybQ3Eq6ILJcGC0vifMcWk2vN8T+Plb.GKhDcC3Vi7nNvIm3FUsmHvq80EmHDBmt8jR0BIkpW4zR3IF6eRI6kwAHSPLcQCm5tnT9GAkvSQozITZImNLsHzLIhkOO0ooDtA8ovcyzTIIWTJI1opBxPZdae5E7FZvXLhba55tFA9YkJYyJjABIm3OPxLBkjHjBi8csZ2nbqj8mYIvJPwnADFaOQjgrM4jSAbV+9JMImXa2JDwGxWXK3uUWck3H1UR9mHNEfr7qWlrJQTgr95DtVqzumbjjeUHmY3dj5Gz.NWRjQKjmS.ESjgJMY+kkcSwlJiIoRtuxvOPFyvLPhj+Mju+LiYKJZUP.WOyvV0q9t.lSNneWtdMxkzfA7wIB2V2TBr3CSBvRtilJQkrI7JePHejcCUfm8p097sELnQWxvSG0rF0PsZnQ9f7B4ZivRGbM9kPWahhJiSMdzEFUHBca4FHzUdCBnlap9syEFE.pG2PxYkUxHgY3zyMdDsDt2YKwCkhK4zVXX8lMGSMCNBUp+Gbbzfjm6T22GD2SHXZmFeedmZbOG+2TCLPiSKJz+bEB6r+f9cfAtLNb5RIO.1bGbJqZIw10Zaq.c3RuXi+.qQAyaswiBl+5fn9TlVcFKoKvNp5Iwd.NIiGkmA9lBXSxih6LltN2G5eOiwt4VcKfElWfaLu.KNu.KMu.2bdA9t4E3V2OP630OMvn5mz1fPsZWOdTBFWWRAEXrZE8Wr5mNUF
</code></pre>
]]></description><link>https://forum.hise.audio/post/121755</link><guid isPermaLink="true">https://forum.hise.audio/post/121755</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 03 Jul 2026 13:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Hashtag # in a string causing EOF? on Fri, 03 Jul 2026 13:40:06 GMT]]></title><description><![CDATA[<p dir="auto">That's because I needed <code>'#'</code> instead of <code>"#"</code></p>
]]></description><link>https://forum.hise.audio/post/121754</link><guid isPermaLink="true">https://forum.hise.audio/post/121754</guid><dc:creator><![CDATA[ustk]]></dc:creator><pubDate>Fri, 03 Jul 2026 13:40:06 GMT</pubDate></item></channel></rss>