Licence of the PCRE library =========================== PCRE is a library of functions to support regular expressions whose syntax and semantics are as close as possible to those of the Perl 5 language. | Written by Philip Hazel | Copyright (c) 1997-2005 University of Cambridge ---------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Cambridge nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Regular expression syntax and semantics ======================================= As the regular expressions supported by this module are enormous, the reader is referred to http://perldoc.perl.org/perlre.html for the full documentation of Perl's regular expressions. Because the backslash ``\`` is a meta character both in the Nimrod programming language and in regular expressions, it is strongly recommended that one uses the *raw* strings of Nimrod, so that backslashes are interpreted by the regular expression engine:: r"\S" # matches any character that is not whitespace A regular expression is a pattern that is matched against a subject string from left to right. Most characters stand for themselves in a pattern, and match the corresponding characters in the subject. As a trivial example, the pattern:: The quick brown fox matches a portion of a subject string that is identical to itself. The power of regular expressions comes from the ability to include alternatives and repetitions in the pattern. These are encoded in the pattern by the use of metacharacters, which do not stand for themselves but instead are interpreted in some special way. There are two different sets of metacharacters: those that are recognized anywhere in the pattern except within square brackets, and those that are recognized in square brackets. Outside square brackets, the metacharacters are as follows: ============== ============================================================ meta character meaning ============== ============================================================ ``\`` general escape character with several uses ``^`` assert start of string (or line, in multiline mode) ``$`` assert end of string (or line, in multiline mode) ``.`` match any character except newline (by default) ``[`` start character class definition ``|`` start of alternative branch ``(`` start subpattern ``)`` end subpattern ``?`` extends the meaning of ``(`` also 0 or 1 quantifier also quantifier minimizer ``*`` 0 or more quantifier ``+`` 1 or more quantifier also "possessive quantifier" ``{`` start min/max quantifier ============== ============================================================ Part of a pattern that is in square brackets is called a "character class". In a character class the only metacharacters are: ============== ============================================================ meta character meaning ============== ============================================================ ``\`` general escape character ``^`` negate the class, but only if the first character ``-`` indicates character range ``[`` POSIX character class (only if followed by POSIX syntax) ``]`` terminates the character class ============== ============================================================ The following sections describe the use of each of the metacharacters. Backslash --------- The `backslash`:idx: character has several uses. Firstly, if it is followed by a non-alphanumeric character, it takes away any special meaning that character may have. This use of backslash as an escape character applies both inside and outside character classes. For example, if you want to match a ``*`` character, you write ``\*`` in the pattern. This escaping action applies whether or not the following character would otherwise be interpreted as a metacharacter, so it is always safe to precede a non-alphanumeric with backslash to specify that it stands for itself. In particular, if you want to match a backslash, you write ``\\``. Non-printing characters ----------------------- A second use of backslash provides a way of encoding non-printing characters in patterns in a visible manner. There is no restriction on the appearance of non-printing characters, apart from the binary zero that terminates a pattern, but when a pattern is being prepared by text editing, it is usually easier to use one of the following escape sequences than the binary character it represents:: ============== ============================================================ character meaning ============== ============================================================ ``\a`` alarm, that is, the BEL character (hex 07) ``\e`` escape (hex 1B) ``\f`` formfeed (hex 0C) ``\n`` newline (hex 0A) ``\r`` carriage return (hex 0D) ``\t`` tab (hex 09) ``\ddd`` char
#
#
#            Nim's Runtime Library
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

proc reprInt(x: int64): string {.compilerproc.} = return $x

proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
  if ntfEnumHole notin typ.flags:
    if e <%