59 lines
1.5 KiB
HTML
59 lines
1.5 KiB
HTML
<h2>Comment</h2>
|
|
<pre><code>/* This is
|
|
multi-line
|
|
comment */
|
|
// This is single-line comment</code></pre>
|
|
|
|
<h2>String</h2>
|
|
<pre><code>"text in double quotes"
|
|
'text in single quotes'
|
|
'case-sensitive text'!
|
|
'text ''Nevod'' in quotes'
|
|
"text ""Nevod"" in double quotes"
|
|
'text prefix'*
|
|
'case-sensitive text prefix'!*</code></pre>
|
|
|
|
<h2>Keyword</h2>
|
|
<pre><code>@inside
|
|
@outside
|
|
@having
|
|
@search
|
|
@where</code></pre>
|
|
|
|
<h2>Package Import</h2>
|
|
<pre><code>@require "Common/DateTime.np"
|
|
@require "Common/Url.np"</code></pre>
|
|
|
|
<h2>Namespace</h2>
|
|
<pre><code>@namespace My { }
|
|
@namespace My.Domain { }</code></pre>
|
|
|
|
<h2>Pattern</h2>
|
|
<pre><code>@pattern #Percentage = Num + ?Space + {'%', 'pct.', 'pct', 'percent'};
|
|
@pattern #GUID = Word(8) + [3 '-' + Word(4)] + '-' + Word(12);
|
|
@pattern #HashTag = '#' + {AlphaNum, Alpha, '_'} + [0+ {Word, '_'}];</code></pre>
|
|
|
|
<h2>Full Example</h2>
|
|
<pre><code>@namespace Common
|
|
{
|
|
@search @pattern Url(Domain, Path, Query, Anchor) =
|
|
Method + Domain:Url.Domain + ?Port + ?Path:Url.Path +
|
|
?Query:Url.Query + ?Anchor:Url.Anchor
|
|
@where
|
|
{
|
|
Method = {'http', 'https' , 'ftp', 'mailto', 'file', 'data', 'irc'} + '://';
|
|
Domain = Word + [1+ '.' + Word + [0+ {Word, '_', '-'}]];
|
|
Port = ':' + Num;
|
|
Path = ?'/' + [0+ {Word, '/', '_', '+', '-', '%', '.'}];
|
|
Query = '?' + ?(Param + [0+ '&' + Param])
|
|
@where
|
|
{
|
|
Param = Identifier + '=' + Identifier
|
|
@where
|
|
{
|
|
Identifier = {Alpha, AlphaNum, '_'} + [0+ {Word, '_'}];
|
|
};
|
|
};
|
|
Anchor(Value) = '#' + Value:{Word};
|
|
};
|
|
}</code></pre> |