Nim Programming Language

Slight housekeeping - squashed history for Nim lexer.

commit efd4fcb6713cebe989e45ff67141e1f66a83ccbe
Author: singularperturbation <sloanes.k@gmail.com>
Date:   Wed Nov 26 05:15:53 2014 -0600

    Nim Programming Language

    This is a combination of commits to implement a RegexLexer for the Nim
    programming language (http://nim-lang.org).  It's heavily based on the Pygments
    Lexer for Nim- most of the regexes are just straightforwardly copied to the
    Rouge model.  The major distinctions are adding a few keywords to be recognized
    by the lexer, addressing the bug so that an apostrophe is optional in type
    suffixes when not ambiguous.

    Dev conveniences

    Scaffolding + comment highlighting

    Strings + newlines

    Pop->Pop! and underscorize

    Also added regex from function output 'underscorize'.  Consider
    refactoring as a compiled regexes with opWords, etc.?

    Floats and class vars to constants

    I decided that it was better programming practice (looking at the very
    clean go.rb and others) to have the keywords, pseudokeywords, etc. as
    constants rather than as class variables under Nim.  (It also makes the
    documentation for Nim.rb much cleaner).

    Handling floats:
    In Pygments, we can push multiple states on the stack (and then yield a
    token) by creating a rule with something like:

    <state name> (if needed):
      r'<regex>', <token name>, ['state1','state2']

    But in Rouge, you can only have a rule with one of:
      rule /regex/,token
      rule /regex/,token,state
      rule /regex/, { |match| #block }

    so to push both and then yield Num::Float, I created a block that pushed
    both (and then yielded Num::Float with token).  Will do testing to see
    if this works.

    Finished - now debugging

    Fix for number suffixes

    I edited the regexes for the integers and floats to better support
    suffixes.  In the case of floats, I had an erroneous "\'" (escaped
    single quote) in the regex for the 'Numbers' block because of how the
    Pygments regex was setup.

    For unsigned integers, I added an extra rule in the ':intsuffix' state
    to check for 'u' or 'U'. This allows the annotation for unsigned
    integers as specified in the manual.

    Optional apostrophe w/ numeric types

    This fixes the issue described here:
    https://github.com/Araq/Nimrod/wiki/Pygments-issues in the section on
    'Incorrect type suffix highlighting':

    var x = 0f64
    var y = 0'f64

    should have the same highlighting with/without apostrophe.  The only
    case in which the apostrophe is *not* optional is when specifying type
    precision with hexadecimal digits - that *can* cause ambiguity, so the
    apostrophe is required. Numeric regexes updated to accomodate this.

    Examples for Nim

    Added examples in the lib/rouge/demos/ and spec/visual/samples/
    directories for the Nim programming language.  The former is a (somewhat
    contrived) example of fixed width output and mathematical functions; the
    other is taken from http://nimrod-by-example.github.io/, which is
    available under public domain per terms of its license as of time of
    writing.

    Reverting irrelevant changes

    Some of the changes that I made (to .gitignore, the Rakefile, and adding
    the Nim pygments lexer in the project root) were useful only to me and
    should not be a part of the final commit.
Merge pull request #200 from singularperturbation/master

Nim Programming Language