- ..
- __init__.py
- _asy_builtins.py
- _cl_builtins.py
- _cocoa_builtins.py
- _csound_builtins.py
- _lasso_builtins.py
- _lua_builtins.py
- _mapping.py
- _mql_builtins.py
- _openedge_builtins.py
- _php_builtins.py
- _postgres_builtins.py
- _scilab_builtins.py
- _sourcemod_builtins.py
- _stan_builtins.py
- _stata_builtins.py
- _tsql_builtins.py
- _vim_builtins.py
- actionscript.py
- agile.py
- algebra.py
- ambient.py
- ampl.py
- apl.py
- archetype.py
- asm.py
- automation.py
- basic.py
- bibtex.py
- business.py
- c_cpp.py
- c_like.py
- capnproto.py
- chapel.py
- clean.py
- compiled.py
- configs.py
- console.py
- crystal.py
- csound.py
- css.py
- d.py
- dalvik.py
- data.py
- diff.py
- dotnet.py
- dsls.py
- dylan.py
- ecl.py
- eiffel.py
- elm.py
- erlang.py
- esoteric.py
- ezhil.py
- factor.py
- fantom.py
- felix.py
- forth.py
- fortran.py
- foxpro.py
- functional.py
- go.py
- grammar_notation.py
- graph.py
- graphics.py
- haskell.py
- haxe.py
- hdl.py
- hexdump.py
- html.py
- idl.py
- igor.py
- inferno.py
- installers.py
- int_fiction.py
- iolang.py
- j.py
- javascript.py
- julia.py
- jvm.py
- lisp.py
- make.py
- markup.py
- math.py
- matlab.py
- ml.py
- modeling.py
- modula2.py
- monte.py
- ncl.py
- nimrod.py
- nit.py
- nix.py
- oberon.py
- objective.py
- ooc.py
- other.py
- parasail.py
- parsers.py
- pascal.py
- pawn.py
- perl.py
- php.py
- praat.py
- prolog.py
- python.py
- qvt.py
- r.py
- rdf.py
- rebol.py
- resource.py
- rnc.py
- roboconf.py
- robotframework.py
- ruby.py
- rust.py
- sas.py
- scripting.py
- shell.py
- smalltalk.py
- smv.py
- snobol.py
- special.py
- sql.py
- stata.py
- supercollider.py
- tcl.py
- templates.py
- testing.py
- text.py
- textedit.py
- textfmts.py
- theorem.py
- trafficscript.py
- typoscript.py
- urbi.py
- varnish.py
- verification.py
- web.py
- webmisc.py
- whiley.py
- x10.py
j.py @master — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | # -*- coding: utf-8 -*-
"""
pygments.lexers.j
~~~~~~~~~~~~~~~~~
Lexer for the J programming language.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer, words, include
from pygments.token import Comment, Keyword, Name, Number, Operator, Punctuation, \
String, Text
__all__ = ['JLexer']
class JLexer(RegexLexer):
"""
For `J <http://jsoftware.com/>`_ source code.
.. versionadded:: 2.1
"""
name = 'J'
aliases = ['j']
filenames = ['*.ijs']
mimetypes = ['text/x-j']
validName = r'\b[a-zA-Z]\w*'
tokens = {
'root': [
# Shebang script
(r'#!.*$', Comment.Preproc),
# Comments
(r'NB\..*', Comment.Single),
(r'\n+\s*Note', Comment.Multiline, 'comment'),
(r'\s*Note.*', Comment.Single),
# Whitespace
(r'\s+', Text),
# Strings
(r"'", String, 'singlequote'),
# Definitions
(r'0\s+:\s*0|noun\s+define\s*$', Name.Entity, 'nounDefinition'),
(r'(([1-4]|13)\s+:\s*0|(adverb|conjunction|dyad|monad|verb)\s+define)\b',
Name.Function, 'explicitDefinition'),
# Flow Control
(words(('for_', 'goto_', 'label_'), suffix=validName+'\.'), Name.Label),
(words((
'assert', 'break', 'case', 'catch', 'catchd',
'catcht', 'continue', 'do', 'else', 'elseif',
'end', 'fcase', 'for', 'if', 'return',
'select', 'throw', 'try', 'while', 'whilst',
), suffix='\.'), Name.Label),
# Variable Names
(validName, Name.Variable),
# Standard Library
(words((
'ARGV', 'CR', 'CRLF', 'DEL', 'Debug',
'EAV', 'EMPTY', 'FF', 'JVERSION', 'LF',
'LF2', 'Note', 'TAB', 'alpha17', 'alpha27',
'apply', 'bind', 'boxopen', 'boxxopen', 'bx',
'clear', 'cutLF', 'cutopen', 'datatype', 'def',
'dfh', 'drop', 'each', 'echo', 'empty',
'erase', 'every', 'evtloop', 'exit', 'expand',
'fetch', 'file2url', 'fixdotdot', 'fliprgb', 'getargs',
'getenv', 'hfd', 'inv', 'inverse', 'iospath',
'isatty', 'isutf8', 'items', 'leaf', 'list',
'nameclass', 'namelist', 'names', 'nc',
'nl', 'on', 'pick', 'rows',
'script', 'scriptd', 'sign', 'sminfo', 'smoutput',
'sort', 'split', 'stderr', 'stdin', 'stdout',
'table', 'take', 'timespacex', 'timex', 'tmoutput',
'toCRLF', 'toHOST', 'toJ', 'tolower', 'toupper',
'type', 'ucp', 'ucpcount', 'usleep', 'utf8',
'uucp',
)), Name.Function),
# Copula
(r'=[.:]', Operator),
# Builtins
(r'[-=+*#$%@!~`^&";:.,<>{}\[\]\\|/]', Operator),
# Short Keywords
(r'[abCdDeEfHiIjLMoprtT]\.', Keyword.Reserved),
(r'[aDiLpqsStux]\:', Keyword.Reserved),
(r'(_[0-9])\:', Keyword.Constant),
# Parens
(r'\(', Punctuation, 'parentheses'),
# Numbers
include('numbers'),
],
'comment': [
(r'[^)]', Comment.Multiline),
(r'^\)', Comment.Multiline, '#pop'),
(r'[)]', Comment.Multiline),
],
'explicitDefinition': [
(r'\b[nmuvxy]\b', Name.Decorator),
include('root'),
(r'[^)]', Name),
(r'^\)', Name.Label, '#pop'),
(r'[)]', Name),
],
'numbers': [
(r'\b_{1,2}\b', Number),
(r'_?\d+(\.\d+)?(\s*[ejr]\s*)_?\d+(\.?=\d+)?', Number),
(r'_?\d+\.(?=\d+)', Number.Float),
(r'_?\d+x', Number.Integer.Long),
(r'_?\d+', Number.Integer),
],
'nounDefinition': [
(r'[^)]', String),
(r'^\)', Name.Label, '#pop'),
(r'[)]', String),
],
'parentheses': [
(r'\)', Punctuation, '#pop'),
# include('nounDefinition'),
include('explicitDefinition'),
include('root'),
],
'singlequote': [
(r"[^']", String),
(r"''", String),
(r"'", String, '#pop'),
],
}
|