<?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[OpenSCAD 3D modelling language support]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I´m using <a href="http://www.thingiverse.com/thing:15363" rel="nofollow ugc">http://www.thingiverse.com/thing:15363</a> Notepad++ configuration files to have context color,  syntax highlight and auto completion in Notepad++ with OpenSCAD files. However those files do not allow for listing modules and functions in functions list windows. It seems from the manual that I have to create a new parser in functionList.xml. I tried to create a new parser for this language from the existing ones without success. I’m not a fluent programmer. I only need to detect the words ‘module’ and ‘function’.</p>
<h2>I added the following to functionsList.xml :</h2>
<pre><code>    &lt;association ext=".scad" id="OpenSCAD_file"/&gt;			
</code></pre>
<p dir="auto">&lt;/associationMap&gt;</p>
<h2>&lt;parsers&gt;<br />
&lt;parser id=“OpenSCAD_file” displayName=“OpenSCAD” commentExpr=“((/*.<em>?*)/|(//.</em>?$))”&gt;<br />
&lt;function<br />
mainExpr=“^[\t ]*(module|function)\w+”<br />
displayMode=“$functionName”&gt;<br />
&lt;functionName&gt;<br />
&lt;nameExpr expr=“[^\t(module|function)]+[\w]+”/&gt;<br />
&lt;/functionName&gt;<br />
&lt;/function&gt;<br />
&lt;/parser&gt;</h2>
<p dir="auto">Maybe there are some erros in this code, I don’t know. Any help is welcome. Thanks a lot.<br />
Kind regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/10610/openscad-3d-modelling-language-support</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 09:39:52 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/10610.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Oct 2015 00:01:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OpenSCAD 3D modelling language support on Sat, 24 Oct 2015 11:39:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello <strong>Joao</strong>,</p>
<p dir="auto">When the possibility to link a <strong>parser_ID</strong> to a name of <strong>user-defined</strong> language was, first, added, in N++ <strong>v6.5</strong>, on October 2014, I noticed that the other method, using the <strong>extension</strong> name of <strong>user-defined</strong> files, <em><strong>didn’t work</strong> at all</em>. Of course, I informed Don ( and some other guys too ) about that issue ! Refer to the <strong>first</strong> part of my post, below :</p>
<p dir="auto"><a href="http://sourceforge.net/p/notepad-plus/discussion/331753/thread/627d7ac2/#9ff7" rel="nofollow ugc">http://sourceforge.net/p/notepad-plus/discussion/331753/thread/627d7ac2/#9ff7</a></p>
<p dir="auto"><strong>Unfortunately</strong>, that issue hasn’t been fixed, yet. So, <strong>Joao</strong>, in the <strong>assocciationMap</strong> node, you MUST use the only syntax :</p>
<pre><code>&lt;association userDefinedLangName="OpenSCAD" id="OpenSCAD_file"/&gt;
</code></pre>
<p dir="auto">By the way, you just have to create a new <strong>user-defined</strong> language with name <strong>OpenSCAD</strong>, using the extension <strong>scad</strong>. It’s no use to define the <strong>characteristics</strong> of your language, to allow your own functionList <strong>parser</strong> to work :-)</p>
<hr />
<p dir="auto"><strong>Secondly</strong>, I, slightly, changed your regexes for, both, the <strong>mainExpr</strong> and <strong>Expr</strong> items :</p>
<ul>
<li>
<p dir="auto">I suppose that there is, at least, <strong>one blank</strong> character, after the key words <strong>Module</strong> and <strong>Function</strong></p>
</li>
<li>
<p dir="auto">I changed the syntax <strong><code>[\t ]</code></strong>, with the simple <strong><code>\h</code></strong> syntax. Indeed, the <strong>exact</strong> meaning of <strong><code>\h</code></strong>, with the  <strong>BOOST</strong> regex library, used in N++, is <strong><code>[\t \xA0]</code></strong> ( also known as an <strong>horizontal blank</strong> character )</p>
</li>
<li>
<p dir="auto">In <strong>expr</strong>, I use the <strong><code>\K</code></strong> syntax, which allows the regex engine to <strong>forget</strong> everything located on the <strong>left</strong> of this form ! So, the <strong>exact</strong> name of the module or the function, <strong>without</strong> any possible <strong>leading blank</strong> characters, will be displayed in the <strong>FunctionList</strong> window :-)</p>
</li>
</ul>
<p dir="auto">Therefore, in the <strong>parsers</strong> node, add the lines below :</p>
<pre><code>&lt;parser id="OpenSCAD_file" displayName="OpenSCAD" commentExpr="((/*.?*)/|(//.?$))"&gt;
    &lt;function
        mainExpr="^\h*(module|function)\h+\w+"
        displayMode="$functionName"&gt;
        &lt;functionName&gt;
            &lt;nameExpr expr="^\h*(module|function)\h+\K\w+"/&gt;
        &lt;/functionName&gt;
     &lt;/function&gt;
&lt;/parser&gt;
</code></pre>
<p dir="auto">For instance, these regexes allow the detection of these <strong>four</strong> syntaxes, below :</p>
<pre><code>module Test_1

function       Test2

       module Test3

			function	Test_4
</code></pre>
<hr />
<p dir="auto"><strong>Thirdly</strong>, your regex, used to detect the <strong>comments</strong>, <strong><code>((/*.?*)/|(//.?$))</code></strong>, is NOT a <strong>valid</strong> regular expression ! So, to define the correct regex, could you tell me the <strong>different</strong> cases of comments, in <strong>OpenSCAD</strong> language. From the general form of this regex, I presume that :</p>
<ul>
<li>
<p dir="auto">A comment <strong>line</strong> begins with a double slash <strong><code>//</code></strong></p>
</li>
<li>
<p dir="auto">A comment <strong>block</strong> begins, with the form <strong><code>/*</code></strong> and ends with the form <strong><code>*/</code></strong></p>
</li>
</ul>
<p dir="auto">Am I right about it ?</p>
<hr />
<p dir="auto">See you soon !</p>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">Some people may think : Why couldn’t he use a <strong>lookbehind</strong> construction in <strong>expr</strong> ?</p>
<p dir="auto">Indeed, the form below, with a <strong>positive lookbehind</strong> , seemingly, should work nice ?</p>
<pre><code>&lt;nameExpr expr="(?&lt;=(module|function)\h+)\w+"/&gt;
</code></pre>
<p dir="auto">But, in the <strong>BOOST</strong> regex library, <strong>lookbehinds</strong> must represent <strong>an UNIQUE FIXED length</strong> strings. So, this regex is <strong>INVALID</strong>, for two reasons :</p>
<ul>
<li>
<p dir="auto">The <strong>two</strong> parts of the <strong>alternative</strong>, <strong><code>(module|function)</code></strong>, have a different length ( <strong>6</strong> characters for the string <strong>module</strong> and <strong>8</strong> characters for the string <strong>function</strong> )</p>
</li>
<li>
<p dir="auto">The form <strong><code>\h+</code></strong> is <strong>NOT</strong> a fixed length string, as it stands for <strong>one or more</strong> horizontal blank character(s) !</p>
</li>
</ul>
<p dir="auto">Luckily, the <strong><code>\K</code></strong> <strong>syntax</strong> allows the regex engine to match :</p>
<ul>
<li>
<p dir="auto"><strong>First</strong>, the part of the regex, located <strong>before</strong> the <strong><code>\K</code></strong> form</p>
</li>
<li>
<p dir="auto"><strong>Secondly</strong>, the part of the regex, located, <strong>after</strong> the <strong><code>\K</code></strong> form, which is the <strong>final</strong> regex matched !</p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/11582</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/11582</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 24 Oct 2015 11:39:06 GMT</pubDate></item></channel></rss>