| 1 | <h2>Comment</h2> |
| 2 | <pre><code>/* This is |
| 3 | multi-line |
| 4 | comment */ |
| 5 | // This is single-line comment</code></pre> |
| 6 | |
| 7 | <h2>String</h2> |
| 8 | <pre><code>"text in double quotes" |
| 9 | 'text in single quotes' |
| 10 | 'case-sensitive text'! |
| 11 | 'text ''Nevod'' in quotes' |
| 12 | "text ""Nevod"" in double quotes" |
| 13 | 'text prefix'* |
| 14 | 'case-sensitive text prefix'!*</code></pre> |
| 15 | |
| 16 | <h2>Keyword</h2> |
| 17 | <pre><code>@inside |
| 18 | @outside |
| 19 | @having |
| 20 | @search |
| 21 | @where</code></pre> |
| 22 | |
| 23 | <h2>Package Import</h2> |
| 24 | <pre><code>@require "Common/DateTime.np" |
| 25 | @require "Common/Url.np"</code></pre> |
| 26 | |
| 27 | <h2>Namespace</h2> |
| 28 | <pre><code>@namespace My { } |
| 29 | @namespace My.Domain { }</code></pre> |
| 30 | |
| 31 | <h2>Pattern</h2> |
| 32 | <pre><code>@pattern #Percentage = Num + ?Space + {'%', 'pct.', 'pct', 'percent'}; |
| 33 | @pattern #GUID = Word(8) + [3 '-' + Word(4)] + '-' + Word(12); |
| 34 | @pattern #HashTag = '#' + {AlphaNum, Alpha, '_'} + [0+ {Word, '_'}];</code></pre> |
| 35 | |
| 36 | <h2>Full Example</h2> |
| 37 | <pre><code>@namespace Common |
| 38 | { |
| 39 | @search @pattern Url(Domain, Path, Query, Anchor) = |
| 40 | Method + Domain:Url.Domain + ?Port + ?Path:Url.Path + |
| 41 | ?Query:Url.Query + ?Anchor:Url.Anchor |
| 42 | @where |
| 43 | { |
| 44 | Method = {'http', 'https' , 'ftp', 'mailto', 'file', 'data', 'irc'} + '://'; |
| 45 | Domain = Word + [1+ '.' + Word + [0+ {Word, '_', '-'}]]; |
| 46 | Port = ':' + Num; |
| 47 | Path = ?'/' + [0+ {Word, '/', '_', '+', '-', '%', '.'}]; |
| 48 | Query = '?' + ?(Param + [0+ '&' + Param]) |
| 49 | @where |
| 50 | { |
| 51 | Param = Identifier + '=' + Identifier |
| 52 | @where |
| 53 | { |
| 54 | Identifier = {Alpha, AlphaNum, '_'} + [0+ {Word, '_'}]; |
| 55 | }; |
| 56 | }; |
| 57 | Anchor(Value) = '#' + Value:{Word}; |
| 58 | }; |
| 59 | }</code></pre> |