nim function

Mode nim(
  1. Highlight hljs
)

Highlight.js language definition for nim.

Implementation

Mode nim(Highlight hljs) {
  return Mode(
    name: r'Nim',
    keywords: {
      r'keyword': [
        r'addr',
        r'and',
        r'as',
        r'asm',
        r'bind',
        r'block',
        r'break',
        r'case',
        r'cast',
        r'concept',
        r'const',
        r'continue',
        r'converter',
        r'defer',
        r'discard',
        r'distinct',
        r'div',
        r'do',
        r'elif',
        r'else',
        r'end',
        r'enum',
        r'except',
        r'export',
        r'finally',
        r'for',
        r'from',
        r'func',
        r'generic',
        r'guarded',
        r'if',
        r'import',
        r'in',
        r'include',
        r'interface',
        r'is',
        r'isnot',
        r'iterator',
        r'let',
        r'macro',
        r'method',
        r'mixin',
        r'mod',
        r'nil',
        r'not',
        r'notin',
        r'object',
        r'of',
        r'or',
        r'out',
        r'proc',
        r'ptr',
        r'raise',
        r'ref',
        r'return',
        r'shared',
        r'shl',
        r'shr',
        r'static',
        r'template',
        r'try',
        r'tuple',
        r'type',
        r'using',
        r'var',
        r'when',
        r'while',
        r'with',
        r'without',
        r'xor',
        r'yield',
      ],
      r'literal': [r'true', r'false'],
      r'type': [
        r'int',
        r'int8',
        r'int16',
        r'int32',
        r'int64',
        r'uint',
        r'uint8',
        r'uint16',
        r'uint32',
        r'uint64',
        r'float',
        r'float32',
        r'float64',
        r'bool',
        r'char',
        r'string',
        r'cstring',
        r'pointer',
        r'expr',
        r'stmt',
        r'void',
        r'auto',
        r'any',
        r'range',
        r'array',
        r'openarray',
        r'varargs',
        r'seq',
        r'set',
        r'clong',
        r'culong',
        r'cchar',
        r'cschar',
        r'cshort',
        r'cint',
        r'csize',
        r'clonglong',
        r'cfloat',
        r'cdouble',
        r'clongdouble',
        r'cuchar',
        r'cushort',
        r'cuint',
        r'culonglong',
        r'cstringarray',
        r'semistatic',
      ],
      r'built_in': [r'stdin', r'stdout', r'stderr', r'result'],
    },
    contains: [
      Mode(scope: r'meta', begin: r'\{\.', end: r'\.\}', relevance: 10),
      Mode(
        scope: r'string',
        begin: r'[a-zA-Z]\w*"',
        end: r'"',
        contains: [Mode(begin: r'""')],
      ),
      Mode(scope: r'string', begin: r'([a-zA-Z]\w*)?"""', end: r'"""'),
      Mode(
        scope: r'string',
        begin: r'"',
        end: r'"',
        illegal: r'\n',
        contains: [Mode(begin: r'\\[\s\S]', relevance: 0)],
      ),
      Mode(scope: r'type', begin: r'\b[A-Z]\w+\b', relevance: 0),
      Mode(
        scope: r'number',
        relevance: 0,
        variants: [
          Mode(
            begin: r"\b(0[xX][0-9a-fA-F][_0-9a-fA-F]*)('?[iIuU](8|16|32|64))?",
          ),
          Mode(begin: r"\b(0o[0-7][_0-7]*)('?[iIuUfF](8|16|32|64))?"),
          Mode(begin: r"\b(0(b|B)[01][_01]*)('?[iIuUfF](8|16|32|64))?"),
          Mode(begin: r"\b(\d[_\d]*)('?[iIuUfF](8|16|32|64))?"),
        ],
      ),
      Mode(
        scope: r'comment',
        begin: r'#',
        end: r'$',
        contains: [
          Mode(
            scope: r'doctag',
            begin: r'[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)',
            end: r'(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):',
            excludeBegin: true,
            relevance: 0,
          ),
          Mode(
            begin:
                r"[ ]+((?:I|a|is|so|us|to|at|if|in|it|on|[A-Za-z]+['](d|ve|re|ll|t|s|n)|[A-Za-z]+[-][a-z]+|[A-Za-z][a-z]{2,})[.]?[:]?([.][ ]|[ ])){3}",
          ),
        ],
      ),
    ],
  );
}