go.mod: use chroma v2
This commit is contained in:
parent
5dbaf66868
commit
ff030abf6c
4
go.mod
4
go.mod
|
@ -3,8 +3,8 @@ module github.com/kevinburke/chroma-markdown
|
|||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/alecthomas/chroma v0.10.0
|
||||
github.com/alecthomas/chroma/v2 v2.11.1
|
||||
golang.org/x/sys v0.14.0
|
||||
)
|
||||
|
||||
require github.com/dlclark/regexp2 v1.8.0 // indirect
|
||||
require github.com/dlclark/regexp2 v1.10.0 // indirect
|
||||
|
|
23
go.sum
23
go.sum
|
@ -1,18 +1,9 @@
|
|||
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
|
||||
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dlclark/regexp2 v1.8.0 h1:rJD5HeGIT/2b5CDk63FVCwZA3qgYElfg+oQK7uH5pfE=
|
||||
github.com/dlclark/regexp2 v1.8.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
|
||||
github.com/alecthomas/chroma/v2 v2.11.1 h1:m9uUtgcdAwgfFNxuqj7AIG75jD2YmL61BBIJWtdzJPs=
|
||||
github.com/alecthomas/chroma/v2 v2.11.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
|
||||
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
|
||||
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
|
||||
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
8
main.go
8
main.go
|
@ -10,10 +10,10 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/chroma"
|
||||
"github.com/alecthomas/chroma/formatters/html"
|
||||
"github.com/alecthomas/chroma/lexers"
|
||||
"github.com/alecthomas/chroma/styles"
|
||||
"github.com/alecthomas/chroma/v2"
|
||||
"github.com/alecthomas/chroma/v2/formatters/html"
|
||||
"github.com/alecthomas/chroma/v2/lexers"
|
||||
"github.com/alecthomas/chroma/v2/styles"
|
||||
)
|
||||
|
||||
// dataPipedIn returns true if the user piped data via stdin.
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
.PHONY: chromad upload all
|
||||
|
||||
VERSION ?= $(shell git describe --tags --dirty --always)
|
||||
|
||||
all: README.md tokentype_string.go
|
||||
|
||||
README.md: lexers/*/*.go
|
||||
./table.py
|
||||
|
||||
tokentype_string.go: types.go
|
||||
go generate
|
||||
|
||||
chromad:
|
||||
rm -f chromad
|
||||
(export CGOENABLED=0 GOOS=linux GOARCH=amd64; cd ./cmd/chromad && go build -ldflags="-X 'main.version=$(VERSION)'" -o ../../chromad .)
|
||||
|
||||
upload: chromad
|
||||
scp chromad root@swapoff.org: && \
|
||||
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
|
|
@ -1,285 +0,0 @@
|
|||
# Chroma — A general purpose syntax highlighter in pure Go
|
||||
[![Golang Documentation](https://godoc.org/github.com/alecthomas/chroma?status.svg)](https://godoc.org/github.com/alecthomas/chroma) [![CI](https://github.com/alecthomas/chroma/actions/workflows/ci.yml/badge.svg)](https://github.com/alecthomas/chroma/actions/workflows/ci.yml) [![Slack chat](https://img.shields.io/static/v1?logo=slack&style=flat&label=slack&color=green&message=gophers)](https://invite.slack.golangbridge.org/)
|
||||
|
||||
> **NOTE:** As Chroma has just been released, its API is still in flux. That said, the high-level interface should not change significantly.
|
||||
|
||||
Chroma takes source code and other structured text and converts it into syntax
|
||||
highlighted HTML, ANSI-coloured text, etc.
|
||||
|
||||
Chroma is based heavily on [Pygments](http://pygments.org/), and includes
|
||||
translators for Pygments lexers and styles.
|
||||
|
||||
<a id="markdown-table-of-contents" name="table-of-contents"></a>
|
||||
## Table of Contents
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
1. [Table of Contents](#table-of-contents)
|
||||
2. [Supported languages](#supported-languages)
|
||||
3. [Try it](#try-it)
|
||||
4. [Using the library](#using-the-library)
|
||||
1. [Quick start](#quick-start)
|
||||
2. [Identifying the language](#identifying-the-language)
|
||||
3. [Formatting the output](#formatting-the-output)
|
||||
4. [The HTML formatter](#the-html-formatter)
|
||||
5. [More detail](#more-detail)
|
||||
1. [Lexers](#lexers)
|
||||
2. [Formatters](#formatters)
|
||||
3. [Styles](#styles)
|
||||
6. [Command-line interface](#command-line-interface)
|
||||
7. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
<a id="markdown-supported-languages" name="supported-languages"></a>
|
||||
## Supported languages
|
||||
|
||||
Prefix | Language
|
||||
:----: | --------
|
||||
A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Angular2, ANTLR, ApacheConf, APL, AppleScript, Arduino, Awk
|
||||
B | Ballerina, Base Makefile, Bash, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, Brainfuck
|
||||
C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython
|
||||
D | D, Dart, Diff, Django/Jinja, Docker, DTD, Dylan
|
||||
E | EBNF, Elixir, Elm, EmacsLisp, Erlang
|
||||
F | Factor, Fish, Forth, Fortran, FSharp
|
||||
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy
|
||||
H | Handlebars, Haskell, Haxe, HCL, Hexdump, HLB, HTML, HTTP, Hy
|
||||
I | Idris, Igor, INI, Io
|
||||
J | J, Java, JavaScript, JSON, Julia, Jungle
|
||||
K | Kotlin
|
||||
L | Lighttpd configuration file, LLVM, Lua
|
||||
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
||||
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
||||
O | Objective-C, OCaml, Octave, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode
|
||||
P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Protocol Buffer, Puppet, Python 2, Python
|
||||
Q | QBasic
|
||||
R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust
|
||||
S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Standard ML, Stylus, Svelte, Swift, SYSTEMD, systemverilog
|
||||
T | TableGen, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
||||
V | VB.net, verilog, VHDL, VimL, vue
|
||||
W | WDTE
|
||||
X | XML, Xorg
|
||||
Y | YAML, YANG
|
||||
Z | Zig
|
||||
|
||||
|
||||
_I will attempt to keep this section up to date, but an authoritative list can be
|
||||
displayed with `chroma --list`._
|
||||
|
||||
<a id="markdown-try-it" name="try-it"></a>
|
||||
## Try it
|
||||
|
||||
Try out various languages and styles on the [Chroma Playground](https://swapoff.org/chroma/playground/).
|
||||
|
||||
<a id="markdown-using-the-library" name="using-the-library"></a>
|
||||
## Using the library
|
||||
|
||||
Chroma, like Pygments, has the concepts of
|
||||
[lexers](https://github.com/alecthomas/chroma/tree/master/lexers),
|
||||
[formatters](https://github.com/alecthomas/chroma/tree/master/formatters) and
|
||||
[styles](https://github.com/alecthomas/chroma/tree/master/styles).
|
||||
|
||||
Lexers convert source text into a stream of tokens, styles specify how token
|
||||
types are mapped to colours, and formatters convert tokens and styles into
|
||||
formatted output.
|
||||
|
||||
A package exists for each of these, containing a global `Registry` variable
|
||||
with all of the registered implementations. There are also helper functions
|
||||
for using the registry in each package, such as looking up lexers by name or
|
||||
matching filenames, etc.
|
||||
|
||||
In all cases, if a lexer, formatter or style can not be determined, `nil` will
|
||||
be returned. In this situation you may want to default to the `Fallback`
|
||||
value in each respective package, which provides sane defaults.
|
||||
|
||||
<a id="markdown-quick-start" name="quick-start"></a>
|
||||
### Quick start
|
||||
|
||||
A convenience function exists that can be used to simply format some source
|
||||
text, without any effort:
|
||||
|
||||
```go
|
||||
err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai")
|
||||
```
|
||||
|
||||
<a id="markdown-identifying-the-language" name="identifying-the-language"></a>
|
||||
### Identifying the language
|
||||
|
||||
To highlight code, you'll first have to identify what language the code is
|
||||
written in. There are three primary ways to do that:
|
||||
|
||||
1. Detect the language from its filename.
|
||||
|
||||
```go
|
||||
lexer := lexers.Match("foo.go")
|
||||
```
|
||||
|
||||
3. Explicitly specify the language by its Chroma syntax ID (a full list is available from `lexers.Names()`).
|
||||
|
||||
```go
|
||||
lexer := lexers.Get("go")
|
||||
```
|
||||
|
||||
3. Detect the language from its content.
|
||||
|
||||
```go
|
||||
lexer := lexers.Analyse("package main\n\nfunc main()\n{\n}\n")
|
||||
```
|
||||
|
||||
In all cases, `nil` will be returned if the language can not be identified.
|
||||
|
||||
```go
|
||||
if lexer == nil {
|
||||
lexer = lexers.Fallback
|
||||
}
|
||||
```
|
||||
|
||||
At this point, it should be noted that some lexers can be extremely chatty. To
|
||||
mitigate this, you can use the coalescing lexer to coalesce runs of identical
|
||||
token types into a single token:
|
||||
|
||||
```go
|
||||
lexer = chroma.Coalesce(lexer)
|
||||
```
|
||||
|
||||
<a id="markdown-formatting-the-output" name="formatting-the-output"></a>
|
||||
### Formatting the output
|
||||
|
||||
Once a language is identified you will need to pick a formatter and a style (theme).
|
||||
|
||||
```go
|
||||
style := styles.Get("swapoff")
|
||||
if style == nil {
|
||||
style = styles.Fallback
|
||||
}
|
||||
formatter := formatters.Get("html")
|
||||
if formatter == nil {
|
||||
formatter = formatters.Fallback
|
||||
}
|
||||
```
|
||||
|
||||
Then obtain an iterator over the tokens:
|
||||
|
||||
```go
|
||||
contents, err := ioutil.ReadAll(r)
|
||||
iterator, err := lexer.Tokenise(nil, string(contents))
|
||||
```
|
||||
|
||||
And finally, format the tokens from the iterator:
|
||||
|
||||
```go
|
||||
err := formatter.Format(w, style, iterator)
|
||||
```
|
||||
|
||||
<a id="markdown-the-html-formatter" name="the-html-formatter"></a>
|
||||
### The HTML formatter
|
||||
|
||||
By default the `html` registered formatter generates standalone HTML with
|
||||
embedded CSS. More flexibility is available through the `formatters/html` package.
|
||||
|
||||
Firstly, the output generated by the formatter can be customised with the
|
||||
following constructor options:
|
||||
|
||||
- `Standalone()` - generate standalone HTML with embedded CSS.
|
||||
- `WithClasses()` - use classes rather than inlined style attributes.
|
||||
- `ClassPrefix(prefix)` - prefix each generated CSS class.
|
||||
- `TabWidth(width)` - Set the rendered tab width, in characters.
|
||||
- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
|
||||
- `LinkableLineNumbers()` - Make the line numbers linkable and be a link to themselves.
|
||||
- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
|
||||
- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
|
||||
|
||||
If `WithClasses()` is used, the corresponding CSS can be obtained from the formatter with:
|
||||
|
||||
```go
|
||||
formatter := html.New(html.WithClasses())
|
||||
err := formatter.WriteCSS(w, style)
|
||||
```
|
||||
|
||||
<a id="markdown-more-detail" name="more-detail"></a>
|
||||
## More detail
|
||||
|
||||
<a id="markdown-lexers" name="lexers"></a>
|
||||
### Lexers
|
||||
|
||||
See the [Pygments documentation](http://pygments.org/docs/lexerdevelopment/)
|
||||
for details on implementing lexers. Most concepts apply directly to Chroma,
|
||||
but see existing lexer implementations for real examples.
|
||||
|
||||
In many cases lexers can be automatically converted directly from Pygments by
|
||||
using the included Python 3 script `pygments2chroma.py`. I use something like
|
||||
the following:
|
||||
|
||||
```sh
|
||||
python3 _tools/pygments2chroma.py \
|
||||
pygments.lexers.jvm.KotlinLexer \
|
||||
> lexers/k/kotlin.go \
|
||||
&& gofmt -s -w lexers/k/kotlin.go
|
||||
```
|
||||
|
||||
See notes in [pygments-lexers.txt](https://github.com/alecthomas/chroma/blob/master/pygments-lexers.txt)
|
||||
for a list of lexers, and notes on some of the issues importing them.
|
||||
|
||||
<a id="markdown-formatters" name="formatters"></a>
|
||||
### Formatters
|
||||
|
||||
Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour, and true-colour.
|
||||
|
||||
A `noop` formatter is included that outputs the token text only, and a `tokens`
|
||||
formatter outputs raw tokens. The latter is useful for debugging lexers.
|
||||
|
||||
<a id="markdown-styles" name="styles"></a>
|
||||
### Styles
|
||||
|
||||
Chroma styles use the [same syntax](http://pygments.org/docs/styles/) as Pygments.
|
||||
|
||||
All Pygments styles have been converted to Chroma using the `_tools/style.py` script.
|
||||
|
||||
When you work with one of [Chroma's styles](https://github.com/alecthomas/chroma/tree/master/styles), know that the `chroma.Background` token type provides the default style for tokens. It does so by defining a foreground color and background color.
|
||||
|
||||
For example, this gives each token name not defined in the style a default color of `#f8f8f8` and uses `#000000` for the highlighted code block's background:
|
||||
|
||||
~~~go
|
||||
chroma.Background: "#f8f8f2 bg:#000000",
|
||||
~~~
|
||||
|
||||
Also, token types in a style file are hierarchical. For instance, when `CommentSpecial` is not defined, Chroma uses the token style from `Comment`. So when several comment tokens use the same color, you'll only need to define `Comment` and override the one that has a different color.
|
||||
|
||||
For a quick overview of the available styles and how they look, check out the [Chroma Style Gallery](https://xyproto.github.io/splash/docs/).
|
||||
|
||||
<a id="markdown-command-line-interface" name="command-line-interface"></a>
|
||||
## Command-line interface
|
||||
|
||||
A command-line interface to Chroma is included.
|
||||
|
||||
Binaries are available to install from [the releases page](https://github.com/alecthomas/chroma/releases).
|
||||
|
||||
The CLI can be used as a preprocessor to colorise output of `less(1)`,
|
||||
see documentation for the `LESSOPEN` environment variable.
|
||||
|
||||
The `--fail` flag can be used to suppress output and return with exit status
|
||||
1 to facilitate falling back to some other preprocessor in case chroma
|
||||
does not resolve a specific lexer to use for the given file. For example:
|
||||
|
||||
```shell
|
||||
export LESSOPEN='| p() { chroma --fail "$1" || cat "$1"; }; p "%s"'
|
||||
```
|
||||
|
||||
Replace `cat` with your favourite fallback preprocessor.
|
||||
|
||||
When invoked as `.lessfilter`, the `--fail` flag is automatically turned
|
||||
on under the hood for easy integration with [lesspipe shipping with
|
||||
Debian and derivatives](https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS);
|
||||
for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`.
|
||||
|
||||
<a id="markdown-whats-missing-compared-to-pygments" name="whats-missing-compared-to-pygments"></a>
|
||||
## What's missing compared to Pygments?
|
||||
|
||||
- Quite a few lexers, for various reasons (pull-requests welcome):
|
||||
- Pygments lexers for complex languages often include custom code to
|
||||
handle certain aspects, such as Raku's ability to nest code inside
|
||||
regular expressions. These require time and effort to convert.
|
||||
- I mostly only converted languages I had heard of, to reduce the porting cost.
|
||||
- Some more esoteric features of Pygments are omitted for simplicity.
|
||||
- Though the Chroma API supports content detection, very few languages support them.
|
||||
I have plans to implement a statistical analyser at some point, but not enough time.
|
|
@ -1,60 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// ABAP lexer.
|
||||
var Abap = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ABAP",
|
||||
Aliases: []string{"abap"},
|
||||
Filenames: []string{"*.abap", "*.ABAP"},
|
||||
MimeTypes: []string{"text/x-abap"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
abapRules,
|
||||
))
|
||||
|
||||
func abapRules() Rules {
|
||||
return Rules{
|
||||
"common": {
|
||||
{`\s+`, Text, nil},
|
||||
{`^\*.*$`, CommentSingle, nil},
|
||||
{`\".*?\n`, CommentSingle, nil},
|
||||
{`##\w+`, CommentSpecial, nil},
|
||||
},
|
||||
"variable-names": {
|
||||
{`<\S+>`, NameVariable, nil},
|
||||
{`\w[\w~]*(?:(\[\])|->\*)?`, NameVariable, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("common"),
|
||||
{`CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION)`, Keyword, nil},
|
||||
{`(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|TRANSACTION|TRANSFORMATION))\b`, Keyword, nil},
|
||||
{`(FORM|PERFORM)(\s+)(\w+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`(PERFORM)(\s+)(\()(\w+)(\))`, ByGroups(Keyword, Text, Punctuation, NameVariable, Punctuation), nil},
|
||||
{`(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)`, ByGroups(Keyword, Text, NameFunction, Text, Keyword), nil},
|
||||
{`(METHOD)(\s+)([\w~]+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`(\s+)([\w\-]+)([=\-]>)([\w\-~]+)`, ByGroups(Text, NameVariable, Operator, NameFunction), nil},
|
||||
{`(?<=(=|-)>)([\w\-~]+)(?=\()`, NameFunction, nil},
|
||||
{`(TEXT)(-)(\d{3})`, ByGroups(Keyword, Punctuation, LiteralNumberInteger), nil},
|
||||
{`(TEXT)(-)(\w{3})`, ByGroups(Keyword, Punctuation, NameVariable), nil},
|
||||
{`(ADD-CORRESPONDING|AUTHORITY-CHECK|CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|DELETE-ADJACENT|DIVIDE-CORRESPONDING|EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|INTERFACE-POOL|INVERTED-DATE|LOAD-OF-PROGRAM|LOG-POINT|MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|OUTPUT-LENGTH|PRINT-CONTROL|SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|SYNTAX-CHECK|SYSTEM-EXCEPTIONS|TYPE-POOL|TYPE-POOLS|NO-DISPLAY)\b`, Keyword, nil},
|
||||
{`(?<![-\>])(CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|(PUBLIC|PRIVATE|PROTECTED)\s+SECTION|(TYPE|LIKE)\s+((LINE\s+OF|REF\s+TO|(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|(GROUP|ORDER) BY|HAVING|SEPARATED BY|GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|PF-STATUS|(PROPERTY|REFERENCE)\s+OF|RUN\s+TIME|TIME\s+(STAMP)?)?|SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|(CLOSE|OPEN)\s+(DATASET|CURSOR)|(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|DATABASE|SHARED\s+(MEMORY|BUFFER))|DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|FREE\s(MEMORY|OBJECT)?|PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|ON\s+(VALUE-REQUEST|HELP-REQUEST))|AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|SCREEN)|COMMENT|FUNCTION\s+KEY|INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|SKIP|ULINE)|LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|TO LIST-PROCESSING|TO TRANSACTION)(ENDING|STARTING)\s+AT|FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|(BEGIN|END)\s+OF|DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|COMPARING(\s+ALL\s+FIELDS)?|(INSERT|APPEND)(\s+INITIAL\s+LINE\s+(IN)?TO|\s+LINES\s+OF)?|IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|END-OF-(DEFINITION|PAGE|SELECTION)|WITH\s+FRAME(\s+TITLE)|(REPLACE|FIND)\s+((FIRST|ALL)\s+OCCURRENCES?\s+OF\s+)?(SUBSTRING|REGEX)?|MATCH\s+(LENGTH|COUNT|LINE|OFFSET)|(RESPECTING|IGNORING)\s+CASE|IN\s+UPDATE\s+TASK|(SOURCE|RESULT)\s+(XML)?|REFERENCE\s+INTO|AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE|COMMON\s+PART)\b`, Keyword, nil},
|
||||
{`(^|(?<=(\s|\.)))(ABBREVIATED|ABSTRACT|ADD|ALIASES|ALIGN|ALPHA|ASSERT|AS|ASSIGN(ING)?|AT(\s+FIRST)?|BACK|BLOCK|BREAK-POINT|CASE|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|COUNTRY|CURRENCY|DATA|DATE|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|DETAIL|DIRECTORY|DIVIDE|DO|DUMMY|ELSE(IF)?|ENDAT|ENDCASE|ENDCATCH|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|ENDIF|ENDINTERFACE|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|ENDWHILE|ENHANCEMENT|EVENTS|EXACT|EXCEPTIONS?|EXIT|EXPONENT|EXPORT|EXPORTING|EXTRACT|FETCH|FIELDS?|FOR|FORM|FORMAT|FREE|FROM|FUNCTION|HIDE|ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|LANGUAGE|LEAVE|LENGTH|LINES|LOAD|LOCAL|JOIN|KEY|NEXT|MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFIER|MODIFY|MOVE|MULTIPLY|NODES|NUMBER|OBLIGATORY|OBJECT|OF|OFF|ON|OTHERS|OVERLAY|PACK|PAD|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|PF\d\d|RAISE|RAISING|RANGES?|READ|RECEIVE|REDEFINITION|REFRESH|REJECT|REPORT|RESERVE|RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|REPLACE|SCROLL|SEARCH|SELECT|SHIFT|SIGN|SINGLE|SIZE|SKIP|SORT|SPLIT|STATICS|STOP|STYLE|SUBMATCHES|SUBMIT|SUBTRACT|SUM(?!\()|SUMMARY|SUMMING|SUPPLY|TABLE|TABLES|TIMESTAMP|TIMES?|TIMEZONE|TITLE|\??TO|TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|ULINE|UNDER|UNPACK|UPDATE|USING|VALUE|VALUES|VIA|VARYING|VARY|WAIT|WHEN|WHERE|WIDTH|WHILE|WITH|WINDOW|WRITE|XSD|ZERO)\b`, Keyword, nil},
|
||||
{`(abs|acos|asin|atan|boolc|boolx|bit_set|char_off|charlen|ceil|cmax|cmin|condense|contains|contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|count|count_any_of|count_any_not_of|dbmaxlen|distance|escape|exp|find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|insert|lines|log|log10|match|matches|nmax|nmin|numofchar|repeat|replace|rescale|reverse|round|segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|substring|substring_after|substring_from|substring_before|substring_to|tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|xstrlen)(\()\b`, ByGroups(NameBuiltin, Punctuation), nil},
|
||||
{`&[0-9]`, Name, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`(?<=(\s|.))(AND|OR|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b`, OperatorWord, nil},
|
||||
Include("variable-names"),
|
||||
{`[?*<>=\-+&]`, Operator, nil},
|
||||
{`'(''|[^'])*'`, LiteralStringSingle, nil},
|
||||
{"`([^`])*`", LiteralStringSingle, nil},
|
||||
{`([|}])([^{}|]*?)([|{])`, ByGroups(Punctuation, LiteralStringSingle, Punctuation), nil},
|
||||
{`[/;:()\[\],.]`, Punctuation, nil},
|
||||
{`(!)(\w+)`, ByGroups(Operator, Name), nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Abnf lexer.
|
||||
var Abnf = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ABNF",
|
||||
Aliases: []string{"abnf"},
|
||||
Filenames: []string{"*.abnf"},
|
||||
MimeTypes: []string{"text/x-abnf"},
|
||||
},
|
||||
abnfRules,
|
||||
))
|
||||
|
||||
func abnfRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`;.*$`, CommentSingle, nil},
|
||||
{`(%[si])?"[^"]*"`, Literal, nil},
|
||||
{`%b[01]+\-[01]+\b`, Literal, nil},
|
||||
{`%b[01]+(\.[01]+)*\b`, Literal, nil},
|
||||
{`%d[0-9]+\-[0-9]+\b`, Literal, nil},
|
||||
{`%d[0-9]+(\.[0-9]+)*\b`, Literal, nil},
|
||||
{`%x[0-9a-fA-F]+\-[0-9a-fA-F]+\b`, Literal, nil},
|
||||
{`%x[0-9a-fA-F]+(\.[0-9a-fA-F]+)*\b`, Literal, nil},
|
||||
{`\b[0-9]+\*[0-9]+`, Operator, nil},
|
||||
{`\b[0-9]+\*`, Operator, nil},
|
||||
{`\b[0-9]+`, Operator, nil},
|
||||
{`\*`, Operator, nil},
|
||||
{Words(``, `\b`, `ALPHA`, `BIT`, `CHAR`, `CR`, `CRLF`, `CTL`, `DIGIT`, `DQUOTE`, `HEXDIG`, `HTAB`, `LF`, `LWSP`, `OCTET`, `SP`, `VCHAR`, `WSP`), Keyword, nil},
|
||||
{`[a-zA-Z][a-zA-Z0-9-]+\b`, NameClass, nil},
|
||||
{`(=/|=|/)`, Operator, nil},
|
||||
{`[\[\]()]`, Punctuation, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Actionscript lexer.
|
||||
var Actionscript = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ActionScript",
|
||||
Aliases: []string{"as", "actionscript"},
|
||||
Filenames: []string{"*.as"},
|
||||
MimeTypes: []string{"application/x-actionscript", "text/x-actionscript", "text/actionscript"},
|
||||
NotMultiline: true,
|
||||
DotAll: true,
|
||||
},
|
||||
actionscriptRules,
|
||||
))
|
||||
|
||||
func actionscriptRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`/(\\\\|\\/|[^/\n])*/[gim]*`, LiteralStringRegex, nil},
|
||||
{`[~^*!%&<>|+=:;,/?\\-]+`, Operator, nil},
|
||||
{`[{}\[\]();.]+`, Punctuation, nil},
|
||||
{Words(``, `\b`, `case`, `default`, `for`, `each`, `in`, `while`, `do`, `break`, `return`, `continue`, `if`, `else`, `throw`, `try`, `catch`, `var`, `with`, `new`, `typeof`, `arguments`, `instanceof`, `this`, `switch`), Keyword, nil},
|
||||
{Words(``, `\b`, `class`, `public`, `final`, `internal`, `native`, `override`, `private`, `protected`, `static`, `import`, `extends`, `implements`, `interface`, `intrinsic`, `return`, `super`, `dynamic`, `function`, `const`, `get`, `namespace`, `package`, `set`), KeywordDeclaration, nil},
|
||||
{`(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\b`, KeywordConstant, nil},
|
||||
{Words(``, `\b`, `Accessibility`, `AccessibilityProperties`, `ActionScriptVersion`, `ActivityEvent`, `AntiAliasType`, `ApplicationDomain`, `AsBroadcaster`, `Array`, `AsyncErrorEvent`, `AVM1Movie`, `BevelFilter`, `Bitmap`, `BitmapData`, `BitmapDataChannel`, `BitmapFilter`, `BitmapFilterQuality`, `BitmapFilterType`, `BlendMode`, `BlurFilter`, `Boolean`, `ByteArray`, `Camera`, `Capabilities`, `CapsStyle`, `Class`, `Color`, `ColorMatrixFilter`, `ColorTransform`, `ContextMenu`, `ContextMenuBuiltInItems`, `ContextMenuEvent`, `ContextMenuItem`, `ConvultionFilter`, `CSMSettings`, `DataEvent`, `Date`, `DefinitionError`, `DeleteObjectSample`, `Dictionary`, `DisplacmentMapFilter`, `DisplayObject`, `DisplacmentMapFilterMode`, `DisplayObjectContainer`, `DropShadowFilter`, `Endian`, `EOFError`, `Error`, `ErrorEvent`, `EvalError`, `Event`, `EventDispatcher`, `EventPhase`, `ExternalInterface`, `FileFilter`, `FileReference`, `FileReferenceList`, `FocusDirection`, `FocusEvent`, `Font`, `FontStyle`, `FontType`, `FrameLabel`, `FullScreenEvent`, `Function`, `GlowFilter`, `GradientBevelFilter`, `GradientGlowFilter`, `GradientType`, `Graphics`, `GridFitType`, `HTTPStatusEvent`, `IBitmapDrawable`, `ID3Info`, `IDataInput`, `IDataOutput`, `IDynamicPropertyOutputIDynamicPropertyWriter`, `IEventDispatcher`, `IExternalizable`, `IllegalOperationError`, `IME`, `IMEConversionMode`, `IMEEvent`, `int`, `InteractiveObject`, `InterpolationMethod`, `InvalidSWFError`, `InvokeEvent`, `IOError`, `IOErrorEvent`, `JointStyle`, `Key`, `Keyboard`, `KeyboardEvent`, `KeyLocation`, `LineScaleMode`, `Loader`, `LoaderContext`, `LoaderInfo`, `LoadVars`, `LocalConnection`, `Locale`, `Math`, `Matrix`, `MemoryError`, `Microphone`, `MorphShape`, `Mouse`, `MouseEvent`, `MovieClip`, `MovieClipLoader`, `Namespace`, `NetConnection`, `NetStatusEvent`, `NetStream`, `NewObjectSample`, `Number`, `Object`, `ObjectEncoding`, `PixelSnapping`, `Point`, `PrintJob`, `PrintJobOptions`, `PrintJobOrientation`, `ProgressEvent`, `Proxy`, `QName`, `RangeError`, `Rectangle`, `ReferenceError`, `RegExp`, `Responder`, `Sample`, `Scene`, `ScriptTimeoutError`, `Security`, `SecurityDomain`, `SecurityError`, `SecurityErrorEvent`, `SecurityPanel`, `Selection`, `Shape`, `SharedObject`, `SharedObjectFlushStatus`, `SimpleButton`, `Socket`, `Sound`, `SoundChannel`, `SoundLoaderContext`, `SoundMixer`, `SoundTransform`, `SpreadMethod`, `Sprite`, `StackFrame`, `StackOverflowError`, `Stage`, `StageAlign`, `StageDisplayState`, `StageQuality`, `StageScaleMode`, `StaticText`, `StatusEvent`, `String`, `StyleSheet`, `SWFVersion`, `SyncEvent`, `SyntaxError`, `System`, `TextColorType`, `TextField`, `TextFieldAutoSize`, `TextFieldType`, `TextFormat`, `TextFormatAlign`, `TextLineMetrics`, `TextRenderer`, `TextSnapshot`, `Timer`, `TimerEvent`, `Transform`, `TypeError`, `uint`, `URIError`, `URLLoader`, `URLLoaderDataFormat`, `URLRequest`, `URLRequestHeader`, `URLRequestMethod`, `URLStream`, `URLVariabeles`, `VerifyError`, `Video`, `XML`, `XMLDocument`, `XMLList`, `XMLNode`, `XMLNodeType`, `XMLSocket`, `XMLUI`), NameBuiltin, nil},
|
||||
{Words(``, `\b`, `decodeURI`, `decodeURIComponent`, `encodeURI`, `escape`, `eval`, `isFinite`, `isNaN`, `isXMLName`, `clearInterval`, `fscommand`, `getTimer`, `getURL`, `getVersion`, `parseFloat`, `parseInt`, `setInterval`, `trace`, `updateAfterEvent`, `unescape`), NameFunction, nil},
|
||||
{`[$a-zA-Z_]\w*`, NameOther, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Actionscript 3 lexer.
|
||||
var Actionscript3 = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ActionScript 3",
|
||||
Aliases: []string{"as3", "actionscript3"},
|
||||
Filenames: []string{"*.as"},
|
||||
MimeTypes: []string{"application/x-actionscript3", "text/x-actionscript3", "text/actionscript3"},
|
||||
DotAll: true,
|
||||
},
|
||||
actionscript3Rules,
|
||||
))
|
||||
|
||||
func actionscript3Rules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(function\s+)([$a-zA-Z_]\w*)(\s*)(\()`, ByGroups(KeywordDeclaration, NameFunction, Text, Operator), Push("funcparams")},
|
||||
{`(var|const)(\s+)([$a-zA-Z_]\w*)(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?)`, ByGroups(KeywordDeclaration, Text, Name, Text, Punctuation, Text, KeywordType), nil},
|
||||
{`(import|package)(\s+)((?:[$a-zA-Z_]\w*|\.)+)(\s*)`, ByGroups(Keyword, Text, NameNamespace, Text), nil},
|
||||
{`(new)(\s+)([$a-zA-Z_]\w*(?:\.<\w+>)?)(\s*)(\()`, ByGroups(Keyword, Text, KeywordType, Text, Operator), nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`/(\\\\|\\/|[^\n])*/[gisx]*`, LiteralStringRegex, nil},
|
||||
{`(\.)([$a-zA-Z_]\w*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`(case|default|for|each|in|while|do|break|return|continue|if|else|throw|try|catch|with|new|typeof|arguments|instanceof|this|switch|import|include|as|is)\b`, Keyword, nil},
|
||||
{`(class|public|final|internal|native|override|private|protected|static|import|extends|implements|interface|intrinsic|return|super|dynamic|function|const|get|namespace|package|set)\b`, KeywordDeclaration, nil},
|
||||
{`(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b`, KeywordConstant, nil},
|
||||
{`(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|unescape)\b`, NameFunction, nil},
|
||||
{`[$a-zA-Z_]\w*`, Name, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`[~^*!%&<>|+=:;,/?\\{}\[\]().-]+`, Operator, nil},
|
||||
},
|
||||
"funcparams": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(\s*)(\.\.\.)?([$a-zA-Z_]\w*)(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?|\*)(\s*)`, ByGroups(Text, Punctuation, Name, Text, Operator, Text, KeywordType, Text), Push("defval")},
|
||||
{`\)`, Operator, Push("type")},
|
||||
},
|
||||
"type": {
|
||||
{`(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?|\*)`, ByGroups(Text, Operator, Text, KeywordType), Pop(2)},
|
||||
{`\s+`, Text, Pop(2)},
|
||||
Default(Pop(2)),
|
||||
},
|
||||
"defval": {
|
||||
{`(=)(\s*)([^(),]+)(\s*)(,?)`, ByGroups(Operator, Text, UsingSelf("root"), Text, Operator), Pop(1)},
|
||||
{`,`, Operator, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Ada lexer.
|
||||
var Ada = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Ada",
|
||||
Aliases: []string{"ada", "ada95", "ada2005"},
|
||||
Filenames: []string{"*.adb", "*.ads", "*.ada"},
|
||||
MimeTypes: []string{"text/x-ada"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
adaRules,
|
||||
))
|
||||
|
||||
func adaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`--.*?\n`, CommentSingle, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`function|procedure|entry`, KeywordDeclaration, Push("subprogram")},
|
||||
{`(subtype|type)(\s+)(\w+)`, ByGroups(KeywordDeclaration, Text, KeywordType), Push("type_def")},
|
||||
{`task|protected`, KeywordDeclaration, nil},
|
||||
{`(subtype)(\s+)`, ByGroups(KeywordDeclaration, Text), nil},
|
||||
{`(end)(\s+)`, ByGroups(KeywordReserved, Text), Push("end")},
|
||||
{`(pragma)(\s+)(\w+)`, ByGroups(KeywordReserved, Text, CommentPreproc), nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{Words(``, `\b`, `Address`, `Byte`, `Boolean`, `Character`, `Controlled`, `Count`, `Cursor`, `Duration`, `File_Mode`, `File_Type`, `Float`, `Generator`, `Integer`, `Long_Float`, `Long_Integer`, `Long_Long_Float`, `Long_Long_Integer`, `Natural`, `Positive`, `Reference_Type`, `Short_Float`, `Short_Integer`, `Short_Short_Float`, `Short_Short_Integer`, `String`, `Wide_Character`, `Wide_String`), KeywordType, nil},
|
||||
{`(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b`, OperatorWord, nil},
|
||||
{`generic|private`, KeywordDeclaration, nil},
|
||||
{`package`, KeywordDeclaration, Push("package")},
|
||||
{`array\b`, KeywordReserved, Push("array_def")},
|
||||
{`(with|use)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`(\w+)(\s*)(:)(\s*)(constant)`, ByGroups(NameConstant, Text, Punctuation, Text, KeywordReserved), nil},
|
||||
{`<<\w+>>`, NameLabel, nil},
|
||||
{`(\w+)(\s*)(:)(\s*)(declare|begin|loop|for|while)`, ByGroups(NameLabel, Text, Punctuation, Text, KeywordReserved), nil},
|
||||
{Words(`\b`, `\b`, `abort`, `abs`, `abstract`, `accept`, `access`, `aliased`, `all`, `array`, `at`, `begin`, `body`, `case`, `constant`, `declare`, `delay`, `delta`, `digits`, `do`, `else`, `elsif`, `end`, `entry`, `exception`, `exit`, `interface`, `for`, `goto`, `if`, `is`, `limited`, `loop`, `new`, `null`, `of`, `or`, `others`, `out`, `overriding`, `pragma`, `protected`, `raise`, `range`, `record`, `renames`, `requeue`, `return`, `reverse`, `select`, `separate`, `subtype`, `synchronized`, `task`, `tagged`, `terminate`, `then`, `type`, `until`, `when`, `while`, `xor`), KeywordReserved, nil},
|
||||
{`"[^"]*"`, LiteralString, nil},
|
||||
Include("attribute"),
|
||||
Include("numbers"),
|
||||
{`'[^']'`, LiteralStringChar, nil},
|
||||
{`(\w+)(\s*|[(,])`, ByGroups(Name, UsingSelf("root")), nil},
|
||||
{`(<>|=>|:=|[()|:;,.'])`, Punctuation, nil},
|
||||
{`[*<>+=/&-]`, Operator, nil},
|
||||
{`\n+`, Text, nil},
|
||||
},
|
||||
"numbers": {
|
||||
{`[0-9_]+#[0-9a-f]+#`, LiteralNumberHex, nil},
|
||||
{`[0-9_]+\.[0-9_]*`, LiteralNumberFloat, nil},
|
||||
{`[0-9_]+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"attribute": {
|
||||
{`(')(\w+)`, ByGroups(Punctuation, NameAttribute), nil},
|
||||
},
|
||||
"subprogram": {
|
||||
{`\(`, Punctuation, Push("#pop", "formal_part")},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`is\b`, KeywordReserved, Pop(1)},
|
||||
{`"[^"]+"|\w+`, NameFunction, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"end": {
|
||||
{`(if|case|record|loop|select)`, KeywordReserved, nil},
|
||||
{`"[^"]+"|[\w.]+`, NameFunction, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
},
|
||||
"type_def": {
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`\(`, Punctuation, Push("formal_part")},
|
||||
{`with|and|use`, KeywordReserved, nil},
|
||||
{`array\b`, KeywordReserved, Push("#pop", "array_def")},
|
||||
{`record\b`, KeywordReserved, Push("record_def")},
|
||||
{`(null record)(;)`, ByGroups(KeywordReserved, Punctuation), Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"array_def": {
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`(\w+)(\s+)(range)`, ByGroups(KeywordType, Text, KeywordReserved), nil},
|
||||
Include("root"),
|
||||
},
|
||||
"record_def": {
|
||||
{`end record`, KeywordReserved, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+`, NameNamespace, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"formal_part": {
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`\w+`, NameVariable, nil},
|
||||
{`,|:[^=]`, Punctuation, nil},
|
||||
{`(in|not|null|out|access)\b`, KeywordReserved, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"package": {
|
||||
{`body`, KeywordDeclaration, nil},
|
||||
{`is\s+new|renames`, KeywordReserved, nil},
|
||||
{`is`, KeywordReserved, Pop(1)},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`\(`, Punctuation, Push("package_instantiation")},
|
||||
{`([\w.]+)`, NameClass, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"package_instantiation": {
|
||||
{`("[^"]+"|\w+)(\s+)(=>)`, ByGroups(NameVariable, Text, Punctuation), nil},
|
||||
{`[\w.\'"]`, Text, nil},
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Al lexer.
|
||||
var Al = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "AL",
|
||||
Aliases: []string{"al"},
|
||||
Filenames: []string{"*.al", "*.dal"},
|
||||
MimeTypes: []string{"text/x-al"},
|
||||
DotAll: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
alRules,
|
||||
))
|
||||
|
||||
// https://github.com/microsoft/AL/blob/master/grammar/alsyntax.tmlanguage
|
||||
func alRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
{`(?s)\/\*.*?\\*\*\/`, CommentMultiline, nil},
|
||||
{`(?s)//.*?\n`, CommentSingle, nil},
|
||||
{`\"([^\"])*\"`, Text, nil},
|
||||
{`'([^'])*'`, LiteralString, nil},
|
||||
{`\b(?i:(ARRAY|ASSERTERROR|BEGIN|BREAK|CASE|DO|DOWNTO|ELSE|END|EVENT|EXIT|FOR|FOREACH|FUNCTION|IF|IMPLEMENTS|IN|INDATASET|INTERFACE|INTERNAL|LOCAL|OF|PROCEDURE|PROGRAM|PROTECTED|REPEAT|RUNONCLIENT|SECURITYFILTERING|SUPPRESSDISPOSE|TEMPORARY|THEN|TO|TRIGGER|UNTIL|VAR|WHILE|WITH|WITHEVENTS))\b`, Keyword, nil},
|
||||
{`\b(?i:(AND|DIV|MOD|NOT|OR|XOR))\b`, OperatorWord, nil},
|
||||
{`\b(?i:(AVERAGE|CONST|COUNT|EXIST|FIELD|FILTER|LOOKUP|MAX|MIN|ORDER|SORTING|SUM|TABLEDATA|UPPERLIMIT|WHERE|ASCENDING|DESCENDING))\b`, Keyword, nil},
|
||||
{`\b(?i:(CODEUNIT|PAGE|PAGEEXTENSION|PAGECUSTOMIZATION|DOTNET|ENUM|ENUMEXTENSION|VALUE|QUERY|REPORT|TABLE|TABLEEXTENSION|XMLPORT|PROFILE|CONTROLADDIN|REPORTEXTENSION|INTERFACE|PERMISSIONSET|PERMISSIONSETEXTENSION|ENTITLEMENT))\b`, Keyword, nil},
|
||||
{`\b(?i:(Action|Array|Automation|BigInteger|BigText|Blob|Boolean|Byte|Char|ClientType|Code|Codeunit|CompletionTriggerErrorLevel|ConnectionType|Database|DataClassification|DataScope|Date|DateFormula|DateTime|Decimal|DefaultLayout|Dialog|Dictionary|DotNet|DotNetAssembly|DotNetTypeDeclaration|Duration|Enum|ErrorInfo|ErrorType|ExecutionContext|ExecutionMode|FieldClass|FieldRef|FieldType|File|FilterPageBuilder|Guid|InStream|Integer|Joker|KeyRef|List|ModuleDependencyInfo|ModuleInfo|None|Notification|NotificationScope|ObjectType|Option|OutStream|Page|PageResult|Query|Record|RecordId|RecordRef|Report|ReportFormat|SecurityFilter|SecurityFiltering|Table|TableConnectionType|TableFilter|TestAction|TestField|TestFilterField|TestPage|TestPermissions|TestRequestPage|Text|TextBuilder|TextConst|TextEncoding|Time|TransactionModel|TransactionType|Variant|Verbosity|Version|XmlPort|HttpContent|HttpHeaders|HttpClient|HttpRequestMessage|HttpResponseMessage|JsonToken|JsonValue|JsonArray|JsonObject|View|Views|XmlAttribute|XmlAttributeCollection|XmlComment|XmlCData|XmlDeclaration|XmlDocument|XmlDocumentType|XmlElement|XmlNamespaceManager|XmlNameTable|XmlNode|XmlNodeList|XmlProcessingInstruction|XmlReadOptions|XmlText|XmlWriteOptions|WebServiceActionContext|WebServiceActionResultCode|SessionSettings))\b`, Keyword, nil},
|
||||
{`\b([<>]=|<>|<|>)\b?`, Operator, nil},
|
||||
{`\b(\-|\+|\/|\*)\b`, Operator, nil},
|
||||
{`\s*(\:=|\+=|-=|\/=|\*=)\s*?`, Operator, nil},
|
||||
{`\b(?i:(ADD|ADDFIRST|ADDLAST|ADDAFTER|ADDBEFORE|ACTION|ACTIONS|AREA|ASSEMBLY|CHARTPART|CUEGROUP|CUSTOMIZES|COLUMN|DATAITEM|DATASET|ELEMENTS|EXTENDS|FIELD|FIELDGROUP|FIELDATTRIBUTE|FIELDELEMENT|FIELDGROUPS|FIELDS|FILTER|FIXED|GRID|GROUP|MOVEAFTER|MOVEBEFORE|KEY|KEYS|LABEL|LABELS|LAYOUT|MODIFY|MOVEFIRST|MOVELAST|MOVEBEFORE|MOVEAFTER|PART|REPEATER|USERCONTROL|REQUESTPAGE|SCHEMA|SEPARATOR|SYSTEMPART|TABLEELEMENT|TEXTATTRIBUTE|TEXTELEMENT|TYPE))\b`, Keyword, nil},
|
||||
{`\s*[(\.\.)&\|]\s*`, Operator, nil},
|
||||
{`\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b`, LiteralNumber, nil},
|
||||
{`[;:,]`, Punctuation, nil},
|
||||
{`#[ \t]*(if|else|elif|endif|define|undef|region|endregion|pragma)\b.*?\n`, CommentPreproc, nil},
|
||||
{`\w+`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Angular2 lexer.
|
||||
var Angular2 = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Angular2",
|
||||
Aliases: []string{"ng2"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
angular2Rules,
|
||||
))
|
||||
|
||||
func angular2Rules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^{([*#]+`, Other, nil},
|
||||
{`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("ngExpression")},
|
||||
{`([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text, Operator, Text), Push("attr")},
|
||||
{`([([]+)([\w:.-]+)([\])]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text), nil},
|
||||
{`([*#])([\w:.-]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Operator), Push("attr")},
|
||||
{`([*#])([\w:.-]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation), nil},
|
||||
},
|
||||
"ngExpression": {
|
||||
{`\s+(\|\s+)?`, Text, nil},
|
||||
{`\}\}`, CommentPreproc, Pop(1)},
|
||||
{`:?(true|false)`, LiteralStringBoolean, nil},
|
||||
{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
|
||||
{`[a-zA-Z][\w-]*(\(.*\))?`, NameVariable, nil},
|
||||
{`\.[\w-]+(\(.*\))?`, NameVariable, nil},
|
||||
{`(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)`, ByGroups(Operator, Text, LiteralString, Text, Operator, Text, LiteralString, Text), nil},
|
||||
},
|
||||
"attr": {
|
||||
{`".*?"`, LiteralString, Pop(1)},
|
||||
{`'.*?'`, LiteralString, Pop(1)},
|
||||
{`[^\s>]+`, LiteralString, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// ANTLR lexer.
|
||||
var ANTLR = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ANTLR",
|
||||
Aliases: []string{"antlr"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
antlrRules,
|
||||
))
|
||||
|
||||
func antlrRules() Rules {
|
||||
return Rules{
|
||||
"whitespace": {
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
},
|
||||
"comments": {
|
||||
{`//.*$`, Comment, nil},
|
||||
{`/\*(.|\n)*?\*/`, Comment, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
Include("comments"),
|
||||
{`(lexer|parser|tree)?(\s*)(grammar\b)(\s*)([A-Za-z]\w*)(;)`, ByGroups(Keyword, TextWhitespace, Keyword, TextWhitespace, NameClass, Punctuation), nil},
|
||||
{`options\b`, Keyword, Push("options")},
|
||||
{`tokens\b`, Keyword, Push("tokens")},
|
||||
{`(scope)(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(Keyword, TextWhitespace, NameVariable, TextWhitespace, Punctuation), Push("action")},
|
||||
{`(catch|finally)\b`, Keyword, Push("exception")},
|
||||
{`(@[A-Za-z]\w*)(\s*)(::)?(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, NameLabel, TextWhitespace, Punctuation), Push("action")},
|
||||
{`((?:protected|private|public|fragment)\b)?(\s*)([A-Za-z]\w*)(!)?`, ByGroups(Keyword, TextWhitespace, NameLabel, Punctuation), Push("rule-alts", "rule-prelims")},
|
||||
},
|
||||
"exception": {
|
||||
{`\n`, TextWhitespace, Pop(1)},
|
||||
{`\s`, TextWhitespace, nil},
|
||||
Include("comments"),
|
||||
{`\[`, Punctuation, Push("nested-arg-action")},
|
||||
{`\{`, Punctuation, Push("action")},
|
||||
},
|
||||
"rule-prelims": {
|
||||
Include("whitespace"),
|
||||
Include("comments"),
|
||||
{`returns\b`, Keyword, nil},
|
||||
{`\[`, Punctuation, Push("nested-arg-action")},
|
||||
{`\{`, Punctuation, Push("action")},
|
||||
{`(throws)(\s+)([A-Za-z]\w*)`, ByGroups(Keyword, TextWhitespace, NameLabel), nil},
|
||||
{`(,)(\s*)([A-Za-z]\w*)`, ByGroups(Punctuation, TextWhitespace, NameLabel), nil},
|
||||
{`options\b`, Keyword, Push("options")},
|
||||
{`(scope)(\s+)(\{)`, ByGroups(Keyword, TextWhitespace, Punctuation), Push("action")},
|
||||
{`(scope)(\s+)([A-Za-z]\w*)(\s*)(;)`, ByGroups(Keyword, TextWhitespace, NameLabel, TextWhitespace, Punctuation), nil},
|
||||
{`(@[A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation), Push("action")},
|
||||
{`:`, Punctuation, Pop(1)},
|
||||
},
|
||||
"rule-alts": {
|
||||
Include("whitespace"),
|
||||
Include("comments"),
|
||||
{`options\b`, Keyword, Push("options")},
|
||||
{`:`, Punctuation, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralString, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`<<([^>]|>[^>])>>`, LiteralString, nil},
|
||||
{`\$?[A-Z_]\w*`, NameConstant, nil},
|
||||
{`\$?[a-z_]\w*`, NameVariable, nil},
|
||||
{`(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)`, Operator, nil},
|
||||
{`,`, Punctuation, nil},
|
||||
{`\[`, Punctuation, Push("nested-arg-action")},
|
||||
{`\{`, Punctuation, Push("action")},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
},
|
||||
"tokens": {
|
||||
Include("whitespace"),
|
||||
Include("comments"),
|
||||
{`\{`, Punctuation, nil},
|
||||
{`([A-Z]\w*)(\s*)(=)?(\s*)(\'(?:\\\\|\\\'|[^\']*)\')?(\s*)(;)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, LiteralString, TextWhitespace, Punctuation), nil},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"options": {
|
||||
Include("whitespace"),
|
||||
Include("comments"),
|
||||
{`\{`, Punctuation, nil},
|
||||
{`([A-Za-z]\w*)(\s*)(=)(\s*)([A-Za-z]\w*|\'(?:\\\\|\\\'|[^\']*)\'|[0-9]+|\*)(\s*)(;)`, ByGroups(NameVariable, TextWhitespace, Punctuation, TextWhitespace, Text, TextWhitespace, Punctuation), nil},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"action": {
|
||||
{`([^${}\'"/\\]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|\\(?!%)|/)+`, Other, nil},
|
||||
{`(\\)(%)`, ByGroups(Punctuation, Other), nil},
|
||||
{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
|
||||
{`\{`, Punctuation, Push()},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"nested-arg-action": {
|
||||
{`([^$\[\]\'"/]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|/)+`, Other, nil},
|
||||
{`\[`, Punctuation, Push()},
|
||||
{`\]`, Punctuation, Pop(1)},
|
||||
{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
|
||||
{`(\\\\|\\\]|\\\[|[^\[\]])+`, Other, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Apacheconf lexer.
|
||||
var Apacheconf = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ApacheConf",
|
||||
Aliases: []string{"apacheconf", "aconf", "apache"},
|
||||
Filenames: []string{".htaccess", "apache.conf", "apache2.conf"},
|
||||
MimeTypes: []string{"text/x-apacheconf"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
apacheconfRules,
|
||||
))
|
||||
|
||||
func apacheconfRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(#.*?)$`, Comment, nil},
|
||||
{`(<[^\s>]+)(?:(\s+)(.*?))?(>)`, ByGroups(NameTag, Text, LiteralString, NameTag), nil},
|
||||
{`([a-z]\w*)(\s+)`, ByGroups(NameBuiltin, Text), Push("value")},
|
||||
{`\.+`, Text, nil},
|
||||
},
|
||||
"value": {
|
||||
{`\\\n`, Text, nil},
|
||||
{`$`, Text, Pop(1)},
|
||||
{`\\`, Text, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil},
|
||||
{`\d+`, LiteralNumber, nil},
|
||||
{`/([a-z0-9][\w./-]+)`, LiteralStringOther, nil},
|
||||
{`(on|off|none|any|all|double|email|dns|min|minimal|os|productonly|full|emerg|alert|crit|error|warn|notice|info|debug|registry|script|inetd|standalone|user|group)\b`, Keyword, nil},
|
||||
{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil},
|
||||
{`[^\s"\\]+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Apl lexer.
|
||||
var Apl = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "APL",
|
||||
Aliases: []string{"apl"},
|
||||
Filenames: []string{"*.apl"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
aplRules,
|
||||
))
|
||||
|
||||
func aplRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`[⍝#].*$`, CommentSingle, nil},
|
||||
{`\'((\'\')|[^\'])*\'`, LiteralStringSingle, nil},
|
||||
{`"(("")|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`[⋄◇()]`, Punctuation, nil},
|
||||
{`[\[\];]`, LiteralStringRegex, nil},
|
||||
{`⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*`, NameFunction, nil},
|
||||
{`[A-Za-zΔ∆⍙_][A-Za-zΔ∆⍙_¯0-9]*`, NameVariable, nil},
|
||||
{`¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?`, LiteralNumber, nil},
|
||||
{`[\.\\/⌿⍀¨⍣⍨⍠⍤∘⍥@⌺⌶⍢]`, NameAttribute, nil},
|
||||
{`[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗⊆⍸]`, Operator, nil},
|
||||
{`⍬`, NameConstant, nil},
|
||||
{`[⎕⍞]`, NameVariableGlobal, nil},
|
||||
{`[←→]`, KeywordDeclaration, nil},
|
||||
{`[⍺⍵⍶⍹∇:]`, NameBuiltinPseudo, nil},
|
||||
{`[{}]`, KeywordType, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Applescript lexer.
|
||||
var Applescript = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "AppleScript",
|
||||
Aliases: []string{"applescript"},
|
||||
Filenames: []string{"*.applescript"},
|
||||
MimeTypes: []string{},
|
||||
DotAll: true,
|
||||
},
|
||||
applescriptRules,
|
||||
))
|
||||
|
||||
func applescriptRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`¬\n`, LiteralStringEscape, nil},
|
||||
{`'s\s+`, Text, nil},
|
||||
{`(--|#).*?$`, Comment, nil},
|
||||
{`\(\*`, CommentMultiline, Push("comment")},
|
||||
{`[(){}!,.:]`, Punctuation, nil},
|
||||
{`(«)([^»]+)(»)`, ByGroups(Text, NameBuiltin, Text), nil},
|
||||
{`\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)`, ByGroups(Keyword, NameBuiltin), nil},
|
||||
{`(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)`, Operator, nil},
|
||||
{`\b(and|or|is equal|equals|(is )?equal to|is not|isn't|isn't equal( to)?|is not equal( to)?|doesn't equal|does not equal|(is )?greater than|comes after|is not less than or equal( to)?|isn't less than or equal( to)?|(is )?less than|comes before|is not greater than or equal( to)?|isn't greater than or equal( to)?|(is )?greater than or equal( to)?|is not less than|isn't less than|does not come before|doesn't come before|(is )?less than or equal( to)?|is not greater than|isn't greater than|does not come after|doesn't come after|starts? with|begins? with|ends? with|contains?|does not contain|doesn't contain|is in|is contained by|is not in|is not contained by|isn't contained by|div|mod|not|(a )?(ref( to)?|reference to)|is|does)\b`, OperatorWord, nil},
|
||||
{`^(\s*(?:on|end)\s+)(zoomed|write to file|will zoom|will show|will select tab view item|will resize( sub views)?|will resign active|will quit|will pop up|will open|will move|will miniaturize|will hide|will finish launching|will display outline cell|will display item cell|will display cell|will display browser cell|will dismiss|will close|will become active|was miniaturized|was hidden|update toolbar item|update parameters|update menu item|shown|should zoom|should selection change|should select tab view item|should select row|should select item|should select column|should quit( after last window closed)?|should open( untitled)?|should expand item|should end editing|should collapse item|should close|should begin editing|selection changing|selection changed|selected tab view item|scroll wheel|rows changed|right mouse up|right mouse dragged|right mouse down|resized( sub views)?|resigned main|resigned key|resigned active|read from file|prepare table drop|prepare table drag|prepare outline drop|prepare outline drag|prepare drop|plugin loaded|parameters updated|panel ended|opened|open untitled|number of rows|number of items|number of browser rows|moved|mouse up|mouse moved|mouse exited|mouse entered|mouse dragged|mouse down|miniaturized|load data representation|launched|keyboard up|keyboard down|items changed|item value changed|item value|item expandable|idle|exposed|end editing|drop|drag( (entered|exited|updated))?|double clicked|document nib name|dialog ended|deminiaturized|data representation|conclude drop|column resized|column moved|column clicked|closed|clicked toolbar item|clicked|choose menu item|child of item|changed|change item value|change cell value|cell value changed|cell value|bounds changed|begin editing|became main|became key|awake from nib|alert ended|activated|action|accept table drop|accept outline drop)`, ByGroups(Keyword, NameFunction), nil},
|
||||
{`^(\s*)(in|on|script|to)(\s+)`, ByGroups(Text, Keyword, Text), nil},
|
||||
{`\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b`, ByGroups(Keyword, NameClass), nil},
|
||||
{`\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b`, NameConstant, nil},
|
||||
{`\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b`, NameBuiltin, nil},
|
||||
{`\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|with|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b`, Keyword, nil},
|
||||
{`\b(global|local|prop(erty)?|set|get)\b`, Keyword, nil},
|
||||
{`\b(but|put|returning|the)\b`, NameBuiltin, nil},
|
||||
{`\b(attachment|attribute run|character|day|month|paragraph|word|year)s?\b`, NameBuiltin, nil},
|
||||
{`\b(about|above|against|apart from|around|aside from|at|below|beneath|beside|between|for|given|instead of|on|onto|out of|over|since)\b`, NameBuiltin, nil},
|
||||
{`\b(accepts arrow key|action method|active|alignment|allowed identifiers|allows branch selection|allows column reordering|allows column resizing|allows column selection|allows customization|allows editing text attributes|allows empty selection|allows mixed state|allows multiple selection|allows reordering|allows undo|alpha( value)?|alternate image|alternate increment value|alternate title|animation delay|associated file name|associated object|auto completes|auto display|auto enables items|auto repeat|auto resizes( outline column)?|auto save expanded items|auto save name|auto save table columns|auto saves configuration|auto scroll|auto sizes all columns to fit|auto sizes cells|background color|bezel state|bezel style|bezeled|border rect|border type|bordered|bounds( rotation)?|box type|button returned|button type|can choose directories|can choose files|can draw|can hide|cell( (background color|size|type))?|characters|class|click count|clicked( data)? column|clicked data item|clicked( data)? row|closeable|collating|color( (mode|panel))|command key down|configuration|content(s| (size|view( margins)?))?|context|continuous|control key down|control size|control tint|control view|controller visible|coordinate system|copies( on scroll)?|corner view|current cell|current column|current( field)? editor|current( menu)? item|current row|current tab view item|data source|default identifiers|delta (x|y|z)|destination window|directory|display mode|displayed cell|document( (edited|rect|view))?|double value|dragged column|dragged distance|dragged items|draws( cell)? background|draws grid|dynamically scrolls|echos bullets|edge|editable|edited( data)? column|edited data item|edited( data)? row|enabled|enclosing scroll view|ending page|error handling|event number|event type|excluded from windows menu|executable path|expanded|fax number|field editor|file kind|file name|file type|first responder|first visible column|flipped|floating|font( panel)?|formatter|frameworks path|frontmost|gave up|grid color|has data items|has horizontal ruler|has horizontal scroller|has parent data item|has resize indicator|has shadow|has sub menu|has vertical ruler|has vertical scroller|header cell|header view|hidden|hides when deactivated|highlights by|horizontal line scroll|horizontal page scroll|horizontal ruler view|horizontally resizable|icon image|id|identifier|ignores multiple clicks|image( (alignment|dims when disabled|frame style|scaling))?|imports graphics|increment value|indentation per level|indeterminate|index|integer value|intercell spacing|item height|key( (code|equivalent( modifier)?|window))?|knob thickness|label|last( visible)? column|leading offset|leaf|level|line scroll|loaded|localized sort|location|loop mode|main( (bunde|menu|window))?|marker follows cell|matrix mode|maximum( content)? size|maximum visible columns|menu( form representation)?|miniaturizable|miniaturized|minimized image|minimized title|minimum column width|minimum( content)? size|modal|modified|mouse down state|movie( (controller|file|rect))?|muted|name|needs display|next state|next text|number of tick marks|only tick mark values|opaque|open panel|option key down|outline table column|page scroll|pages across|pages down|palette label|pane splitter|parent data item|parent window|pasteboard|path( (names|separator))?|playing|plays every frame|plays selection only|position|preferred edge|preferred type|pressure|previous text|prompt|properties|prototype cell|pulls down|rate|released when closed|repeated|requested print time|required file type|resizable|resized column|resource path|returns records|reuses columns|rich text|roll over|row height|rulers visible|save panel|scripts path|scrollable|selectable( identifiers)?|selected cell|selected( data)? columns?|selected data items?|selected( data)? rows?|selected item identifier|selection by rect|send action on arrow key|sends action when done editing|separates columns|separator item|sequence number|services menu|shared frameworks path|shared support path|sheet|shift key down|shows alpha|shows state by|size( mode)?|smart insert delete enabled|sort case sensitivity|sort column|sort order|sort type|sorted( data rows)?|sound|source( mask)?|spell checking enabled|starting page|state|string value|sub menu|super menu|super view|tab key traverses cells|tab state|tab type|tab view|table view|tag|target( printer)?|text color|text container insert|text container origin|text returned|tick mark position|time stamp|title(d| (cell|font|height|position|rect))?|tool tip|toolbar|trailing offset|transparent|treat packages as directories|truncated labels|types|unmodified characters|update views|use sort indicator|user defaults|uses data source|uses ruler|uses threaded animation|uses title from previous column|value wraps|version|vertical( (line scroll|page scroll|ruler view))?|vertically resizable|view|visible( document rect)?|volume|width|window|windows menu|wraps|zoomable|zoomed)\b`, NameAttribute, nil},
|
||||
{`\b(action cell|alert reply|application|box|browser( cell)?|bundle|button( cell)?|cell|clip view|color well|color-panel|combo box( item)?|control|data( (cell|column|item|row|source))?|default entry|dialog reply|document|drag info|drawer|event|font(-panel)?|formatter|image( (cell|view))?|matrix|menu( item)?|item|movie( view)?|open-panel|outline view|panel|pasteboard|plugin|popup button|progress indicator|responder|save-panel|scroll view|secure text field( cell)?|slider|sound|split view|stepper|tab view( item)?|table( (column|header cell|header view|view))|text( (field( cell)?|view))?|toolbar( item)?|user-defaults|view|window)s?\b`, NameBuiltin, nil},
|
||||
{`\b(animate|append|call method|center|close drawer|close panel|display|display alert|display dialog|display panel|go|hide|highlight|increment|item for|load image|load movie|load nib|load panel|load sound|localized string|lock focus|log|open drawer|path for|pause|perform action|play|register|resume|scroll|select( all)?|show|size to fit|start|step back|step forward|stop|synchronize|unlock focus|update)\b`, NameBuiltin, nil},
|
||||
{`\b((in )?back of|(in )?front of|[0-9]+(st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|after|back|before|behind|every|front|index|last|middle|some|that|through|thru|where|whose)\b`, NameBuiltin, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`\b([a-zA-Z]\w*)\b`, NameVariable, nil},
|
||||
{`[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`[-+]?\d+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`\(\*`, CommentMultiline, Push()},
|
||||
{`\*\)`, CommentMultiline, Pop(1)},
|
||||
{`[^*(]+`, CommentMultiline, nil},
|
||||
{`[*(]`, CommentMultiline, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Arduino lexer.
|
||||
var Arduino = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Arduino",
|
||||
Aliases: []string{"arduino"},
|
||||
Filenames: []string{"*.ino"},
|
||||
MimeTypes: []string{"text/x-arduino"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
arduinoRules,
|
||||
))
|
||||
|
||||
func arduinoRules() Rules {
|
||||
return Rules{
|
||||
"statements": {
|
||||
{Words(``, `\b`, `catch`, `const_cast`, `delete`, `dynamic_cast`, `explicit`, `export`, `friend`, `mutable`, `namespace`, `new`, `operator`, `private`, `protected`, `public`, `reinterpret_cast`, `restrict`, `static_cast`, `template`, `this`, `throw`, `throws`, `try`, `typeid`, `typename`, `using`, `virtual`, `constexpr`, `nullptr`, `decltype`, `thread_local`, `alignas`, `alignof`, `static_assert`, `noexcept`, `override`, `final`), Keyword, nil},
|
||||
{`char(16_t|32_t)\b`, KeywordType, nil},
|
||||
{`(class)\b`, ByGroups(Keyword, Text), Push("classname")},
|
||||
{`(R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")`, ByGroups(LiteralStringAffix, LiteralString, LiteralStringDelimiter, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, LiteralString), nil},
|
||||
{`(u8|u|U)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||
{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||
{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil},
|
||||
{`0[0-7]+[LlUu]*`, LiteralNumberOct, nil},
|
||||
{`\d+[LlUu]*`, LiteralNumberInteger, nil},
|
||||
{`\*/`, Error, nil},
|
||||
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
|
||||
{`[()\[\],.]`, Punctuation, nil},
|
||||
{Words(``, `\b`, `asm`, `auto`, `break`, `case`, `const`, `continue`, `default`, `do`, `else`, `enum`, `extern`, `for`, `goto`, `if`, `register`, `restricted`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `volatile`, `while`), Keyword, nil},
|
||||
{`(_Bool|_Complex|_Imaginary|array|atomic_bool|atomic_char|atomic_int|atomic_llong|atomic_long|atomic_schar|atomic_short|atomic_uchar|atomic_uint|atomic_ullong|atomic_ulong|atomic_ushort|auto|bool|boolean|BooleanVariables|Byte|byte|Char|char|char16_t|char32_t|class|complex|Const|const|const_cast|delete|double|dynamic_cast|enum|explicit|extern|Float|float|friend|inline|Int|int|int16_t|int32_t|int64_t|int8_t|Long|long|new|NULL|null|operator|private|PROGMEM|protected|public|register|reinterpret_cast|short|signed|sizeof|Static|static|static_cast|String|struct|typedef|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|virtual|Void|void|Volatile|volatile|word)\b`, KeywordType, nil},
|
||||
// Start of: Arduino-specific syntax
|
||||
{`(and|final|If|Loop|loop|not|or|override|setup|Setup|throw|try|xor)\b`, Keyword, nil}, // Addition to keywords already defined by C++
|
||||
{`(ANALOG_MESSAGE|BIN|CHANGE|DEC|DEFAULT|DIGITAL_MESSAGE|EXTERNAL|FALLING|FIRMATA_STRING|HALF_PI|HEX|HIGH|INPUT|INPUT_PULLUP|INTERNAL|INTERNAL1V1|INTERNAL1V1|INTERNAL2V56|INTERNAL2V56|LED_BUILTIN|LED_BUILTIN_RX|LED_BUILTIN_TX|LOW|LSBFIRST|MSBFIRST|OCT|OUTPUT|PI|REPORT_ANALOG|REPORT_DIGITAL|RISING|SET_PIN_MODE|SYSEX_START|SYSTEM_RESET|TWO_PI)\b`, KeywordConstant, nil},
|
||||
{`(boolean|const|byte|word|string|String|array)\b`, NameVariable, nil},
|
||||
{`(Keyboard|KeyboardController|MouseController|SoftwareSerial|EthernetServer|EthernetClient|LiquidCrystal|RobotControl|GSMVoiceCall|EthernetUDP|EsploraTFT|HttpClient|RobotMotor|WiFiClient|GSMScanner|FileSystem|Scheduler|GSMServer|YunClient|YunServer|IPAddress|GSMClient|GSMModem|Keyboard|Ethernet|Console|GSMBand|Esplora|Stepper|Process|WiFiUDP|GSM_SMS|Mailbox|USBHost|Firmata|PImage|Client|Server|GSMPIN|FileIO|Bridge|Serial|EEPROM|Stream|Mouse|Audio|Servo|File|Task|GPRS|WiFi|Wire|TFT|GSM|SPI|SD)\b`, NameClass, nil},
|
||||
{`(abs|Abs|accept|ACos|acos|acosf|addParameter|analogRead|AnalogRead|analogReadResolution|AnalogReadResolution|analogReference|AnalogReference|analogWrite|AnalogWrite|analogWriteResolution|AnalogWriteResolution|answerCall|asin|ASin|asinf|atan|ATan|atan2|ATan2|atan2f|atanf|attach|attached|attachGPRS|attachInterrupt|AttachInterrupt|autoscroll|available|availableForWrite|background|beep|begin|beginPacket|beginSD|beginSMS|beginSpeaker|beginTFT|beginTransmission|beginWrite|bit|Bit|BitClear|bitClear|bitRead|BitRead|bitSet|BitSet|BitWrite|bitWrite|blink|blinkVersion|BSSID|buffer|byte|cbrt|cbrtf|Ceil|ceil|ceilf|changePIN|char|charAt|checkPIN|checkPUK|checkReg|circle|cityNameRead|cityNameWrite|clear|clearScreen|click|close|compareTo|compassRead|concat|config|connect|connected|constrain|Constrain|copysign|copysignf|cos|Cos|cosf|cosh|coshf|countryNameRead|countryNameWrite|createChar|cursor|debugPrint|degrees|Delay|delay|DelayMicroseconds|delayMicroseconds|detach|DetachInterrupt|detachInterrupt|DigitalPinToInterrupt|digitalPinToInterrupt|DigitalRead|digitalRead|DigitalWrite|digitalWrite|disconnect|display|displayLogos|drawBMP|drawCompass|encryptionType|end|endPacket|endSMS|endsWith|endTransmission|endWrite|equals|equalsIgnoreCase|exists|exitValue|Exp|exp|expf|fabs|fabsf|fdim|fdimf|fill|find|findUntil|float|floor|Floor|floorf|flush|fma|fmaf|fmax|fmaxf|fmin|fminf|fmod|fmodf|gatewayIP|get|getAsynchronously|getBand|getButton|getBytes|getCurrentCarrier|getIMEI|getKey|getModifiers|getOemKey|getPINUsed|getResult|getSignalStrength|getSocket|getVoiceCallStatus|getXChange|getYChange|hangCall|height|highByte|HighByte|home|hypot|hypotf|image|indexOf|int|interrupts|IPAddress|IRread|isActionDone|isAlpha|isAlphaNumeric|isAscii|isControl|isDigit|isDirectory|isfinite|isGraph|isHexadecimalDigit|isinf|isListening|isLowerCase|isnan|isPIN|isPressed|isPrintable|isPunct|isSpace|isUpperCase|isValid|isWhitespace|keyboardRead|keyPressed|keyReleased|knobRead|lastIndexOf|ldexp|ldexpf|leftToRight|length|line|lineFollowConfig|listen|listenOnLocalhost|loadImage|localIP|log|Log|log10|log10f|logf|long|lowByte|LowByte|lrint|lrintf|lround|lroundf|macAddress|maintain|map|Map|Max|max|messageAvailable|Micros|micros|millis|Millis|Min|min|mkdir|motorsStop|motorsWrite|mouseDragged|mouseMoved|mousePressed|mouseReleased|move|noAutoscroll|noBlink|noBuffer|noCursor|noDisplay|noFill|noInterrupts|NoInterrupts|noListenOnLocalhost|noStroke|noTone|NoTone|onReceive|onRequest|open|openNextFile|overflow|parseCommand|parseFloat|parseInt|parsePacket|pauseMode|peek|PinMode|pinMode|playFile|playMelody|point|pointTo|position|Pow|pow|powf|prepare|press|print|printFirmwareVersion|println|printVersion|process|processInput|PulseIn|pulseIn|pulseInLong|PulseInLong|put|radians|random|Random|randomSeed|RandomSeed|read|readAccelerometer|readBlue|readButton|readBytes|readBytesUntil|readGreen|readJoystickButton|readJoystickSwitch|readJoystickX|readJoystickY|readLightSensor|readMessage|readMicrophone|readNetworks|readRed|readSlider|readString|readStringUntil|readTemperature|ready|rect|release|releaseAll|remoteIP|remoteNumber|remotePort|remove|replace|requestFrom|retrieveCallingNumber|rewindDirectory|rightToLeft|rmdir|robotNameRead|robotNameWrite|round|roundf|RSSI|run|runAsynchronously|running|runShellCommand|runShellCommandAsynchronously|scanNetworks|scrollDisplayLeft|scrollDisplayRight|seek|sendAnalog|sendDigitalPortPair|sendDigitalPorts|sendString|sendSysex|Serial_Available|Serial_Begin|Serial_End|Serial_Flush|Serial_Peek|Serial_Print|Serial_Println|Serial_Read|serialEvent|setBand|setBitOrder|setCharAt|setClockDivider|setCursor|setDataMode|setDNS|setFirmwareVersion|setMode|setPINUsed|setSpeed|setTextSize|setTimeout|ShiftIn|shiftIn|ShiftOut|shiftOut|shutdown|signbit|sin|Sin|sinf|sinh|sinhf|size|sizeof|Sq|sq|Sqrt|sqrt|sqrtf|SSID|startLoop|startsWith|step|stop|stroke|subnetMask|substring|switchPIN|tan|Tan|tanf|tanh|tanhf|tempoWrite|text|toCharArray|toInt|toLowerCase|tone|Tone|toUpperCase|transfer|trim|trunc|truncf|tuneWrite|turn|updateIR|userNameRead|userNameWrite|voiceCall|waitContinue|width|WiFiServer|word|write|writeBlue|writeGreen|writeJSON|writeMessage|writeMicroseconds|writeRed|writeRGB|yield|Yield)\b`, NameFunction, nil},
|
||||
// End of: Arduino-specific syntax
|
||||
{Words(``, `\b`, `inline`, `_inline`, `__inline`, `naked`, `restrict`, `thread`, `typename`), KeywordReserved, nil},
|
||||
{`(__m(128i|128d|128|64))\b`, KeywordReserved, nil},
|
||||
{Words(`__`, `\b`, `asm`, `int8`, `based`, `except`, `int16`, `stdcall`, `cdecl`, `fastcall`, `int32`, `declspec`, `finally`, `int64`, `try`, `leave`, `wchar_t`, `w64`, `unaligned`, `raise`, `noop`, `identifier`, `forceinline`, `assume`), KeywordReserved, nil},
|
||||
{`(true|false|NULL)\b`, NameBuiltin, nil},
|
||||
{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
|
||||
Default(Push("statement")),
|
||||
{Words(`__`, `\b`, `virtual_inheritance`, `uuidof`, `super`, `single_inheritance`, `multiple_inheritance`, `interface`, `event`), KeywordReserved, nil},
|
||||
{`__(offload|blockingoffload|outer)\b`, KeywordPseudo, nil},
|
||||
},
|
||||
"classname": {
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
{`\s*(?=>)`, Text, Pop(1)},
|
||||
},
|
||||
"whitespace": {
|
||||
{`^#if\s+0`, CommentPreproc, Push("if0")},
|
||||
{`^#`, CommentPreproc, Push("macro")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
|
||||
},
|
||||
"statement": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`[{}]`, Punctuation, nil},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
},
|
||||
"function": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`;`, Punctuation, nil},
|
||||
{`\{`, Punctuation, Push()},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
{`[^\\"\n]+`, LiteralString, nil},
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\\`, LiteralString, nil},
|
||||
},
|
||||
"macro": {
|
||||
{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
|
||||
{`[^/\n]+`, CommentPreproc, nil},
|
||||
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
|
||||
{`//.*?\n`, CommentSingle, Pop(1)},
|
||||
{`/`, CommentPreproc, nil},
|
||||
{`(?<=\\)\n`, CommentPreproc, nil},
|
||||
{`\n`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
"if0": {
|
||||
{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
|
||||
{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
|
||||
{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
|
||||
{`.*?\n`, Comment, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
var ArmAsm = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ArmAsm",
|
||||
Aliases: []string{"armasm"},
|
||||
EnsureNL: true,
|
||||
Filenames: []string{"*.s", "*.S"},
|
||||
MimeTypes: []string{"text/x-armasm", "text/x-asm"},
|
||||
},
|
||||
armasmRules,
|
||||
))
|
||||
|
||||
func armasmRules() Rules {
|
||||
return Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`[@;].*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
},
|
||||
"literal": {
|
||||
// Binary
|
||||
{`0b[01]+`, NumberBin, Pop(1)},
|
||||
// Hex
|
||||
{`0x\w{1,8}`, NumberHex, Pop(1)},
|
||||
// Octal
|
||||
{`0\d+`, NumberOct, Pop(1)},
|
||||
// Float
|
||||
{`\d+?\.\d+?`, NumberFloat, Pop(1)},
|
||||
// Integer
|
||||
{`\d+`, NumberInteger, Pop(1)},
|
||||
// String
|
||||
{`(")(.+)(")`, ByGroups(Punctuation, StringDouble, Punctuation), Pop(1)},
|
||||
// Char
|
||||
{`(')(.{1}|\\.{1})(')`, ByGroups(Punctuation, StringChar, Punctuation), Pop(1)},
|
||||
},
|
||||
"opcode": {
|
||||
// Escape at line end
|
||||
{`\n`, Text, Pop(1)},
|
||||
// Comment
|
||||
{`(@|;).*\n`, CommentSingle, Pop(1)},
|
||||
// Whitespace
|
||||
{`(\s+|,)`, Text, nil},
|
||||
// Register by number
|
||||
{`[rapcfxwbhsdqv]\d{1,2}`, NameClass, nil},
|
||||
// Address by hex
|
||||
{`=0x\w+`, ByGroups(Text, NameLabel), nil},
|
||||
// Pseudo address by label
|
||||
{`(=)(\w+)`, ByGroups(Text, NameLabel), nil},
|
||||
// Immediate
|
||||
{`#`, Text, Push("literal")},
|
||||
},
|
||||
"root": {
|
||||
Include("commentsandwhitespace"),
|
||||
// Directive with optional param
|
||||
{`(\.\w+)([ \t]+\w+\s+?)?`, ByGroups(KeywordNamespace, NameLabel), nil},
|
||||
// Label with data
|
||||
{`(\w+)(:)(\s+\.\w+\s+)`, ByGroups(NameLabel, Punctuation, KeywordNamespace), Push("literal")},
|
||||
// Label
|
||||
{`(\w+)(:)`, ByGroups(NameLabel, Punctuation), nil},
|
||||
// Syscall Op
|
||||
{`svc\s+\w+`, NameNamespace, nil},
|
||||
// Opcode
|
||||
{`[a-zA-Z]+`, Text, Push("opcode")},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package a
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Awk lexer.
|
||||
var Awk = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Awk",
|
||||
Aliases: []string{"awk", "gawk", "mawk", "nawk"},
|
||||
Filenames: []string{"*.awk"},
|
||||
MimeTypes: []string{"application/x-awk"},
|
||||
},
|
||||
awkRules,
|
||||
))
|
||||
|
||||
func awkRules() Rules {
|
||||
return Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`#.*$`, CommentSingle, nil},
|
||||
},
|
||||
"slashstartsregex": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/\B`, LiteralStringRegex, Pop(1)},
|
||||
{`(?=/)`, Text, Push("#pop", "badregex")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"badregex": {
|
||||
{`\n`, Text, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
{`^(?=\s|/)`, Text, Push("slashstartsregex")},
|
||||
Include("commentsandwhitespace"),
|
||||
{`\+\+|--|\|\||&&|in\b|\$|!?~|\|&|(\*\*|[-<>+*%\^/!=|])=?`, Operator, Push("slashstartsregex")},
|
||||
{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
|
||||
{`[})\].]`, Punctuation, nil},
|
||||
{`(break|continue|do|while|exit|for|if|else|return|switch|case|default)\b`, Keyword, Push("slashstartsregex")},
|
||||
{`function\b`, KeywordDeclaration, Push("slashstartsregex")},
|
||||
{`(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|length|match|split|patsplit|sprintf|sub|substr|tolower|toupper|close|fflush|getline|next(file)|print|printf|strftime|systime|mktime|delete|system|strtonum|and|compl|lshift|or|rshift|asorti?|isarray|bindtextdomain|dcn?gettext|@(include|load|namespace))\b`, KeywordReserved, nil},
|
||||
{`(ARGC|ARGIND|ARGV|BEGIN(FILE)?|BINMODE|CONVFMT|ENVIRON|END(FILE)?|ERRNO|FIELDWIDTHS|FILENAME|FNR|FPAT|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS|PROCINFO|RLENGTH|RS|RSTART|RT|SUBSEP|TEXTDOMAIN)\b`, NameBuiltin, nil},
|
||||
{`[@$a-zA-Z_]\w*`, NameOther, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Ballerina lexer.
|
||||
var Ballerina = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Ballerina",
|
||||
Aliases: []string{"ballerina"},
|
||||
Filenames: []string{"*.bal"},
|
||||
MimeTypes: []string{"text/x-ballerina"},
|
||||
DotAll: true,
|
||||
},
|
||||
ballerinaRules,
|
||||
))
|
||||
|
||||
func ballerinaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`(break|catch|continue|done|else|finally|foreach|forever|fork|if|lock|match|return|throw|transaction|try|while)\b`, Keyword, nil},
|
||||
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
{`@[^\W\d][\w.]*`, NameDecorator, nil},
|
||||
{`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil},
|
||||
{`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
||||
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
||||
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil},
|
||||
{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
|
||||
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
||||
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
||||
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
||||
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// TODO(moorereason): can this be factored away?
|
||||
var bashAnalyserRe = regexp.MustCompile(`(?m)^#!.*/bin/(?:env |)(?:bash|zsh|sh|ksh)`)
|
||||
|
||||
// Bash lexer.
|
||||
var Bash = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Bash",
|
||||
Aliases: []string{"bash", "sh", "ksh", "zsh", "shell"},
|
||||
Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", ".env", "*.env", "*.exheres-0", "*.exlib", "*.zsh", "*.zshrc", ".bashrc", "bashrc", ".bash_*", "bash_*", "zshrc", ".zshrc", "PKGBUILD"},
|
||||
MimeTypes: []string{"application/x-sh", "application/x-shellscript"},
|
||||
},
|
||||
bashRules,
|
||||
).SetAnalyser(func(text string) float32 {
|
||||
if bashAnalyserRe.FindString(text) != "" {
|
||||
return 1.0
|
||||
}
|
||||
return 0.0
|
||||
}))
|
||||
|
||||
func bashRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("basic"),
|
||||
{"`", LiteralStringBacktick, Push("backticks")},
|
||||
Include("data"),
|
||||
Include("interp"),
|
||||
},
|
||||
"interp": {
|
||||
{`\$\(\(`, Keyword, Push("math")},
|
||||
{`\$\(`, Keyword, Push("paren")},
|
||||
{`\$\{#?`, LiteralStringInterpol, Push("curly")},
|
||||
{`\$[a-zA-Z_]\w*`, NameVariable, nil},
|
||||
{`\$(?:\d+|[#$?!_*@-])`, NameVariable, nil},
|
||||
{`\$`, Text, nil},
|
||||
},
|
||||
"basic": {
|
||||
{`\b(if|fi|else|while|do|done|for|then|return|function|case|select|continue|until|esac|elif)(\s*)\b`, ByGroups(Keyword, Text), nil},
|
||||
{"\\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)(?=[\\s)`])", NameBuiltin, nil},
|
||||
{`\A#!.+\n`, CommentPreproc, nil},
|
||||
{`#.*(\S|$)`, CommentSingle, nil},
|
||||
{`\\[\w\W]`, LiteralStringEscape, nil},
|
||||
{`(\b\w+)(\s*)(\+?=)`, ByGroups(NameVariable, Text, Operator), nil},
|
||||
{`[\[\]{}()=]`, Operator, nil},
|
||||
{`<<<`, Operator, nil},
|
||||
{`<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
|
||||
{`&&|\|\|`, Operator, nil},
|
||||
},
|
||||
"data": {
|
||||
{`(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
|
||||
{`(?s)'.*?'`, LiteralStringSingle, nil},
|
||||
{`;`, Punctuation, nil},
|
||||
{`&`, Punctuation, nil},
|
||||
{`\|`, Punctuation, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\d+(?= |$)`, LiteralNumber, nil},
|
||||
{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil},
|
||||
{`<`, Text, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+`, LiteralStringDouble, nil},
|
||||
Include("interp"),
|
||||
},
|
||||
"curly": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
{`:-`, Keyword, nil},
|
||||
{`\w+`, NameVariable, nil},
|
||||
{"[^}:\"\\'`$\\\\]+", Punctuation, nil},
|
||||
{`:`, Punctuation, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"paren": {
|
||||
{`\)`, Keyword, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"math": {
|
||||
{`\)\)`, Keyword, Pop(1)},
|
||||
{`[-+*/%^|&]|\*\*|\|\|`, Operator, nil},
|
||||
{`\d+#\d+`, LiteralNumber, nil},
|
||||
{`\d+#(?! )`, LiteralNumber, nil},
|
||||
{`\d+`, LiteralNumber, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"backticks": {
|
||||
{"`", LiteralStringBacktick, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// BashSession lexer.
|
||||
var BashSession = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "BashSession",
|
||||
Aliases: []string{"bash-session", "console", "shell-session"},
|
||||
Filenames: []string{".sh-session"},
|
||||
MimeTypes: []string{"text/x-sh"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
bashsessionRules,
|
||||
))
|
||||
|
||||
func bashsessionRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^((?:\[[^]]+@[^]]+\]\s?)?[#$%>])(\s*)(.*\n?)`, ByGroups(GenericPrompt, Text, Using(Bash)), nil},
|
||||
{`^.+\n?`, GenericOutput, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Batchfile lexer.
|
||||
var Batchfile = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Batchfile",
|
||||
Aliases: []string{"bat", "batch", "dosbatch", "winbatch"},
|
||||
Filenames: []string{"*.bat", "*.cmd"},
|
||||
MimeTypes: []string{"application/x-dos-batch"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
batchfileRules,
|
||||
))
|
||||
|
||||
func batchfileRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\)((?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:[^\n\x1a^]|\^[\n\x1a]?[\w\W])*)`, CommentSingle, nil},
|
||||
{`(?=((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:))`, Text, Push("follow")},
|
||||
{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
|
||||
Include("redirect"),
|
||||
{`[\n\x1a]+`, Text, nil},
|
||||
{`\(`, Punctuation, Push("root/compound")},
|
||||
{`@+`, Punctuation, nil},
|
||||
{`((?:for|if|rem)(?:(?=(?:\^[\n\x1a]?)?/)|(?:(?!\^)|(?<=m))(?:(?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+)?(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?)`, ByGroups(Keyword, UsingSelf("text")), Push("follow")},
|
||||
{`(goto(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|])*(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|])*)`, ByGroups(Keyword, UsingSelf("text")), Push("follow")},
|
||||
{Words(``, `(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])`, `assoc`, `break`, `cd`, `chdir`, `cls`, `color`, `copy`, `date`, `del`, `dir`, `dpath`, `echo`, `endlocal`, `erase`, `exit`, `ftype`, `keys`, `md`, `mkdir`, `mklink`, `move`, `path`, `pause`, `popd`, `prompt`, `pushd`, `rd`, `ren`, `rename`, `rmdir`, `setlocal`, `shift`, `start`, `time`, `title`, `type`, `ver`, `verify`, `vol`), Keyword, Push("follow")},
|
||||
{`(call)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("call")},
|
||||
{`call(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])`, Keyword, nil},
|
||||
{`(for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/f(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")},
|
||||
{`(for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/l(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/l", "for")},
|
||||
{`for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^)`, Keyword, Push("for2", "for")},
|
||||
{`(goto(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:?)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("label")},
|
||||
{`(if(?:(?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:/i(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:not(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")},
|
||||
{`rem(((?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)?.*|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])(?:(?:[^\n\x1a^]|\^[\n\x1a]?[\w\W])*))`, CommentSingle, Push("follow")},
|
||||
{`(set(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:\^[\n\x1a]?)?[^\S\n])*)(/a)`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("arithmetic")},
|
||||
{`(set(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:/p)?)((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|^=]|\^[\n\x1a]?[^"=])+)?)((?:(?:\^[\n\x1a]?)?=)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow")},
|
||||
Default(Push("follow")),
|
||||
},
|
||||
"follow": {
|
||||
{`((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:)([\t\v\f\r ,;=\xa0]*)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*))(.*)`, ByGroups(Text, Punctuation, Text, NameLabel, CommentSingle), nil},
|
||||
Include("redirect"),
|
||||
{`(?=[\n\x1a])`, Text, Pop(1)},
|
||||
{`\|\|?|&&?`, Punctuation, Pop(1)},
|
||||
Include("text"),
|
||||
},
|
||||
"arithmetic": {
|
||||
{`0[0-7]+`, LiteralNumberOct, nil},
|
||||
{`0x[\da-f]+`, LiteralNumberHex, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`[(),]+`, Punctuation, nil},
|
||||
{`([=+\-*/!~]|%|\^\^)+`, Operator, nil},
|
||||
{`((?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(\^[\n\x1a]?)?[^()=+\-*/!~%^"\n\x1a&<>|\t\v\f\r ,;=\xa0]|\^[\n\x1a\t\v\f\r ,;=\xa0]?[\w\W])+`, UsingSelf("variable"), nil},
|
||||
{`(?=[\x00|&])`, Text, Pop(1)},
|
||||
Include("follow"),
|
||||
},
|
||||
"call": {
|
||||
{`(:?)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*))`, ByGroups(Punctuation, NameLabel), Pop(1)},
|
||||
},
|
||||
"label": {
|
||||
{`((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*)?)((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|\^[\n\x1a]?[\w\W]|[^"%^\n\x1a&<>|])*)`, ByGroups(NameLabel, CommentSingle), Pop(1)},
|
||||
},
|
||||
"redirect": {
|
||||
{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])\d)?)(>>?&|<&)([\n\x1a\t\v\f\r ,;=\xa0]*)(\d)`, ByGroups(LiteralNumberInteger, Punctuation, Text, LiteralNumberInteger), nil},
|
||||
{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])(?<!\^[\n\x1a])\d)?)(>>?|<)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(LiteralNumberInteger, Punctuation, UsingSelf("text")), nil},
|
||||
},
|
||||
"root/compound": {
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`(?=((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:))`, Text, Push("follow/compound")},
|
||||
{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
|
||||
Include("redirect/compound"),
|
||||
{`[\n\x1a]+`, Text, nil},
|
||||
{`\(`, Punctuation, Push("root/compound")},
|
||||
{`@+`, Punctuation, nil},
|
||||
{`((?:for|if|rem)(?:(?=(?:\^[\n\x1a]?)?/)|(?:(?!\^)|(?<=m))(?:(?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0)])+)?(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?)`, ByGroups(Keyword, UsingSelf("text")), Push("follow/compound")},
|
||||
{`(goto(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|)])*(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|)])*)`, ByGroups(Keyword, UsingSelf("text")), Push("follow/compound")},
|
||||
{Words(``, `(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))`, `assoc`, `break`, `cd`, `chdir`, `cls`, `color`, `copy`, `date`, `del`, `dir`, `dpath`, `echo`, `endlocal`, `erase`, `exit`, `ftype`, `keys`, `md`, `mkdir`, `mklink`, `move`, `path`, `pause`, `popd`, `prompt`, `pushd`, `rd`, `ren`, `rename`, `rmdir`, `setlocal`, `shift`, `start`, `time`, `title`, `type`, `ver`, `verify`, `vol`), Keyword, Push("follow/compound")},
|
||||
{`(call)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("call/compound")},
|
||||
{`call(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))`, Keyword, nil},
|
||||
{`(for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/f(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")},
|
||||
{`(for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/l(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/l", "for")},
|
||||
{`for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^)`, Keyword, Push("for2", "for")},
|
||||
{`(goto(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:?)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("label/compound")},
|
||||
{`(if(?:(?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:/i(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:not(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")},
|
||||
{`rem(((?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)?.*|(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))(?:(?:[^\n\x1a^)]|\^[\n\x1a]?[^)])*))`, CommentSingle, Push("follow/compound")},
|
||||
{`(set(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:\^[\n\x1a]?)?[^\S\n])*)(/a)`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("arithmetic/compound")},
|
||||
{`(set(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:/p)?)((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|^=)]|\^[\n\x1a]?[^"=])+)?)((?:(?:\^[\n\x1a]?)?=)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow/compound")},
|
||||
Default(Push("follow/compound")),
|
||||
},
|
||||
"follow/compound": {
|
||||
{`(?=\))`, Text, Pop(1)},
|
||||
{`((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:)([\t\v\f\r ,;=\xa0]*)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*))(.*)`, ByGroups(Text, Punctuation, Text, NameLabel, CommentSingle), nil},
|
||||
Include("redirect/compound"),
|
||||
{`(?=[\n\x1a])`, Text, Pop(1)},
|
||||
{`\|\|?|&&?`, Punctuation, Pop(1)},
|
||||
Include("text"),
|
||||
},
|
||||
"arithmetic/compound": {
|
||||
{`(?=\))`, Text, Pop(1)},
|
||||
{`0[0-7]+`, LiteralNumberOct, nil},
|
||||
{`0x[\da-f]+`, LiteralNumberHex, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`[(),]+`, Punctuation, nil},
|
||||
{`([=+\-*/!~]|%|\^\^)+`, Operator, nil},
|
||||
{`((?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(\^[\n\x1a]?)?[^()=+\-*/!~%^"\n\x1a&<>|\t\v\f\r ,;=\xa0]|\^[\n\x1a\t\v\f\r ,;=\xa0]?[^)])+`, UsingSelf("variable"), nil},
|
||||
{`(?=[\x00|&])`, Text, Pop(1)},
|
||||
Include("follow"),
|
||||
},
|
||||
"call/compound": {
|
||||
{`(?=\))`, Text, Pop(1)},
|
||||
{`(:?)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*))`, ByGroups(Punctuation, NameLabel), Pop(1)},
|
||||
},
|
||||
"label/compound": {
|
||||
{`(?=\))`, Text, Pop(1)},
|
||||
{`((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*)?)((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|\^[\n\x1a]?[^)]|[^"%^\n\x1a&<>|)])*)`, ByGroups(NameLabel, CommentSingle), Pop(1)},
|
||||
},
|
||||
"redirect/compound": {
|
||||
{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])\d)?)(>>?&|<&)([\n\x1a\t\v\f\r ,;=\xa0]*)(\d)`, ByGroups(LiteralNumberInteger, Punctuation, Text, LiteralNumberInteger), nil},
|
||||
{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])(?<!\^[\n\x1a])\d)?)(>>?|<)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0)])+))+))`, ByGroups(LiteralNumberInteger, Punctuation, UsingSelf("text")), nil},
|
||||
},
|
||||
"variable-or-escape": {
|
||||
{`(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))`, NameVariable, nil},
|
||||
{`%%|\^[\n\x1a]?(\^!|[\w\W])`, LiteralStringEscape, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))`, NameVariable, nil},
|
||||
{`\^!|%%`, LiteralStringEscape, nil},
|
||||
{`[^"%^\n\x1a]+|[%^]`, LiteralStringDouble, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"sqstring": {
|
||||
Include("variable-or-escape"),
|
||||
{`[^%]+|%`, LiteralStringSingle, nil},
|
||||
},
|
||||
"bqstring": {
|
||||
Include("variable-or-escape"),
|
||||
{`[^%]+|%`, LiteralStringBacktick, nil},
|
||||
},
|
||||
"text": {
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
Include("variable-or-escape"),
|
||||
{`[^"%^\n\x1a&<>|\t\v\f\r ,;=\xa0\d)]+|.`, Text, nil},
|
||||
},
|
||||
"variable": {
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
Include("variable-or-escape"),
|
||||
{`[^"%^\n\x1a]+|.`, NameVariable, nil},
|
||||
},
|
||||
"for": {
|
||||
{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(in)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(\()`, ByGroups(UsingSelf("text"), Keyword, UsingSelf("text"), Punctuation), Pop(1)},
|
||||
Include("follow"),
|
||||
},
|
||||
"for2": {
|
||||
{`\)`, Punctuation, nil},
|
||||
{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(do(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, ByGroups(UsingSelf("text"), Keyword), Pop(1)},
|
||||
{`[\n\x1a]+`, Text, nil},
|
||||
Include("follow"),
|
||||
},
|
||||
"for/f": {
|
||||
{`(")((?:(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"])*?")([\n\x1a\t\v\f\r ,;=\xa0]*)(\))`, ByGroups(LiteralStringDouble, UsingSelf("string"), Text, Punctuation), nil},
|
||||
{`"`, LiteralStringDouble, Push("#pop", "for2", "string")},
|
||||
{`('(?:%%|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[\w\W])*?')([\n\x1a\t\v\f\r ,;=\xa0]*)(\))`, ByGroups(UsingSelf("sqstring"), Text, Punctuation), nil},
|
||||
{"(`(?:%%|(?:(?:%(?:\\*|(?:~[a-z]*(?:\\$[^:]+:)?)?\\d|[^%:\\n\\x1a]+(?::(?:~(?:-?\\d+)?(?:,(?:-?\\d+)?)?|(?:[^%\\n\\x1a^]|\\^[^%\\n\\x1a])[^=\\n\\x1a]*=(?:[^%\\n\\x1a^]|\\^[^%\\n\\x1a])*)?)?%))|(?:\\^?![^!:\\n\\x1a]+(?::(?:~(?:-?\\d+)?(?:,(?:-?\\d+)?)?|(?:[^!\\n\\x1a^]|\\^[^!\\n\\x1a])[^=\\n\\x1a]*=(?:[^!\\n\\x1a^]|\\^[^!\\n\\x1a])*)?)?\\^?!))|[\\w\\W])*?`)([\\n\\x1a\\t\\v\\f\\r ,;=\\xa0]*)(\\))", ByGroups(UsingSelf("bqstring"), Text, Punctuation), nil},
|
||||
Include("for2"),
|
||||
},
|
||||
"for/l": {
|
||||
{`-?\d+`, LiteralNumberInteger, nil},
|
||||
Include("for2"),
|
||||
},
|
||||
"if": {
|
||||
{`((?:cmdextversion|errorlevel)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(\d+)`, ByGroups(Keyword, UsingSelf("text"), LiteralNumberInteger), Pop(1)},
|
||||
{`(defined(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(Keyword, UsingSelf("text"), UsingSelf("variable")), Pop(1)},
|
||||
{`(exist(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(Keyword, UsingSelf("text")), Pop(1)},
|
||||
{`((?:-?(?:0[0-7]+|0x[\da-f]+|\d+)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:equ|geq|gtr|leq|lss|neq))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:-?(?:0[0-7]+|0x[\da-f]+|\d+)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, ByGroups(UsingSelf("arithmetic"), OperatorWord, UsingSelf("arithmetic")), Pop(1)},
|
||||
{`(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)`, UsingSelf("text"), Push("#pop", "if2")},
|
||||
},
|
||||
"if2": {
|
||||
{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(==)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(UsingSelf("text"), Operator, UsingSelf("text")), Pop(1)},
|
||||
{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:equ|geq|gtr|leq|lss|neq))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(UsingSelf("text"), OperatorWord, UsingSelf("text")), Pop(1)},
|
||||
},
|
||||
"(?": {
|
||||
{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
|
||||
{`\(`, Punctuation, Push("#pop", "else?", "root/compound")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"else?": {
|
||||
{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
|
||||
{`else(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])`, Keyword, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Bibtex lexer.
|
||||
var Bibtex = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "BibTeX",
|
||||
Aliases: []string{"bib", "bibtex"},
|
||||
Filenames: []string{"*.bib"},
|
||||
MimeTypes: []string{"text/x-bibtex"},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
bibtexRules,
|
||||
))
|
||||
|
||||
func bibtexRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`@comment`, Comment, nil},
|
||||
{`@preamble`, NameClass, Push("closing-brace", "value", "opening-brace")},
|
||||
{`@string`, NameClass, Push("closing-brace", "field", "opening-brace")},
|
||||
{"@[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameClass, Push("closing-brace", "command-body", "opening-brace")},
|
||||
{`.+`, Comment, nil},
|
||||
},
|
||||
"opening-brace": {
|
||||
Include("whitespace"),
|
||||
{`[{(]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"closing-brace": {
|
||||
Include("whitespace"),
|
||||
{`[})]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"command-body": {
|
||||
Include("whitespace"),
|
||||
{`[^\s\,\}]+`, NameLabel, Push("#pop", "fields")},
|
||||
},
|
||||
"fields": {
|
||||
Include("whitespace"),
|
||||
{`,`, Punctuation, Push("field")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"field": {
|
||||
Include("whitespace"),
|
||||
{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameAttribute, Push("value", "=")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"=": {
|
||||
Include("whitespace"),
|
||||
{`=`, Punctuation, Pop(1)},
|
||||
},
|
||||
"value": {
|
||||
Include("whitespace"),
|
||||
{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameVariable, nil},
|
||||
{`"`, LiteralString, Push("quoted-string")},
|
||||
{`\{`, LiteralString, Push("braced-string")},
|
||||
{`[\d]+`, LiteralNumber, nil},
|
||||
{`#`, Punctuation, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"quoted-string": {
|
||||
{`\{`, LiteralString, Push("braced-string")},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`[^\{\"]+`, LiteralString, nil},
|
||||
},
|
||||
"braced-string": {
|
||||
{`\{`, LiteralString, Push()},
|
||||
{`\}`, LiteralString, Pop(1)},
|
||||
{`[^\{\}]+`, LiteralString, nil},
|
||||
},
|
||||
"whitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Bicep lexer.
|
||||
var Bicep = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Bicep",
|
||||
Aliases: []string{"bicep"},
|
||||
Filenames: []string{"*.bicep"},
|
||||
},
|
||||
bicepRules,
|
||||
))
|
||||
|
||||
func bicepRules() Rules {
|
||||
bicepFunctions := []string{
|
||||
"any",
|
||||
"array",
|
||||
"concat",
|
||||
"contains",
|
||||
"empty",
|
||||
"first",
|
||||
"intersection",
|
||||
"items",
|
||||
"last",
|
||||
"length",
|
||||
"min",
|
||||
"max",
|
||||
"range",
|
||||
"skip",
|
||||
"take",
|
||||
"union",
|
||||
"dateTimeAdd",
|
||||
"utcNow",
|
||||
"deployment",
|
||||
"environment",
|
||||
"loadFileAsBase64",
|
||||
"loadTextContent",
|
||||
"int",
|
||||
"json",
|
||||
"extensionResourceId",
|
||||
"getSecret",
|
||||
"list",
|
||||
"listKeys",
|
||||
"listKeyValue",
|
||||
"listAccountSas",
|
||||
"listSecrets",
|
||||
"pickZones",
|
||||
"reference",
|
||||
"resourceId",
|
||||
"subscriptionResourceId",
|
||||
"tenantResourceId",
|
||||
"managementGroup",
|
||||
"resourceGroup",
|
||||
"subscription",
|
||||
"tenant",
|
||||
"base64",
|
||||
"base64ToJson",
|
||||
"base64ToString",
|
||||
"dataUri",
|
||||
"dataUriToString",
|
||||
"endsWith",
|
||||
"format",
|
||||
"guid",
|
||||
"indexOf",
|
||||
"lastIndexOf",
|
||||
"length",
|
||||
"newGuid",
|
||||
"padLeft",
|
||||
"replace",
|
||||
"split",
|
||||
"startsWith",
|
||||
"string",
|
||||
"substring",
|
||||
"toLower",
|
||||
"toUpper",
|
||||
"trim",
|
||||
"uniqueString",
|
||||
"uri",
|
||||
"uriComponent",
|
||||
"uriComponentToString",
|
||||
}
|
||||
|
||||
return Rules{
|
||||
"root": {
|
||||
{`//[^\n\r]+`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`([']?\w+[']?)(:)`, ByGroups(NameProperty, Punctuation), nil},
|
||||
{`\b('(resourceGroup|subscription|managementGroup|tenant)')\b`, KeywordNamespace, nil},
|
||||
{`'[\w\$\{\(\)\}\.]{1,}?'`, LiteralStringInterpol, nil},
|
||||
{`('''|').*?('''|')`, LiteralString, nil},
|
||||
{`\b(allowed|batchSize|description|maxLength|maxValue|metadata|minLength|minValue|secure)\b`, NameDecorator, nil},
|
||||
{`\b(az|sys)\.`, NameNamespace, nil},
|
||||
{`\b(` + strings.Join(bicepFunctions, "|") + `)\b`, NameFunction, nil},
|
||||
// https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-logical
|
||||
{`\b(bool)(\()`, ByGroups(NameFunction, Punctuation), nil},
|
||||
{`\b(for|if|in)\b`, Keyword, nil},
|
||||
{`\b(module|output|param|resource|var)\b`, KeywordDeclaration, nil},
|
||||
{`\b(array|bool|int|object|string)\b`, KeywordType, nil},
|
||||
// https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/operators
|
||||
{`(>=|>|<=|<|==|!=|=~|!~|::|&&|\?\?|!|-|%|\*|\/|\+)`, Operator, nil},
|
||||
{`[\(\)\[\]\.:\?{}@=]`, Punctuation, nil},
|
||||
{`[\w_-]+`, Text, nil},
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Blitzbasic lexer.
|
||||
var Blitzbasic = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "BlitzBasic",
|
||||
Aliases: []string{"blitzbasic", "b3d", "bplus"},
|
||||
Filenames: []string{"*.bb", "*.decls"},
|
||||
MimeTypes: []string{"text/x-bb"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
blitzbasicRules,
|
||||
))
|
||||
|
||||
func blitzbasicRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[ \t]+`, Text, nil},
|
||||
{`;.*?\n`, CommentSingle, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`[0-9]+\.[0-9]*(?!\.)`, LiteralNumberFloat, nil},
|
||||
{`\.[0-9]+(?!\.)`, LiteralNumberFloat, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`\$[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
{`\%[10]+`, LiteralNumberBin, nil},
|
||||
{Words(`\b`, `\b`, `Shl`, `Shr`, `Sar`, `Mod`, `Or`, `And`, `Not`, `Abs`, `Sgn`, `Handle`, `Int`, `Float`, `Str`, `First`, `Last`, `Before`, `After`), Operator, nil},
|
||||
{`([+\-*/~=<>^])`, Operator, nil},
|
||||
{`[(),:\[\]\\]`, Punctuation, nil},
|
||||
{`\.([ \t]*)([a-z]\w*)`, NameLabel, nil},
|
||||
{`\b(New)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||
{`\b(Gosub|Goto)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameLabel), nil},
|
||||
{`\b(Object)\b([ \t]*)([.])([ \t]*)([a-z]\w*)\b`, ByGroups(Operator, Text, Punctuation, Text, NameClass), nil},
|
||||
{`\b([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?\b([ \t]*)(\()`, ByGroups(NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass, Text, Punctuation), nil},
|
||||
{`\b(Function)\b([ \t]+)([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(KeywordReserved, Text, NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
|
||||
{`\b(Type)([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||
{`\b(Pi|True|False|Null)\b`, KeywordConstant, nil},
|
||||
{`\b(Local|Global|Const|Field|Dim)\b`, KeywordDeclaration, nil},
|
||||
{Words(`\b`, `\b`, `End`, `Return`, `Exit`, `Chr`, `Len`, `Asc`, `New`, `Delete`, `Insert`, `Include`, `Function`, `Type`, `If`, `Then`, `Else`, `ElseIf`, `EndIf`, `For`, `To`, `Next`, `Step`, `Each`, `While`, `Wend`, `Repeat`, `Until`, `Forever`, `Select`, `Case`, `Default`, `Goto`, `Gosub`, `Data`, `Read`, `Restore`), KeywordReserved, nil},
|
||||
{`([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(NameVariable, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
|
||||
},
|
||||
"string": {
|
||||
{`""`, LiteralStringDouble, nil},
|
||||
{`"C?`, LiteralStringDouble, Pop(1)},
|
||||
{`[^"]+`, LiteralStringDouble, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Bnf lexer.
|
||||
var Bnf = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "BNF",
|
||||
Aliases: []string{"bnf"},
|
||||
Filenames: []string{"*.bnf"},
|
||||
MimeTypes: []string{"text/x-bnf"},
|
||||
},
|
||||
bnfRules,
|
||||
))
|
||||
|
||||
func bnfRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(<)([ -;=?-~]+)(>)`, ByGroups(Punctuation, NameClass, Punctuation), nil},
|
||||
{`::=`, Operator, nil},
|
||||
{`[^<>:]+`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Brainfuck lexer.
|
||||
var Brainfuck = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Brainfuck",
|
||||
Aliases: []string{"brainfuck", "bf"},
|
||||
Filenames: []string{"*.bf", "*.b"},
|
||||
MimeTypes: []string{"application/x-brainfuck"},
|
||||
},
|
||||
brainfuckRules,
|
||||
))
|
||||
|
||||
func brainfuckRules() Rules {
|
||||
return Rules{
|
||||
"common": {
|
||||
{`[.,]+`, NameTag, nil},
|
||||
{`[+-]+`, NameBuiltin, nil},
|
||||
{`[<>]+`, NameVariable, nil},
|
||||
{`[^.,+\-<>\[\]]+`, Comment, nil},
|
||||
},
|
||||
"root": {
|
||||
{`\[`, Keyword, Push("loop")},
|
||||
{`\]`, Error, nil},
|
||||
Include("common"),
|
||||
},
|
||||
"loop": {
|
||||
{`\[`, Keyword, Push()},
|
||||
{`\]`, Keyword, Pop(1)},
|
||||
Include("common"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// C lexer.
|
||||
var C = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "C",
|
||||
Aliases: []string{"c"},
|
||||
Filenames: []string{"*.c", "*.h", "*.idc", "*.x[bp]m"},
|
||||
MimeTypes: []string{"text/x-chdr", "text/x-csrc", "image/x-xbitmap", "image/x-xpixmap"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
cRules,
|
||||
))
|
||||
|
||||
func cRules() Rules {
|
||||
return Rules{
|
||||
"whitespace": {
|
||||
{`^#if\s+0`, CommentPreproc, Push("if0")},
|
||||
{`^#`, CommentPreproc, Push("macro")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
|
||||
},
|
||||
"statements": {
|
||||
{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||
{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil},
|
||||
{`0[0-7]+[LlUu]*`, LiteralNumberOct, nil},
|
||||
{`\d+[LlUu]*`, LiteralNumberInteger, nil},
|
||||
{`\*/`, Error, nil},
|
||||
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
|
||||
{`[()\[\],.]`, Punctuation, nil},
|
||||
{Words(``, `\b`, `asm`, `auto`, `break`, `case`, `const`, `continue`, `default`, `do`, `else`, `enum`, `extern`, `for`, `goto`, `if`, `register`, `restricted`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `volatile`, `while`), Keyword, nil},
|
||||
{`(bool|int|long|float|short|double|char((8|16|32)_t)?|unsigned|signed|void|u?int(_fast|_least|)(8|16|32|64)_t)\b`, KeywordType, nil},
|
||||
{Words(``, `\b`, `inline`, `_inline`, `__inline`, `naked`, `restrict`, `thread`, `typename`), KeywordReserved, nil},
|
||||
{`(__m(128i|128d|128|64))\b`, KeywordReserved, nil},
|
||||
{Words(`__`, `\b`, `asm`, `int8`, `based`, `except`, `int16`, `stdcall`, `cdecl`, `fastcall`, `int32`, `declspec`, `finally`, `int64`, `try`, `leave`, `wchar_t`, `w64`, `unaligned`, `raise`, `noop`, `identifier`, `forceinline`, `assume`), KeywordReserved, nil},
|
||||
{`(true|false|NULL)\b`, NameBuiltin, nil},
|
||||
{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
|
||||
Default(Push("statement")),
|
||||
},
|
||||
"statement": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`[{}]`, Punctuation, nil},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
},
|
||||
"function": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`;`, Punctuation, nil},
|
||||
{`\{`, Punctuation, Push()},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
{`[^\\"\n]+`, LiteralString, nil},
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\\`, LiteralString, nil},
|
||||
},
|
||||
"macro": {
|
||||
{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
|
||||
{`[^/\n]+`, CommentPreproc, nil},
|
||||
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
|
||||
{`//.*?\n`, CommentSingle, Pop(1)},
|
||||
{`/`, CommentPreproc, nil},
|
||||
{`(?<=\\)\n`, CommentPreproc, nil},
|
||||
{`\n`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
"if0": {
|
||||
{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
|
||||
{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
|
||||
{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
|
||||
{`.*?\n`, Comment, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cap'N'Proto Proto lexer.
|
||||
var CapNProto = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Cap'n Proto",
|
||||
Aliases: []string{"capnp"},
|
||||
Filenames: []string{"*.capnp"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
capNProtoRules,
|
||||
))
|
||||
|
||||
func capNProtoRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*?$`, CommentSingle, nil},
|
||||
{`@[0-9a-zA-Z]*`, NameDecorator, nil},
|
||||
{`=`, Literal, Push("expression")},
|
||||
{`:`, NameClass, Push("type")},
|
||||
{`\$`, NameAttribute, Push("annotation")},
|
||||
{`(struct|enum|interface|union|import|using|const|annotation|extends|in|of|on|as|with|from|fixed)\b`, Keyword, nil},
|
||||
{`[\w.]+`, Name, nil},
|
||||
{`[^#@=:$\w]+`, Text, nil},
|
||||
},
|
||||
"type": {
|
||||
{`[^][=;,(){}$]+`, NameClass, nil},
|
||||
{`[[(]`, NameClass, Push("parentype")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"parentype": {
|
||||
{`[^][;()]+`, NameClass, nil},
|
||||
{`[[(]`, NameClass, Push()},
|
||||
{`[])]`, NameClass, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"expression": {
|
||||
{`[^][;,(){}$]+`, Literal, nil},
|
||||
{`[[(]`, Literal, Push("parenexp")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"parenexp": {
|
||||
{`[^][;()]+`, Literal, nil},
|
||||
{`[[(]`, Literal, Push()},
|
||||
{`[])]`, Literal, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"annotation": {
|
||||
{`[^][;,(){}=:]+`, NameAttribute, nil},
|
||||
{`[[(]`, NameAttribute, Push("annexp")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"annexp": {
|
||||
{`[^][;()]+`, NameAttribute, nil},
|
||||
{`[[(]`, NameAttribute, Push()},
|
||||
{`[])]`, NameAttribute, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Ceylon lexer.
|
||||
var Ceylon = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Ceylon",
|
||||
Aliases: []string{"ceylon"},
|
||||
Filenames: []string{"*.ceylon"},
|
||||
MimeTypes: []string{"text/x-ceylon"},
|
||||
DotAll: true,
|
||||
},
|
||||
ceylonRules,
|
||||
))
|
||||
|
||||
func ceylonRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("comment")},
|
||||
{`(shared|abstract|formal|default|actual|variable|deprecated|small|late|literal|doc|by|see|throws|optional|license|tagged|final|native|annotation|sealed)\b`, NameDecorator, nil},
|
||||
{`(break|case|catch|continue|else|finally|for|in|if|return|switch|this|throw|try|while|is|exists|dynamic|nonempty|then|outer|assert|let)\b`, Keyword, nil},
|
||||
{`(abstracts|extends|satisfies|super|given|of|out|assign)\b`, KeywordDeclaration, nil},
|
||||
{`(function|value|void|new)\b`, KeywordType, nil},
|
||||
{`(assembly|module|package)(\s+)`, ByGroups(KeywordNamespace, Text), nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(class|interface|object|alias)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'`, LiteralStringChar, nil},
|
||||
{"\".*``.*``.*\"", LiteralStringInterpol, nil},
|
||||
{`(\.)([a-z_]\w*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`[a-zA-Z_]\w*:`, NameLabel, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
|
||||
{`\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?`, LiteralNumberFloat, nil},
|
||||
{`\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?`, LiteralNumberFloat, nil},
|
||||
{`[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?`, LiteralNumberFloat, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?`, LiteralNumberFloat, nil},
|
||||
{`#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+`, LiteralNumberHex, nil},
|
||||
{`#[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`\$([01]{4})(_[01]{4})+`, LiteralNumberBin, nil},
|
||||
{`\$[01]+`, LiteralNumberBin, nil},
|
||||
{`\d{1,3}(_\d{3})+[kMGTP]?`, LiteralNumberInteger, nil},
|
||||
{`[0-9]+[kMGTP]?`, LiteralNumberInteger, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`[A-Za-z_]\w*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`[a-z][\w.]*`, NameNamespace, Pop(1)},
|
||||
},
|
||||
"comment": {
|
||||
{`[^*/]`, CommentMultiline, nil},
|
||||
{`/\*`, CommentMultiline, Push()},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[*/]`, CommentMultiline, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cfengine3 lexer.
|
||||
var Cfengine3 = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "CFEngine3",
|
||||
Aliases: []string{"cfengine3", "cf3"},
|
||||
Filenames: []string{"*.cf"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
cfengine3Rules,
|
||||
))
|
||||
|
||||
func cfengine3Rules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*?\n`, Comment, nil},
|
||||
{`(body)(\s+)(\S+)(\s+)(control)`, ByGroups(Keyword, Text, Keyword, Text, Keyword), nil},
|
||||
{`(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()`, ByGroups(Keyword, Text, Keyword, Text, NameFunction, Punctuation), Push("arglist")},
|
||||
{`(body|bundle)(\s+)(\S+)(\s+)(\w+)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil},
|
||||
{`(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)`, ByGroups(Punctuation, NameVariable, Punctuation, Text, KeywordType, Text, Operator, Text), nil},
|
||||
{`(\S+)(\s*)(=>)(\s*)`, ByGroups(KeywordReserved, Text, Operator, Text), nil},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`(\w+)(\()`, ByGroups(NameFunction, Punctuation), nil},
|
||||
{`([\w.!&|()]+)(::)`, ByGroups(NameClass, Punctuation), nil},
|
||||
{`(\w+)(:)`, ByGroups(KeywordDeclaration, Punctuation), nil},
|
||||
{`@[{(][^)}]+[})]`, NameVariable, nil},
|
||||
{`[(){},;]`, Punctuation, nil},
|
||||
{`=>`, Operator, nil},
|
||||
{`->`, Operator, nil},
|
||||
{`\d+\.\d+`, LiteralNumberFloat, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`\w+`, NameFunction, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"string": {
|
||||
{`\$[{(]`, LiteralStringInterpol, Push("interpol")},
|
||||
{`\\.`, LiteralStringEscape, nil},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\n`, LiteralString, nil},
|
||||
{`.`, LiteralString, nil},
|
||||
},
|
||||
"interpol": {
|
||||
{`\$[{(]`, LiteralStringInterpol, Push()},
|
||||
{`[})]`, LiteralStringInterpol, Pop(1)},
|
||||
{`[^${()}]+`, LiteralStringInterpol, nil},
|
||||
},
|
||||
"arglist": {
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`,`, Punctuation, nil},
|
||||
{`\w+`, NameVariable, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Chaiscript lexer.
|
||||
var Chaiscript = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "ChaiScript",
|
||||
Aliases: []string{"chai", "chaiscript"},
|
||||
Filenames: []string{"*.chai"},
|
||||
MimeTypes: []string{"text/x-chaiscript", "application/x-chaiscript"},
|
||||
DotAll: true,
|
||||
},
|
||||
chaiscriptRules,
|
||||
))
|
||||
|
||||
func chaiscriptRules() Rules {
|
||||
return Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`^\#.*?\n`, CommentSingle, nil},
|
||||
},
|
||||
"slashstartsregex": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)`, LiteralStringRegex, Pop(1)},
|
||||
{`(?=/)`, Text, Push("#pop", "badregex")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"badregex": {
|
||||
{`\n`, Text, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`\n`, Text, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")},
|
||||
{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
|
||||
{`[})\].]`, Punctuation, nil},
|
||||
{`[=+\-*/]`, Operator, nil},
|
||||
{`(for|in|while|do|break|return|continue|if|else|throw|try|catch)\b`, Keyword, Push("slashstartsregex")},
|
||||
{`(var)\b`, KeywordDeclaration, Push("slashstartsregex")},
|
||||
{`(attr|def|fun)\b`, KeywordReserved, nil},
|
||||
{`(true|false)\b`, KeywordConstant, nil},
|
||||
{`(eval|throw)\b`, NameBuiltin, nil},
|
||||
{"`\\S+`", NameBuiltin, nil},
|
||||
{`[$a-zA-Z_]\w*`, NameOther, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"`, LiteralStringDouble, Push("dqstring")},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
},
|
||||
"dqstring": {
|
||||
{`\$\{[^"}]+?\}`, LiteralStringInterpol, nil},
|
||||
{`\$`, LiteralStringDouble, nil},
|
||||
{`\\\\`, LiteralStringDouble, nil},
|
||||
{`\\"`, LiteralStringDouble, nil},
|
||||
{`[^\\"$]+`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
. "github.com/alecthomas/chroma/lexers/p" // nolint
|
||||
)
|
||||
|
||||
// Cheetah lexer.
|
||||
var Cheetah = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Cheetah",
|
||||
Aliases: []string{"cheetah", "spitfire"},
|
||||
Filenames: []string{"*.tmpl", "*.spt"},
|
||||
MimeTypes: []string{"application/x-cheetah", "application/x-spitfire"},
|
||||
},
|
||||
cheetahRules,
|
||||
))
|
||||
|
||||
func cheetahRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(##[^\n]*)$`, ByGroups(Comment), nil},
|
||||
{`#[*](.|\n)*?[*]#`, Comment, nil},
|
||||
{`#end[^#\n]*(?:#|$)`, CommentPreproc, nil},
|
||||
{`#slurp$`, CommentPreproc, nil},
|
||||
{`(#[a-zA-Z]+)([^#\n]*)(#|$)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
|
||||
{`(\$)([a-zA-Z_][\w.]*\w)`, ByGroups(CommentPreproc, Using(Python)), nil},
|
||||
{`(\$\{!?)(.*?)(\})(?s)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
|
||||
{`(?sx)
|
||||
(.+?) # anything, followed by:
|
||||
(?:
|
||||
(?=\#[#a-zA-Z]*) | # an eval comment
|
||||
(?=\$[a-zA-Z_{]) | # a substitution
|
||||
\Z # end of string
|
||||
)
|
||||
`, Other, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Clojure lexer.
|
||||
var Clojure = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Clojure",
|
||||
Aliases: []string{"clojure", "clj"},
|
||||
Filenames: []string{"*.clj"},
|
||||
MimeTypes: []string{"text/x-clojure", "application/x-clojure"},
|
||||
},
|
||||
clojureRules,
|
||||
))
|
||||
|
||||
func clojureRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`;.*$`, CommentSingle, nil},
|
||||
{`[,\s]+`, Text, nil},
|
||||
{`-?\d+\.\d+`, LiteralNumberFloat, nil},
|
||||
{`-?\d+`, LiteralNumberInteger, nil},
|
||||
{`0x-?[abcdef\d]+`, LiteralNumberHex, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{`\\(.|[a-z]+)`, LiteralStringChar, nil},
|
||||
{`::?#?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{"~@|[`\\'#^~&@]", Operator, nil},
|
||||
{Words(``, ` `, `.`, `def`, `do`, `fn`, `if`, `let`, `new`, `quote`, `var`, `loop`), Keyword, nil},
|
||||
{Words(``, ` `, `def-`, `defn`, `defn-`, `defmacro`, `defmulti`, `defmethod`, `defstruct`, `defonce`, `declare`, `definline`, `definterface`, `defprotocol`, `defrecord`, `deftype`, `defproject`, `ns`), KeywordDeclaration, nil},
|
||||
{Words(``, ` `, `*`, `+`, `-`, `->`, `/`, `<`, `<=`, `=`, `==`, `>`, `>=`, `..`, `accessor`, `agent`, `agent-errors`, `aget`, `alength`, `all-ns`, `alter`, `and`, `append-child`, `apply`, `array-map`, `aset`, `aset-boolean`, `aset-byte`, `aset-char`, `aset-double`, `aset-float`, `aset-int`, `aset-long`, `aset-short`, `assert`, `assoc`, `await`, `await-for`, `bean`, `binding`, `bit-and`, `bit-not`, `bit-or`, `bit-shift-left`, `bit-shift-right`, `bit-xor`, `boolean`, `branch?`, `butlast`, `byte`, `cast`, `char`, `children`, `class`, `clear-agent-errors`, `comment`, `commute`, `comp`, `comparator`, `complement`, `concat`, `conj`, `cons`, `constantly`, `cond`, `if-not`, `construct-proxy`, `contains?`, `count`, `create-ns`, `create-struct`, `cycle`, `dec`, `deref`, `difference`, `disj`, `dissoc`, `distinct`, `doall`, `doc`, `dorun`, `doseq`, `dosync`, `dotimes`, `doto`, `double`, `down`, `drop`, `drop-while`, `edit`, `end?`, `ensure`, `eval`, `every?`, `false?`, `ffirst`, `file-seq`, `filter`, `find`, `find-doc`, `find-ns`, `find-var`, `first`, `float`, `flush`, `for`, `fnseq`, `frest`, `gensym`, `get-proxy-class`, `get`, `hash-map`, `hash-set`, `identical?`, `identity`, `if-let`, `import`, `in-ns`, `inc`, `index`, `insert-child`, `insert-left`, `insert-right`, `inspect-table`, `inspect-tree`, `instance?`, `int`, `interleave`, `intersection`, `into`, `into-array`, `iterate`, `join`, `key`, `keys`, `keyword`, `keyword?`, `last`, `lazy-cat`, `lazy-cons`, `left`, `lefts`, `line-seq`, `list*`, `list`, `load`, `load-file`, `locking`, `long`, `loop`, `macroexpand`, `macroexpand-1`, `make-array`, `make-node`, `map`, `map-invert`, `map?`, `mapcat`, `max`, `max-key`, `memfn`, `merge`, `merge-with`, `meta`, `min`, `min-key`, `name`, `namespace`, `neg?`, `new`, `newline`, `next`, `nil?`, `node`, `not`, `not-any?`, `not-every?`, `not=`, `ns-imports`, `ns-interns`, `ns-map`, `ns-name`, `ns-publics`, `ns-refers`, `ns-resolve`, `ns-unmap`, `nth`, `nthrest`, `or`, `parse`, `partial`, `path`, `peek`, `pop`, `pos?`, `pr`, `pr-str`, `print`, `print-str`, `println`, `println-str`, `prn`, `prn-str`, `project`, `proxy`, `proxy-mappings`, `quot`, `rand`, `rand-int`, `range`, `re-find`, `re-groups`, `re-matcher`, `re-matches`, `re-pattern`, `re-seq`, `read`, `read-line`, `reduce`, `ref`, `ref-set`, `refer`, `rem`, `remove`, `remove-method`, `remove-ns`, `rename`, `rename-keys`, `repeat`, `replace`, `replicate`, `resolve`, `rest`, `resultset-seq`, `reverse`, `rfirst`, `right`, `rights`, `root`, `rrest`, `rseq`, `second`, `select`, `select-keys`, `send`, `send-off`, `seq`, `seq-zip`, `seq?`, `set`, `short`, `slurp`, `some`, `sort`, `sort-by`, `sorted-map`, `sorted-map-by`, `sorted-set`, `special-symbol?`, `split-at`, `split-with`, `str`, `string?`, `struct`, `struct-map`, `subs`, `subvec`, `symbol`, `symbol?`, `sync`, `take`, `take-nth`, `take-while`, `test`, `time`, `to-array`, `to-array-2d`, `tree-seq`, `true?`, `union`, `up`, `update-proxy`, `val`, `vals`, `var-get`, `var-set`, `var?`, `vector`, `vector-zip`, `vector?`, `when`, `when-first`, `when-let`, `when-not`, `with-local-vars`, `with-meta`, `with-open`, `with-out-str`, `xml-seq`, `xml-zip`, `zero?`, `zipmap`, `zipper`), NameBuiltin, nil},
|
||||
{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil},
|
||||
{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil},
|
||||
{`(\[|\])`, Punctuation, nil},
|
||||
{`(\{|\})`, Punctuation, nil},
|
||||
{`(\(|\))`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cmake lexer.
|
||||
var Cmake = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "CMake",
|
||||
Aliases: []string{"cmake"},
|
||||
Filenames: []string{"*.cmake", "CMakeLists.txt"},
|
||||
MimeTypes: []string{"text/x-cmake"},
|
||||
},
|
||||
cmakeRules,
|
||||
))
|
||||
|
||||
func cmakeRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\b(\w+)([ \t]*)(\()`, ByGroups(NameBuiltin, Text, Punctuation), Push("args")},
|
||||
Include("keywords"),
|
||||
Include("ws"),
|
||||
},
|
||||
"args": {
|
||||
{`\(`, Punctuation, Push()},
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`(\$\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||
{`(\$ENV\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||
{`(\$<)(.+?)(>)`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||
{`(?s)".*?"`, LiteralStringDouble, nil},
|
||||
{`\\\S+`, LiteralString, nil},
|
||||
{`[^)$"# \t\n]+`, LiteralString, nil},
|
||||
{`\n`, Text, nil},
|
||||
Include("keywords"),
|
||||
Include("ws"),
|
||||
},
|
||||
"string": {},
|
||||
"keywords": {
|
||||
{`\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|MSVC70|MSVC71|MSVC80|MSVC90)\b`, Keyword, nil},
|
||||
},
|
||||
"ws": {
|
||||
{`[ \t]+`, Text, nil},
|
||||
{`#.*\n`, Comment, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cobol lexer.
|
||||
var Cobol = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "COBOL",
|
||||
Aliases: []string{"cobol"},
|
||||
Filenames: []string{"*.cob", "*.COB", "*.cpy", "*.CPY"},
|
||||
MimeTypes: []string{"text/x-cobol"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
cobolRules,
|
||||
))
|
||||
|
||||
func cobolRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("comment"),
|
||||
Include("strings"),
|
||||
Include("core"),
|
||||
Include("nums"),
|
||||
{`[a-z0-9]([\w\-]*[a-z0-9]+)?`, NameVariable, nil},
|
||||
{`[ \t]+`, Text, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`(^.{6}[*/].*\n|^.{6}|\*>.*\n)`, Comment, nil},
|
||||
},
|
||||
"core": {
|
||||
{`(^|(?<=[^\w\-]))(ALL\s+)?((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)\s*($|(?=[^\w\-]))`, NameConstant, nil},
|
||||
{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACCEPT`, `ADD`, `ALLOCATE`, `CALL`, `CANCEL`, `CLOSE`, `COMPUTE`, `CONFIGURATION`, `CONTINUE`, `DATA`, `DELETE`, `DISPLAY`, `DIVIDE`, `DIVISION`, `ELSE`, `END`, `END-ACCEPT`, `END-ADD`, `END-CALL`, `END-COMPUTE`, `END-DELETE`, `END-DISPLAY`, `END-DIVIDE`, `END-EVALUATE`, `END-IF`, `END-MULTIPLY`, `END-OF-PAGE`, `END-PERFORM`, `END-READ`, `END-RETURN`, `END-REWRITE`, `END-SEARCH`, `END-START`, `END-STRING`, `END-SUBTRACT`, `END-UNSTRING`, `END-WRITE`, `ENVIRONMENT`, `EVALUATE`, `EXIT`, `FD`, `FILE`, `FILE-CONTROL`, `FOREVER`, `FREE`, `GENERATE`, `GO`, `GOBACK`, `IDENTIFICATION`, `IF`, `INITIALIZE`, `INITIATE`, `INPUT-OUTPUT`, `INSPECT`, `INVOKE`, `I-O-CONTROL`, `LINKAGE`, `LOCAL-STORAGE`, `MERGE`, `MOVE`, `MULTIPLY`, `OPEN`, `PERFORM`, `PROCEDURE`, `PROGRAM-ID`, `RAISE`, `READ`, `RELEASE`, `RESUME`, `RETURN`, `REWRITE`, `SCREEN`, `SD`, `SEARCH`, `SECTION`, `SET`, `SORT`, `START`, `STOP`, `STRING`, `SUBTRACT`, `SUPPRESS`, `TERMINATE`, `THEN`, `UNLOCK`, `UNSTRING`, `USE`, `VALIDATE`, `WORKING-STORAGE`, `WRITE`), KeywordReserved, nil},
|
||||
{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACCESS`, `ADDRESS`, `ADVANCING`, `AFTER`, `ALL`, `ALPHABET`, `ALPHABETIC`, `ALPHABETIC-LOWER`, `ALPHABETIC-UPPER`, `ALPHANUMERIC`, `ALPHANUMERIC-EDITED`, `ALSO`, `ALTER`, `ALTERNATEANY`, `ARE`, `AREA`, `AREAS`, `ARGUMENT-NUMBER`, `ARGUMENT-VALUE`, `AS`, `ASCENDING`, `ASSIGN`, `AT`, `AUTO`, `AUTO-SKIP`, `AUTOMATIC`, `AUTOTERMINATE`, `BACKGROUND-COLOR`, `BASED`, `BEEP`, `BEFORE`, `BELL`, `BLANK`, `BLINK`, `BLOCK`, `BOTTOM`, `BY`, `BYTE-LENGTH`, `CHAINING`, `CHARACTER`, `CHARACTERS`, `CLASS`, `CODE`, `CODE-SET`, `COL`, `COLLATING`, `COLS`, `COLUMN`, `COLUMNS`, `COMMA`, `COMMAND-LINE`, `COMMIT`, `COMMON`, `CONSTANT`, `CONTAINS`, `CONTENT`, `CONTROL`, `CONTROLS`, `CONVERTING`, `COPY`, `CORR`, `CORRESPONDING`, `COUNT`, `CRT`, `CURRENCY`, `CURSOR`, `CYCLE`, `DATE`, `DAY`, `DAY-OF-WEEK`, `DE`, `DEBUGGING`, `DECIMAL-POINT`, `DECLARATIVES`, `DEFAULT`, `DELIMITED`, `DELIMITER`, `DEPENDING`, `DESCENDING`, `DETAIL`, `DISK`, `DOWN`, `DUPLICATES`, `DYNAMIC`, `EBCDIC`, `ENTRY`, `ENVIRONMENT-NAME`, `ENVIRONMENT-VALUE`, `EOL`, `EOP`, `EOS`, `ERASE`, `ERROR`, `ESCAPE`, `EXCEPTION`, `EXCLUSIVE`, `EXTEND`, `EXTERNAL`, `FILE-ID`, `FILLER`, `FINAL`, `FIRST`, `FIXED`, `FLOAT-LONG`, `FLOAT-SHORT`, `FOOTING`, `FOR`, `FOREGROUND-COLOR`, `FORMAT`, `FROM`, `FULL`, `FUNCTION`, `FUNCTION-ID`, `GIVING`, `GLOBAL`, `GROUP`, `HEADING`, `HIGHLIGHT`, `I-O`, `ID`, `IGNORE`, `IGNORING`, `IN`, `INDEX`, `INDEXED`, `INDICATE`, `INITIAL`, `INITIALIZED`, `INPUT`, `INTO`, `INTRINSIC`, `INVALID`, `IS`, `JUST`, `JUSTIFIED`, `KEY`, `LABEL`, `LAST`, `LEADING`, `LEFT`, `LENGTH`, `LIMIT`, `LIMITS`, `LINAGE`, `LINAGE-COUNTER`, `LINE`, `LINES`, `LOCALE`, `LOCK`, `LOWLIGHT`, `MANUAL`, `MEMORY`, `MINUS`, `MODE`, `MULTIPLE`, `NATIONAL`, `NATIONAL-EDITED`, `NATIVE`, `NEGATIVE`, `NEXT`, `NO`, `NULL`, `NULLS`, `NUMBER`, `NUMBERS`, `NUMERIC`, `NUMERIC-EDITED`, `OBJECT-COMPUTER`, `OCCURS`, `OF`, `OFF`, `OMITTED`, `ON`, `ONLY`, `OPTIONAL`, `ORDER`, `ORGANIZATION`, `OTHER`, `OUTPUT`, `OVERFLOW`, `OVERLINE`, `PACKED-DECIMAL`, `PADDING`, `PAGE`, `PARAGRAPH`, `PLUS`, `POINTER`, `POSITION`, `POSITIVE`, `PRESENT`, `PREVIOUS`, `PRINTER`, `PRINTING`, `PROCEDURE-POINTER`, `PROCEDURES`, `PROCEED`, `PROGRAM`, `PROGRAM-POINTER`, `PROMPT`, `QUOTE`, `QUOTES`, `RANDOM`, `RD`, `RECORD`, `RECORDING`, `RECORDS`, `RECURSIVE`, `REDEFINES`, `REEL`, `REFERENCE`, `RELATIVE`, `REMAINDER`, `REMOVAL`, `RENAMES`, `REPLACING`, `REPORT`, `REPORTING`, `REPORTS`, `REPOSITORY`, `REQUIRED`, `RESERVE`, `RETURNING`, `REVERSE-VIDEO`, `REWIND`, `RIGHT`, `ROLLBACK`, `ROUNDED`, `RUN`, `SAME`, `SCROLL`, `SECURE`, `SEGMENT-LIMIT`, `SELECT`, `SENTENCE`, `SEPARATE`, `SEQUENCE`, `SEQUENTIAL`, `SHARING`, `SIGN`, `SIGNED`, `SIGNED-INT`, `SIGNED-LONG`, `SIGNED-SHORT`, `SIZE`, `SORT-MERGE`, `SOURCE`, `SOURCE-COMPUTER`, `SPECIAL-NAMES`, `STANDARD`, `STANDARD-1`, `STANDARD-2`, `STATUS`, `SUM`, `SYMBOLIC`, `SYNC`, `SYNCHRONIZED`, `TALLYING`, `TAPE`, `TEST`, `THROUGH`, `THRU`, `TIME`, `TIMES`, `TO`, `TOP`, `TRAILING`, `TRANSFORM`, `TYPE`, `UNDERLINE`, `UNIT`, `UNSIGNED`, `UNSIGNED-INT`, `UNSIGNED-LONG`, `UNSIGNED-SHORT`, `UNTIL`, `UP`, `UPDATE`, `UPON`, `USAGE`, `USING`, `VALUE`, `VALUES`, `VARYING`, `WAIT`, `WHEN`, `WITH`, `WORDS`, `YYYYDDD`, `YYYYMMDD`), KeywordPseudo, nil},
|
||||
{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACTIVE-CLASS`, `ALIGNED`, `ANYCASE`, `ARITHMETIC`, `ATTRIBUTE`, `B-AND`, `B-NOT`, `B-OR`, `B-XOR`, `BIT`, `BOOLEAN`, `CD`, `CENTER`, `CF`, `CH`, `CHAIN`, `CLASS-ID`, `CLASSIFICATION`, `COMMUNICATION`, `CONDITION`, `DATA-POINTER`, `DESTINATION`, `DISABLE`, `EC`, `EGI`, `EMI`, `ENABLE`, `END-RECEIVE`, `ENTRY-CONVENTION`, `EO`, `ESI`, `EXCEPTION-OBJECT`, `EXPANDS`, `FACTORY`, `FLOAT-BINARY-16`, `FLOAT-BINARY-34`, `FLOAT-BINARY-7`, `FLOAT-DECIMAL-16`, `FLOAT-DECIMAL-34`, `FLOAT-EXTENDED`, `FORMAT`, `FUNCTION-POINTER`, `GET`, `GROUP-USAGE`, `IMPLEMENTS`, `INFINITY`, `INHERITS`, `INTERFACE`, `INTERFACE-ID`, `INVOKE`, `LC_ALL`, `LC_COLLATE`, `LC_CTYPE`, `LC_MESSAGES`, `LC_MONETARY`, `LC_NUMERIC`, `LC_TIME`, `LINE-COUNTER`, `MESSAGE`, `METHOD`, `METHOD-ID`, `NESTED`, `NONE`, `NORMAL`, `OBJECT`, `OBJECT-REFERENCE`, `OPTIONS`, `OVERRIDE`, `PAGE-COUNTER`, `PF`, `PH`, `PROPERTY`, `PROTOTYPE`, `PURGE`, `QUEUE`, `RAISE`, `RAISING`, `RECEIVE`, `RELATION`, `REPLACE`, `REPRESENTS-NOT-A-NUMBER`, `RESET`, `RESUME`, `RETRY`, `RF`, `RH`, `SECONDS`, `SEGMENT`, `SELF`, `SEND`, `SOURCES`, `STATEMENT`, `STEP`, `STRONG`, `SUB-QUEUE-1`, `SUB-QUEUE-2`, `SUB-QUEUE-3`, `SUPER`, `SYMBOL`, `SYSTEM-DEFAULT`, `TABLE`, `TERMINAL`, `TEXT`, `TYPEDEF`, `UCS-4`, `UNIVERSAL`, `USER-DEFAULT`, `UTF-16`, `UTF-8`, `VAL-STATUS`, `VALID`, `VALIDATE`, `VALIDATE-STATUS`), Error, nil},
|
||||
{`(^|(?<=[^\w\-]))(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|BINARY-C-LONG|BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|BINARY)\s*($|(?=[^\w\-]))`, KeywordType, nil},
|
||||
{`(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)`, Operator, nil},
|
||||
{`([(),;:&%.])`, Punctuation, nil},
|
||||
{`(^|(?<=[^\w\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG(?:10)?|LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*($|(?=[^\w\-]))`, NameFunction, nil},
|
||||
{`(^|(?<=[^\w\-]))(true|false)\s*($|(?=[^\w\-]))`, NameBuiltin, nil},
|
||||
{`(^|(?<=[^\w\-]))(equal|equals|ne|lt|le|gt|ge|greater|less|than|not|and|or)\s*($|(?=[^\w\-]))`, OperatorWord, nil},
|
||||
},
|
||||
"strings": {
|
||||
{`"[^"\n]*("|\n)`, LiteralStringDouble, nil},
|
||||
{`'[^'\n]*('|\n)`, LiteralStringSingle, nil},
|
||||
},
|
||||
"nums": {
|
||||
{`\d+(\s*|\.$|$)`, LiteralNumberInteger, nil},
|
||||
{`[+-]?\d*\.\d+(E[-+]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`[+-]?\d+\.\d*(E[-+]?\d+)?`, LiteralNumberFloat, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Coffeescript lexer.
|
||||
var Coffeescript = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "CoffeeScript",
|
||||
Aliases: []string{"coffee-script", "coffeescript", "coffee"},
|
||||
Filenames: []string{"*.coffee"},
|
||||
MimeTypes: []string{"text/coffeescript"},
|
||||
NotMultiline: true,
|
||||
DotAll: true,
|
||||
},
|
||||
coffeescriptRules,
|
||||
))
|
||||
|
||||
func coffeescriptRules() Rules {
|
||||
return Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`###[^#].*?###`, CommentMultiline, nil},
|
||||
{`#(?!##[^#]).*?\n`, CommentSingle, nil},
|
||||
},
|
||||
"multilineregex": {
|
||||
{`[^/#]+`, LiteralStringRegex, nil},
|
||||
{`///([gim]+\b|\B)`, LiteralStringRegex, Pop(1)},
|
||||
{`#\{`, LiteralStringInterpol, Push("interpoling_string")},
|
||||
{`[/#]`, LiteralStringRegex, nil},
|
||||
},
|
||||
"slashstartsregex": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`///`, LiteralStringRegex, Push("#pop", "multilineregex")},
|
||||
{`/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)`, LiteralStringRegex, Pop(1)},
|
||||
{`/`, Operator, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"root": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`^(?=\s|/)`, Text, Push("slashstartsregex")},
|
||||
{"\\+\\+|~|&&|\\band\\b|\\bor\\b|\\bis\\b|\\bisnt\\b|\\bnot\\b|\\?|:|\\|\\||\\\\(?=\\n)|(<<|>>>?|==?(?!>)|!=?|=(?!>)|-(?!>)|[<>+*`%&\\|\\^/])=?", Operator, Push("slashstartsregex")},
|
||||
{`(?:\([^()]*\))?\s*[=-]>`, NameFunction, Push("slashstartsregex")},
|
||||
{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
|
||||
{`[})\].]`, Punctuation, nil},
|
||||
{`(?<![.$])(for|own|in|of|while|until|loop|break|return|continue|switch|when|then|if|unless|else|throw|try|catch|finally|new|delete|typeof|instanceof|super|extends|this|class|by)\b`, Keyword, Push("slashstartsregex")},
|
||||
{`(?<![.$])(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil},
|
||||
{`(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b`, NameBuiltin, nil},
|
||||
{`[$a-zA-Z_][\w.:$]*\s*[:=]\s`, NameVariable, Push("slashstartsregex")},
|
||||
{`@[$a-zA-Z_][\w.:$]*\s*[:=]\s`, NameVariableInstance, Push("slashstartsregex")},
|
||||
{`@`, NameOther, Push("slashstartsregex")},
|
||||
{`@?[$a-zA-Z_][\w$]*`, NameOther, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"""`, LiteralString, Push("tdqs")},
|
||||
{`'''`, LiteralString, Push("tsqs")},
|
||||
{`"`, LiteralString, Push("dqs")},
|
||||
{`'`, LiteralString, Push("sqs")},
|
||||
},
|
||||
"strings": {
|
||||
{`[^#\\\'"]+`, LiteralString, nil},
|
||||
},
|
||||
"interpoling_string": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"dqs": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\.|\'`, LiteralString, nil},
|
||||
{`#\{`, LiteralStringInterpol, Push("interpoling_string")},
|
||||
{`#`, LiteralString, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
"sqs": {
|
||||
{`'`, LiteralString, Pop(1)},
|
||||
{`#|\\.|"`, LiteralString, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
"tdqs": {
|
||||
{`"""`, LiteralString, Pop(1)},
|
||||
{`\\.|\'|"`, LiteralString, nil},
|
||||
{`#\{`, LiteralStringInterpol, Push("interpoling_string")},
|
||||
{`#`, LiteralString, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
"tsqs": {
|
||||
{`'''`, LiteralString, Pop(1)},
|
||||
{`#|\\.|\'|"`, LiteralString, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cfstatement lexer.
|
||||
var Cfstatement = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "cfstatement",
|
||||
Aliases: []string{"cfs"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
cfstatementRules,
|
||||
))
|
||||
|
||||
func cfstatementRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*(?:.|\n)*?\*/`, CommentMultiline, nil},
|
||||
{`\+\+|--`, Operator, nil},
|
||||
{`[-+*/^&=!]`, Operator, nil},
|
||||
{`<=|>=|<|>|==`, Operator, nil},
|
||||
{`mod\b`, Operator, nil},
|
||||
{`(eq|lt|gt|lte|gte|not|is|and|or)\b`, Operator, nil},
|
||||
{`\|\||&&`, Operator, nil},
|
||||
{`\?`, Operator, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`'.*?'`, LiteralStringSingle, nil},
|
||||
{`\d+`, LiteralNumber, nil},
|
||||
{`(if|else|len|var|xml|default|break|switch|component|property|function|do|try|catch|in|continue|for|return|while|required|any|array|binary|boolean|component|date|guid|numeric|query|string|struct|uuid|case)\b`, Keyword, nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(application|session|client|cookie|super|this|variables|arguments)\b`, NameConstant, nil},
|
||||
{`([a-z_$][\w.]*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||
{`[a-z_$][\w.]*`, NameVariable, nil},
|
||||
{`[()\[\]{};:,.\\]`, Punctuation, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"string": {
|
||||
{`""`, LiteralStringDouble, nil},
|
||||
{`#.+?#`, LiteralStringInterpol, nil},
|
||||
{`[^"#]+`, LiteralStringDouble, nil},
|
||||
{`#`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Coq lexer.
|
||||
var Coq = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Coq",
|
||||
Aliases: []string{"coq"},
|
||||
Filenames: []string{"*.v"},
|
||||
MimeTypes: []string{"text/x-coq"},
|
||||
},
|
||||
coqRules,
|
||||
))
|
||||
|
||||
func coqRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`false|true|\(\)|\[\]`, NameBuiltinPseudo, nil},
|
||||
{`\(\*`, Comment, Push("comment")},
|
||||
{Words(`\b`, `\b`, `Section`, `Module`, `End`, `Require`, `Import`, `Export`, `Variable`, `Variables`, `Parameter`, `Parameters`, `Axiom`, `Hypothesis`, `Hypotheses`, `Notation`, `Local`, `Tactic`, `Reserved`, `Scope`, `Open`, `Close`, `Bind`, `Delimit`, `Definition`, `Let`, `Ltac`, `Fixpoint`, `CoFixpoint`, `Morphism`, `Relation`, `Implicit`, `Arguments`, `Set`, `Unset`, `Contextual`, `Strict`, `Prenex`, `Implicits`, `Inductive`, `CoInductive`, `Record`, `Structure`, `Canonical`, `Coercion`, `Theorem`, `Lemma`, `Corollary`, `Proposition`, `Fact`, `Remark`, `Example`, `Proof`, `Goal`, `Save`, `Qed`, `Defined`, `Hint`, `Resolve`, `Rewrite`, `View`, `Search`, `Show`, `Print`, `Printing`, `All`, `Graph`, `Projections`, `inside`, `outside`, `Check`, `Global`, `Instance`, `Class`, `Existing`, `Universe`, `Polymorphic`, `Monomorphic`, `Context`), KeywordNamespace, nil},
|
||||
{Words(`\b`, `\b`, `forall`, `exists`, `exists2`, `fun`, `fix`, `cofix`, `struct`, `match`, `end`, `in`, `return`, `let`, `if`, `is`, `then`, `else`, `for`, `of`, `nosimpl`, `with`, `as`), Keyword, nil},
|
||||
{Words(`\b`, `\b`, `Type`, `Prop`), KeywordType, nil},
|
||||
{Words(`\b`, `\b`, `pose`, `set`, `move`, `case`, `elim`, `apply`, `clear`, `hnf`, `intro`, `intros`, `generalize`, `rename`, `pattern`, `after`, `destruct`, `induction`, `using`, `refine`, `inversion`, `injection`, `rewrite`, `congr`, `unlock`, `compute`, `ring`, `field`, `replace`, `fold`, `unfold`, `change`, `cutrewrite`, `simpl`, `have`, `suff`, `wlog`, `suffices`, `without`, `loss`, `nat_norm`, `assert`, `cut`, `trivial`, `revert`, `bool_congr`, `nat_congr`, `symmetry`, `transitivity`, `auto`, `split`, `left`, `right`, `autorewrite`, `tauto`, `setoid_rewrite`, `intuition`, `eauto`, `eapply`, `econstructor`, `etransitivity`, `constructor`, `erewrite`, `red`, `cbv`, `lazy`, `vm_compute`, `native_compute`, `subst`), Keyword, nil},
|
||||
{Words(`\b`, `\b`, `by`, `done`, `exact`, `reflexivity`, `tauto`, `romega`, `omega`, `assumption`, `solve`, `contradiction`, `discriminate`, `congruence`), KeywordPseudo, nil},
|
||||
{Words(`\b`, `\b`, `do`, `last`, `first`, `try`, `idtac`, `repeat`), KeywordReserved, nil},
|
||||
{`\b([A-Z][\w\']*)`, Name, nil},
|
||||
{"(\u03bb|\u03a0|\\|\\}|\\{\\||\\\\/|/\\\\|=>|~|\\}|\\|]|\\||\\{<|\\{|`|_|]|\\[\\||\\[>|\\[<|\\[|\\?\\?|\\?|>\\}|>]|>|=|<->|<-|<|;;|;|:>|:=|::|:|\\.\\.|\\.|->|-\\.|-|,|\\+|\\*|\\)|\\(|&&|&|#|!=)", Operator, nil},
|
||||
{`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil},
|
||||
{`\b(unit|nat|bool|string|ascii|list)\b`, KeywordType, nil},
|
||||
{`[^\W\d][\w']*`, Name, nil},
|
||||
{`\d[\d_]*`, LiteralNumberInteger, nil},
|
||||
{`0[xX][\da-fA-F][\da-fA-F_]*`, LiteralNumberHex, nil},
|
||||
{`0[oO][0-7][0-7_]*`, LiteralNumberOct, nil},
|
||||
{`0[bB][01][01_]*`, LiteralNumberBin, nil},
|
||||
{`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)`, LiteralNumberFloat, nil},
|
||||
{`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'`, LiteralStringChar, nil},
|
||||
{`'.'`, LiteralStringChar, nil},
|
||||
{`'`, Keyword, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`[~?][a-z][\w\']*:`, Name, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^(*)]+`, Comment, nil},
|
||||
{`\(\*`, Comment, Push()},
|
||||
{`\*\)`, Comment, Pop(1)},
|
||||
{`[(*)]`, Comment, nil},
|
||||
},
|
||||
"string": {
|
||||
{`[^"]+`, LiteralStringDouble, nil},
|
||||
{`""`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
},
|
||||
"dotted": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\.`, Punctuation, nil},
|
||||
{`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil},
|
||||
{`[A-Z][\w\']*`, NameClass, Pop(1)},
|
||||
{`[a-z][a-z0-9_\']*`, Name, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// CPP lexer.
|
||||
var CPP = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "C++",
|
||||
Aliases: []string{"cpp", "c++"},
|
||||
Filenames: []string{"*.cpp", "*.hpp", "*.c++", "*.h++", "*.cc", "*.hh", "*.cxx", "*.hxx", "*.C", "*.H", "*.cp", "*.CPP"},
|
||||
MimeTypes: []string{"text/x-c++hdr", "text/x-c++src"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
cppRules,
|
||||
))
|
||||
|
||||
func cppRules() Rules {
|
||||
return Rules{
|
||||
"statements": {
|
||||
{Words(``, `\b`, `catch`, `const_cast`, `delete`, `dynamic_cast`, `explicit`, `export`, `friend`, `mutable`, `namespace`, `new`, `operator`, `private`, `protected`, `public`, `reinterpret_cast`, `restrict`, `static_cast`, `template`, `this`, `throw`, `throws`, `try`, `typeid`, `typename`, `using`, `virtual`, `constexpr`, `nullptr`, `decltype`, `thread_local`, `alignas`, `alignof`, `static_assert`, `noexcept`, `override`, `final`, `concept`, `requires`, `consteval`, `co_await`, `co_return`, `co_yield`), Keyword, nil},
|
||||
{`(enum)\b(\s+)(class)\b(\s*)`, ByGroups(Keyword, Text, Keyword, Text), Push("classname")},
|
||||
{`(class|struct|enum|union)\b(\s*)`, ByGroups(Keyword, Text), Push("classname")},
|
||||
{`\[\[.+\]\]`, NameAttribute, nil},
|
||||
{`(R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")`, ByGroups(LiteralStringAffix, LiteralString, LiteralStringDelimiter, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, LiteralString), nil},
|
||||
{`(u8|u|U)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||
{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||
{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||
{`0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*`, LiteralNumberHex, nil},
|
||||
{`0('?[0-7]+)+[LlUu]*`, LiteralNumberOct, nil},
|
||||
{`0[Bb][01]('?[01]+)*[LlUu]*`, LiteralNumberBin, nil},
|
||||
{`[0-9]('?[0-9]+)*[LlUu]*`, LiteralNumberInteger, nil},
|
||||
{`\*/`, Error, nil},
|
||||
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
|
||||
{`[()\[\],.]`, Punctuation, nil},
|
||||
{Words(``, `\b`, `asm`, `auto`, `break`, `case`, `const`, `continue`, `default`, `do`, `else`, `enum`, `extern`, `for`, `goto`, `if`, `register`, `restricted`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `volatile`, `while`), Keyword, nil},
|
||||
{`(bool|int|long|float|short|double|char((8|16|32)_t)?|wchar_t|unsigned|signed|void|u?int(_fast|_least|)(8|16|32|64)_t)\b`, KeywordType, nil},
|
||||
{Words(``, `\b`, `inline`, `_inline`, `__inline`, `naked`, `restrict`, `thread`, `typename`), KeywordReserved, nil},
|
||||
{`(__m(128i|128d|128|64))\b`, KeywordReserved, nil},
|
||||
{Words(`__`, `\b`, `asm`, `int8`, `based`, `except`, `int16`, `stdcall`, `cdecl`, `fastcall`, `int32`, `declspec`, `finally`, `int64`, `try`, `leave`, `w64`, `unaligned`, `raise`, `noop`, `identifier`, `forceinline`, `assume`), KeywordReserved, nil},
|
||||
{`(true|false|NULL)\b`, NameBuiltin, nil},
|
||||
{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
|
||||
{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
|
||||
Default(Push("statement")),
|
||||
{Words(`__`, `\b`, `virtual_inheritance`, `uuidof`, `super`, `single_inheritance`, `multiple_inheritance`, `interface`, `event`), KeywordReserved, nil},
|
||||
{`__(offload|blockingoffload|outer)\b`, KeywordPseudo, nil},
|
||||
},
|
||||
"classname": {
|
||||
{`(\[\[.+\]\])(\s*)`, ByGroups(NameAttribute, Text), nil},
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
{`\s*(?=[>{])`, Text, Pop(1)},
|
||||
},
|
||||
"whitespace": {
|
||||
{`^#if\s+0`, CommentPreproc, Push("if0")},
|
||||
{`^#`, CommentPreproc, Push("macro")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
|
||||
},
|
||||
"statement": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`[{]`, Punctuation, Push("root")},
|
||||
{`[;}]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"function": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`;`, Punctuation, nil},
|
||||
{`\{`, Punctuation, Push()},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
{`[^\\"\n]+`, LiteralString, nil},
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\\`, LiteralString, nil},
|
||||
},
|
||||
"macro": {
|
||||
{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
|
||||
{`[^/\n]+`, CommentPreproc, nil},
|
||||
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
|
||||
{`//.*?\n`, CommentSingle, Pop(1)},
|
||||
{`/`, CommentPreproc, nil},
|
||||
{`(?<=\\)\n`, CommentPreproc, nil},
|
||||
{`\n`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
"if0": {
|
||||
{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
|
||||
{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
|
||||
{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
|
||||
{`.*?\n`, Comment, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// CassandraCQL lexer.
|
||||
var CassandraCQL = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Cassandra CQL",
|
||||
Aliases: []string{"cassandra", "cql"},
|
||||
Filenames: []string{"*.cql"},
|
||||
MimeTypes: []string{"text/x-cql"},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
cassandraCQLRules,
|
||||
))
|
||||
|
||||
func cassandraCQLRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
{`(--|\/\/).*\n?`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`(ascii|bigint|blob|boolean|counter|date|decimal|double|float|frozen|inet|int|list|map|set|smallint|text|time|timestamp|timeuuid|tinyint|tuple|uuid|varchar|varint)\b`, NameBuiltin, nil},
|
||||
{Words(``, `\b`, `ADD`, `AGGREGATE`, `ALL`, `ALLOW`, `ALTER`, `AND`, `ANY`, `APPLY`, `AS`, `ASC`, `AUTHORIZE`, `BATCH`, `BEGIN`, `BY`, `CLUSTERING`, `COLUMNFAMILY`, `COMPACT`, `CONSISTENCY`, `COUNT`, `CREATE`, `CUSTOM`, `DELETE`, `DESC`, `DISTINCT`, `DROP`, `EACH_QUORUM`, `ENTRIES`, `EXISTS`, `FILTERING`, `FROM`, `FULL`, `GRANT`, `IF`, `IN`, `INDEX`, `INFINITY`, `INSERT`, `INTO`, `KEY`, `KEYS`, `KEYSPACE`, `KEYSPACES`, `LEVEL`, `LIMIT`, `LOCAL_ONE`, `LOCAL_QUORUM`, `MATERIALIZED`, `MODIFY`, `NAN`, `NORECURSIVE`, `NOSUPERUSER`, `NOT`, `OF`, `ON`, `ONE`, `ORDER`, `PARTITION`, `PASSWORD`, `PER`, `PERMISSION`, `PERMISSIONS`, `PRIMARY`, `QUORUM`, `RENAME`, `REVOKE`, `SCHEMA`, `SELECT`, `STATIC`, `STORAGE`, `SUPERUSER`, `TABLE`, `THREE`, `TO`, `TOKEN`, `TRUNCATE`, `TTL`, `TWO`, `TYPE`, `UNLOGGED`, `UPDATE`, `USE`, `USER`, `USERS`, `USING`, `VALUES`, `VIEW`, `WHERE`, `WITH`, `WRITETIME`, `REPLICATION`, `OR`, `REPLACE`, `FUNCTION`, `CALLED`, `INPUT`, `RETURNS`, `LANGUAGE`, `ROLE`, `ROLES`, `TRIGGER`, `DURABLE_WRITES`, `LOGIN`, `OPTIONS`, `LOGGED`, `SFUNC`, `STYPE`, `FINALFUNC`, `INITCOND`, `IS`, `CONTAINS`, `JSON`, `PAGING`, `OFF`), Keyword, nil},
|
||||
{"[+*/<>=~!@#%^&|`?-]+", Operator, nil},
|
||||
{
|
||||
`(?s)(java|javascript)(\s+)(AS)(\s+)('|\$\$)(.*?)(\5)`,
|
||||
UsingByGroup(
|
||||
internal.Get,
|
||||
1, 6,
|
||||
NameBuiltin, TextWhitespace, Keyword, TextWhitespace,
|
||||
LiteralStringHeredoc, LiteralStringHeredoc, LiteralStringHeredoc,
|
||||
),
|
||||
nil,
|
||||
},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`0x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
{`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`, LiteralNumberHex, nil},
|
||||
{`\.[0-9]+(e[+-]?[0-9]+)?`, Error, nil},
|
||||
{`-?[0-9]+(\.[0-9])?(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`'`, LiteralStringSingle, Push("string")},
|
||||
{`"`, LiteralStringName, Push("quoted-ident")},
|
||||
{`\$\$`, LiteralStringHeredoc, Push("dollar-string")},
|
||||
{`[a-z_]\w*`, Name, nil},
|
||||
{`:(['"]?)[a-z]\w*\b\1`, NameVariable, nil},
|
||||
{`[;:()\[\]\{\},.]`, Punctuation, nil},
|
||||
},
|
||||
"multiline-comments": {
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[^/*]+`, CommentMultiline, nil},
|
||||
{`[/*]`, CommentMultiline, nil},
|
||||
},
|
||||
"string": {
|
||||
{`[^']+`, LiteralStringSingle, nil},
|
||||
{`''`, LiteralStringSingle, nil},
|
||||
{`'`, LiteralStringSingle, Pop(1)},
|
||||
},
|
||||
"quoted-ident": {
|
||||
{`[^"]+`, LiteralStringName, nil},
|
||||
{`""`, LiteralStringName, nil},
|
||||
{`"`, LiteralStringName, Pop(1)},
|
||||
},
|
||||
"dollar-string": {
|
||||
{`[^\$]+`, LiteralStringHeredoc, nil},
|
||||
{`\$\$`, LiteralStringHeredoc, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Crystal lexer.
|
||||
var Crystal = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Crystal",
|
||||
Aliases: []string{"cr", "crystal"},
|
||||
Filenames: []string{"*.cr"},
|
||||
MimeTypes: []string{"text/x-crystal"},
|
||||
DotAll: true,
|
||||
},
|
||||
crystalRules,
|
||||
))
|
||||
|
||||
func crystalRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*?$`, CommentSingle, nil},
|
||||
{Words(``, `\b`, `abstract`, `asm`, `as`, `begin`, `break`, `case`, `do`, `else`, `elsif`, `end`, `ensure`, `extend`, `ifdef`, `if`, `include`, `instance_sizeof`, `next`, `of`, `pointerof`, `private`, `protected`, `rescue`, `return`, `require`, `sizeof`, `super`, `then`, `typeof`, `unless`, `until`, `when`, `while`, `with`, `yield`), Keyword, nil},
|
||||
{Words(``, `\b`, `true`, `false`, `nil`), KeywordConstant, nil},
|
||||
{`(module|lib)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil},
|
||||
{`(def|fun|macro)(\s+)((?:[a-zA-Z_]\w*::)*)`, ByGroups(Keyword, Text, NameNamespace), Push("funcname")},
|
||||
{"def(?=[*%&^`~+-/\\[<>=])", Keyword, Push("funcname")},
|
||||
{`(class|struct|union|type|alias|enum)(\s+)((?:[a-zA-Z_]\w*::)*)`, ByGroups(Keyword, Text, NameNamespace), Push("classname")},
|
||||
{`(self|out|uninitialized)\b|(is_a|responds_to)\?`, KeywordPseudo, nil},
|
||||
{Words(``, `\b`, `debugger`, `record`, `pp`, `assert_responds_to`, `spawn`, `parallel`, `getter`, `setter`, `property`, `delegate`, `def_hash`, `def_equals`, `def_equals_and_hash`, `forward_missing_to`), NameBuiltinPseudo, nil},
|
||||
{`getter[!?]|property[!?]|__(DIR|FILE|LINE)__\b`, NameBuiltinPseudo, nil},
|
||||
{Words(`(?<!\.)`, `\b`, `Object`, `Value`, `Struct`, `Reference`, `Proc`, `Class`, `Nil`, `Symbol`, `Enum`, `Void`, `Bool`, `Number`, `Int`, `Int8`, `Int16`, `Int32`, `Int64`, `UInt8`, `UInt16`, `UInt32`, `UInt64`, `Float`, `Float32`, `Float64`, `Char`, `String`, `Pointer`, `Slice`, `Range`, `Exception`, `Regex`, `Mutex`, `StaticArray`, `Array`, `Hash`, `Set`, `Tuple`, `Deque`, `Box`, `Process`, `File`, `Dir`, `Time`, `Channel`, `Concurrent`, `Scheduler`, `abort`, `at_exit`, `caller`, `delay`, `exit`, `fork`, `future`, `get_stack_top`, `gets`, `lazy`, `loop`, `main`, `p`, `print`, `printf`, `puts`, `raise`, `rand`, `read_line`, `sleep`, `sprintf`, `system`, `with_color`), NameBuiltin, nil},
|
||||
{"(?<!\\w)(<<-?)([\"`\\']?)([a-zA-Z_]\\w*)(\\2)(.*?\\n)", StringHeredoc, nil},
|
||||
{`(<<-?)("|\')()(\2)(.*?\n)`, StringHeredoc, nil},
|
||||
{`__END__`, CommentPreproc, Push("end-part")},
|
||||
{`(?:^|(?<=[=<>~!:])|(?<=(?:\s|;)when\s)|(?<=(?:\s|;)or\s)|(?<=(?:\s|;)and\s)|(?<=\.index\s)|(?<=\.scan\s)|(?<=\.sub\s)|(?<=\.sub!\s)|(?<=\.gsub\s)|(?<=\.gsub!\s)|(?<=\.match\s)|(?<=(?:\s|;)if\s)|(?<=(?:\s|;)elsif\s)|(?<=^when\s)|(?<=^index\s)|(?<=^scan\s)|(?<=^sub\s)|(?<=^gsub\s)|(?<=^sub!\s)|(?<=^gsub!\s)|(?<=^match\s)|(?<=^if\s)|(?<=^elsif\s))(\s*)(/)`, ByGroups(Text, LiteralStringRegex), Push("multiline-regex")},
|
||||
{`(?<=\(|,|\[)/`, LiteralStringRegex, Push("multiline-regex")},
|
||||
{`(\s+)(/)(?![\s=])`, ByGroups(Text, LiteralStringRegex), Push("multiline-regex")},
|
||||
{`(0o[0-7]+(?:_[0-7]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberOct, Text, Operator), nil},
|
||||
{`(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberHex, Text, Operator), nil},
|
||||
{`(0b[01]+(?:_[01]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberBin, Text, Operator), nil},
|
||||
{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)(?:e[+-]?[0-9]+)?(?:_?f[0-9]+)?)(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil},
|
||||
{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)(?:_?f[0-9]+)?)(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil},
|
||||
{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)?(?:_?f[0-9]+))(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil},
|
||||
{`(0\b|[1-9][\d]*(?:_\d+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberInteger, Text, Operator), nil},
|
||||
{`@@[a-zA-Z_]\w*`, NameVariableClass, nil},
|
||||
{`@[a-zA-Z_]\w*`, NameVariableInstance, nil},
|
||||
{`\$\w+`, NameVariableGlobal, nil},
|
||||
{"\\$[!@&`\\'+~=/\\\\,;.<>_*$?:\"^-]", NameVariableGlobal, nil},
|
||||
{`\$-[0adFiIlpvw]`, NameVariableGlobal, nil},
|
||||
{`::`, Operator, nil},
|
||||
Include("strings"),
|
||||
{`\?(\\[MC]-)*(\\([\\befnrtv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)(?!\w)`, LiteralStringChar, nil},
|
||||
{`[A-Z][A-Z_]+\b`, NameConstant, nil},
|
||||
{`\{%`, LiteralStringInterpol, Push("in-macro-control")},
|
||||
{`\{\{`, LiteralStringInterpol, Push("in-macro-expr")},
|
||||
{`(@\[)(\s*)([A-Z]\w*)`, ByGroups(Operator, Text, NameDecorator), Push("in-attr")},
|
||||
{Words(`(\.|::)`, ``, `!=`, `!~`, `!`, `%`, `&&`, `&`, `**`, `*`, `+`, `-`, `/`, `<=>`, `<<`, `<=`, `<`, `===`, `==`, `=~`, `=`, `>=`, `>>`, `>`, `[]=`, `[]?`, `[]`, `^`, `||`, `|`, `~`), ByGroups(Operator, NameOperator), nil},
|
||||
{"(\\.|::)([a-zA-Z_]\\w*[!?]?|[*%&^`~+\\-/\\[<>=])", ByGroups(Operator, Name), nil},
|
||||
{`[a-zA-Z_]\w*(?:[!?](?!=))?`, Name, nil},
|
||||
{`(\[|\]\??|\*\*|<=>?|>=|<<?|>>?|=~|===|!~|&&?|\|\||\.{1,3})`, Operator, nil},
|
||||
{`[-+/*%=<>&!^|~]=?`, Operator, nil},
|
||||
{`[(){};,/?:\\]`, Punctuation, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"funcname": {
|
||||
{"(?:([a-zA-Z_]\\w*)(\\.))?([a-zA-Z_]\\w*[!?]?|\\*\\*?|[-+]@?|[/%&|^`~]|\\[\\]=?|<<|>>|<=?>|>=?|===?)", ByGroups(NameClass, Operator, NameFunction), Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"classname": {
|
||||
{`[A-Z_]\w*`, NameClass, nil},
|
||||
{`(\()(\s*)([A-Z_]\w*)(\s*)(\))`, ByGroups(Punctuation, Text, NameClass, Text, Punctuation), nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"in-intp": {
|
||||
{`\{`, LiteralStringInterpol, Push()},
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"string-intp": {
|
||||
{`#\{`, LiteralStringInterpol, Push("in-intp")},
|
||||
},
|
||||
"string-escaped": {
|
||||
{`\\([\\befnstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
},
|
||||
"string-intp-escaped": {
|
||||
Include("string-intp"),
|
||||
Include("string-escaped"),
|
||||
},
|
||||
"interpolated-regex": {
|
||||
Include("string-intp"),
|
||||
{`[\\#]`, LiteralStringRegex, nil},
|
||||
{`[^\\#]+`, LiteralStringRegex, nil},
|
||||
},
|
||||
"interpolated-string": {
|
||||
Include("string-intp"),
|
||||
{`[\\#]`, LiteralStringOther, nil},
|
||||
{`[^\\#]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"multiline-regex": {
|
||||
Include("string-intp"),
|
||||
{`\\\\`, LiteralStringRegex, nil},
|
||||
{`\\/`, LiteralStringRegex, nil},
|
||||
{`[\\#]`, LiteralStringRegex, nil},
|
||||
{`[^\\/#]+`, LiteralStringRegex, nil},
|
||||
{`/[imsx]*`, LiteralStringRegex, Pop(1)},
|
||||
},
|
||||
"end-part": {
|
||||
{`.+`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
"in-macro-control": {
|
||||
{`\{%`, LiteralStringInterpol, Push()},
|
||||
{`%\}`, LiteralStringInterpol, Pop(1)},
|
||||
{`for\b|in\b`, Keyword, nil},
|
||||
Include("root"),
|
||||
},
|
||||
"in-macro-expr": {
|
||||
{`\{\{`, LiteralStringInterpol, Push()},
|
||||
{`\}\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"in-attr": {
|
||||
{`\[`, Operator, Push()},
|
||||
{`\]`, Operator, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"strings": {
|
||||
{`\:@{0,2}[a-zA-Z_]\w*[!?]?`, LiteralStringSymbol, nil},
|
||||
{Words(`\:@{0,2}`, ``, `!=`, `!~`, `!`, `%`, `&&`, `&`, `**`, `*`, `+`, `-`, `/`, `<=>`, `<<`, `<=`, `<`, `===`, `==`, `=~`, `=`, `>=`, `>>`, `>`, `[]=`, `[]?`, `[]`, `^`, `||`, `|`, `~`), LiteralStringSymbol, nil},
|
||||
{`:'(\\\\|\\'|[^'])*'`, LiteralStringSymbol, nil},
|
||||
{`'(\\\\|\\'|[^']|\\[^'\\]+)'`, LiteralStringChar, nil},
|
||||
{`:"`, LiteralStringSymbol, Push("simple-sym")},
|
||||
{`([a-zA-Z_]\w*)(:)(?!:)`, ByGroups(LiteralStringSymbol, Punctuation), nil},
|
||||
{`"`, LiteralStringDouble, Push("simple-string")},
|
||||
{"(?<!\\.)`", LiteralStringBacktick, Push("simple-backtick")},
|
||||
{`%\{`, LiteralStringOther, Push("cb-intp-string")},
|
||||
{`%[wi]\{`, LiteralStringOther, Push("cb-string")},
|
||||
{`%r\{`, LiteralStringRegex, Push("cb-regex")},
|
||||
{`%\[`, LiteralStringOther, Push("sb-intp-string")},
|
||||
{`%[wi]\[`, LiteralStringOther, Push("sb-string")},
|
||||
{`%r\[`, LiteralStringRegex, Push("sb-regex")},
|
||||
{`%\(`, LiteralStringOther, Push("pa-intp-string")},
|
||||
{`%[wi]\(`, LiteralStringOther, Push("pa-string")},
|
||||
{`%r\(`, LiteralStringRegex, Push("pa-regex")},
|
||||
{`%<`, LiteralStringOther, Push("ab-intp-string")},
|
||||
{`%[wi]<`, LiteralStringOther, Push("ab-string")},
|
||||
{`%r<`, LiteralStringRegex, Push("ab-regex")},
|
||||
{`(%r([\W_]))((?:\\\2|(?!\2).)*)(\2[imsx]*)`, String, nil},
|
||||
{`(%[wi]([\W_]))((?:\\\2|(?!\2).)*)(\2)`, String, nil},
|
||||
{`(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)`, ByGroups(Text, LiteralStringOther, None), nil},
|
||||
{`^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)`, ByGroups(Text, LiteralStringOther, None), nil},
|
||||
{`(%([\[{(<]))((?:\\\2|(?!\2).)*)(\2)`, String, nil},
|
||||
},
|
||||
"simple-string": {
|
||||
Include("string-intp-escaped"),
|
||||
{`[^\\"#]+`, LiteralStringDouble, nil},
|
||||
{`[\\#]`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
},
|
||||
"simple-sym": {
|
||||
Include("string-escaped"),
|
||||
{`[^\\"#]+`, LiteralStringSymbol, nil},
|
||||
{`[\\#]`, LiteralStringSymbol, nil},
|
||||
{`"`, LiteralStringSymbol, Pop(1)},
|
||||
},
|
||||
"simple-backtick": {
|
||||
Include("string-intp-escaped"),
|
||||
{"[^\\\\`#]+", LiteralStringBacktick, nil},
|
||||
{`[\\#]`, LiteralStringBacktick, nil},
|
||||
{"`", LiteralStringBacktick, Pop(1)},
|
||||
},
|
||||
"cb-intp-string": {
|
||||
{`\\[\{]`, LiteralStringOther, nil},
|
||||
{`\{`, LiteralStringOther, Push()},
|
||||
{`\}`, LiteralStringOther, Pop(1)},
|
||||
Include("string-intp-escaped"),
|
||||
{`[\\#{}]`, LiteralStringOther, nil},
|
||||
{`[^\\#{}]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"cb-string": {
|
||||
{`\\[\\{}]`, LiteralStringOther, nil},
|
||||
{`\{`, LiteralStringOther, Push()},
|
||||
{`\}`, LiteralStringOther, Pop(1)},
|
||||
{`[\\#{}]`, LiteralStringOther, nil},
|
||||
{`[^\\#{}]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"cb-regex": {
|
||||
{`\\[\\{}]`, LiteralStringRegex, nil},
|
||||
{`\{`, LiteralStringRegex, Push()},
|
||||
{`\}[imsx]*`, LiteralStringRegex, Pop(1)},
|
||||
Include("string-intp"),
|
||||
{`[\\#{}]`, LiteralStringRegex, nil},
|
||||
{`[^\\#{}]+`, LiteralStringRegex, nil},
|
||||
},
|
||||
"sb-intp-string": {
|
||||
{`\\[\[]`, LiteralStringOther, nil},
|
||||
{`\[`, LiteralStringOther, Push()},
|
||||
{`\]`, LiteralStringOther, Pop(1)},
|
||||
Include("string-intp-escaped"),
|
||||
{`[\\#\[\]]`, LiteralStringOther, nil},
|
||||
{`[^\\#\[\]]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"sb-string": {
|
||||
{`\\[\\\[\]]`, LiteralStringOther, nil},
|
||||
{`\[`, LiteralStringOther, Push()},
|
||||
{`\]`, LiteralStringOther, Pop(1)},
|
||||
{`[\\#\[\]]`, LiteralStringOther, nil},
|
||||
{`[^\\#\[\]]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"sb-regex": {
|
||||
{`\\[\\\[\]]`, LiteralStringRegex, nil},
|
||||
{`\[`, LiteralStringRegex, Push()},
|
||||
{`\][imsx]*`, LiteralStringRegex, Pop(1)},
|
||||
Include("string-intp"),
|
||||
{`[\\#\[\]]`, LiteralStringRegex, nil},
|
||||
{`[^\\#\[\]]+`, LiteralStringRegex, nil},
|
||||
},
|
||||
"pa-intp-string": {
|
||||
{`\\[\(]`, LiteralStringOther, nil},
|
||||
{`\(`, LiteralStringOther, Push()},
|
||||
{`\)`, LiteralStringOther, Pop(1)},
|
||||
Include("string-intp-escaped"),
|
||||
{`[\\#()]`, LiteralStringOther, nil},
|
||||
{`[^\\#()]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"pa-string": {
|
||||
{`\\[\\()]`, LiteralStringOther, nil},
|
||||
{`\(`, LiteralStringOther, Push()},
|
||||
{`\)`, LiteralStringOther, Pop(1)},
|
||||
{`[\\#()]`, LiteralStringOther, nil},
|
||||
{`[^\\#()]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"pa-regex": {
|
||||
{`\\[\\()]`, LiteralStringRegex, nil},
|
||||
{`\(`, LiteralStringRegex, Push()},
|
||||
{`\)[imsx]*`, LiteralStringRegex, Pop(1)},
|
||||
Include("string-intp"),
|
||||
{`[\\#()]`, LiteralStringRegex, nil},
|
||||
{`[^\\#()]+`, LiteralStringRegex, nil},
|
||||
},
|
||||
"ab-intp-string": {
|
||||
{`\\[<]`, LiteralStringOther, nil},
|
||||
{`<`, LiteralStringOther, Push()},
|
||||
{`>`, LiteralStringOther, Pop(1)},
|
||||
Include("string-intp-escaped"),
|
||||
{`[\\#<>]`, LiteralStringOther, nil},
|
||||
{`[^\\#<>]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"ab-string": {
|
||||
{`\\[\\<>]`, LiteralStringOther, nil},
|
||||
{`<`, LiteralStringOther, Push()},
|
||||
{`>`, LiteralStringOther, Pop(1)},
|
||||
{`[\\#<>]`, LiteralStringOther, nil},
|
||||
{`[^\\#<>]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"ab-regex": {
|
||||
{`\\[\\<>]`, LiteralStringRegex, nil},
|
||||
{`<`, LiteralStringRegex, Push()},
|
||||
{`>[imsx]*`, LiteralStringRegex, Pop(1)},
|
||||
Include("string-intp"),
|
||||
{`[\\#<>]`, LiteralStringRegex, nil},
|
||||
{`[^\\#<>]+`, LiteralStringRegex, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// CSharp lexer.
|
||||
var CSharp = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "C#",
|
||||
Aliases: []string{"csharp", "c#"},
|
||||
Filenames: []string{"*.cs"},
|
||||
MimeTypes: []string{"text/x-csharp"},
|
||||
DotAll: true,
|
||||
EnsureNL: true,
|
||||
},
|
||||
cSharpRules,
|
||||
))
|
||||
|
||||
func cSharpRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^\s*\[.*?\]`, NameAttribute, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`///[^\n\r]+`, CommentSpecial, nil},
|
||||
{`//[^\n\r]+`, CommentSingle, nil},
|
||||
{`/[*].*?[*]/`, CommentMultiline, nil},
|
||||
{`\n`, Text, nil},
|
||||
{`[~!%^&*()+=|\[\]:;,.<>/?-]`, Punctuation, nil},
|
||||
{`[{}]`, Punctuation, nil},
|
||||
{`@"(""|[^"])*"`, LiteralString, nil},
|
||||
{`\$@?"(""|[^"])*"`, LiteralString, nil},
|
||||
{`"(\\\\|\\"|[^"\n])*["\n]`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'`, LiteralStringChar, nil},
|
||||
{`0[xX][0-9a-fA-F]+[Ll]?|[0-9_](\.[0-9]*)?([eE][+-]?[0-9]+)?[flFLdD]?`, LiteralNumber, nil},
|
||||
{`#[ \t]*(if|endif|else|elif|define|undef|line|error|warning|region|endregion|pragma|nullable)\b[^\n\r]+`, CommentPreproc, nil},
|
||||
{`\b(extern)(\s+)(alias)\b`, ByGroups(Keyword, Text, Keyword), nil},
|
||||
{`(abstract|as|async|await|base|break|by|case|catch|checked|const|continue|default|delegate|do|else|enum|event|explicit|extern|false|finally|fixed|for|foreach|goto|if|implicit|in|init|internal|is|let|lock|new|null|on|operator|out|override|params|private|protected|public|readonly|ref|return|sealed|sizeof|stackalloc|static|switch|this|throw|true|try|typeof|unchecked|unsafe|virtual|void|while|get|set|new|partial|yield|add|remove|value|alias|ascending|descending|from|group|into|orderby|select|thenby|where|join|equals)\b`, Keyword, nil},
|
||||
{`(global)(::)`, ByGroups(Keyword, Punctuation), nil},
|
||||
{`(bool|byte|char|decimal|double|dynamic|float|int|long|object|sbyte|short|string|uint|ulong|ushort|var)\b\??`, KeywordType, nil},
|
||||
{`(class|struct|record|interface)(\s+)`, ByGroups(Keyword, Text), Push("class")},
|
||||
{`(namespace|using)(\s+)`, ByGroups(Keyword, Text), Push("namespace")},
|
||||
{`@?[_a-zA-Z]\w*`, Name, nil},
|
||||
},
|
||||
"class": {
|
||||
{`@?[_a-zA-Z]\w*`, NameClass, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"namespace": {
|
||||
{`(?=\()`, Text, Pop(1)},
|
||||
{`(@?[_a-zA-Z]\w*|\.)+`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,139 +0,0 @@
|
|||
package c
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Cython lexer.
|
||||
var Cython = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Cython",
|
||||
Aliases: []string{"cython", "pyx", "pyrex"},
|
||||
Filenames: []string{"*.pyx", "*.pxd", "*.pxi"},
|
||||
MimeTypes: []string{"text/x-cython", "application/x-cython"},
|
||||
},
|
||||
cythonRules,
|
||||
))
|
||||
|
||||
func cythonRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\n`, Text, nil},
|
||||
{`^(\s*)("""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringDoc), nil},
|
||||
{`^(\s*)('''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringDoc), nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`#.*$`, Comment, nil},
|
||||
{`[]{}:(),;[]`, Punctuation, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`\\`, Text, nil},
|
||||
{`(in|is|and|or|not)\b`, OperatorWord, nil},
|
||||
{`(<)([a-zA-Z0-9.?]+)(>)`, ByGroups(Punctuation, KeywordType, Punctuation), nil},
|
||||
{`!=|==|<<|>>|[-~+/*%=<>&^|.?]`, Operator, nil},
|
||||
{`(from)(\d+)(<=)(\s+)(<)(\d+)(:)`, ByGroups(Keyword, LiteralNumberInteger, Operator, Name, Operator, Name, Punctuation), nil},
|
||||
Include("keywords"),
|
||||
{`(def|property)(\s+)`, ByGroups(Keyword, Text), Push("funcname")},
|
||||
{`(cp?def)(\s+)`, ByGroups(Keyword, Text), Push("cdef")},
|
||||
{`(cdef)(:)`, ByGroups(Keyword, Punctuation), nil},
|
||||
{`(class|struct)(\s+)`, ByGroups(Keyword, Text), Push("classname")},
|
||||
{`(from)(\s+)`, ByGroups(Keyword, Text), Push("fromimport")},
|
||||
{`(c?import)(\s+)`, ByGroups(Keyword, Text), Push("import")},
|
||||
Include("builtins"),
|
||||
Include("backtick"),
|
||||
{`(?:[rR]|[uU][rR]|[rR][uU])"""`, LiteralString, Push("tdqs")},
|
||||
{`(?:[rR]|[uU][rR]|[rR][uU])'''`, LiteralString, Push("tsqs")},
|
||||
{`(?:[rR]|[uU][rR]|[rR][uU])"`, LiteralString, Push("dqs")},
|
||||
{`(?:[rR]|[uU][rR]|[rR][uU])'`, LiteralString, Push("sqs")},
|
||||
{`[uU]?"""`, LiteralString, Combined("stringescape", "tdqs")},
|
||||
{`[uU]?'''`, LiteralString, Combined("stringescape", "tsqs")},
|
||||
{`[uU]?"`, LiteralString, Combined("stringescape", "dqs")},
|
||||
{`[uU]?'`, LiteralString, Combined("stringescape", "sqs")},
|
||||
Include("name"),
|
||||
Include("numbers"),
|
||||
},
|
||||
"keywords": {
|
||||
{Words(``, `\b`, `assert`, `break`, `by`, `continue`, `ctypedef`, `del`, `elif`, `else`, `except`, `except?`, `exec`, `finally`, `for`, `fused`, `gil`, `global`, `if`, `include`, `lambda`, `nogil`, `pass`, `print`, `raise`, `return`, `try`, `while`, `yield`, `as`, `with`), Keyword, nil},
|
||||
{`(DEF|IF|ELIF|ELSE)\b`, CommentPreproc, nil},
|
||||
},
|
||||
"builtins": {
|
||||
{Words(`(?<!\.)`, `\b`, `__import__`, `abs`, `all`, `any`, `apply`, `basestring`, `bin`, `bool`, `buffer`, `bytearray`, `bytes`, `callable`, `chr`, `classmethod`, `cmp`, `coerce`, `compile`, `complex`, `delattr`, `dict`, `dir`, `divmod`, `enumerate`, `eval`, `execfile`, `exit`, `file`, `filter`, `float`, `frozenset`, `getattr`, `globals`, `hasattr`, `hash`, `hex`, `id`, `input`, `int`, `intern`, `isinstance`, `issubclass`, `iter`, `len`, `list`, `locals`, `long`, `map`, `max`, `min`, `next`, `object`, `oct`, `open`, `ord`, `pow`, `property`, `range`, `raw_input`, `reduce`, `reload`, `repr`, `reversed`, `round`, `set`, `setattr`, `slice`, `sorted`, `staticmethod`, `str`, `sum`, `super`, `tuple`, `type`, `unichr`, `unicode`, `unsigned`, `vars`, `xrange`, `zip`), NameBuiltin, nil},
|
||||
{`(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL)\b`, NameBuiltinPseudo, nil},
|
||||
{Words(`(?<!\.)`, `\b`, `ArithmeticError`, `AssertionError`, `AttributeError`, `BaseException`, `DeprecationWarning`, `EOFError`, `EnvironmentError`, `Exception`, `FloatingPointError`, `FutureWarning`, `GeneratorExit`, `IOError`, `ImportError`, `ImportWarning`, `IndentationError`, `IndexError`, `KeyError`, `KeyboardInterrupt`, `LookupError`, `MemoryError`, `NameError`, `NotImplemented`, `NotImplementedError`, `OSError`, `OverflowError`, `OverflowWarning`, `PendingDeprecationWarning`, `ReferenceError`, `RuntimeError`, `RuntimeWarning`, `StandardError`, `StopIteration`, `SyntaxError`, `SyntaxWarning`, `SystemError`, `SystemExit`, `TabError`, `TypeError`, `UnboundLocalError`, `UnicodeDecodeError`, `UnicodeEncodeError`, `UnicodeError`, `UnicodeTranslateError`, `UnicodeWarning`, `UserWarning`, `ValueError`, `Warning`, `ZeroDivisionError`), NameException, nil},
|
||||
},
|
||||
"numbers": {
|
||||
{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`0\d+`, LiteralNumberOct, nil},
|
||||
{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
|
||||
{`\d+L`, LiteralNumberIntegerLong, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"backtick": {
|
||||
{"`.*?`", LiteralStringBacktick, nil},
|
||||
},
|
||||
"name": {
|
||||
{`@\w+`, NameDecorator, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"funcname": {
|
||||
{`[a-zA-Z_]\w*`, NameFunction, Pop(1)},
|
||||
},
|
||||
"cdef": {
|
||||
{`(public|readonly|extern|api|inline)\b`, KeywordReserved, nil},
|
||||
{`(struct|enum|union|class)\b`, Keyword, nil},
|
||||
{`([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)`, ByGroups(NameFunction, Text), Pop(1)},
|
||||
{`([a-zA-Z_]\w*)(\s*)(,)`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||
{`from\b`, Keyword, Pop(1)},
|
||||
{`as\b`, Keyword, nil},
|
||||
{`:`, Punctuation, Pop(1)},
|
||||
{`(?=["\'])`, Text, Pop(1)},
|
||||
{`[a-zA-Z_]\w*`, KeywordType, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
"classname": {
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`(\s+)(as)(\s+)`, ByGroups(Text, Keyword, Text), nil},
|
||||
{`[a-zA-Z_][\w.]*`, NameNamespace, nil},
|
||||
{`(\s*)(,)(\s*)`, ByGroups(Text, Operator, Text), nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"fromimport": {
|
||||
{`(\s+)(c?import)\b`, ByGroups(Text, Keyword), Pop(1)},
|
||||
{`[a-zA-Z_.][\w.]*`, NameNamespace, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"stringescape": {
|
||||
{`\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
},
|
||||
"strings": {
|
||||
{`%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil},
|
||||
{`[^\\\'"%\n]+`, LiteralString, nil},
|
||||
{`[\'"\\]`, LiteralString, nil},
|
||||
{`%`, LiteralString, nil},
|
||||
},
|
||||
"nl": {
|
||||
{`\n`, LiteralString, nil},
|
||||
},
|
||||
"dqs": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\\\|\\"|\\\n`, LiteralStringEscape, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
"sqs": {
|
||||
{`'`, LiteralString, Pop(1)},
|
||||
{`\\\\|\\'|\\\n`, LiteralStringEscape, nil},
|
||||
Include("strings"),
|
||||
},
|
||||
"tdqs": {
|
||||
{`"""`, LiteralString, Pop(1)},
|
||||
Include("strings"),
|
||||
Include("nl"),
|
||||
},
|
||||
"tsqs": {
|
||||
{`'''`, LiteralString, Pop(1)},
|
||||
Include("strings"),
|
||||
Include("nl"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
// Package circular exists to break circular dependencies between lexers.
|
||||
package circular
|
|
@ -1,86 +0,0 @@
|
|||
package circular
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// PHP lexer for pure PHP code (not embedded in HTML).
|
||||
var PHP = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "PHP",
|
||||
Aliases: []string{"php", "php3", "php4", "php5"},
|
||||
Filenames: []string{"*.php", "*.php[345]", "*.inc"},
|
||||
MimeTypes: []string{"text/x-php"},
|
||||
DotAll: true,
|
||||
CaseInsensitive: true,
|
||||
EnsureNL: true,
|
||||
},
|
||||
phpRules,
|
||||
))
|
||||
|
||||
func phpRules() Rules {
|
||||
return phpCommonRules().Rename("php", "root")
|
||||
}
|
||||
|
||||
func phpCommonRules() Rules {
|
||||
return Rules{
|
||||
"php": {
|
||||
{`\?>`, CommentPreproc, Pop(1)},
|
||||
{`(<<<)([\'"]?)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)(\2\n.*?\n\s*)(\3)(;?)(\n)`, ByGroups(LiteralString, LiteralString, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, Punctuation, Text), nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`#.*?\n`, CommentSingle, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*\*/`, CommentMultiline, nil},
|
||||
{`/\*\*.*?\*/`, LiteralStringDoc, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`(->|::)(\s*)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)`, ByGroups(Operator, Text, NameAttribute), nil},
|
||||
{`[~!%^&*+=|:.<>/@-]+`, Operator, nil},
|
||||
{`\?`, Operator, nil},
|
||||
{`[\[\]{}();,]+`, Punctuation, nil},
|
||||
{`(class)(\s+)`, ByGroups(Keyword, Text), Push("classname")},
|
||||
{`(function)(\s*)(?=\()`, ByGroups(Keyword, Text), nil},
|
||||
{`(function)(\s+)(&?)(\s*)`, ByGroups(Keyword, Text, Operator, Text), Push("functionname")},
|
||||
{`(const)(\s+)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)`, ByGroups(Keyword, Text, NameConstant), nil},
|
||||
{`(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|FALSE|print|for|require|continue|foreach|require_once|declare|return|default|static|do|switch|die|stdClass|echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|virtual|endfor|include_once|while|endforeach|global|endif|list|endswitch|new|endwhile|not|array|E_ALL|NULL|final|php_user_filter|interface|implements|public|private|protected|abstract|clone|try|catch|throw|this|use|namespace|trait|yield|finally)\b`, Keyword, nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
Include("magicconstants"),
|
||||
{`\$\{\$+(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*\}`, NameVariable, nil},
|
||||
{`\$+(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*`, NameVariable, nil},
|
||||
{`(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*`, NameOther, nil},
|
||||
{`(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`\d+e[+-]?[0-9]+`, LiteralNumberFloat, nil},
|
||||
{`0[0-7]+`, LiteralNumberOct, nil},
|
||||
{`0x[a-f0-9_]+`, LiteralNumberHex, nil},
|
||||
{`\d[\d_]*`, LiteralNumberInteger, nil},
|
||||
{`0b[01]+`, LiteralNumberBin, nil},
|
||||
{`'([^'\\]*(?:\\.[^'\\]*)*)'`, LiteralStringSingle, nil},
|
||||
{"`([^`\\\\]*(?:\\\\.[^`\\\\]*)*)`", LiteralStringBacktick, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
},
|
||||
"magicfuncs": {
|
||||
{Words(``, `\b`, `__construct`, `__destruct`, `__call`, `__callStatic`, `__get`, `__set`, `__isset`, `__unset`, `__sleep`, `__wakeup`, `__toString`, `__invoke`, `__set_state`, `__clone`, `__debugInfo`), NameFunctionMagic, nil},
|
||||
},
|
||||
"magicconstants": {
|
||||
{Words(``, `\b`, `__LINE__`, `__FILE__`, `__DIR__`, `__FUNCTION__`, `__CLASS__`, `__TRAIT__`, `__METHOD__`, `__NAMESPACE__`), NameConstant, nil},
|
||||
},
|
||||
"classname": {
|
||||
{`(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*`, NameClass, Pop(1)},
|
||||
},
|
||||
"functionname": {
|
||||
Include("magicfuncs"),
|
||||
{`(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*`, NameFunction, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`[^{$"\\]+`, LiteralStringDouble, nil},
|
||||
{`\\([nrt"$\\]|[0-7]{1,3}|x[0-9a-f]{1,2})`, LiteralStringEscape, nil},
|
||||
{`\$(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*(\[\S+?\]|->(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)?`, LiteralStringInterpol, nil},
|
||||
{`(\{\$\{)(.*?)(\}\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
|
||||
{`(\{)(\$.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
|
||||
{`(\$\{)(\S+)(\})`, ByGroups(LiteralStringInterpol, NameVariable, LiteralStringInterpol), nil},
|
||||
{`[${\\]`, LiteralStringDouble, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// D lexer. https://dlang.org/spec/lex.html
|
||||
var D = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "D",
|
||||
Aliases: []string{"d"},
|
||||
Filenames: []string{"*.d", "*.di"},
|
||||
MimeTypes: []string{"text/x-d"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
dRules,
|
||||
))
|
||||
|
||||
func dRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#comment
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`/\+.*?\+/`, CommentMultiline, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#keywords
|
||||
{`(asm|assert|body|break|case|cast|catch|continue|default|debug|delete|deprecated|do|else|finally|for|foreach|foreach_reverse|goto|if|in|invariant|is|macro|mixin|new|out|pragma|return|super|switch|this|throw|try|version|while|with)\b`, Keyword, nil},
|
||||
{`__(FILE|FILE_FULL_PATH|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__\b`, NameBuiltin, nil},
|
||||
{`__(traits|vector|parameters)\b`, NameBuiltin, nil},
|
||||
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
|
||||
// https://dlang.org/spec/attribute.html#uda
|
||||
{`@[\w.]*`, NameDecorator, nil},
|
||||
{`(abstract|auto|alias|align|const|delegate|enum|export|final|function|inout|lazy|nothrow|override|package|private|protected|public|pure|static|synchronized|template|volatile|__gshared)\b`, KeywordDeclaration, nil},
|
||||
|
||||
// https://dlang.org/spec/type.html#basic-data-types
|
||||
{`(void|bool|byte|ubyte|short|ushort|int|uint|long|ulong|cent|ucent|float|double|real|ifloat|idouble|ireal|cfloat|cdouble|creal|char|wchar|dchar|string|wstring|dstring)\b`, KeywordType, nil},
|
||||
{`(module)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(class|interface|struct|template|union)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
|
||||
// https://dlang.org/spec/lex.html#string_literals
|
||||
// TODO support delimited strings
|
||||
{`[qr]?"(\\\\|\\"|[^"])*"[cwd]?`, LiteralString, nil},
|
||||
{"(`)([^`]*)(`)[cwd]?", LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#floatliteral
|
||||
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFL]?i?|[0-9][eE][+\-]?[0-9][0-9_]*[fFL]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFL]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFL]?`, LiteralNumberFloat, nil},
|
||||
// https://dlang.org/spec/lex.html#integerliteral
|
||||
{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
|
||||
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
||||
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
||||
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
||||
{`([~^*!%&\[\](){}<>|+=:;,./?-]|q{)`, Operator, nil},
|
||||
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+\*?`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Dart lexer.
|
||||
var Dart = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Dart",
|
||||
Aliases: []string{"dart"},
|
||||
Filenames: []string{"*.dart"},
|
||||
MimeTypes: []string{"text/x-dart"},
|
||||
DotAll: true,
|
||||
},
|
||||
dartRules,
|
||||
))
|
||||
|
||||
func dartRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("string_literal"),
|
||||
{`#!(.*?)$`, CommentPreproc, nil},
|
||||
{`\b(import|export)\b`, Keyword, Push("import_decl")},
|
||||
{`\b(library|source|part of|part)\b`, Keyword, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`\b(class)\b(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b`, Keyword, nil},
|
||||
{`\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b`, KeywordDeclaration, nil},
|
||||
{`\b(bool|double|dynamic|int|num|Object|String|void)\b`, KeywordType, nil},
|
||||
{`\b(false|null|true)\b`, KeywordConstant, nil},
|
||||
{`[~!%^&*+=|?:<>/-]|as\b`, Operator, nil},
|
||||
{`[a-zA-Z_$]\w*:`, NameLabel, nil},
|
||||
{`[a-zA-Z_$]\w*`, Name, nil},
|
||||
{`[(){}\[\],.;]`, Punctuation, nil},
|
||||
{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`\d+(\.\d*)?([eE][+-]?\d+)?`, LiteralNumber, nil},
|
||||
{`\.\d+([eE][+-]?\d+)?`, LiteralNumber, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`[a-zA-Z_$]\w*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import_decl": {
|
||||
Include("string_literal"),
|
||||
{`\s+`, Text, nil},
|
||||
{`\b(as|show|hide)\b`, Keyword, nil},
|
||||
{`[a-zA-Z_$]\w*`, Name, nil},
|
||||
{`\,`, Punctuation, nil},
|
||||
{`\;`, Punctuation, Pop(1)},
|
||||
},
|
||||
"string_literal": {
|
||||
{`r"""([\w\W]*?)"""`, LiteralStringDouble, nil},
|
||||
{`r'''([\w\W]*?)'''`, LiteralStringSingle, nil},
|
||||
{`r"(.*?)"`, LiteralStringDouble, nil},
|
||||
{`r'(.*?)'`, LiteralStringSingle, nil},
|
||||
{`"""`, LiteralStringDouble, Push("string_double_multiline")},
|
||||
{`'''`, LiteralStringSingle, Push("string_single_multiline")},
|
||||
{`"`, LiteralStringDouble, Push("string_double")},
|
||||
{`'`, LiteralStringSingle, Push("string_single")},
|
||||
},
|
||||
"string_common": {
|
||||
{`\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])`, LiteralStringEscape, nil},
|
||||
{`(\$)([a-zA-Z_]\w*)`, ByGroups(LiteralStringInterpol, Name), nil},
|
||||
{`(\$\{)(.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
|
||||
},
|
||||
"string_double": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`[^"$\\\n]+`, LiteralStringDouble, nil},
|
||||
Include("string_common"),
|
||||
{`\$+`, LiteralStringDouble, nil},
|
||||
},
|
||||
"string_double_multiline": {
|
||||
{`"""`, LiteralStringDouble, Pop(1)},
|
||||
{`[^"$\\]+`, LiteralStringDouble, nil},
|
||||
Include("string_common"),
|
||||
{`(\$|\")+`, LiteralStringDouble, nil},
|
||||
},
|
||||
"string_single": {
|
||||
{`'`, LiteralStringSingle, Pop(1)},
|
||||
{`[^'$\\\n]+`, LiteralStringSingle, nil},
|
||||
Include("string_common"),
|
||||
{`\$+`, LiteralStringSingle, nil},
|
||||
},
|
||||
"string_single_multiline": {
|
||||
{`'''`, LiteralStringSingle, Pop(1)},
|
||||
{`[^\'$\\]+`, LiteralStringSingle, nil},
|
||||
Include("string_common"),
|
||||
{`(\$|\')+`, LiteralStringSingle, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Diff lexer.
|
||||
var Diff = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Diff",
|
||||
Aliases: []string{"diff", "udiff"},
|
||||
EnsureNL: true,
|
||||
Filenames: []string{"*.diff", "*.patch"},
|
||||
MimeTypes: []string{"text/x-diff", "text/x-patch"},
|
||||
},
|
||||
diffRules,
|
||||
))
|
||||
|
||||
func diffRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{` .*\n`, Text, nil},
|
||||
{`\+.*\n`, GenericInserted, nil},
|
||||
{`-.*\n`, GenericDeleted, nil},
|
||||
{`!.*\n`, GenericStrong, nil},
|
||||
{`@.*\n`, GenericSubheading, nil},
|
||||
{`([Ii]ndex|diff).*\n`, GenericHeading, nil},
|
||||
{`=.*\n`, GenericHeading, nil},
|
||||
{`.*\n`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Django/Jinja lexer.
|
||||
var DjangoJinja = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Django/Jinja",
|
||||
Aliases: []string{"django", "jinja"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{"application/x-django-templating", "application/x-jinja"},
|
||||
DotAll: true,
|
||||
},
|
||||
djangoJinjaRules,
|
||||
))
|
||||
|
||||
func djangoJinjaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^{]+`, Other, nil},
|
||||
{`\{\{`, CommentPreproc, Push("var")},
|
||||
{`\{[*#].*?[*#]\}`, Comment, nil},
|
||||
{`(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endcomment)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Comment, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
|
||||
{`(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endraw)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Text, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
|
||||
{`(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword, Text, NameFunction), Push("block")},
|
||||
{`(\{%)(-?\s*)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword), Push("block")},
|
||||
{`\{`, Other, nil},
|
||||
},
|
||||
"varnames": {
|
||||
{`(\|)(\s*)([a-zA-Z_]\w*)`, ByGroups(Operator, Text, NameFunction), nil},
|
||||
{`(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil},
|
||||
{`(_|true|false|none|True|False|None)\b`, KeywordPseudo, nil},
|
||||
{`(in|as|reversed|recursive|not|and|or|is|if|else|import|with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b`, Keyword, nil},
|
||||
{`(loop|block|super|forloop)\b`, NameBuiltin, nil},
|
||||
{`[a-zA-Z_][\w-]*`, NameVariable, nil},
|
||||
{`\.\w+`, NameVariable, nil},
|
||||
{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`([{}()\[\]+\-*/,:~]|[><=]=?)`, Operator, nil},
|
||||
{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
|
||||
},
|
||||
"var": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(-?)(\}\})`, ByGroups(Text, CommentPreproc), Pop(1)},
|
||||
Include("varnames"),
|
||||
},
|
||||
"block": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(-?)(%\})`, ByGroups(Text, CommentPreproc), Pop(1)},
|
||||
Include("varnames"),
|
||||
{`.`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/b"
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
"github.com/alecthomas/chroma/lexers/j"
|
||||
)
|
||||
|
||||
// Docker lexer.
|
||||
var Docker = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Docker",
|
||||
Aliases: []string{"docker", "dockerfile"},
|
||||
Filenames: []string{"Dockerfile", "*.docker"},
|
||||
MimeTypes: []string{"text/x-dockerfile-config"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
dockerRules,
|
||||
))
|
||||
|
||||
func dockerRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*`, Comment, nil},
|
||||
{`(ONBUILD)((?:\s*\\?\s*))`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])`, ByGroups(Keyword, Using(b.Bash), Using(j.JSON)), nil},
|
||||
{`(LABEL|ENV|ARG)((?:(?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)`, ByGroups(Keyword, LiteralString), nil},
|
||||
{`((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))`, Keyword, nil},
|
||||
{`(.*\\\n)*.+`, Using(b.Bash), nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Dtd lexer.
|
||||
var Dtd = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "DTD",
|
||||
Aliases: []string{"dtd"},
|
||||
Filenames: []string{"*.dtd"},
|
||||
MimeTypes: []string{"application/xml-dtd"},
|
||||
DotAll: true,
|
||||
},
|
||||
dtdRules,
|
||||
))
|
||||
|
||||
func dtdRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("common"),
|
||||
{`(<!ELEMENT)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("element")},
|
||||
{`(<!ATTLIST)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("attlist")},
|
||||
{`(<!ENTITY)(\s+)(\S+)`, ByGroups(Keyword, Text, NameEntity), Push("entity")},
|
||||
{`(<!NOTATION)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("notation")},
|
||||
{`(<!\[)([^\[\s]+)(\s*)(\[)`, ByGroups(Keyword, NameEntity, Text, Keyword), nil},
|
||||
{`(<!DOCTYPE)(\s+)([^>\s]+)`, ByGroups(Keyword, Text, NameTag), nil},
|
||||
{`PUBLIC|SYSTEM`, KeywordConstant, nil},
|
||||
{`[\[\]>]`, Keyword, nil},
|
||||
},
|
||||
"common": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(%|&)[^;]*;`, NameEntity, nil},
|
||||
{`<!--`, Comment, Push("comment")},
|
||||
{`[(|)*,?+]`, Operator, nil},
|
||||
{`"[^"]*"`, LiteralStringDouble, nil},
|
||||
{`\'[^\']*\'`, LiteralStringSingle, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^-]+`, Comment, nil},
|
||||
{`-->`, Comment, Pop(1)},
|
||||
{`-`, Comment, nil},
|
||||
},
|
||||
"element": {
|
||||
Include("common"),
|
||||
{`EMPTY|ANY|#PCDATA`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameTag, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"attlist": {
|
||||
Include("common"),
|
||||
{`CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION`, KeywordConstant, nil},
|
||||
{`#REQUIRED|#IMPLIED|#FIXED`, KeywordConstant, nil},
|
||||
{`xml:space|xml:lang`, KeywordReserved, nil},
|
||||
{`[^>\s|()?+*,]+`, NameAttribute, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"entity": {
|
||||
Include("common"),
|
||||
{`SYSTEM|PUBLIC|NDATA`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameEntity, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"notation": {
|
||||
Include("common"),
|
||||
{`SYSTEM|PUBLIC`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameAttribute, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Dylan lexer.
|
||||
var Dylan = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Dylan",
|
||||
Aliases: []string{"dylan"},
|
||||
Filenames: []string{"*.dylan", "*.dyl", "*.intr"},
|
||||
MimeTypes: []string{"text/x-dylan"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
func() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Whitespace, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`([a-z0-9-]+:)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Whitespace, LiteralString), nil},
|
||||
Default(Push("code")),
|
||||
},
|
||||
"code": {
|
||||
{`\s+`, Whitespace, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("comment")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
|
||||
{`#b[01]+`, LiteralNumberBin, nil},
|
||||
{`#o[0-7]+`, LiteralNumberOct, nil},
|
||||
{`[-+]?(\d*\.\d+([ed][-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)`, LiteralNumberFloat, nil},
|
||||
{`[-+]?\d+`, LiteralNumberInteger, nil},
|
||||
{`#x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
|
||||
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)(:)(token|name|variable|expression|body|case-body|\*)`,
|
||||
ByGroups(Operator, NameVariable, Operator, NameBuiltin), nil},
|
||||
{`(\?)(:)(token|name|variable|expression|body|case-body|\*)`,
|
||||
ByGroups(Operator, Operator, NameVariable), nil},
|
||||
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, NameVariable), nil},
|
||||
|
||||
{`(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])`, Punctuation, nil},
|
||||
{`:=`, Operator, nil},
|
||||
{`#[tf]`, Literal, nil},
|
||||
{`#"`, LiteralStringSymbol, Push("symbol")},
|
||||
{`#[a-z0-9-]+`, Keyword, nil},
|
||||
{`#(all-keys|include|key|next|rest)`, Keyword, nil},
|
||||
{`[\w!&*<>|^$%@+~?/=-]+:`, KeywordConstant, nil},
|
||||
{`<[\w!&*<>|^$%@+~?/=-]+>`, NameClass, nil},
|
||||
{`\*[\w!&*<>|^$%@+~?/=-]+\*`, NameVariableGlobal, nil},
|
||||
{`\$[\w!&*<>|^$%@+~?/=-]+`, NameConstant, nil},
|
||||
{`(let|method|function)([ \t]+)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(NameBuiltin, Whitespace, NameVariable), nil},
|
||||
{`(error|signal|return|break)`, NameException, nil},
|
||||
{`(\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, Name), nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^*/]`, CommentMultiline, nil},
|
||||
{`/\*`, CommentMultiline, Push()},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[*/]`, CommentMultiline, nil},
|
||||
},
|
||||
"symbol": {
|
||||
{`"`, LiteralStringSymbol, Pop(1)},
|
||||
{`[^\\"]+`, LiteralStringSymbol, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
{`[^\\"\n]+`, LiteralString, nil},
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\\`, LiteralString, nil},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
|
@ -1,55 +0,0 @@
|
|||
package e
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Ebnf lexer.
|
||||
var Ebnf = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "EBNF",
|
||||
Aliases: []string{"ebnf"},
|
||||
Filenames: []string{"*.ebnf"},
|
||||
MimeTypes: []string{"text/x-ebnf"},
|
||||
},
|
||||
ebnfRules,
|
||||
))
|
||||
|
||||
func ebnfRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
Include("comment_start"),
|
||||
Include("identifier"),
|
||||
{`=`, Operator, Push("production")},
|
||||
},
|
||||
"production": {
|
||||
Include("whitespace"),
|
||||
Include("comment_start"),
|
||||
Include("identifier"),
|
||||
{`"[^"]*"`, LiteralStringDouble, nil},
|
||||
{`'[^']*'`, LiteralStringSingle, nil},
|
||||
{`(\?[^?]*\?)`, NameEntity, nil},
|
||||
{`[\[\]{}(),|]`, Punctuation, nil},
|
||||
{`-`, Operator, nil},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`\.`, Punctuation, Pop(1)},
|
||||
},
|
||||
"whitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"comment_start": {
|
||||
{`\(\*`, CommentMultiline, Push("comment")},
|
||||
},
|
||||
"comment": {
|
||||
{`[^*)]`, CommentMultiline, nil},
|
||||
Include("comment_start"),
|
||||
{`\*\)`, CommentMultiline, Pop(1)},
|
||||
{`[*)]`, CommentMultiline, nil},
|
||||
},
|
||||
"identifier": {
|
||||
{`([a-zA-Z][\w \-]*)`, Keyword, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
package e
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Elixir lexer.
|
||||
var Elixir = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Elixir",
|
||||
Aliases: []string{"elixir", "ex", "exs"},
|
||||
Filenames: []string{"*.ex", "*.exs"},
|
||||
MimeTypes: []string{"text/x-elixir"},
|
||||
},
|
||||
elixirRules,
|
||||
))
|
||||
|
||||
func elixirRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`#.*$`, CommentSingle, nil},
|
||||
{`(\?)(\\x\{)([\da-fA-F]+)(\})`, ByGroups(LiteralStringChar, LiteralStringEscape, LiteralNumberHex, LiteralStringEscape), nil},
|
||||
{`(\?)(\\x[\da-fA-F]{1,2})`, ByGroups(LiteralStringChar, LiteralStringEscape), nil},
|
||||
{`(\?)(\\[abdefnrstv])`, ByGroups(LiteralStringChar, LiteralStringEscape), nil},
|
||||
{`\?\\?.`, LiteralStringChar, nil},
|
||||
{`:::`, LiteralStringSymbol, nil},
|
||||
{`::`, Operator, nil},
|
||||
{`:(?:\.\.\.|<<>>|%\{\}|%|\{\})`, LiteralStringSymbol, nil},
|
||||
{`:(?:(?:\.\.\.|[a-z_]\w*[!?]?)|[A-Z]\w*(?:\.[A-Z]\w*)*|(?:\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>|\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~|\<|\>|\+|\-|\*|\/|\!|\^|\&))`, LiteralStringSymbol, nil},
|
||||
{`:"`, LiteralStringSymbol, Push("string_double_atom")},
|
||||
{`:'`, LiteralStringSymbol, Push("string_single_atom")},
|
||||
{`((?:\.\.\.|<<>>|%\{\}|%|\{\})|(?:(?:\.\.\.|[a-z_]\w*[!?]?)|[A-Z]\w*(?:\.[A-Z]\w*)*|(?:\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>|\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~|\<|\>|\+|\-|\*|\/|\!|\^|\&)))(:)(?=\s|\n)`, ByGroups(LiteralStringSymbol, Punctuation), nil},
|
||||
{`(fn|do|end|after|else|rescue|catch)\b`, Keyword, nil},
|
||||
{`(not|and|or|when|in)\b`, OperatorWord, nil},
|
||||
{`(case|cond|for|if|unless|try|receive|raise|quote|unquote|unquote_splicing|throw|super|while)\b`, Keyword, nil},
|
||||
{`(def|defp|defmodule|defprotocol|defmacro|defmacrop|defdelegate|defexception|defstruct|defimpl|defcallback)\b`, KeywordDeclaration, nil},
|
||||
{`(import|require|use|alias)\b`, KeywordNamespace, nil},
|
||||
{`(nil|true|false)\b`, NameConstant, nil},
|
||||
{`(_|__MODULE__|__DIR__|__ENV__|__CALLER__)\b`, NamePseudo, nil},
|
||||
{`@(?:\.\.\.|[a-z_]\w*[!?]?)`, NameAttribute, nil},
|
||||
{`(?:\.\.\.|[a-z_]\w*[!?]?)`, Name, nil},
|
||||
{`(%?)([A-Z]\w*(?:\.[A-Z]\w*)*)`, ByGroups(Punctuation, NameClass), nil},
|
||||
{`\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>`, Operator, nil},
|
||||
{`\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~`, Operator, nil},
|
||||
{`\\\\|\<\<|\>\>|\=\>|\(|\)|\:|\;|\,|\[|\]`, Punctuation, nil},
|
||||
{`&\d`, NameEntity, nil},
|
||||
{`\<|\>|\+|\-|\*|\/|\!|\^|\&`, Operator, nil},
|
||||
{`0b[01](_?[01])*`, LiteralNumberBin, nil},
|
||||
{`0o[0-7](_?[0-7])*`, LiteralNumberOct, nil},
|
||||
{`0x[\da-fA-F](_?[\dA-Fa-f])*`, LiteralNumberHex, nil},
|
||||
{`\d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?`, LiteralNumberFloat, nil},
|
||||
{`\d(_?\d)*`, LiteralNumberInteger, nil},
|
||||
{`"""\s*`, LiteralStringHeredoc, Push("heredoc_double")},
|
||||
{`'''\s*$`, LiteralStringHeredoc, Push("heredoc_single")},
|
||||
{`"`, LiteralStringDouble, Push("string_double")},
|
||||
{`'`, LiteralStringSingle, Push("string_single")},
|
||||
Include("sigils"),
|
||||
{`%\{`, Punctuation, Push("map_key")},
|
||||
{`\{`, Punctuation, Push("tuple")},
|
||||
},
|
||||
"heredoc_double": {
|
||||
{`^\s*"""`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_interpol"),
|
||||
},
|
||||
"heredoc_single": {
|
||||
{`^\s*'''`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_interpol"),
|
||||
},
|
||||
"heredoc_interpol": {
|
||||
{`[^#\\\n]+`, LiteralStringHeredoc, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringHeredoc, nil},
|
||||
{`\n+`, LiteralStringHeredoc, nil},
|
||||
Include("interpol"),
|
||||
},
|
||||
"heredoc_no_interpol": {
|
||||
{`[^\\\n]+`, LiteralStringHeredoc, nil},
|
||||
{`\\.`, LiteralStringHeredoc, nil},
|
||||
{`\n+`, LiteralStringHeredoc, nil},
|
||||
},
|
||||
"escapes": {
|
||||
{`(\\x\{)([\da-fA-F]+)(\})`, ByGroups(LiteralStringEscape, LiteralNumberHex, LiteralStringEscape), nil},
|
||||
{`(\\x[\da-fA-F]{1,2})`, LiteralStringEscape, nil},
|
||||
{`(\\[abdefnrstv])`, LiteralStringEscape, nil},
|
||||
},
|
||||
"interpol": {
|
||||
{`#\{`, LiteralStringInterpol, Push("interpol_string")},
|
||||
},
|
||||
"interpol_string": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"map_key": {
|
||||
Include("root"),
|
||||
{`:`, Punctuation, Push("map_val")},
|
||||
{`=>`, Punctuation, Push("map_val")},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"map_val": {
|
||||
Include("root"),
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`(?=\})`, Punctuation, Pop(1)},
|
||||
},
|
||||
"tuple": {
|
||||
Include("root"),
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"string_double": {
|
||||
{`[^#"\\]+`, LiteralStringDouble, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringDouble, nil},
|
||||
{`(")`, ByGroups(LiteralStringDouble), Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"string_single": {
|
||||
{`[^#'\\]+`, LiteralStringSingle, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringSingle, nil},
|
||||
{`(')`, ByGroups(LiteralStringSingle), Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"string_double_atom": {
|
||||
{`[^#"\\]+`, LiteralStringSymbol, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringSymbol, nil},
|
||||
{`(")`, ByGroups(LiteralStringSymbol), Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"string_single_atom": {
|
||||
{`[^#'\\]+`, LiteralStringSymbol, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringSymbol, nil},
|
||||
{`(')`, ByGroups(LiteralStringSymbol), Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"sigils": {
|
||||
{`(~[a-z])(""")`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triquot-end", "triquot-intp")},
|
||||
{`(~[A-Z])(""")`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triquot-end", "triquot-no-intp")},
|
||||
{`(~[a-z])(''')`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triapos-end", "triapos-intp")},
|
||||
{`(~[A-Z])(''')`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triapos-end", "triapos-no-intp")},
|
||||
{`~[a-z]\{`, LiteralStringOther, Push("cb-intp")},
|
||||
{`~[A-Z]\{`, LiteralStringOther, Push("cb-no-intp")},
|
||||
{`~[a-z]\[`, LiteralStringOther, Push("sb-intp")},
|
||||
{`~[A-Z]\[`, LiteralStringOther, Push("sb-no-intp")},
|
||||
{`~[a-z]\(`, LiteralStringOther, Push("pa-intp")},
|
||||
{`~[A-Z]\(`, LiteralStringOther, Push("pa-no-intp")},
|
||||
{`~[a-z]<`, LiteralStringOther, Push("ab-intp")},
|
||||
{`~[A-Z]<`, LiteralStringOther, Push("ab-no-intp")},
|
||||
{`~[a-z]/`, LiteralStringOther, Push("slas-intp")},
|
||||
{`~[A-Z]/`, LiteralStringOther, Push("slas-no-intp")},
|
||||
{`~[a-z]\|`, LiteralStringOther, Push("pipe-intp")},
|
||||
{`~[A-Z]\|`, LiteralStringOther, Push("pipe-no-intp")},
|
||||
{`~[a-z]"`, LiteralStringOther, Push("quot-intp")},
|
||||
{`~[A-Z]"`, LiteralStringOther, Push("quot-no-intp")},
|
||||
{`~[a-z]'`, LiteralStringOther, Push("apos-intp")},
|
||||
{`~[A-Z]'`, LiteralStringOther, Push("apos-no-intp")},
|
||||
},
|
||||
"triquot-end": {
|
||||
{`[a-zA-Z]+`, LiteralStringOther, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"triquot-intp": {
|
||||
{`^\s*"""`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_interpol"),
|
||||
},
|
||||
"triquot-no-intp": {
|
||||
{`^\s*"""`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_no_interpol"),
|
||||
},
|
||||
"triapos-end": {
|
||||
{`[a-zA-Z]+`, LiteralStringOther, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"triapos-intp": {
|
||||
{`^\s*'''`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_interpol"),
|
||||
},
|
||||
"triapos-no-intp": {
|
||||
{`^\s*'''`, LiteralStringHeredoc, Pop(1)},
|
||||
Include("heredoc_no_interpol"),
|
||||
},
|
||||
"cb-intp": {
|
||||
{`[^#\}\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\}[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"cb-no-intp": {
|
||||
{`[^\}\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\}[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"sb-intp": {
|
||||
{`[^#\]\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\][a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"sb-no-intp": {
|
||||
{`[^\]\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\][a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"pa-intp": {
|
||||
{`[^#\)\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\)[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"pa-no-intp": {
|
||||
{`[^\)\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\)[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"ab-intp": {
|
||||
{`[^#>\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`>[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"ab-no-intp": {
|
||||
{`[^>\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`>[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"slas-intp": {
|
||||
{`[^#/\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`/[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"slas-no-intp": {
|
||||
{`[^/\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`/[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"pipe-intp": {
|
||||
{`[^#\|\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\|[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"pipe-no-intp": {
|
||||
{`[^\|\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`\|[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"quot-intp": {
|
||||
{`[^#"\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`"[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"quot-no-intp": {
|
||||
{`[^"\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`"[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
"apos-intp": {
|
||||
{`[^#'\\]+`, LiteralStringOther, nil},
|
||||
Include("escapes"),
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`'[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
Include("interpol"),
|
||||
},
|
||||
"apos-no-intp": {
|
||||
{`[^'\\]+`, LiteralStringOther, nil},
|
||||
{`\\.`, LiteralStringOther, nil},
|
||||
{`'[a-zA-Z]*`, LiteralStringOther, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package e
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Elm lexer.
|
||||
var Elm = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Elm",
|
||||
Aliases: []string{"elm"},
|
||||
Filenames: []string{"*.elm"},
|
||||
MimeTypes: []string{"text/x-elm"},
|
||||
},
|
||||
elmRules,
|
||||
))
|
||||
|
||||
func elmRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\{-`, CommentMultiline, Push("comment")},
|
||||
{`--.*`, CommentSingle, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`"`, LiteralString, Push("doublequote")},
|
||||
{`^\s*module\s*`, KeywordNamespace, Push("imports")},
|
||||
{`^\s*import\s*`, KeywordNamespace, Push("imports")},
|
||||
{`\[glsl\|.*`, NameEntity, Push("shader")},
|
||||
{Words(``, `\b`, `alias`, `as`, `case`, `else`, `if`, `import`, `in`, `let`, `module`, `of`, `port`, `then`, `type`, `where`), KeywordReserved, nil},
|
||||
{`[A-Z]\w*`, KeywordType, nil},
|
||||
{`^main `, KeywordReserved, nil},
|
||||
{Words(`\(`, `\)`, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil},
|
||||
{Words(``, ``, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil},
|
||||
Include("numbers"),
|
||||
{`[a-z_][a-zA-Z_\']*`, NameVariable, nil},
|
||||
{`[,()\[\]{}]`, Punctuation, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`-(?!\})`, CommentMultiline, nil},
|
||||
{`\{-`, CommentMultiline, Push("comment")},
|
||||
{`[^-}]`, CommentMultiline, nil},
|
||||
{`-\}`, CommentMultiline, Pop(1)},
|
||||
},
|
||||
"doublequote": {
|
||||
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||
{`\\[nrfvb\\"]`, LiteralStringEscape, nil},
|
||||
{`[^"]`, LiteralString, nil},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
},
|
||||
"imports": {
|
||||
{`\w+(\.\w+)*`, NameClass, Pop(1)},
|
||||
},
|
||||
"numbers": {
|
||||
{`_?\d+\.(?=\d+)`, LiteralNumberFloat, nil},
|
||||
{`_?\d+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"shader": {
|
||||
{`\|(?!\])`, NameEntity, nil},
|
||||
{`\|\]`, NameEntity, Pop(1)},
|
||||
{`.*\n`, NameEntity, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package e
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Erlang lexer.
|
||||
var Erlang = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Erlang",
|
||||
Aliases: []string{"erlang"},
|
||||
Filenames: []string{"*.erl", "*.hrl", "*.es", "*.escript"},
|
||||
MimeTypes: []string{"text/x-erlang"},
|
||||
},
|
||||
erlangRules,
|
||||
))
|
||||
|
||||
func erlangRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`%.*\n`, Comment, nil},
|
||||
{Words(``, `\b`, `after`, `begin`, `case`, `catch`, `cond`, `end`, `fun`, `if`, `let`, `of`, `query`, `receive`, `try`, `when`), Keyword, nil},
|
||||
{Words(``, `\b`, `abs`, `append_element`, `apply`, `atom_to_list`, `binary_to_list`, `bitstring_to_list`, `binary_to_term`, `bit_size`, `bump_reductions`, `byte_size`, `cancel_timer`, `check_process_code`, `delete_module`, `demonitor`, `disconnect_node`, `display`, `element`, `erase`, `exit`, `float`, `float_to_list`, `fun_info`, `fun_to_list`, `function_exported`, `garbage_collect`, `get`, `get_keys`, `group_leader`, `hash`, `hd`, `integer_to_list`, `iolist_to_binary`, `iolist_size`, `is_atom`, `is_binary`, `is_bitstring`, `is_boolean`, `is_builtin`, `is_float`, `is_function`, `is_integer`, `is_list`, `is_number`, `is_pid`, `is_port`, `is_process_alive`, `is_record`, `is_reference`, `is_tuple`, `length`, `link`, `list_to_atom`, `list_to_binary`, `list_to_bitstring`, `list_to_existing_atom`, `list_to_float`, `list_to_integer`, `list_to_pid`, `list_to_tuple`, `load_module`, `localtime_to_universaltime`, `make_tuple`, `md5`, `md5_final`, `md5_update`, `memory`, `module_loaded`, `monitor`, `monitor_node`, `node`, `nodes`, `open_port`, `phash`, `phash2`, `pid_to_list`, `port_close`, `port_command`, `port_connect`, `port_control`, `port_call`, `port_info`, `port_to_list`, `process_display`, `process_flag`, `process_info`, `purge_module`, `put`, `read_timer`, `ref_to_list`, `register`, `resume_process`, `round`, `send`, `send_after`, `send_nosuspend`, `set_cookie`, `setelement`, `size`, `spawn`, `spawn_link`, `spawn_monitor`, `spawn_opt`, `split_binary`, `start_timer`, `statistics`, `suspend_process`, `system_flag`, `system_info`, `system_monitor`, `system_profile`, `term_to_binary`, `tl`, `trace`, `trace_delivered`, `trace_info`, `trace_pattern`, `trunc`, `tuple_size`, `tuple_to_list`, `universaltime_to_localtime`, `unlink`, `unregister`, `whereis`), NameBuiltin, nil},
|
||||
{Words(``, `\b`, `and`, `andalso`, `band`, `bnot`, `bor`, `bsl`, `bsr`, `bxor`, `div`, `not`, `or`, `orelse`, `rem`, `xor`), OperatorWord, nil},
|
||||
{`^-`, Punctuation, Push("directive")},
|
||||
{`(\+\+?|--?|\*|/|<|>|/=|=:=|=/=|=<|>=|==?|<-|!|\?)`, Operator, nil},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`<<`, NameLabel, nil},
|
||||
{`>>`, NameLabel, nil},
|
||||
{`((?:[a-z]\w*|'[^\n']*[^\\]'))(:)`, ByGroups(NameNamespace, Punctuation), nil},
|
||||
{`(?:^|(?<=:))((?:[a-z]\w*|'[^\n']*[^\\]'))(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||
{`[+-]?(?:[2-9]|[12][0-9]|3[0-6])#[0-9a-zA-Z]+`, LiteralNumberInteger, nil},
|
||||
{`[+-]?\d+`, LiteralNumberInteger, nil},
|
||||
{`[+-]?\d+.\d+`, LiteralNumberFloat, nil},
|
||||
{`[]\[:_@\".{}()|;,]`, Punctuation, nil},
|
||||
{`(?:[A-Z_]\w*)`, NameVariable, nil},
|
||||
{`(?:[a-z]\w*|'[^\n']*[^\\]')`, Name, nil},
|
||||
{`\?(?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]'))`, NameConstant, nil},
|
||||
{`\$(?:(?:\\(?:[bdefnrstv\'"\\]|[0-7][0-7]?[0-7]?|(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})|\^[a-zA-Z]))|\\[ %]|[^\\])`, LiteralStringChar, nil},
|
||||
{`#(?:[a-z]\w*|'[^\n']*[^\\]')(:?\.(?:[a-z]\w*|'[^\n']*[^\\]'))?`, NameLabel, nil},
|
||||
{`\A#!.+\n`, CommentHashbang, nil},
|
||||
{`#\{`, Punctuation, Push("map_key")},
|
||||
},
|
||||
"string": {
|
||||
{`(?:\\(?:[bdefnrstv\'"\\]|[0-7][0-7]?[0-7]?|(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})|\^[a-zA-Z]))`, LiteralStringEscape, nil},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`~[0-9.*]*[~#+BPWXb-ginpswx]`, LiteralStringInterpol, nil},
|
||||
{`[^"\\~]+`, LiteralString, nil},
|
||||
{`~`, LiteralString, nil},
|
||||
},
|
||||
"directive": {
|
||||
{`(define)(\s*)(\()((?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]')))`, ByGroups(NameEntity, Text, Punctuation, NameConstant), Pop(1)},
|
||||
{`(record)(\s*)(\()((?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]')))`, ByGroups(NameEntity, Text, Punctuation, NameLabel), Pop(1)},
|
||||
{`(?:[a-z]\w*|'[^\n']*[^\\]')`, NameEntity, Pop(1)},
|
||||
},
|
||||
"map_key": {
|
||||
Include("root"),
|
||||
{`=>`, Punctuation, Push("map_val")},
|
||||
{`:=`, Punctuation, Push("map_val")},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"map_val": {
|
||||
Include("root"),
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`(?=\})`, Punctuation, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Factor lexer.
|
||||
var Factor = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Factor",
|
||||
Aliases: []string{"factor"},
|
||||
Filenames: []string{"*.factor"},
|
||||
MimeTypes: []string{"text/x-factor"},
|
||||
},
|
||||
factorRules,
|
||||
))
|
||||
|
||||
func factorRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#!.*$`, CommentPreproc, nil},
|
||||
Default(Push("base")),
|
||||
},
|
||||
"base": {
|
||||
{`\s+`, Text, nil},
|
||||
{`((?:MACRO|MEMO|TYPED)?:[:]?)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`(M:[:]?)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameFunction), nil},
|
||||
{`(C:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameClass), nil},
|
||||
{`(GENERIC:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameFunction), nil},
|
||||
{`\(\s`, NameFunction, Push("stackeffect")},
|
||||
{`;\s`, Keyword, nil},
|
||||
{`(USING:)(\s+)`, ByGroups(KeywordNamespace, Text), Push("vocabs")},
|
||||
{`(USE:|UNUSE:|IN:|QUALIFIED:)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameNamespace), nil},
|
||||
{`(QUALIFIED-WITH:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameNamespace, Text, NameNamespace), nil},
|
||||
{`(FROM:|EXCLUDE:)(\s+)(\S+)(\s+=>\s)`, ByGroups(KeywordNamespace, Text, NameNamespace, Text), Push("words")},
|
||||
{`(RENAME:)(\s+)(\S+)(\s+)(\S+)(\s+=>\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameNamespace, Text, NameFunction), nil},
|
||||
{`(ALIAS:|TYPEDEF:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameFunction), nil},
|
||||
{`(DEFER:|FORGET:|POSTPONE:)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction), nil},
|
||||
{`(TUPLE:|ERROR:)(\s+)(\S+)(\s+<\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), Push("slots")},
|
||||
{`(TUPLE:|ERROR:|BUILTIN:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), Push("slots")},
|
||||
{`(MIXIN:|UNION:|INTERSECTION:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil},
|
||||
{`(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), nil},
|
||||
{`(C:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameClass), nil},
|
||||
{`(INSTANCE:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), nil},
|
||||
{`(SLOT:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`(SINGLETON:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil},
|
||||
{`SINGLETONS:`, Keyword, Push("classes")},
|
||||
{`(CONSTANT:|SYMBOL:|MAIN:|HELP:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil},
|
||||
{`SYMBOLS:\s`, Keyword, Push("words")},
|
||||
{`SYNTAX:\s`, Keyword, nil},
|
||||
{`ALIEN:\s`, Keyword, nil},
|
||||
{`(STRUCT:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil},
|
||||
{`(FUNCTION:)(\s+\S+\s+)(\S+)(\s+\(\s+[^)]+\)\s)`, ByGroups(KeywordNamespace, Text, NameFunction, Text), nil},
|
||||
{`(FUNCTION-ALIAS:)(\s+)(\S+)(\s+\S+\s+)(\S+)(\s+\(\s+[^)]+\)\s)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameFunction, Text), nil},
|
||||
{`(?:<PRIVATE|PRIVATE>)\s`, KeywordNamespace, nil},
|
||||
{`"""\s+(?:.|\n)*?\s+"""`, LiteralString, nil},
|
||||
{`"(?:\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`\S+"\s+(?:\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`CHAR:\s+(?:\\[\\abfnrstv]|[^\\]\S*)\s`, LiteralStringChar, nil},
|
||||
{`!\s+.*$`, Comment, nil},
|
||||
{`#!\s+.*$`, Comment, nil},
|
||||
{`/\*\s+(?:.|\n)*?\s\*/\s`, Comment, nil},
|
||||
{`[tf]\s`, NameConstant, nil},
|
||||
{`[\\$]\s+\S+`, NameConstant, nil},
|
||||
{`M\\\s+\S+\s+\S+`, NameConstant, nil},
|
||||
{`[+-]?(?:[\d,]*\d)?\.(?:\d([\d,]*\d)?)?(?:[eE][+-]?\d+)?\s`, LiteralNumber, nil},
|
||||
{`[+-]?\d(?:[\d,]*\d)?(?:[eE][+-]?\d+)?\s`, LiteralNumber, nil},
|
||||
{`0x[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s`, LiteralNumber, nil},
|
||||
{`NAN:\s+[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s`, LiteralNumber, nil},
|
||||
{`0b[01]+\s`, LiteralNumberBin, nil},
|
||||
{`0o[0-7]+\s`, LiteralNumberOct, nil},
|
||||
{`(?:\d([\d,]*\d)?)?\+\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s`, LiteralNumber, nil},
|
||||
{`(?:\-\d([\d,]*\d)?)?\-\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s`, LiteralNumber, nil},
|
||||
{`(?:deprecated|final|foldable|flushable|inline|recursive)\s`, Keyword, nil},
|
||||
{Words(``, `\s`, `-rot`, `2bi`, `2bi@`, `2bi*`, `2curry`, `2dip`, `2drop`, `2dup`, `2keep`, `2nip`, `2over`, `2tri`, `2tri@`, `2tri*`, `3bi`, `3curry`, `3dip`, `3drop`, `3dup`, `3keep`, `3tri`, `4dip`, `4drop`, `4dup`, `4keep`, `<wrapper>`, `=`, `>boolean`, `clone`, `?`, `?execute`, `?if`, `and`, `assert`, `assert=`, `assert?`, `bi`, `bi-curry`, `bi-curry@`, `bi-curry*`, `bi@`, `bi*`, `boa`, `boolean`, `boolean?`, `both?`, `build`, `call`, `callstack`, `callstack>array`, `callstack?`, `clear`, `(clone)`, `compose`, `compose?`, `curry`, `curry?`, `datastack`, `die`, `dip`, `do`, `drop`, `dup`, `dupd`, `either?`, `eq?`, `equal?`, `execute`, `hashcode`, `hashcode*`, `identity-hashcode`, `identity-tuple`, `identity-tuple?`, `if`, `if*`, `keep`, `loop`, `most`, `new`, `nip`, `not`, `null`, `object`, `or`, `over`, `pick`, `prepose`, `retainstack`, `rot`, `same?`, `swap`, `swapd`, `throw`, `tri`, `tri-curry`, `tri-curry@`, `tri-curry*`, `tri@`, `tri*`, `tuple`, `tuple?`, `unless`, `unless*`, `until`, `when`, `when*`, `while`, `with`, `wrapper`, `wrapper?`, `xor`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `2cache`, `<enum>`, `>alist`, `?at`, `?of`, `assoc`, `assoc-all?`, `assoc-any?`, `assoc-clone-like`, `assoc-combine`, `assoc-diff`, `assoc-diff!`, `assoc-differ`, `assoc-each`, `assoc-empty?`, `assoc-filter`, `assoc-filter!`, `assoc-filter-as`, `assoc-find`, `assoc-hashcode`, `assoc-intersect`, `assoc-like`, `assoc-map`, `assoc-map-as`, `assoc-partition`, `assoc-refine`, `assoc-size`, `assoc-stack`, `assoc-subset?`, `assoc-union`, `assoc-union!`, `assoc=`, `assoc>map`, `assoc?`, `at`, `at+`, `at*`, `cache`, `change-at`, `clear-assoc`, `delete-at`, `delete-at*`, `enum`, `enum?`, `extract-keys`, `inc-at`, `key?`, `keys`, `map>assoc`, `maybe-set-at`, `new-assoc`, `of`, `push-at`, `rename-at`, `set-at`, `sift-keys`, `sift-values`, `substitute`, `unzip`, `value-at`, `value-at*`, `value?`, `values`, `zip`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `2cleave`, `2cleave>quot`, `3cleave`, `3cleave>quot`, `4cleave`, `4cleave>quot`, `alist>quot`, `call-effect`, `case`, `case-find`, `case>quot`, `cleave`, `cleave>quot`, `cond`, `cond>quot`, `deep-spread>quot`, `execute-effect`, `linear-case-quot`, `no-case`, `no-case?`, `no-cond`, `no-cond?`, `recursive-hashcode`, `shallow-spread>quot`, `spread`, `to-fixed-point`, `wrong-values`, `wrong-values?`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `-`, `/`, `/f`, `/i`, `/mod`, `2/`, `2^`, `<`, `<=`, `<fp-nan>`, `>`, `>=`, `>bignum`, `>fixnum`, `>float`, `>integer`, `(all-integers?)`, `(each-integer)`, `(find-integer)`, `*`, `+`, `?1+`, `abs`, `align`, `all-integers?`, `bignum`, `bignum?`, `bit?`, `bitand`, `bitnot`, `bitor`, `bits>double`, `bits>float`, `bitxor`, `complex`, `complex?`, `denominator`, `double>bits`, `each-integer`, `even?`, `find-integer`, `find-last-integer`, `fixnum`, `fixnum?`, `float`, `float>bits`, `float?`, `fp-bitwise=`, `fp-infinity?`, `fp-nan-payload`, `fp-nan?`, `fp-qnan?`, `fp-sign`, `fp-snan?`, `fp-special?`, `if-zero`, `imaginary-part`, `integer`, `integer>fixnum`, `integer>fixnum-strict`, `integer?`, `log2`, `log2-expects-positive`, `log2-expects-positive?`, `mod`, `neg`, `neg?`, `next-float`, `next-power-of-2`, `number`, `number=`, `number?`, `numerator`, `odd?`, `out-of-fixnum-range`, `out-of-fixnum-range?`, `power-of-2?`, `prev-float`, `ratio`, `ratio?`, `rational`, `rational?`, `real`, `real-part`, `real?`, `recip`, `rem`, `sgn`, `shift`, `sq`, `times`, `u<`, `u<=`, `u>`, `u>=`, `unless-zero`, `unordered?`, `when-zero`, `zero?`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `1sequence`, `2all?`, `2each`, `2map`, `2map-as`, `2map-reduce`, `2reduce`, `2selector`, `2sequence`, `3append`, `3append-as`, `3each`, `3map`, `3map-as`, `3sequence`, `4sequence`, `<repetition>`, `<reversed>`, `<slice>`, `?first`, `?last`, `?nth`, `?second`, `?set-nth`, `accumulate`, `accumulate!`, `accumulate-as`, `all?`, `any?`, `append`, `append!`, `append-as`, `assert-sequence`, `assert-sequence=`, `assert-sequence?`, `binary-reduce`, `bounds-check`, `bounds-check?`, `bounds-error`, `bounds-error?`, `but-last`, `but-last-slice`, `cartesian-each`, `cartesian-map`, `cartesian-product`, `change-nth`, `check-slice`, `check-slice-error`, `clone-like`, `collapse-slice`, `collector`, `collector-for`, `concat`, `concat-as`, `copy`, `count`, `cut`, `cut-slice`, `cut*`, `delete-all`, `delete-slice`, `drop-prefix`, `each`, `each-from`, `each-index`, `empty?`, `exchange`, `filter`, `filter!`, `filter-as`, `find`, `find-from`, `find-index`, `find-index-from`, `find-last`, `find-last-from`, `first`, `first2`, `first3`, `first4`, `flip`, `follow`, `fourth`, `glue`, `halves`, `harvest`, `head`, `head-slice`, `head-slice*`, `head*`, `head?`, `if-empty`, `immutable`, `immutable-sequence`, `immutable-sequence?`, `immutable?`, `index`, `index-from`, `indices`, `infimum`, `infimum-by`, `insert-nth`, `interleave`, `iota`, `iota-tuple`, `iota-tuple?`, `join`, `join-as`, `last`, `last-index`, `last-index-from`, `length`, `lengthen`, `like`, `longer`, `longer?`, `longest`, `map`, `map!`, `map-as`, `map-find`, `map-find-last`, `map-index`, `map-integers`, `map-reduce`, `map-sum`, `max-length`, `member-eq?`, `member?`, `midpoint@`, `min-length`, `mismatch`, `move`, `new-like`, `new-resizable`, `new-sequence`, `non-negative-integer-expected`, `non-negative-integer-expected?`, `nth`, `nths`, `pad-head`, `pad-tail`, `padding`, `partition`, `pop`, `pop*`, `prefix`, `prepend`, `prepend-as`, `produce`, `produce-as`, `product`, `push`, `push-all`, `push-either`, `push-if`, `reduce`, `reduce-index`, `remove`, `remove!`, `remove-eq`, `remove-eq!`, `remove-nth`, `remove-nth!`, `repetition`, `repetition?`, `replace-slice`, `replicate`, `replicate-as`, `rest`, `rest-slice`, `reverse`, `reverse!`, `reversed`, `reversed?`, `second`, `selector`, `selector-for`, `sequence`, `sequence-hashcode`, `sequence=`, `sequence?`, `set-first`, `set-fourth`, `set-last`, `set-length`, `set-nth`, `set-second`, `set-third`, `short`, `shorten`, `shorter`, `shorter?`, `shortest`, `sift`, `slice`, `slice-error`, `slice-error?`, `slice?`, `snip`, `snip-slice`, `start`, `start*`, `subseq`, `subseq?`, `suffix`, `suffix!`, `sum`, `sum-lengths`, `supremum`, `supremum-by`, `surround`, `tail`, `tail-slice`, `tail-slice*`, `tail*`, `tail?`, `third`, `trim`, `trim-head`, `trim-head-slice`, `trim-slice`, `trim-tail`, `trim-tail-slice`, `unclip`, `unclip-last`, `unclip-last-slice`, `unclip-slice`, `unless-empty`, `virtual-exemplar`, `virtual-sequence`, `virtual-sequence?`, `virtual@`, `when-empty`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `+@`, `change`, `change-global`, `counter`, `dec`, `get`, `get-global`, `global`, `inc`, `init-namespaces`, `initialize`, `is-global`, `make-assoc`, `namespace`, `namestack`, `off`, `on`, `set`, `set-global`, `set-namestack`, `toggle`, `with-global`, `with-scope`, `with-variable`, `with-variables`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `1array`, `2array`, `3array`, `4array`, `<array>`, `>array`, `array`, `array?`, `pair`, `pair?`, `resize-array`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `(each-stream-block-slice)`, `(each-stream-block)`, `(stream-contents-by-block)`, `(stream-contents-by-element)`, `(stream-contents-by-length-or-block)`, `(stream-contents-by-length)`, `+byte+`, `+character+`, `bad-seek-type`, `bad-seek-type?`, `bl`, `contents`, `each-block`, `each-block-size`, `each-block-slice`, `each-line`, `each-morsel`, `each-stream-block`, `each-stream-block-slice`, `each-stream-line`, `error-stream`, `flush`, `input-stream`, `input-stream?`, `invalid-read-buffer`, `invalid-read-buffer?`, `lines`, `nl`, `output-stream`, `output-stream?`, `print`, `read`, `read-into`, `read-partial`, `read-partial-into`, `read-until`, `read1`, `readln`, `seek-absolute`, `seek-absolute?`, `seek-end`, `seek-end?`, `seek-input`, `seek-output`, `seek-relative`, `seek-relative?`, `stream-bl`, `stream-contents`, `stream-contents*`, `stream-copy`, `stream-copy*`, `stream-element-type`, `stream-flush`, `stream-length`, `stream-lines`, `stream-nl`, `stream-print`, `stream-read`, `stream-read-into`, `stream-read-partial`, `stream-read-partial-into`, `stream-read-partial-unsafe`, `stream-read-unsafe`, `stream-read-until`, `stream-read1`, `stream-readln`, `stream-seek`, `stream-seekable?`, `stream-tell`, `stream-write`, `stream-write1`, `tell-input`, `tell-output`, `with-error-stream`, `with-error-stream*`, `with-error>output`, `with-input-output+error-streams`, `with-input-output+error-streams*`, `with-input-stream`, `with-input-stream*`, `with-output-stream`, `with-output-stream*`, `with-output>error`, `with-output+error-stream`, `with-output+error-stream*`, `with-streams`, `with-streams*`, `write`, `write1`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `1string`, `<string>`, `>string`, `resize-string`, `string`, `string?`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `1vector`, `<vector>`, `>vector`, `?push`, `vector`, `vector?`), NameBuiltin, nil},
|
||||
{Words(``, `\s`, `<condition>`, `<continuation>`, `<restart>`, `attempt-all`, `attempt-all-error`, `attempt-all-error?`, `callback-error-hook`, `callcc0`, `callcc1`, `cleanup`, `compute-restarts`, `condition`, `condition?`, `continuation`, `continuation?`, `continue`, `continue-restart`, `continue-with`, `current-continuation`, `error`, `error-continuation`, `error-in-thread`, `error-thread`, `ifcc`, `ignore-errors`, `in-callback?`, `original-error`, `recover`, `restart`, `restart?`, `restarts`, `rethrow`, `rethrow-restarts`, `return`, `return-continuation`, `thread-error-hook`, `throw-continue`, `throw-restarts`, `with-datastack`, `with-return`), NameBuiltin, nil},
|
||||
{`\S+`, Text, nil},
|
||||
},
|
||||
"stackeffect": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\(\s+`, NameFunction, Push("stackeffect")},
|
||||
{`\)\s`, NameFunction, Pop(1)},
|
||||
{`--\s`, NameFunction, nil},
|
||||
{`\S+`, NameVariable, nil},
|
||||
},
|
||||
"slots": {
|
||||
{`\s+`, Text, nil},
|
||||
{`;\s`, Keyword, Pop(1)},
|
||||
{`(\{\s+)(\S+)(\s+[^}]+\s+\}\s)`, ByGroups(Text, NameVariable, Text), nil},
|
||||
{`\S+`, NameVariable, nil},
|
||||
},
|
||||
"vocabs": {
|
||||
{`\s+`, Text, nil},
|
||||
{`;\s`, Keyword, Pop(1)},
|
||||
{`\S+`, NameNamespace, nil},
|
||||
},
|
||||
"classes": {
|
||||
{`\s+`, Text, nil},
|
||||
{`;\s`, Keyword, Pop(1)},
|
||||
{`\S+`, NameClass, nil},
|
||||
},
|
||||
"words": {
|
||||
{`\s+`, Text, nil},
|
||||
{`;\s`, Keyword, Pop(1)},
|
||||
{`\S+`, NameFunction, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Fennel lexer.
|
||||
var Fennel = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Fennel",
|
||||
Aliases: []string{"fennel", "fnl"},
|
||||
Filenames: []string{"*.fennel"},
|
||||
MimeTypes: []string{"text/x-fennel", "application/x-fennel"},
|
||||
},
|
||||
fennelRules,
|
||||
))
|
||||
|
||||
// Here's some Fennel code used to generate the lists of keywords:
|
||||
// (local fennel (require :fennel))
|
||||
//
|
||||
// (fn member? [t x] (each [_ y (ipairs t)] (when (= y x) (lua "return true"))))
|
||||
//
|
||||
// (local declarations [:fn :lambda :λ :local :var :global :macro :macros])
|
||||
// (local keywords [])
|
||||
// (local globals [])
|
||||
//
|
||||
// (each [name data (pairs (fennel.syntax))]
|
||||
// (if (member? declarations name) nil ; already populated
|
||||
// data.special? (table.insert keywords name)
|
||||
// data.macro? (table.insert keywords name)
|
||||
// data.global? (table.insert globals name)))
|
||||
//
|
||||
// (fn quoted [tbl]
|
||||
// (table.sort tbl)
|
||||
// (table.concat (icollect [_ k (ipairs tbl)]
|
||||
// (string.format "`%s`" k)) ", "))
|
||||
//
|
||||
// (print :Keyword (quoted keywords))
|
||||
// (print :KeywordDeclaration (quoted declarations))
|
||||
// (print :NameBuiltin (quoted globals))
|
||||
|
||||
func fennelRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`;.*$`, CommentSingle, nil},
|
||||
{`\s+`, Whitespace, nil},
|
||||
{`-?\d+\.\d+`, LiteralNumberFloat, nil},
|
||||
{`-?\d+`, LiteralNumberInteger, nil},
|
||||
{`0x-?[abcdef\d]+`, LiteralNumberHex, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{`\\(.|[a-z]+)`, LiteralStringChar, nil},
|
||||
{`::?#?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{"~@|[`\\'#^~&@]", Operator, nil},
|
||||
{Words(``, ` `, `#`, `%`, `*`, `+`, `-`, `->`, `->>`, `-?>`, `-?>>`, `.`, `..`, `/`, `//`, `:`, `<`, `<=`, `=`, `>`, `>=`, `?.`, `^`, `accumulate`, `and`, `band`, `bnot`, `bor`, `bxor`, `collect`, `comment`, `do`, `doc`, `doto`, `each`, `eval-compiler`, `for`, `hashfn`, `icollect`, `if`, `import-macros`, `include`, `length`, `let`, `lshift`, `lua`, `macrodebug`, `match`, `not`, `not=`, `or`, `partial`, `pick-args`, `pick-values`, `quote`, `require-macros`, `rshift`, `set`, `set-forcibly!`, `tset`, `values`, `when`, `while`, `with-open`, `~=`), Keyword, nil},
|
||||
{Words(``, ` `, `fn`, `global`, `lambda`, `local`, `macro`, `macros`, `var`, `λ`), KeywordDeclaration, nil},
|
||||
{Words(``, ` `, `_G`, `arg`, `assert`, `bit32`, `bit32.arshift`, `bit32.band`, `bit32.bnot`, `bit32.bor`, `bit32.btest`, `bit32.bxor`, `bit32.extract`, `bit32.lrotate`, `bit32.lshift`, `bit32.replace`, `bit32.rrotate`, `bit32.rshift`, `collectgarbage`, `coroutine`, `coroutine.create`, `coroutine.resume`, `coroutine.running`, `coroutine.status`, `coroutine.wrap`, `coroutine.yield`, `debug`, `debug.debug`, `debug.gethook`, `debug.getinfo`, `debug.getlocal`, `debug.getmetatable`, `debug.getregistry`, `debug.getupvalue`, `debug.getuservalue`, `debug.sethook`, `debug.setlocal`, `debug.setmetatable`, `debug.setupvalue`, `debug.setuservalue`, `debug.traceback`, `debug.upvalueid`, `debug.upvaluejoin`, `dofile`, `error`, `getmetatable`, `io`, `io.close`, `io.flush`, `io.input`, `io.lines`, `io.open`, `io.output`, `io.popen`, `io.read`, `io.tmpfile`, `io.type`, `io.write`, `ipairs`, `load`, `loadfile`, `loadstring`, `math`, `math.abs`, `math.acos`, `math.asin`, `math.atan`, `math.atan2`, `math.ceil`, `math.cos`, `math.cosh`, `math.deg`, `math.exp`, `math.floor`, `math.fmod`, `math.frexp`, `math.ldexp`, `math.log`, `math.log10`, `math.max`, `math.min`, `math.modf`, `math.pow`, `math.rad`, `math.random`, `math.randomseed`, `math.sin`, `math.sinh`, `math.sqrt`, `math.tan`, `math.tanh`, `module`, `next`, `os`, `os.clock`, `os.date`, `os.difftime`, `os.execute`, `os.exit`, `os.getenv`, `os.remove`, `os.rename`, `os.setlocale`, `os.time`, `os.tmpname`, `package`, `package.loadlib`, `package.searchpath`, `package.seeall`, `pairs`, `pcall`, `print`, `rawequal`, `rawget`, `rawlen`, `rawset`, `require`, `select`, `setmetatable`, `string`, `string.byte`, `string.char`, `string.dump`, `string.find`, `string.format`, `string.gmatch`, `string.gsub`, `string.len`, `string.lower`, `string.match`, `string.rep`, `string.reverse`, `string.sub`, `string.upper`, `table`, `table.concat`, `table.insert`, `table.maxn`, `table.pack`, `table.remove`, `table.sort`, `table.unpack`, `tonumber`, `tostring`, `type`, `unpack`, `xpcall`), NameBuiltin, nil},
|
||||
{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil},
|
||||
{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil},
|
||||
{`(\[|\])`, Punctuation, nil},
|
||||
{`(\{|\})`, Punctuation, nil},
|
||||
{`(\(|\))`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Fish lexer.
|
||||
var Fish = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Fish",
|
||||
Aliases: []string{"fish", "fishshell"},
|
||||
Filenames: []string{"*.fish", "*.load"},
|
||||
MimeTypes: []string{"application/x-fish"},
|
||||
},
|
||||
fishRules,
|
||||
))
|
||||
|
||||
func fishRules() Rules {
|
||||
keywords := []string{
|
||||
`begin`, `end`, `if`, `else`, `while`, `break`, `for`, `return`, `function`, `block`,
|
||||
`case`, `continue`, `switch`, `not`, `and`, `or`, `set`, `echo`, `exit`, `pwd`, `true`,
|
||||
`false`, `cd`, `cdh`, `count`, `test`,
|
||||
}
|
||||
keywordsPattern := Words(`\b`, `\b`, keywords...)
|
||||
|
||||
builtins := []string{
|
||||
`alias`, `bg`, `bind`, `breakpoint`, `builtin`, `argparse`, `abbr`, `string`, `command`,
|
||||
`commandline`, `complete`, `contains`, `dirh`, `dirs`, `disown`, `emit`, `eval`, `exec`,
|
||||
`fg`, `fish`, `fish_add_path`, `fish_breakpoint_prompt`, `fish_command_not_found`,
|
||||
`fish_config`, `fish_git_prompt`, `fish_greeting`, `fish_hg_prompt`, `fish_indent`,
|
||||
`fish_is_root_user`, `fish_key_reader`, `fish_mode_prompt`, `fish_opt`, `fish_pager`,
|
||||
`fish_prompt`, `fish_right_prompt`, `fish_status_to_signal`, `fish_svn_prompt`,
|
||||
`fish_title`, `fish_update_completions`, `fish_vcs_prompt`, `fishd`, `funced`,
|
||||
`funcsave`, `functions`, `help`, `history`, `isatty`, `jobs`, `math`, `mimedb`, `nextd`,
|
||||
`open`, `prompt_pwd`, `realpath`, `popd`, `prevd`, `psub`, `pushd`, `random`, `read`,
|
||||
`set_color`, `source`, `status`, `suspend`, `trap`, `type`, `ulimit`, `umask`, `vared`,
|
||||
`fc`, `getopts`, `hash`, `kill`, `printf`, `time`, `wait`,
|
||||
}
|
||||
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("basic"),
|
||||
Include("interp"),
|
||||
Include("data"),
|
||||
},
|
||||
"interp": {
|
||||
{`\$\(\(`, Keyword, Push("math")},
|
||||
{`\(`, Keyword, Push("paren")},
|
||||
{`\$#?(\w+|.)`, NameVariable, nil},
|
||||
},
|
||||
"basic": {
|
||||
{Words(`(?<=(?:^|\A|;|&&|\|\||\||`+keywordsPattern+`)\s*)`, `(?=;?\b)`, keywords...), Keyword, nil},
|
||||
{`(?<=for\s+\S+\s+)in\b`, Keyword, nil},
|
||||
{Words(`\b`, `\s*\b(?!\.)`, builtins...), NameBuiltin, nil},
|
||||
{`#!.*\n`, CommentHashbang, nil},
|
||||
{`#.*\n`, Comment, nil},
|
||||
{`\\[\w\W]`, LiteralStringEscape, nil},
|
||||
{`(\b\w+)(\s*)(=)`, ByGroups(NameVariable, Text, Operator), nil},
|
||||
{`[\[\]()={}]`, Operator, nil},
|
||||
{`(?<=\[[^\]]+)\.\.|-(?=[^\[]+\])`, Operator, nil},
|
||||
{`<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
|
||||
{`(?<=set\s+(?:--?[^\d\W][\w-]*\s+)?)\w+`, NameVariable, nil},
|
||||
{`(?<=for\s+)\w[\w-]*(?=\s+in)`, NameVariable, nil},
|
||||
{`(?<=function\s+)\w(?:[^\n])*?(?= *[-\n])`, NameFunction, nil},
|
||||
{`(?<=(?:^|\b(?:and|or|sudo)\b|;|\|\||&&|\||\(|(?:\b\w+\s*=\S+\s)) *)\w[\w-]*`, NameFunction, nil},
|
||||
},
|
||||
"data": {
|
||||
{`(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"`, LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
|
||||
{`(?s)'.*?'`, LiteralStringSingle, nil},
|
||||
{`;`, Punctuation, nil},
|
||||
{`&&|\|\||&|\||\^|<|>`, Operator, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\b\d+\b`, LiteralNumber, nil},
|
||||
{`(?<=\s+)--?[^\d][\w-]*`, NameAttribute, nil},
|
||||
{".+?", Text, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+`, LiteralStringDouble, nil},
|
||||
Include("interp"),
|
||||
},
|
||||
"paren": {
|
||||
{`\)`, Keyword, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"math": {
|
||||
{`\)\)`, Keyword, Pop(1)},
|
||||
{`[-+*/%^|&]|\*\*|\|\|`, Operator, nil},
|
||||
{`\d+#\d+`, LiteralNumber, nil},
|
||||
{`\d+#(?! )`, LiteralNumber, nil},
|
||||
{`\d+`, LiteralNumber, nil},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Forth lexer.
|
||||
var Forth = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Forth",
|
||||
Aliases: []string{"forth"},
|
||||
Filenames: []string{"*.frt", "*.fth", "*.fs"},
|
||||
MimeTypes: []string{"application/x-forth"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
forthRules,
|
||||
))
|
||||
|
||||
func forthRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\\.*?\n`, CommentSingle, nil},
|
||||
{`\([\s].*?\)`, CommentSingle, nil},
|
||||
{`(:|variable|constant|value|buffer:)(\s+)`, ByGroups(KeywordNamespace, Text), Push("worddef")},
|
||||
{`([.sc]")(\s+?)`, ByGroups(LiteralString, Text), Push("stringdef")},
|
||||
{`(blk|block|buffer|evaluate|flush|load|save-buffers|update|empty-buffers|list|refill|scr|thru|\#s|\*\/mod|\+loop|\/mod|0<|0=|1\+|1-|2!|2\*|2\/|2@|2drop|2dup|2over|2swap|>body|>in|>number|>r|\?dup|abort|abort\"|abs|accept|align|aligned|allot|and|base|begin|bl|c!|c,|c@|cell\+|cells|char|char\+|chars|constant|count|cr|create|decimal|depth|do|does>|drop|dup|else|emit|environment\?|evaluate|execute|exit|fill|find|fm\/mod|here|hold|i|if|immediate|invert|j|key|leave|literal|loop|lshift|m\*|max|min|mod|move|negate|or|over|postpone|quit|r>|r@|recurse|repeat|rot|rshift|s\"|s>d|sign|sm\/rem|source|space|spaces|state|swap|then|type|u\.|u\<|um\*|um\/mod|unloop|until|variable|while|word|xor|\[char\]|\[\'\]|@|!|\#|<\#|\#>|:|;|\+|-|\*|\/|,|<|>|\|1\+|1-|\.|\.r|0<>|0>|2>r|2r>|2r@|:noname|\?do|again|c\"|case|compile,|endcase|endof|erase|false|hex|marker|nip|of|pad|parse|pick|refill|restore-input|roll|save-input|source-id|to|true|tuck|u\.r|u>|unused|value|within|\[compile\]|\#tib|convert|expect|query|span|tib|2constant|2literal|2variable|d\+|d-|d\.|d\.r|d0<|d0=|d2\*|d2\/|d<|d=|d>s|dabs|dmax|dmin|dnegate|m\*\/|m\+|2rot|du<|catch|throw|abort|abort\"|at-xy|key\?|page|ekey|ekey>char|ekey\?|emit\?|ms|time&date|BIN|CLOSE-FILE|CREATE-FILE|DELETE-FILE|FILE-POSITION|FILE-SIZE|INCLUDE-FILE|INCLUDED|OPEN-FILE|R\/O|R\/W|READ-FILE|READ-LINE|REPOSITION-FILE|RESIZE-FILE|S\"|SOURCE-ID|W/O|WRITE-FILE|WRITE-LINE|FILE-STATUS|FLUSH-FILE|REFILL|RENAME-FILE|>float|d>f|f!|f\*|f\+|f-|f\/|f0<|f0=|f<|f>d|f@|falign|faligned|fconstant|fdepth|fdrop|fdup|fliteral|float\+|floats|floor|fmax|fmin|fnegate|fover|frot|fround|fswap|fvariable|represent|df!|df@|dfalign|dfaligned|dfloat\+|dfloats|f\*\*|f\.|fabs|facos|facosh|falog|fasin|fasinh|fatan|fatan2|fatanh|fcos|fcosh|fe\.|fexp|fexpm1|fln|flnp1|flog|fs\.|fsin|fsincos|fsinh|fsqrt|ftan|ftanh|f~|precision|set-precision|sf!|sf@|sfalign|sfaligned|sfloat\+|sfloats|\(local\)|to|locals\||allocate|free|resize|definitions|find|forth-wordlist|get-current|get-order|search-wordlist|set-current|set-order|wordlist|also|forth|only|order|previous|-trailing|\/string|blank|cmove|cmove>|compare|search|sliteral|.s|dump|see|words|;code|ahead|assembler|bye|code|cs-pick|cs-roll|editor|state|\[else\]|\[if\]|\[then\]|forget|defer|defer@|defer!|action-of|begin-structure|field:|buffer:|parse-name|buffer:|traverse-wordlist|n>r|nr>|2value|fvalue|name>interpret|name>compile|name>string|cfield:|end-structure)\s`, Keyword, nil},
|
||||
{`(\$[0-9A-F]+)`, LiteralNumberHex, nil},
|
||||
{`(\#|%|&|\-|\+)?[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`(\#|%|&|\-|\+)?[0-9.]+`, KeywordType, nil},
|
||||
{`(@i|!i|@e|!e|pause|noop|turnkey|sleep|itype|icompare|sp@|sp!|rp@|rp!|up@|up!|>a|a>|a@|a!|a@+|a@-|>b|b>|b@|b!|b@+|b@-|find-name|1ms|sp0|rp0|\(evaluate\)|int-trap|int!)\s`, NameConstant, nil},
|
||||
{`(do-recognizer|r:fail|recognizer:|get-recognizers|set-recognizers|r:float|r>comp|r>int|r>post|r:name|r:word|r:dnum|r:num|recognizer|forth-recognizer|rec:num|rec:float|rec:word)\s`, NameDecorator, nil},
|
||||
{`(Evalue|Rvalue|Uvalue|Edefer|Rdefer|Udefer)(\s+)`, ByGroups(KeywordNamespace, Text), Push("worddef")},
|
||||
{`[^\s]+(?=[\s])`, NameFunction, nil},
|
||||
},
|
||||
"worddef": {
|
||||
{`\S+`, NameClass, Pop(1)},
|
||||
},
|
||||
"stringdef": {
|
||||
{`[^"]+`, LiteralString, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Fortran lexer.
|
||||
var Fortran = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Fortran",
|
||||
Aliases: []string{"fortran"},
|
||||
Filenames: []string{"*.f03", "*.f90", "*.F03", "*.F90"},
|
||||
MimeTypes: []string{"text/x-fortran"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
fortranRules,
|
||||
))
|
||||
|
||||
func fortranRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^#.*\n`, CommentPreproc, nil},
|
||||
{`!.*\n`, Comment, nil},
|
||||
Include("strings"),
|
||||
Include("core"),
|
||||
{`[a-z][\w$]*`, Name, nil},
|
||||
Include("nums"),
|
||||
{`[\s]+`, Text, nil},
|
||||
},
|
||||
"core": {
|
||||
{Words(`\b`, `\s*\b`, `ABSTRACT`, `ACCEPT`, `ALL`, `ALLSTOP`, `ALLOCATABLE`, `ALLOCATE`, `ARRAY`, `ASSIGN`, `ASSOCIATE`, `ASYNCHRONOUS`, `BACKSPACE`, `BIND`, `BLOCK`, `BLOCKDATA`, `BYTE`, `CALL`, `CASE`, `CLASS`, `CLOSE`, `CODIMENSION`, `COMMON`, `CONCURRRENT`, `CONTIGUOUS`, `CONTAINS`, `CONTINUE`, `CRITICAL`, `CYCLE`, `DATA`, `DEALLOCATE`, `DECODE`, `DEFERRED`, `DIMENSION`, `DO`, `ELEMENTAL`, `ELSE`, `ENCODE`, `END`, `ENTRY`, `ENUM`, `ENUMERATOR`, `EQUIVALENCE`, `EXIT`, `EXTENDS`, `EXTERNAL`, `EXTRINSIC`, `FILE`, `FINAL`, `FORALL`, `FORMAT`, `FUNCTION`, `GENERIC`, `GOTO`, `IF`, `IMAGES`, `IMPLICIT`, `IMPORT`, `IMPURE`, `INCLUDE`, `INQUIRE`, `INTENT`, `INTERFACE`, `INTRINSIC`, `IS`, `LOCK`, `MEMORY`, `MODULE`, `NAMELIST`, `NULLIFY`, `NONE`, `NON_INTRINSIC`, `NON_OVERRIDABLE`, `NOPASS`, `OPEN`, `OPTIONAL`, `OPTIONS`, `PARAMETER`, `PASS`, `PAUSE`, `POINTER`, `PRINT`, `PRIVATE`, `PROGRAM`, `PROCEDURE`, `PROTECTED`, `PUBLIC`, `PURE`, `READ`, `RECURSIVE`, `RESULT`, `RETURN`, `REWIND`, `SAVE`, `SELECT`, `SEQUENCE`, `STOP`, `SUBMODULE`, `SUBROUTINE`, `SYNC`, `SYNCALL`, `SYNCIMAGES`, `SYNCMEMORY`, `TARGET`, `THEN`, `TYPE`, `UNLOCK`, `USE`, `VALUE`, `VOLATILE`, `WHERE`, `WRITE`, `WHILE`), Keyword, nil},
|
||||
{Words(`\b`, `\s*\b`, `CHARACTER`, `COMPLEX`, `DOUBLE PRECISION`, `DOUBLE COMPLEX`, `INTEGER`, `LOGICAL`, `REAL`, `C_INT`, `C_SHORT`, `C_LONG`, `C_LONG_LONG`, `C_SIGNED_CHAR`, `C_SIZE_T`, `C_INT8_T`, `C_INT16_T`, `C_INT32_T`, `C_INT64_T`, `C_INT_LEAST8_T`, `C_INT_LEAST16_T`, `C_INT_LEAST32_T`, `C_INT_LEAST64_T`, `C_INT_FAST8_T`, `C_INT_FAST16_T`, `C_INT_FAST32_T`, `C_INT_FAST64_T`, `C_INTMAX_T`, `C_INTPTR_T`, `C_FLOAT`, `C_DOUBLE`, `C_LONG_DOUBLE`, `C_FLOAT_COMPLEX`, `C_DOUBLE_COMPLEX`, `C_LONG_DOUBLE_COMPLEX`, `C_BOOL`, `C_CHAR`, `C_PTR`, `C_FUNPTR`), KeywordType, nil},
|
||||
{`(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)`, Operator, nil},
|
||||
{`(::)`, KeywordDeclaration, nil},
|
||||
{`[()\[\],:&%;.]`, Punctuation, nil},
|
||||
{Words(`\b`, `\s*\b`, `Abort`, `Abs`, `Access`, `AChar`, `ACos`, `ACosH`, `AdjustL`, `AdjustR`, `AImag`, `AInt`, `Alarm`, `All`, `Allocated`, `ALog`, `AMax`, `AMin`, `AMod`, `And`, `ANInt`, `Any`, `ASin`, `ASinH`, `Associated`, `ATan`, `ATanH`, `Atomic_Define`, `Atomic_Ref`, `BesJ`, `BesJN`, `Bessel_J0`, `Bessel_J1`, `Bessel_JN`, `Bessel_Y0`, `Bessel_Y1`, `Bessel_YN`, `BesY`, `BesYN`, `BGE`, `BGT`, `BLE`, `BLT`, `Bit_Size`, `BTest`, `CAbs`, `CCos`, `Ceiling`, `CExp`, `Char`, `ChDir`, `ChMod`, `CLog`, `Cmplx`, `Command_Argument_Count`, `Complex`, `Conjg`, `Cos`, `CosH`, `Count`, `CPU_Time`, `CShift`, `CSin`, `CSqRt`, `CTime`, `C_Loc`, `C_Associated`, `C_Null_Ptr`, `C_Null_Funptr`, `C_F_Pointer`, `C_F_ProcPointer`, `C_Null_Char`, `C_Alert`, `C_Backspace`, `C_Form_Feed`, `C_FunLoc`, `C_Sizeof`, `C_New_Line`, `C_Carriage_Return`, `C_Horizontal_Tab`, `C_Vertical_Tab`, `DAbs`, `DACos`, `DASin`, `DATan`, `Date_and_Time`, `DbesJ`, `DbesJN`, `DbesY`, `DbesYN`, `Dble`, `DCos`, `DCosH`, `DDiM`, `DErF`, `DErFC`, `DExp`, `Digits`, `DiM`, `DInt`, `DLog`, `DMax`, `DMin`, `DMod`, `DNInt`, `Dot_Product`, `DProd`, `DSign`, `DSinH`, `DShiftL`, `DShiftR`, `DSin`, `DSqRt`, `DTanH`, `DTan`, `DTime`, `EOShift`, `Epsilon`, `ErF`, `ErFC`, `ErFC_Scaled`, `ETime`, `Execute_Command_Line`, `Exit`, `Exp`, `Exponent`, `Extends_Type_Of`, `FDate`, `FGet`, `FGetC`, `FindLoc`, `Float`, `Floor`, `Flush`, `FNum`, `FPutC`, `FPut`, `Fraction`, `FSeek`, `FStat`, `FTell`, `Gamma`, `GError`, `GetArg`, `Get_Command`, `Get_Command_Argument`, `Get_Environment_Variable`, `GetCWD`, `GetEnv`, `GetGId`, `GetLog`, `GetPId`, `GetUId`, `GMTime`, `HostNm`, `Huge`, `Hypot`, `IAbs`, `IAChar`, `IAll`, `IAnd`, `IAny`, `IArgC`, `IBClr`, `IBits`, `IBSet`, `IChar`, `IDate`, `IDiM`, `IDInt`, `IDNInt`, `IEOr`, `IErrNo`, `IFix`, `Imag`, `ImagPart`, `Image_Index`, `Index`, `Int`, `IOr`, `IParity`, `IRand`, `IsaTty`, `IShft`, `IShftC`, `ISign`, `Iso_C_Binding`, `Is_Contiguous`, `Is_Iostat_End`, `Is_Iostat_Eor`, `ITime`, `Kill`, `Kind`, `LBound`, `LCoBound`, `Len`, `Len_Trim`, `LGe`, `LGt`, `Link`, `LLe`, `LLt`, `LnBlnk`, `Loc`, `Log`, `Log_Gamma`, `Logical`, `Long`, `LShift`, `LStat`, `LTime`, `MaskL`, `MaskR`, `MatMul`, `Max`, `MaxExponent`, `MaxLoc`, `MaxVal`, `MClock`, `Merge`, `Merge_Bits`, `Move_Alloc`, `Min`, `MinExponent`, `MinLoc`, `MinVal`, `Mod`, `Modulo`, `MvBits`, `Nearest`, `New_Line`, `NInt`, `Norm2`, `Not`, `Null`, `Num_Images`, `Or`, `Pack`, `Parity`, `PError`, `Precision`, `Present`, `Product`, `Radix`, `Rand`, `Random_Number`, `Random_Seed`, `Range`, `Real`, `RealPart`, `Rename`, `Repeat`, `Reshape`, `RRSpacing`, `RShift`, `Same_Type_As`, `Scale`, `Scan`, `Second`, `Selected_Char_Kind`, `Selected_Int_Kind`, `Selected_Real_Kind`, `Set_Exponent`, `Shape`, `ShiftA`, `ShiftL`, `ShiftR`, `Short`, `Sign`, `Signal`, `SinH`, `Sin`, `Sleep`, `Sngl`, `Spacing`, `Spread`, `SqRt`, `SRand`, `Stat`, `Storage_Size`, `Sum`, `SymLnk`, `System`, `System_Clock`, `Tan`, `TanH`, `Time`, `This_Image`, `Tiny`, `TrailZ`, `Transfer`, `Transpose`, `Trim`, `TtyNam`, `UBound`, `UCoBound`, `UMask`, `Unlink`, `Unpack`, `Verify`, `XOr`, `ZAbs`, `ZCos`, `ZExp`, `ZLog`, `ZSin`, `ZSqRt`), NameBuiltin, nil},
|
||||
{`\.(true|false)\.`, NameBuiltin, nil},
|
||||
{`\.(eq|ne|lt|le|gt|ge|not|and|or|eqv|neqv)\.`, OperatorWord, nil},
|
||||
},
|
||||
"strings": {
|
||||
{`(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"`, LiteralStringDouble, nil},
|
||||
{`(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
|
||||
},
|
||||
"nums": {
|
||||
{`\d+(?![.e])(_[a-z]\w+)?`, LiteralNumberInteger, nil},
|
||||
{`[+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)?`, LiteralNumberFloat, nil},
|
||||
{`[+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?`, LiteralNumberFloat, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// FortranFixed lexer.
|
||||
var FortranFixed = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "FortranFixed",
|
||||
Aliases: []string{"fortranfixed"},
|
||||
Filenames: []string{"*.f", "*.F"},
|
||||
MimeTypes: []string{"text/x-fortran"},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
func() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[C*].*\n`, Comment, nil},
|
||||
{`#.*\n`, CommentPreproc, nil},
|
||||
{`[\t ]*!.*\n`, Comment, nil},
|
||||
{`(.{5})`, NameLabel, Push("cont-char")},
|
||||
{`.*\n`, Using(Fortran), nil},
|
||||
},
|
||||
"cont-char": {
|
||||
{` `, Text, Push("code")},
|
||||
{`0`, Comment, Push("code")},
|
||||
{`.`, GenericStrong, Push("code")},
|
||||
},
|
||||
"code": {
|
||||
{`(.{66})(.*)(\n)`, ByGroups(Using(Fortran), Comment, Text), Push("root")},
|
||||
{`.*\n`, Using(Fortran), Push("root")},
|
||||
Default(Push("root")),
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
|
@ -1,98 +0,0 @@
|
|||
package f
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Fsharp lexer.
|
||||
var Fsharp = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "FSharp",
|
||||
Aliases: []string{"fsharp"},
|
||||
Filenames: []string{"*.fs", "*.fsi"},
|
||||
MimeTypes: []string{"text/x-fsharp"},
|
||||
},
|
||||
fsharpRules,
|
||||
))
|
||||
|
||||
func fsharpRules() Rules {
|
||||
return Rules{
|
||||
"escape-sequence": {
|
||||
{`\\[\\"\'ntbrafv]`, LiteralStringEscape, nil},
|
||||
{`\\[0-9]{3}`, LiteralStringEscape, nil},
|
||||
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||
{`\\U[0-9a-fA-F]{8}`, LiteralStringEscape, nil},
|
||||
},
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\(\)|\[\]`, NameBuiltinPseudo, nil},
|
||||
{`\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)`, NameNamespace, Push("dotted")},
|
||||
{`\b([A-Z][\w\']*)`, Name, nil},
|
||||
{`///.*?\n`, LiteralStringDoc, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`\(\*(?!\))`, Comment, Push("comment")},
|
||||
{`@"`, LiteralString, Push("lstring")},
|
||||
{`"""`, LiteralString, Push("tqs")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`\b(open|module)(\s+)([\w.]+)`, ByGroups(Keyword, Text, NameNamespace), nil},
|
||||
{`\b(let!?)(\s+)(\w+)`, ByGroups(Keyword, Text, NameVariable), nil},
|
||||
{`\b(type)(\s+)(\w+)`, ByGroups(Keyword, Text, NameClass), nil},
|
||||
{`\b(member|override)(\s+)(\w+)(\.)(\w+)`, ByGroups(Keyword, Text, Name, Punctuation, NameFunction), nil},
|
||||
{`\b(abstract|as|assert|base|begin|class|default|delegate|do!|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|function|fun|global|if|inherit|inline|interface|internal|in|lazy|let!|let|match|member|module|mutable|namespace|new|null|of|open|override|private|public|rec|return!|return|select|static|struct|then|to|true|try|type|upcast|use!|use|val|void|when|while|with|yield!|yield|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b`, Keyword, nil},
|
||||
{"``([^`\\n\\r\\t]|`[^`\\n\\r\\t])+``", Name, nil},
|
||||
{"(!=|#|&&|&|\\(|\\)|\\*|\\+|,|-\\.|->|-|\\.\\.|\\.|::|:=|:>|:|;;|;|<-|<\\]|<|>\\]|>|\\?\\?|\\?|\\[<|\\[\\||\\[|\\]|_|`|\\{|\\|\\]|\\||\\}|~|<@@|<@|=|@>|@@>)", Operator, nil},
|
||||
{`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil},
|
||||
{`\b(and|or|not)\b`, OperatorWord, nil},
|
||||
{`\b(sbyte|byte|char|nativeint|unativeint|float32|single|float|double|int8|uint8|int16|uint16|int32|uint32|int64|uint64|decimal|unit|bool|string|list|exn|obj|enum)\b`, KeywordType, nil},
|
||||
{`#[ \t]*(if|endif|else|line|nowarn|light|\d+)\b.*?\n`, CommentPreproc, nil},
|
||||
{`[^\W\d][\w']*`, Name, nil},
|
||||
{`\d[\d_]*[uU]?[yslLnQRZINGmM]?`, LiteralNumberInteger, nil},
|
||||
{`0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?`, LiteralNumberHex, nil},
|
||||
{`0[oO][0-7][0-7_]*[uU]?[yslLn]?`, LiteralNumberOct, nil},
|
||||
{`0[bB][01][01_]*[uU]?[yslLn]?`, LiteralNumberBin, nil},
|
||||
{`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?`, LiteralNumberFloat, nil},
|
||||
{`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?`, LiteralStringChar, nil},
|
||||
{`'.'`, LiteralStringChar, nil},
|
||||
{`'`, Keyword, nil},
|
||||
{`@?"`, LiteralStringDouble, Push("string")},
|
||||
{`[~?][a-z][\w\']*:`, NameVariable, nil},
|
||||
},
|
||||
"dotted": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\.`, Punctuation, nil},
|
||||
{`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil},
|
||||
{`[A-Z][\w\']*`, Name, Pop(1)},
|
||||
{`[a-z_][\w\']*`, Name, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"comment": {
|
||||
{`[^(*)@"]+`, Comment, nil},
|
||||
{`\(\*`, Comment, Push()},
|
||||
{`\*\)`, Comment, Pop(1)},
|
||||
{`@"`, LiteralString, Push("lstring")},
|
||||
{`"""`, LiteralString, Push("tqs")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`[(*)@]`, Comment, nil},
|
||||
},
|
||||
"string": {
|
||||
{`[^\\"]+`, LiteralString, nil},
|
||||
Include("escape-sequence"),
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\n`, LiteralString, nil},
|
||||
{`"B?`, LiteralString, Pop(1)},
|
||||
},
|
||||
"lstring": {
|
||||
{`[^"]+`, LiteralString, nil},
|
||||
{`\n`, LiteralString, nil},
|
||||
{`""`, LiteralString, nil},
|
||||
{`"B?`, LiteralString, Pop(1)},
|
||||
},
|
||||
"tqs": {
|
||||
{`[^"]+`, LiteralString, nil},
|
||||
{`\n`, LiteralString, nil},
|
||||
{`"""B?`, LiteralString, Pop(1)},
|
||||
{`"`, LiteralString, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Gas lexer.
|
||||
var Gas = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "GAS",
|
||||
Aliases: []string{"gas", "asm"},
|
||||
Filenames: []string{"*.s", "*.S"},
|
||||
MimeTypes: []string{"text/x-gas"},
|
||||
},
|
||||
gasRules,
|
||||
))
|
||||
|
||||
func gasRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+):`, NameLabel, nil},
|
||||
{`\.(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, Push("directive-args")},
|
||||
{`lock|rep(n?z)?|data\d+`, NameAttribute, nil},
|
||||
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameFunction, Push("instruction-args")},
|
||||
{`[\r\n]+`, Text, nil},
|
||||
},
|
||||
"directive-args": {
|
||||
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil},
|
||||
{`"(\\"|[^"])*"`, LiteralString, nil},
|
||||
{`@(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, nil},
|
||||
{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
||||
{`[\r\n]+`, Text, Pop(1)},
|
||||
Include("punctuation"),
|
||||
Include("whitespace"),
|
||||
},
|
||||
"instruction-args": {
|
||||
{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation), nil},
|
||||
{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))([-+])((?:0[xX][a-zA-Z0-9]+|\d+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation, LiteralNumberInteger, Punctuation), nil},
|
||||
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil},
|
||||
{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
||||
{`%(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameVariable, nil},
|
||||
{`$(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
||||
{`$'(.|\\')'`, LiteralStringChar, nil},
|
||||
{`[\r\n]+`, Text, Pop(1)},
|
||||
Include("punctuation"),
|
||||
Include("whitespace"),
|
||||
},
|
||||
"whitespace": {
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`[;#].*?\n`, Comment, nil},
|
||||
},
|
||||
"punctuation": {
|
||||
{`[-*,.()\[\]!:]+`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,122 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Gherkin lexer.
|
||||
var Gherkin = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Gherkin",
|
||||
Aliases: []string{"cucumber", "Cucumber", "gherkin", "Gherkin"},
|
||||
Filenames: []string{"*.feature", "*.FEATURE"},
|
||||
MimeTypes: []string{"text/x-gherkin"},
|
||||
},
|
||||
gherkinRules,
|
||||
))
|
||||
|
||||
func gherkinRules() Rules {
|
||||
stepKeywords := `^(\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )`
|
||||
|
||||
featureKeywords := `^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$`
|
||||
|
||||
featureElementKeywords := `^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$`
|
||||
|
||||
examplesKeywords := `^(\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$`
|
||||
|
||||
return Rules{
|
||||
"comments": {
|
||||
{`\s*#.*$`, Comment, nil},
|
||||
},
|
||||
"featureElements": {
|
||||
{stepKeywords, Keyword, Push("stepContentStack")},
|
||||
Include("comments"),
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
"featureElementsOnStack": {
|
||||
{stepKeywords, Keyword, Pop(2)},
|
||||
Include("comments"),
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
"examplesTable": {
|
||||
{`\s+\|`, Keyword, Push("examplesTableHeader")},
|
||||
Include("comments"),
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
"examplesTableHeader": {
|
||||
{`\s+\|\s*$`, Keyword, Pop(2)},
|
||||
Include("comments"),
|
||||
{`\\\|`, NameVariable, nil},
|
||||
{`\s*\|`, Keyword, nil},
|
||||
{`[^|]`, NameVariable, nil},
|
||||
},
|
||||
"scenarioSectionsOnStack": {
|
||||
{featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElementsOnStack")},
|
||||
},
|
||||
"narrative": {
|
||||
Include("scenarioSectionsOnStack"),
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
"tableVars": {
|
||||
{`(<[^>]+>)`, NameVariable, nil},
|
||||
},
|
||||
"numbers": {
|
||||
{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralString, nil},
|
||||
},
|
||||
"string": {
|
||||
Include("tableVars"),
|
||||
{`(\s|.)`, LiteralString, nil},
|
||||
},
|
||||
"pyString": {
|
||||
{`"""`, Keyword, Pop(1)},
|
||||
Include("string"),
|
||||
},
|
||||
"stepContentRoot": {
|
||||
{`$`, Keyword, Pop(1)},
|
||||
Include("stepContent"),
|
||||
},
|
||||
"stepContentStack": {
|
||||
{`$`, Keyword, Pop(2)},
|
||||
Include("stepContent"),
|
||||
},
|
||||
"stepContent": {
|
||||
{`"`, NameFunction, Push("doubleString")},
|
||||
Include("tableVars"),
|
||||
Include("numbers"),
|
||||
Include("comments"),
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
"tableContent": {
|
||||
{`\s+\|\s*$`, Keyword, Pop(1)},
|
||||
Include("comments"),
|
||||
{`\\\|`, LiteralString, nil},
|
||||
{`\s*\|`, Keyword, nil},
|
||||
{`"`, LiteralString, Push("doubleStringTable")},
|
||||
Include("string"),
|
||||
},
|
||||
"doubleString": {
|
||||
{`"`, NameFunction, Pop(1)},
|
||||
Include("string"),
|
||||
},
|
||||
"doubleStringTable": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
Include("string"),
|
||||
},
|
||||
"root": {
|
||||
{`\n`, NameFunction, nil},
|
||||
Include("comments"),
|
||||
{`"""`, Keyword, Push("pyString")},
|
||||
{`\s+\|`, Keyword, Push("tableContent")},
|
||||
{`"`, NameFunction, Push("doubleString")},
|
||||
Include("tableVars"),
|
||||
Include("numbers"),
|
||||
{`(\s*)(@[^@\r\n\t ]+)`, ByGroups(NameFunction, NameTag), nil},
|
||||
{stepKeywords, ByGroups(NameFunction, Keyword), Push("stepContentRoot")},
|
||||
{featureKeywords, ByGroups(Keyword, Keyword, NameFunction), Push("narrative")},
|
||||
{featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElements")},
|
||||
{examplesKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("examplesTable")},
|
||||
{`(\s|.)`, NameFunction, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// GLSL lexer.
|
||||
var GLSL = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "GLSL",
|
||||
Aliases: []string{"glsl"},
|
||||
Filenames: []string{"*.vert", "*.frag", "*.geo"},
|
||||
MimeTypes: []string{"text/x-glslsrc"},
|
||||
},
|
||||
glslRules,
|
||||
))
|
||||
|
||||
func glslRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^#.*`, CommentPreproc, nil},
|
||||
{`//.*`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?`, Operator, nil},
|
||||
{`[?:]`, Operator, nil},
|
||||
{`\bdefined\b`, Operator, nil},
|
||||
{`[;{}(),\[\]]`, Punctuation, nil},
|
||||
{`[+-]?\d*\.\d+([eE][-+]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`[+-]?\d+\.\d*([eE][-+]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`0[xX][0-9a-fA-F]*`, LiteralNumberHex, nil},
|
||||
{`0[0-7]*`, LiteralNumberOct, nil},
|
||||
{`[1-9][0-9]*`, LiteralNumberInteger, nil},
|
||||
{Words(`\b`, `\b`, `attribute`, `const`, `uniform`, `varying`, `centroid`, `break`, `continue`, `do`, `for`, `while`, `if`, `else`, `in`, `out`, `inout`, `float`, `int`, `void`, `bool`, `true`, `false`, `invariant`, `discard`, `return`, `mat2`, `mat3mat4`, `mat2x2`, `mat3x2`, `mat4x2`, `mat2x3`, `mat3x3`, `mat4x3`, `mat2x4`, `mat3x4`, `mat4x4`, `vec2`, `vec3`, `vec4`, `ivec2`, `ivec3`, `ivec4`, `bvec2`, `bvec3`, `bvec4`, `sampler1D`, `sampler2D`, `sampler3DsamplerCube`, `sampler1DShadow`, `sampler2DShadow`, `struct`), Keyword, nil},
|
||||
{Words(`\b`, `\b`, `asm`, `class`, `union`, `enum`, `typedef`, `template`, `this`, `packed`, `goto`, `switch`, `default`, `inline`, `noinline`, `volatile`, `public`, `static`, `extern`, `external`, `interface`, `long`, `short`, `double`, `half`, `fixed`, `unsigned`, `lowp`, `mediump`, `highp`, `precision`, `input`, `output`, `hvec2`, `hvec3`, `hvec4`, `dvec2`, `dvec3`, `dvec4`, `fvec2`, `fvec3`, `fvec4`, `sampler2DRect`, `sampler3DRect`, `sampler2DRectShadow`, `sizeof`, `cast`, `namespace`, `using`), Keyword, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
{`\.`, Punctuation, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,49 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Go lexer.
|
||||
var Graphql = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "GraphQL",
|
||||
Aliases: []string{"graphql", "graphqls", "gql"},
|
||||
Filenames: []string{"*.graphql", "*.graphqls"},
|
||||
},
|
||||
graphqlRules,
|
||||
))
|
||||
|
||||
func graphqlRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(query|mutation|subscription|fragment|scalar|implements|interface|union|enum|input|type)`, KeywordDeclaration, Push("type")},
|
||||
{`(on|extend|schema|directive|\.\.\.)`, KeywordDeclaration, nil},
|
||||
{`(QUERY|MUTATION|SUBSCRIPTION|FIELD|FRAGMENT_DEFINITION|FRAGMENT_SPREAD|INLINE_FRAGMENT|SCHEMA|SCALAR|OBJECT|FIELD_DEFINITION|ARGUMENT_DEFINITION|INTERFACE|UNION|ENUM|ENUM_VALUE|INPUT_OBJECT|INPUT_FIELD_DEFINITION)\b`, KeywordConstant, nil},
|
||||
{`[^\W\d]\w*`, NameProperty, nil},
|
||||
{`\@\w+`, NameDecorator, nil},
|
||||
{`:`, Punctuation, Push("type")},
|
||||
{`[\(\)\{\}\[\],!\|=]`, Punctuation, nil},
|
||||
{`\$\w+`, NameVariable, nil},
|
||||
{`\d+i`, LiteralNumber, nil},
|
||||
{`\d+\.\d*([Ee][-+]\d+)?i`, LiteralNumber, nil},
|
||||
{`\.\d+([Ee][-+]\d+)?i`, LiteralNumber, nil},
|
||||
{`\d+[Ee][-+]\d+i`, LiteralNumber, nil},
|
||||
{`\d+(\.\d+[eE][+\-]?\d+|\.\d*|[eE][+\-]?\d+)`, LiteralNumberFloat, nil},
|
||||
{`\.\d+([eE][+\-]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`(0|[1-9][0-9]*)`, LiteralNumberInteger, nil},
|
||||
{`"""[\x00-\x7F]*?"""`, LiteralString, nil},
|
||||
{`"(\\["\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|[^\\])"`, LiteralStringChar, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`"(true|false|null)*"`, Literal, nil},
|
||||
{`[\r\n\s]+`, Whitespace, nil},
|
||||
{`#[^\r\n]*`, Comment, nil},
|
||||
},
|
||||
// Treats the next word as a class, default rules it would be a property
|
||||
"type": {
|
||||
{`[^\W\d]\w*`, NameClass, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Groff lexer.
|
||||
var Groff = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Groff",
|
||||
Aliases: []string{"groff", "nroff", "man"},
|
||||
Filenames: []string{"*.[1-9]", "*.1p", "*.3pm", "*.man"},
|
||||
MimeTypes: []string{"application/x-troff", "text/troff"},
|
||||
},
|
||||
func() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(\.)(\w+)`, ByGroups(Text, Keyword), Push("request")},
|
||||
{`\.`, Punctuation, Push("request")},
|
||||
{`[^\\\n]+`, Text, Push("textline")},
|
||||
Default(Push("textline")),
|
||||
},
|
||||
"textline": {
|
||||
Include("escapes"),
|
||||
{`[^\\\n]+`, Text, nil},
|
||||
{`\n`, Text, Pop(1)},
|
||||
},
|
||||
"escapes": {
|
||||
{`\\"[^\n]*`, Comment, nil},
|
||||
{`\\[fn]\w`, LiteralStringEscape, nil},
|
||||
{`\\\(.{2}`, LiteralStringEscape, nil},
|
||||
{`\\.\[.*\]`, LiteralStringEscape, nil},
|
||||
{`\\.`, LiteralStringEscape, nil},
|
||||
{`\\\n`, Text, Push("request")},
|
||||
},
|
||||
"request": {
|
||||
{`\n`, Text, Pop(1)},
|
||||
Include("escapes"),
|
||||
{`"[^\n"]+"`, LiteralStringDouble, nil},
|
||||
{`\d+`, LiteralNumber, nil},
|
||||
{`\S+`, LiteralString, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
|
@ -1,62 +0,0 @@
|
|||
package g
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Groovy lexer.
|
||||
var Groovy = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Groovy",
|
||||
Aliases: []string{"groovy"},
|
||||
Filenames: []string{"*.groovy", "*.gradle"},
|
||||
MimeTypes: []string{"text/x-groovy"},
|
||||
DotAll: true,
|
||||
},
|
||||
groovyRules,
|
||||
))
|
||||
|
||||
func groovyRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#!(.*?)$`, CommentPreproc, Push("base")},
|
||||
Default(Push("base")),
|
||||
},
|
||||
"base": {
|
||||
{`^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`@[a-zA-Z_][\w.]*`, NameDecorator, nil},
|
||||
{`(as|assert|break|case|catch|continue|default|do|else|finally|for|if|in|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b`, Keyword, nil},
|
||||
{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil},
|
||||
{`(def|boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil},
|
||||
{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), nil},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`""".*?"""`, LiteralStringDouble, nil},
|
||||
{`'''.*?'''`, LiteralStringSingle, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`\$/((?!/\$).)*/\$`, LiteralString, nil},
|
||||
{`/(\\\\|\\"|[^/])*/`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||
{`(\.)([a-zA-Z_]\w*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`[a-zA-Z_]\w*:`, NameLabel, nil},
|
||||
{`[a-zA-Z_$]\w*`, Name, nil},
|
||||
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
|
||||
{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+L?`, LiteralNumberInteger, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+\*?`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Handlebars lexer.
|
||||
var Handlebars = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Handlebars",
|
||||
Aliases: []string{"handlebars", "hbs"},
|
||||
Filenames: []string{"*.handlebars", "*.hbs"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
handlebarsRules,
|
||||
))
|
||||
|
||||
func handlebarsRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^{]+`, Other, nil},
|
||||
{`\{\{!.*\}\}`, Comment, nil},
|
||||
{`(\{\{\{)(\s*)`, ByGroups(CommentSpecial, Text), Push("tag")},
|
||||
{`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("tag")},
|
||||
},
|
||||
"tag": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\}\}\}`, CommentSpecial, Pop(1)},
|
||||
{`\}\}`, CommentPreproc, Pop(1)},
|
||||
{`([#/]*)(each|if|unless|else|with|log|in(?:line)?)`, ByGroups(Keyword, Keyword), nil},
|
||||
{`#\*inline`, Keyword, nil},
|
||||
{`([#/])([\w-]+)`, ByGroups(NameFunction, NameFunction), nil},
|
||||
{`([\w-]+)(=)`, ByGroups(NameAttribute, Operator), nil},
|
||||
{`(>)(\s*)(@partial-block)`, ByGroups(Keyword, Text, Keyword), nil},
|
||||
{`(#?>)(\s*)([\w-]+)`, ByGroups(Keyword, Text, NameVariable), nil},
|
||||
{`(>)(\s*)(\()`, ByGroups(Keyword, Text, Punctuation), Push("dynamic-partial")},
|
||||
Include("generic"),
|
||||
},
|
||||
"dynamic-partial": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`(lookup)(\s+)(\.|this)(\s+)`, ByGroups(Keyword, Text, NameVariable, Text), nil},
|
||||
{`(lookup)(\s+)(\S+)`, ByGroups(Keyword, Text, UsingSelf("variable")), nil},
|
||||
{`[\w-]+`, NameFunction, nil},
|
||||
Include("generic"),
|
||||
},
|
||||
"variable": {
|
||||
{`[a-zA-Z][\w-]*`, NameVariable, nil},
|
||||
{`\.[\w-]+`, NameVariable, nil},
|
||||
{`(this\/|\.\/|(\.\.\/)+)[\w-]+`, NameVariable, nil},
|
||||
},
|
||||
"generic": {
|
||||
Include("variable"),
|
||||
{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Haskell lexer.
|
||||
var Haskell = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Haskell",
|
||||
Aliases: []string{"haskell", "hs"},
|
||||
Filenames: []string{"*.hs"},
|
||||
MimeTypes: []string{"text/x-haskell"},
|
||||
},
|
||||
haskellRules,
|
||||
))
|
||||
|
||||
func haskellRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`--(?![!#$%&*+./<=>?@^|_~:\\]).*?$`, CommentSingle, nil},
|
||||
{`\{-`, CommentMultiline, Push("comment")},
|
||||
{`\bimport\b`, KeywordReserved, Push("import")},
|
||||
{`\bmodule\b`, KeywordReserved, Push("module")},
|
||||
{`\berror\b`, NameException, nil},
|
||||
{`\b(case|class|data|default|deriving|do|else|family|if|in|infix[lr]?|instance|let|newtype|of|then|type|where|_)(?!\')\b`, KeywordReserved, nil},
|
||||
{`'[^\\]'`, LiteralStringChar, nil},
|
||||
{`^[_\p{Ll}][\w\']*`, NameFunction, nil},
|
||||
{`'?[_\p{Ll}][\w']*`, Name, nil},
|
||||
{`('')?[\p{Lu}][\w\']*`, KeywordType, nil},
|
||||
{`(')[\p{Lu}][\w\']*`, KeywordType, nil},
|
||||
{`(')\[[^\]]*\]`, KeywordType, nil},
|
||||
{`(')\([^)]*\)`, KeywordType, nil},
|
||||
{`\\(?![:!#$%&*+.\\/<=>?@^|~-]+)`, NameFunction, nil},
|
||||
{`(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)`, OperatorWord, nil},
|
||||
{`:[:!#$%&*+.\\/<=>?@^|~-]*`, KeywordType, nil},
|
||||
{`[:!#$%&*+.\\/<=>?@^|~-]+`, Operator, nil},
|
||||
{`\d+[eE][+-]?\d+`, LiteralNumberFloat, nil},
|
||||
{`\d+\.\d+([eE][+-]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`0[oO][0-7]+`, LiteralNumberOct, nil},
|
||||
{`0[xX][\da-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`'`, LiteralStringChar, Push("character")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`\[\]`, KeywordType, nil},
|
||||
{`\(\)`, NameBuiltin, nil},
|
||||
{"[][(),;`{}]", Punctuation, nil},
|
||||
},
|
||||
"import": {
|
||||
{`\s+`, Text, nil},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`qualified\b`, Keyword, nil},
|
||||
{`([\p{Lu}][\w.]*)(\s+)(as)(\s+)([\p{Lu}][\w.]*)`, ByGroups(NameNamespace, Text, Keyword, Text, Name), Pop(1)},
|
||||
{`([\p{Lu}][\w.]*)(\s+)(hiding)(\s+)(\()`, ByGroups(NameNamespace, Text, Keyword, Text, Punctuation), Push("funclist")},
|
||||
{`([\p{Lu}][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")},
|
||||
{`[\w.]+`, NameNamespace, Pop(1)},
|
||||
},
|
||||
"module": {
|
||||
{`\s+`, Text, nil},
|
||||
{`([\p{Lu}][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")},
|
||||
{`[\p{Lu}][\w.]*`, NameNamespace, Pop(1)},
|
||||
},
|
||||
"funclist": {
|
||||
{`\s+`, Text, nil},
|
||||
{`[\p{Lu}]\w*`, KeywordType, nil},
|
||||
{`(_[\w\']+|[\p{Ll}][\w\']*)`, NameFunction, nil},
|
||||
{`--(?![!#$%&*+./<=>?@^|_~:\\]).*?$`, CommentSingle, nil},
|
||||
{`\{-`, CommentMultiline, Push("comment")},
|
||||
{`,`, Punctuation, nil},
|
||||
{`[:!#$%&*+.\\/<=>?@^|~-]+`, Operator, nil},
|
||||
{`\(`, Punctuation, Push("funclist", "funclist")},
|
||||
{`\)`, Punctuation, Pop(2)},
|
||||
},
|
||||
"comment": {
|
||||
{`[^-{}]+`, CommentMultiline, nil},
|
||||
{`\{-`, CommentMultiline, Push()},
|
||||
{`-\}`, CommentMultiline, Pop(1)},
|
||||
{`[-{}]`, CommentMultiline, nil},
|
||||
},
|
||||
"character": {
|
||||
{`[^\\']'`, LiteralStringChar, Pop(1)},
|
||||
{`\\`, LiteralStringEscape, Push("escape")},
|
||||
{`'`, LiteralStringChar, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`[^\\"]+`, LiteralString, nil},
|
||||
{`\\`, LiteralStringEscape, Push("escape")},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
},
|
||||
"escape": {
|
||||
{`[abfnrtv"\'&\\]`, LiteralStringEscape, Pop(1)},
|
||||
{`\^[][\p{Lu}@^_]`, LiteralStringEscape, Pop(1)},
|
||||
{`NUL|SOH|[SE]TX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|S[OI]|DLE|DC[1-4]|NAK|SYN|ETB|CAN|EM|SUB|ESC|[FGRU]S|SP|DEL`, LiteralStringEscape, Pop(1)},
|
||||
{`o[0-7]+`, LiteralStringEscape, Pop(1)},
|
||||
{`x[\da-fA-F]+`, LiteralStringEscape, Pop(1)},
|
||||
{`\d+`, LiteralStringEscape, Pop(1)},
|
||||
{`\s+\\`, LiteralStringEscape, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// HCL lexer.
|
||||
var HCL = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "HCL",
|
||||
Aliases: []string{"hcl"},
|
||||
Filenames: []string{"*.hcl"},
|
||||
MimeTypes: []string{"application/x-hcl"},
|
||||
},
|
||||
hclRules,
|
||||
))
|
||||
|
||||
func hclRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("string"),
|
||||
Include("punctuation"),
|
||||
Include("curly"),
|
||||
Include("basic"),
|
||||
Include("whitespace"),
|
||||
{`[0-9]+`, LiteralNumber, nil},
|
||||
},
|
||||
"basic": {
|
||||
{Words(`\b`, `\b`, `true`, `false`), KeywordType, nil},
|
||||
{`\s*/\*`, CommentMultiline, Push("comment")},
|
||||
{`\s*#.*\n`, CommentSingle, nil},
|
||||
{`(.*?)(\s*)(=)`, ByGroups(Name, Text, Operator), nil},
|
||||
{`\d+`, Number, nil},
|
||||
{`\b\w+\b`, Keyword, nil},
|
||||
{`\$\{`, LiteralStringInterpol, Push("var_builtin")},
|
||||
},
|
||||
"function": {
|
||||
{`(\s+)(".*")(\s+)`, ByGroups(Text, LiteralString, Text), nil},
|
||||
Include("punctuation"),
|
||||
Include("curly"),
|
||||
},
|
||||
"var_builtin": {
|
||||
{`\$\{`, LiteralStringInterpol, Push()},
|
||||
{Words(`\b`, `\b`, `concat`, `file`, `join`, `lookup`, `element`), NameBuiltin, nil},
|
||||
Include("string"),
|
||||
Include("punctuation"),
|
||||
{`\s+`, Text, nil},
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`(".*")`, ByGroups(LiteralStringDouble), nil},
|
||||
},
|
||||
"punctuation": {
|
||||
{`[\[\](),.]`, Punctuation, nil},
|
||||
},
|
||||
"curly": {
|
||||
{`\{`, TextPunctuation, nil},
|
||||
{`\}`, TextPunctuation, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^*/]`, CommentMultiline, nil},
|
||||
{`/\*`, CommentMultiline, Push()},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[*/]`, CommentMultiline, nil},
|
||||
},
|
||||
"whitespace": {
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Hexdump lexer.
|
||||
var Hexdump = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Hexdump",
|
||||
Aliases: []string{"hexdump"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
hexdumpRules,
|
||||
))
|
||||
|
||||
func hexdumpRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\n`, Text, nil},
|
||||
Include("offset"),
|
||||
{`([0-9A-Ha-h]{2})(\-)([0-9A-Ha-h]{2})`, ByGroups(LiteralNumberHex, Punctuation, LiteralNumberHex), nil},
|
||||
{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
|
||||
{`(\s{2,3})(\>)(.{16})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), Push("bracket-strings")},
|
||||
{`(\s{2,3})(\|)(.{16})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), Push("piped-strings")},
|
||||
{`(\s{2,3})(\>)(.{1,15})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
|
||||
{`(\s{2,3})(\|)(.{1,15})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
|
||||
{`(\s{2,3})(.{1,15})$`, ByGroups(Text, LiteralString), nil},
|
||||
{`(\s{2,3})(.{16}|.{20})$`, ByGroups(Text, LiteralString), Push("nonpiped-strings")},
|
||||
{`\s`, Text, nil},
|
||||
{`^\*`, Punctuation, nil},
|
||||
},
|
||||
"offset": {
|
||||
{`^([0-9A-Ha-h]+)(:)`, ByGroups(NameLabel, Punctuation), Push("offset-mode")},
|
||||
{`^[0-9A-Ha-h]+`, NameLabel, nil},
|
||||
},
|
||||
"offset-mode": {
|
||||
{`\s`, Text, Pop(1)},
|
||||
{`[0-9A-Ha-h]+`, NameLabel, nil},
|
||||
{`:`, Punctuation, nil},
|
||||
},
|
||||
"piped-strings": {
|
||||
{`\n`, Text, nil},
|
||||
Include("offset"),
|
||||
{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
|
||||
{`(\s{2,3})(\|)(.{1,16})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
|
||||
{`\s`, Text, nil},
|
||||
{`^\*`, Punctuation, nil},
|
||||
},
|
||||
"bracket-strings": {
|
||||
{`\n`, Text, nil},
|
||||
Include("offset"),
|
||||
{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
|
||||
{`(\s{2,3})(\>)(.{1,16})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
|
||||
{`\s`, Text, nil},
|
||||
{`^\*`, Punctuation, nil},
|
||||
},
|
||||
"nonpiped-strings": {
|
||||
{`\n`, Text, nil},
|
||||
Include("offset"),
|
||||
{`([0-9A-Ha-h]{2})(\-)([0-9A-Ha-h]{2})`, ByGroups(LiteralNumberHex, Punctuation, LiteralNumberHex), nil},
|
||||
{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
|
||||
{`(\s{19,})(.{1,20}?)$`, ByGroups(Text, LiteralString), nil},
|
||||
{`(\s{2,3})(.{1,20})$`, ByGroups(Text, LiteralString), nil},
|
||||
{`\s`, Text, nil},
|
||||
{`^\*`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// HLB lexer.
|
||||
var HLB = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "HLB",
|
||||
Aliases: []string{"hlb"},
|
||||
Filenames: []string{"*.hlb"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
hlbRules,
|
||||
))
|
||||
|
||||
func hlbRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(#.*)`, ByGroups(CommentSingle), nil},
|
||||
{`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
|
||||
{`((\b(true|false)\b))`, ByGroups(NameBuiltin), nil},
|
||||
{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
|
||||
{`(\b[a-zA-Z_][a-zA-Z0-9]*\b)(\()`, ByGroups(NameFunction, Punctuation), Push("params")},
|
||||
{`(\{)`, ByGroups(Punctuation), Push("block")},
|
||||
{`(\n|\r|\r\n)`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\"`, LiteralString, nil},
|
||||
{`[^\\"]+`, LiteralString, nil},
|
||||
},
|
||||
"block": {
|
||||
{`(\})`, ByGroups(Punctuation), Pop(1)},
|
||||
{`(#.*)`, ByGroups(CommentSingle), nil},
|
||||
{`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
|
||||
{`((\b(true|false)\b))`, ByGroups(KeywordConstant), nil},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`(with)`, ByGroups(KeywordReserved), nil},
|
||||
{`(as)([\t ]+)(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(KeywordReserved, Text, NameFunction), nil},
|
||||
{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)([\t ]+)(\{)`, ByGroups(KeywordType, Text, Punctuation), Push("block")},
|
||||
{`(?!\b(?:scratch|image|resolve|http|checksum|chmod|filename|git|keepGitDir|local|includePatterns|excludePatterns|followPaths|generate|frontendInput|shell|run|readonlyRootfs|env|dir|user|network|security|host|ssh|secret|mount|target|localPath|uid|gid|mode|readonly|tmpfs|sourcePath|cache|mkdir|createParents|chown|createdTime|mkfile|rm|allowNotFound|allowWildcards|copy|followSymlinks|contentsOnly|unpack|createDestPath)\b)(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(NameOther), nil},
|
||||
{`(\n|\r|\r\n)`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
"params": {
|
||||
{`(\))`, ByGroups(Punctuation), Pop(1)},
|
||||
{`(variadic)`, ByGroups(Keyword), nil},
|
||||
{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
|
||||
{`(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(NameOther), nil},
|
||||
{`(\n|\r|\r\n)`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
. "github.com/alecthomas/chroma/lexers/c" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
. "github.com/alecthomas/chroma/lexers/j" // nolint
|
||||
)
|
||||
|
||||
// HTML lexer.
|
||||
var HTML = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "HTML",
|
||||
Aliases: []string{"html"},
|
||||
Filenames: []string{"*.html", "*.htm", "*.xhtml", "*.xslt"},
|
||||
MimeTypes: []string{"text/html", "application/xhtml+xml"},
|
||||
NotMultiline: true,
|
||||
DotAll: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
htmlRules,
|
||||
))
|
||||
|
||||
func htmlRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^<&]+`, Text, nil},
|
||||
{`&\S*?;`, NameEntity, nil},
|
||||
{`\<\!\[CDATA\[.*?\]\]\>`, CommentPreproc, nil},
|
||||
{`<!--`, Comment, Push("comment")},
|
||||
{`<\?.*?\?>`, CommentPreproc, nil},
|
||||
{`<![^>]*>`, CommentPreproc, nil},
|
||||
{`(<)(\s*)(script)(\s*)`, ByGroups(Punctuation, Text, NameTag, Text), Push("script-content", "tag")},
|
||||
{`(<)(\s*)(style)(\s*)`, ByGroups(Punctuation, Text, NameTag, Text), Push("style-content", "tag")},
|
||||
{`(<)(\s*)([\w:.-]+)`, ByGroups(Punctuation, Text, NameTag), Push("tag")},
|
||||
{`(<)(\s*)(/)(\s*)([\w:.-]+)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^-]+`, Comment, nil},
|
||||
{`-->`, Comment, Pop(1)},
|
||||
{`-`, Comment, nil},
|
||||
},
|
||||
"tag": {
|
||||
{`\s+`, Text, nil},
|
||||
{`([\w:-]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")},
|
||||
{`[\w:-]+`, NameAttribute, nil},
|
||||
{`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)},
|
||||
},
|
||||
"script-content": {
|
||||
{`(<)(\s*)(/)(\s*)(script)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)},
|
||||
{`.+?(?=<\s*/\s*script\s*>)`, Using(Javascript), nil},
|
||||
},
|
||||
"style-content": {
|
||||
{`(<)(\s*)(/)(\s*)(style)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)},
|
||||
{`.+?(?=<\s*/\s*style\s*>)`, Using(CSS), nil},
|
||||
},
|
||||
"attr": {
|
||||
{`".*?"`, LiteralString, Pop(1)},
|
||||
{`'.*?'`, LiteralString, Pop(1)},
|
||||
{`[^\s>]+`, LiteralString, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Hy lexer.
|
||||
var Hy = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Hy",
|
||||
Aliases: []string{"hylang"},
|
||||
Filenames: []string{"*.hy"},
|
||||
MimeTypes: []string{"text/x-hy", "application/x-hy"},
|
||||
},
|
||||
hyRules,
|
||||
))
|
||||
|
||||
func hyRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`;.*$`, CommentSingle, nil},
|
||||
{`[,\s]+`, Text, nil},
|
||||
{`-?\d+\.\d+`, LiteralNumberFloat, nil},
|
||||
{`-?\d+`, LiteralNumberInteger, nil},
|
||||
{`0[0-7]+j?`, LiteralNumberOct, nil},
|
||||
{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{`\\(.|[a-z]+)`, LiteralStringChar, nil},
|
||||
{`^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringDoc), nil},
|
||||
{`^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringDoc), nil},
|
||||
{`::?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
|
||||
{"~@|[`\\'#^~&@]", Operator, nil},
|
||||
Include("py-keywords"),
|
||||
Include("py-builtins"),
|
||||
{Words(``, ` `, `cond`, `for`, `->`, `->>`, `car`, `cdr`, `first`, `rest`, `let`, `when`, `unless`, `import`, `do`, `progn`, `get`, `slice`, `assoc`, `with-decorator`, `,`, `list_comp`, `kwapply`, `~`, `is`, `in`, `is-not`, `not-in`, `quasiquote`, `unquote`, `unquote-splice`, `quote`, `|`, `<<=`, `>>=`, `foreach`, `while`, `eval-and-compile`, `eval-when-compile`), Keyword, nil},
|
||||
{Words(``, ` `, `def`, `defn`, `defun`, `defmacro`, `defclass`, `lambda`, `fn`, `setv`), KeywordDeclaration, nil},
|
||||
{Words(``, ` `, `cycle`, `dec`, `distinct`, `drop`, `even?`, `filter`, `inc`, `instance?`, `iterable?`, `iterate`, `iterator?`, `neg?`, `none?`, `nth`, `numeric?`, `odd?`, `pos?`, `remove`, `repeat`, `repeatedly`, `take`, `take_nth`, `take_while`, `zero?`), NameBuiltin, nil},
|
||||
{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil},
|
||||
{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil},
|
||||
{`(\[|\])`, Punctuation, nil},
|
||||
{`(\{|\})`, Punctuation, nil},
|
||||
{`(\(|\))`, Punctuation, nil},
|
||||
},
|
||||
"py-keywords": {
|
||||
{Words(``, `\b`, `assert`, `break`, `continue`, `del`, `elif`, `else`, `except`, `exec`, `finally`, `for`, `global`, `if`, `lambda`, `pass`, `print`, `raise`, `return`, `try`, `while`, `yield`, `yield from`, `as`, `with`), Keyword, nil},
|
||||
},
|
||||
"py-builtins": {
|
||||
{Words(`(?<!\.)`, `\b`, `__import__`, `abs`, `all`, `any`, `apply`, `basestring`, `bin`, `bool`, `buffer`, `bytearray`, `bytes`, `callable`, `chr`, `classmethod`, `cmp`, `coerce`, `compile`, `complex`, `delattr`, `dict`, `dir`, `divmod`, `enumerate`, `eval`, `execfile`, `exit`, `file`, `filter`, `float`, `frozenset`, `getattr`, `globals`, `hasattr`, `hash`, `hex`, `id`, `input`, `int`, `intern`, `isinstance`, `issubclass`, `iter`, `len`, `list`, `locals`, `long`, `map`, `max`, `min`, `next`, `object`, `oct`, `open`, `ord`, `pow`, `property`, `range`, `raw_input`, `reduce`, `reload`, `repr`, `reversed`, `round`, `set`, `setattr`, `slice`, `sorted`, `staticmethod`, `str`, `sum`, `super`, `tuple`, `type`, `unichr`, `unicode`, `vars`, `xrange`, `zip`), NameBuiltin, nil},
|
||||
{`(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls)\b`, NameBuiltinPseudo, nil},
|
||||
{Words(`(?<!\.)`, `\b`, `ArithmeticError`, `AssertionError`, `AttributeError`, `BaseException`, `DeprecationWarning`, `EOFError`, `EnvironmentError`, `Exception`, `FloatingPointError`, `FutureWarning`, `GeneratorExit`, `IOError`, `ImportError`, `ImportWarning`, `IndentationError`, `IndexError`, `KeyError`, `KeyboardInterrupt`, `LookupError`, `MemoryError`, `NameError`, `NotImplemented`, `NotImplementedError`, `OSError`, `OverflowError`, `OverflowWarning`, `PendingDeprecationWarning`, `ReferenceError`, `RuntimeError`, `RuntimeWarning`, `StandardError`, `StopIteration`, `SyntaxError`, `SyntaxWarning`, `SystemError`, `SystemExit`, `TabError`, `TypeError`, `UnboundLocalError`, `UnicodeDecodeError`, `UnicodeEncodeError`, `UnicodeError`, `UnicodeTranslateError`, `UnicodeWarning`, `UserWarning`, `ValueError`, `VMSError`, `Warning`, `WindowsError`, `ZeroDivisionError`), NameException, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package i
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Idris lexer.
|
||||
var Idris = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Idris",
|
||||
Aliases: []string{"idris", "idr"},
|
||||
Filenames: []string{"*.idr"},
|
||||
MimeTypes: []string{"text/x-idris"},
|
||||
},
|
||||
idrisRules,
|
||||
))
|
||||
|
||||
func idrisRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^(\s*)(%lib|link|flag|include|hide|freeze|access|default|logging|dynamic|name|error_handlers|language)`, ByGroups(Text, KeywordReserved), nil},
|
||||
{`(\s*)(--(?![!#$%&*+./<=>?@^|_~:\\]).*?)$`, ByGroups(Text, CommentSingle), nil},
|
||||
{`(\s*)(\|{3}.*?)$`, ByGroups(Text, CommentSingle), nil},
|
||||
{`(\s*)(\{-)`, ByGroups(Text, CommentMultiline), Push("comment")},
|
||||
{`^(\s*)([^\s(){}]+)(\s*)(:)(\s*)`, ByGroups(Text, NameFunction, Text, OperatorWord, Text), nil},
|
||||
{`\b(case|class|data|default|using|do|else|if|in|infix[lr]?|instance|rewrite|auto|namespace|codata|mutual|private|public|abstract|total|partial|let|proof|of|then|static|where|_|with|pattern|term|syntax|prefix|postulate|parameters|record|dsl|impossible|implicit|tactics|intros|intro|compute|refine|exact|trivial)(?!\')\b`, KeywordReserved, nil},
|
||||
{`(import|module)(\s+)`, ByGroups(KeywordReserved, Text), Push("module")},
|
||||
{`('')?[A-Z][\w\']*`, KeywordType, nil},
|
||||
{`[a-z][\w\']*`, Text, nil},
|
||||
{`(<-|::|->|=>|=)`, OperatorWord, nil},
|
||||
{`([(){}\[\]:!#$%&*+.\\/<=>?@^|~-]+)`, OperatorWord, nil},
|
||||
{`\d+[eE][+-]?\d+`, LiteralNumberFloat, nil},
|
||||
{`\d+\.\d+([eE][+-]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`0[xX][\da-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`'`, LiteralStringChar, Push("character")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`[^\s(){}]+`, Text, nil},
|
||||
{`\s+?`, Text, nil},
|
||||
},
|
||||
"module": {
|
||||
{`\s+`, Text, nil},
|
||||
{`([A-Z][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")},
|
||||
{`[A-Z][\w.]*`, NameNamespace, Pop(1)},
|
||||
},
|
||||
"funclist": {
|
||||
{`\s+`, Text, nil},
|
||||
{`[A-Z]\w*`, KeywordType, nil},
|
||||
{`(_[\w\']+|[a-z][\w\']*)`, NameFunction, nil},
|
||||
{`--.*$`, CommentSingle, nil},
|
||||
{`\{-`, CommentMultiline, Push("comment")},
|
||||
{`,`, Punctuation, nil},
|
||||
{`[:!#$%&*+.\\/<=>?@^|~-]+`, Operator, nil},
|
||||
{`\(`, Punctuation, Push("funclist", "funclist")},
|
||||
{`\)`, Punctuation, Pop(2)},
|
||||
},
|
||||
"comment": {
|
||||
{`[^-{}]+`, CommentMultiline, nil},
|
||||
{`\{-`, CommentMultiline, Push()},
|
||||
{`-\}`, CommentMultiline, Pop(1)},
|
||||
{`[-{}]`, CommentMultiline, nil},
|
||||
},
|
||||
"character": {
|
||||
{`[^\\']`, LiteralStringChar, nil},
|
||||
{`\\`, LiteralStringEscape, Push("escape")},
|
||||
{`'`, LiteralStringChar, Pop(1)},
|
||||
},
|
||||
"string": {
|
||||
{`[^\\"]+`, LiteralString, nil},
|
||||
{`\\`, LiteralStringEscape, Push("escape")},
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
},
|
||||
"escape": {
|
||||
{`[abfnrtv"\'&\\]`, LiteralStringEscape, Pop(1)},
|
||||
{`\^[][A-Z@^_]`, LiteralStringEscape, Pop(1)},
|
||||
{`NUL|SOH|[SE]TX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|S[OI]|DLE|DC[1-4]|NAK|SYN|ETB|CAN|EM|SUB|ESC|[FGRU]S|SP|DEL`, LiteralStringEscape, Pop(1)},
|
||||
{`o[0-7]+`, LiteralStringEscape, Pop(1)},
|
||||
{`x[\da-fA-F]+`, LiteralStringEscape, Pop(1)},
|
||||
{`\d+`, LiteralStringEscape, Pop(1)},
|
||||
{`\s+\\`, LiteralStringEscape, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,29 +0,0 @@
|
|||
package i
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Ini lexer.
|
||||
var Ini = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "INI",
|
||||
Aliases: []string{"ini", "cfg", "dosini"},
|
||||
Filenames: []string{"*.ini", "*.cfg", "*.inf", ".gitconfig", ".editorconfig"},
|
||||
MimeTypes: []string{"text/x-ini", "text/inf"},
|
||||
},
|
||||
iniRules,
|
||||
))
|
||||
|
||||
func iniRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`[;#].*`, CommentSingle, nil},
|
||||
{`\[.*?\]$`, Keyword, nil},
|
||||
{`(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Text, Operator, Text, LiteralString), nil},
|
||||
{`(.+?)$`, NameAttribute, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package i
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Io lexer.
|
||||
var Io = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Io",
|
||||
Aliases: []string{"io"},
|
||||
Filenames: []string{"*.io"},
|
||||
MimeTypes: []string{"text/x-iosrc"},
|
||||
},
|
||||
ioRules,
|
||||
))
|
||||
|
||||
func ioRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`//(.*?)\n`, CommentSingle, nil},
|
||||
{`#(.*?)\n`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`/\+`, CommentMultiline, Push("nestedcomment")},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}`, Operator, nil},
|
||||
{`(clone|do|doFile|doString|method|for|if|else|elseif|then)\b`, Keyword, nil},
|
||||
{`(nil|false|true)\b`, NameConstant, nil},
|
||||
{`(Object|list|List|Map|args|Sequence|Coroutine|File)\b`, NameBuiltin, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"nestedcomment": {
|
||||
{`[^+/]+`, CommentMultiline, nil},
|
||||
{`/\+`, CommentMultiline, Push()},
|
||||
{`\+/`, CommentMultiline, Pop(1)},
|
||||
{`[+/]`, CommentMultiline, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// J lexer.
|
||||
var J = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "J",
|
||||
Aliases: []string{"j"},
|
||||
Filenames: []string{"*.ijs"},
|
||||
MimeTypes: []string{"text/x-j"},
|
||||
},
|
||||
jRules,
|
||||
))
|
||||
|
||||
func jRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#!.*$`, CommentPreproc, nil},
|
||||
{`NB\..*`, CommentSingle, nil},
|
||||
{`\n+\s*Note`, CommentMultiline, Push("comment")},
|
||||
{`\s*Note.*`, CommentSingle, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`'`, LiteralString, Push("singlequote")},
|
||||
{`0\s+:\s*0|noun\s+define\s*$`, NameEntity, Push("nounDefinition")},
|
||||
{`(([1-4]|13)\s+:\s*0|(adverb|conjunction|dyad|monad|verb)\s+define)\b`, NameFunction, Push("explicitDefinition")},
|
||||
{Words(``, `\b[a-zA-Z]\w*\.`, `for_`, `goto_`, `label_`), NameLabel, nil},
|
||||
{Words(``, `\.`, `assert`, `break`, `case`, `catch`, `catchd`, `catcht`, `continue`, `do`, `else`, `elseif`, `end`, `fcase`, `for`, `if`, `return`, `select`, `throw`, `try`, `while`, `whilst`), NameLabel, nil},
|
||||
{`\b[a-zA-Z]\w*`, NameVariable, nil},
|
||||
{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`), NameFunction, nil},
|
||||
{`=[.:]`, Operator, nil},
|
||||
{"[-=+*#$%@!~`^&\";:.,<>{}\\[\\]\\\\|/]", Operator, nil},
|
||||
{`[abCdDeEfHiIjLMoprtT]\.`, KeywordReserved, nil},
|
||||
{`[aDiLpqsStux]\:`, KeywordReserved, nil},
|
||||
{`(_[0-9])\:`, KeywordConstant, nil},
|
||||
{`\(`, Punctuation, Push("parentheses")},
|
||||
Include("numbers"),
|
||||
},
|
||||
"comment": {
|
||||
{`[^)]`, CommentMultiline, nil},
|
||||
{`^\)`, CommentMultiline, Pop(1)},
|
||||
{`[)]`, CommentMultiline, nil},
|
||||
},
|
||||
"explicitDefinition": {
|
||||
{`\b[nmuvxy]\b`, NameDecorator, nil},
|
||||
Include("root"),
|
||||
{`[^)]`, Name, nil},
|
||||
{`^\)`, NameLabel, Pop(1)},
|
||||
{`[)]`, Name, nil},
|
||||
},
|
||||
"numbers": {
|
||||
{`\b_{1,2}\b`, LiteralNumber, nil},
|
||||
{`_?\d+(\.\d+)?(\s*[ejr]\s*)_?\d+(\.?=\d+)?`, LiteralNumber, nil},
|
||||
{`_?\d+\.(?=\d+)`, LiteralNumberFloat, nil},
|
||||
{`_?\d+x`, LiteralNumberIntegerLong, nil},
|
||||
{`_?\d+`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"nounDefinition": {
|
||||
{`[^)]`, LiteralString, nil},
|
||||
{`^\)`, NameLabel, Pop(1)},
|
||||
{`[)]`, LiteralString, nil},
|
||||
},
|
||||
"parentheses": {
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
Include("explicitDefinition"),
|
||||
Include("root"),
|
||||
},
|
||||
"singlequote": {
|
||||
{`[^']`, LiteralString, nil},
|
||||
{`''`, LiteralString, nil},
|
||||
{`'`, LiteralString, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Java lexer.
|
||||
var Java = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Java",
|
||||
Aliases: []string{"java"},
|
||||
Filenames: []string{"*.java"},
|
||||
MimeTypes: []string{"text/x-java"},
|
||||
DotAll: true,
|
||||
EnsureNL: true,
|
||||
},
|
||||
javaRules,
|
||||
))
|
||||
|
||||
func javaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil},
|
||||
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
{`@[^\W\d][\w.]*`, NameDecorator, nil},
|
||||
{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil},
|
||||
{`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil},
|
||||
{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
||||
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
||||
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil},
|
||||
{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
|
||||
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
||||
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
||||
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
||||
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+\*?`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Javascript lexer.
|
||||
var JavascriptRules = Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`<!--`, Comment, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
},
|
||||
"slashstartsregex": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gimuy]+\b|\B)`, LiteralStringRegex, Pop(1)},
|
||||
{`(?=/)`, Text, Push("#pop", "badregex")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"badregex": {
|
||||
{`\n`, Text, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
{`\A#! ?/.*?\n`, CommentHashbang, nil},
|
||||
{`^(?=\s|/|<!--)`, Text, Push("slashstartsregex")},
|
||||
Include("commentsandwhitespace"),
|
||||
{`\d+(\.\d*|[eE][+\-]?\d+)`, LiteralNumberFloat, nil},
|
||||
{`0[bB][01]+`, LiteralNumberBin, nil},
|
||||
{`0[oO][0-7]+`, LiteralNumberOct, nil},
|
||||
{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9][0-9_]*`, LiteralNumberInteger, nil},
|
||||
{`\.\.\.|=>`, Punctuation, nil},
|
||||
{`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")},
|
||||
{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
|
||||
{`[})\].]`, Punctuation, nil},
|
||||
{`(for|in|while|do|break|return|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|this|of)\b`, Keyword, Push("slashstartsregex")},
|
||||
{`(var|let|with|function)\b`, KeywordDeclaration, Push("slashstartsregex")},
|
||||
{`(abstract|async|await|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\b`, KeywordReserved, nil},
|
||||
{`(true|false|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil},
|
||||
{`(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|document|this|window)\b`, NameBuiltin, nil},
|
||||
{`(?:[$_\p{L}\p{N}]|\\u[a-fA-F0-9]{4})(?:(?:[$\p{L}\p{N}]|\\u[a-fA-F0-9]{4}))*`, NameOther, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{"`", LiteralStringBacktick, Push("interp")},
|
||||
},
|
||||
"interp": {
|
||||
{"`", LiteralStringBacktick, Pop(1)},
|
||||
{`\\\\`, LiteralStringBacktick, nil},
|
||||
{"\\\\`", LiteralStringBacktick, nil},
|
||||
{"\\\\[^`\\\\]", LiteralStringBacktick, nil},
|
||||
{`\$\{`, LiteralStringInterpol, Push("interp-inside")},
|
||||
{`\$`, LiteralStringBacktick, nil},
|
||||
{"[^`\\\\$]+", LiteralStringBacktick, nil},
|
||||
},
|
||||
"interp-inside": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
|
||||
// Javascript lexer.
|
||||
var Javascript = internal.Register(MustNewLexer( // nolint: forbidigo
|
||||
&Config{
|
||||
Name: "JavaScript",
|
||||
Aliases: []string{"js", "javascript"},
|
||||
Filenames: []string{"*.js", "*.jsm", "*.mjs"},
|
||||
MimeTypes: []string{"application/javascript", "application/x-javascript", "text/x-javascript", "text/javascript"},
|
||||
DotAll: true,
|
||||
EnsureNL: true,
|
||||
},
|
||||
JavascriptRules,
|
||||
))
|
|
@ -1,65 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// JSON lexer.
|
||||
var JSON = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "JSON",
|
||||
Aliases: []string{"json"},
|
||||
Filenames: []string{"*.json"},
|
||||
MimeTypes: []string{"application/json"},
|
||||
NotMultiline: true,
|
||||
DotAll: true,
|
||||
},
|
||||
jsonRules,
|
||||
))
|
||||
|
||||
func jsonRules() Rules {
|
||||
return Rules{
|
||||
"whitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
},
|
||||
"simplevalue": {
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
|
||||
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
},
|
||||
"objectattribute": {
|
||||
Include("value"),
|
||||
{`:`, Punctuation, nil},
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`\}`, Punctuation, Pop(2)},
|
||||
},
|
||||
"objectvalue": {
|
||||
Include("whitespace"),
|
||||
Include("comment"),
|
||||
{`"(\\\\|\\"|[^"])*"`, NameTag, Push("objectattribute")},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"arrayvalue": {
|
||||
Include("whitespace"),
|
||||
Include("value"),
|
||||
Include("comment"),
|
||||
{`,`, Punctuation, nil},
|
||||
{`\]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"value": {
|
||||
Include("whitespace"),
|
||||
Include("simplevalue"),
|
||||
Include("comment"),
|
||||
{`\{`, Punctuation, Push("objectvalue")},
|
||||
{`\[`, Punctuation, Push("arrayvalue")},
|
||||
},
|
||||
"root": {
|
||||
Include("value"),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// JSX lexer.
|
||||
//
|
||||
// This was generated from https://github.com/fcurella/jsx-lexer
|
||||
var JSX = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "react",
|
||||
Aliases: []string{"jsx", "react"},
|
||||
Filenames: []string{"*.jsx", "*.react"},
|
||||
MimeTypes: []string{"text/jsx", "text/typescript-jsx"},
|
||||
DotAll: true,
|
||||
},
|
||||
jsxRules,
|
||||
))
|
||||
|
||||
func jsxRules() Rules {
|
||||
return Rules{
|
||||
"commentsandwhitespace": {
|
||||
{`\s+`, Text, nil},
|
||||
{`<!--`, Comment, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
},
|
||||
"slashstartsregex": {
|
||||
Include("commentsandwhitespace"),
|
||||
{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gimuy]+\b|\B)`, LiteralStringRegex, Pop(1)},
|
||||
{`(?=/)`, Text, Push("#pop", "badregex")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"badregex": {
|
||||
{`\n`, Text, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
Include("jsx"),
|
||||
{`\A#! ?/.*?\n`, CommentHashbang, nil},
|
||||
{`^(?=\s|/|<!--)`, Text, Push("slashstartsregex")},
|
||||
Include("commentsandwhitespace"),
|
||||
{`(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`0[bB][01]+`, LiteralNumberBin, nil},
|
||||
{`0[oO][0-7]+`, LiteralNumberOct, nil},
|
||||
{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`\.\.\.|=>`, Punctuation, nil},
|
||||
{`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")},
|
||||
{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
|
||||
{`[})\].]`, Punctuation, nil},
|
||||
{`(for|in|while|do|break|return|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|this|of)\b`, Keyword, Push("slashstartsregex")},
|
||||
{`(var|let|with|function)\b`, KeywordDeclaration, Push("slashstartsregex")},
|
||||
{`(abstract|async|await|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\b`, KeywordReserved, nil},
|
||||
{`(true|false|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil},
|
||||
{`(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|document|this|window)\b`, NameBuiltin, nil},
|
||||
{`(?:[$_\p{L}\p{N}]|\\u[a-fA-F0-9]{4})(?:(?:[$\p{L}\p{N}]|\\u[a-fA-F0-9]{4}))*`, NameOther, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{"`", LiteralStringBacktick, Push("interp")},
|
||||
},
|
||||
"interp": {
|
||||
{"`", LiteralStringBacktick, Pop(1)},
|
||||
{`\\\\`, LiteralStringBacktick, nil},
|
||||
{"\\\\`", LiteralStringBacktick, nil},
|
||||
{`\$\{`, LiteralStringInterpol, Push("interp-inside")},
|
||||
{`\$`, LiteralStringBacktick, nil},
|
||||
{"[^`\\\\$]+", LiteralStringBacktick, nil},
|
||||
},
|
||||
"interp-inside": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"jsx": {
|
||||
{`(<)(/?)(>)`, ByGroups(Punctuation, Punctuation, Punctuation), nil},
|
||||
{`(<)([\w\.]+)`, ByGroups(Punctuation, NameTag), Push("tag")},
|
||||
{`(<)(/)([\w\.]+)(>)`, ByGroups(Punctuation, Punctuation, NameTag, Punctuation), nil},
|
||||
},
|
||||
"tag": {
|
||||
{`\s+`, Text, nil},
|
||||
{`([\w]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")},
|
||||
{`[{}]+`, Punctuation, nil},
|
||||
{`[\w\.]+`, NameAttribute, nil},
|
||||
{`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)},
|
||||
},
|
||||
"attr": {
|
||||
{`{`, Punctuation, Push("expression")},
|
||||
{`".*?"`, LiteralString, Pop(1)},
|
||||
{`'.*?'`, LiteralString, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"expression": {
|
||||
{`{`, Punctuation, Push()},
|
||||
{`}`, Punctuation, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,54 +0,0 @@
|
|||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
var Jungle = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Jungle",
|
||||
Aliases: []string{"jungle"},
|
||||
Filenames: []string{"*.jungle"},
|
||||
MimeTypes: []string{"text/x-jungle"},
|
||||
},
|
||||
jungleRules,
|
||||
))
|
||||
|
||||
func jungleRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\n`, Text, nil},
|
||||
{`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil},
|
||||
{`^(?=\S)`, None, Push("instruction")},
|
||||
{`[\.;\[\]\(\)\$]`, Punctuation, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"instruction": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`=`, Operator, Push("value")},
|
||||
{`(?=\S)`, None, Push("var")},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"value": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\$\(`, Punctuation, Push("var")},
|
||||
{`[;\[\]\(\)\$]`, Punctuation, nil},
|
||||
{`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil},
|
||||
{`[\w_\-\.\/\\]+`, Text, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"var": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\b(((re)?source|barrel)Path|excludeAnnotations|annotations|lang)\b`, NameBuiltin, nil},
|
||||
{`\bbase\b`, NameConstant, nil},
|
||||
{`\b(ind|zsm|hrv|ces|dan|dut|eng|fin|fre|deu|gre|hun|ita|nob|po[lr]|rus|sl[ov]|spa|swe|ara|heb|zh[st]|jpn|kor|tha|vie|bul|tur)`, NameConstant, nil},
|
||||
{`\b((semi)?round|rectangle)(-\d+x\d+)?\b`, NameConstant, nil},
|
||||
{`[\.;\[\]\(\$]`, Punctuation, nil},
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package k
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Kotlin lexer.
|
||||
var Kotlin = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Kotlin",
|
||||
Aliases: []string{"kotlin"},
|
||||
Filenames: []string{"*.kt"},
|
||||
MimeTypes: []string{"text/x-kotlin"},
|
||||
DotAll: true,
|
||||
},
|
||||
kotlinRules,
|
||||
))
|
||||
|
||||
func kotlinRules() Rules {
|
||||
const kotlinIdentifier = "(?:[_\\p{L}][\\p{L}\\p{N}]*|`@?[_\\p{L}][\\p{L}\\p{N}]+`)"
|
||||
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^\s*\[.*?\]`, NameAttribute, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`//[^\n]*\n?`, CommentSingle, nil},
|
||||
{`/[*].*?[*]/`, CommentMultiline, nil},
|
||||
{`\n`, Text, nil},
|
||||
{`!==|!in|!is|===`, Operator, nil},
|
||||
{`%=|&&|\*=|\+\+|\+=|--|-=|->|\.\.|\/=|::|<=|==|>=|!!|!=|\|\||\?[:.]`, Operator, nil},
|
||||
{`[~!%^&*()+=|\[\]:;,.<>\/?-]`, Punctuation, nil},
|
||||
{`[{}]`, Punctuation, nil},
|
||||
{`"""`, LiteralString, Push("rawstring")},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`(')(\\u[0-9a-fA-F]{4})(')`, ByGroups(LiteralStringChar, LiteralStringEscape, LiteralStringChar), nil},
|
||||
{`'\\.'|'[^\\]'`, LiteralStringChar, nil},
|
||||
{`0[xX][0-9a-fA-F]+[Uu]?[Ll]?|[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?[fF]?[Uu]?[Ll]?`, LiteralNumber, nil},
|
||||
{`(companion)(\s+)(object)`, ByGroups(Keyword, Text, Keyword), nil},
|
||||
{`(class|interface|object)(\s+)`, ByGroups(Keyword, Text), Push("class")},
|
||||
{`(package|import)(\s+)`, ByGroups(Keyword, Text), Push("package")},
|
||||
{`(val|var)(\s+)`, ByGroups(Keyword, Text), Push("property")},
|
||||
{`(fun)(\s+)`, ByGroups(Keyword, Text), Push("function")},
|
||||
{`(abstract|actual|annotation|as|as\?|break|by|catch|class|companion|const|constructor|continue|crossinline|data|delegate|do|dynamic|else|enum|expect|external|false|field|file|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|it|lateinit|noinline|null|object|open|operator|out|override|package|param|private|property|protected|public|receiver|reified|return|sealed|set|setparam|super|suspend|tailrec|this|throw|true|try|typealias|typeof|val|var|vararg|when|where|while)\b`, Keyword, nil},
|
||||
{`@` + kotlinIdentifier, NameDecorator, nil},
|
||||
{kotlinIdentifier, Name, nil},
|
||||
},
|
||||
"package": {
|
||||
{`\S+`, NameNamespace, Pop(1)},
|
||||
},
|
||||
"class": {
|
||||
// \x60 is the back tick character (`)
|
||||
{`\x60[^\x60]+?\x60`, NameClass, Pop(1)},
|
||||
{kotlinIdentifier, NameClass, Pop(1)},
|
||||
},
|
||||
"property": {
|
||||
{`\x60[^\x60]+?\x60`, NameProperty, Pop(1)},
|
||||
{kotlinIdentifier, NameProperty, Pop(1)},
|
||||
},
|
||||
"generics-specification": {
|
||||
{`<`, Punctuation, Push("generics-specification")}, // required for generics inside generics e.g. <T : List<Int> >
|
||||
{`>`, Punctuation, Pop(1)},
|
||||
{`[,:*?]`, Punctuation, nil},
|
||||
{`(in|out|reified)`, Keyword, nil},
|
||||
{`\x60[^\x60]+?\x60`, NameClass, nil},
|
||||
{kotlinIdentifier, NameClass, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"function": {
|
||||
{`<`, Punctuation, Push("generics-specification")},
|
||||
{`\x60[^\x60]+?\x60`, NameFunction, Pop(1)},
|
||||
{kotlinIdentifier, NameFunction, Pop(1)},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"rawstring": {
|
||||
// raw strings don't allow character escaping
|
||||
{`"""`, LiteralString, Pop(1)},
|
||||
{`(?:[^$"]+|\"{1,2}[^"])+`, LiteralString, nil},
|
||||
Include("string-interpol"),
|
||||
// remaining dollar signs are just a string
|
||||
{`\$`, LiteralString, nil},
|
||||
},
|
||||
"string": {
|
||||
{`\\[tbnr'"\\\$]`, LiteralStringEscape, nil},
|
||||
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
Include("string-interpol"),
|
||||
{`[^\n\\"$]+`, LiteralStringDouble, nil},
|
||||
// remaining dollar signs are just a string
|
||||
{`\$`, LiteralStringDouble, nil},
|
||||
},
|
||||
"string-interpol": {
|
||||
{`\$` + kotlinIdentifier, LiteralStringInterpol, nil},
|
||||
{`\${[^}\n]*}`, LiteralStringInterpol, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package l
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Lighttpd Configuration File lexer.
|
||||
var Lighttpd = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Lighttpd configuration file",
|
||||
Aliases: []string{"lighty", "lighttpd"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{"text/x-lighttpd-conf"},
|
||||
},
|
||||
lighttpdRules,
|
||||
))
|
||||
|
||||
func lighttpdRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*\n`, CommentSingle, nil},
|
||||
{`/\S*`, Name, nil},
|
||||
{`[a-zA-Z._-]+`, Keyword, nil},
|
||||
{`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil},
|
||||
{`[0-9]+`, LiteralNumber, nil},
|
||||
{`=>|=~|\+=|==|=|\+`, Operator, nil},
|
||||
{`\$[A-Z]+`, NameBuiltin, nil},
|
||||
{`[(){}\[\],]`, Punctuation, nil},
|
||||
{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package l
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Llvm lexer.
|
||||
var Llvm = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "LLVM",
|
||||
Aliases: []string{"llvm"},
|
||||
Filenames: []string{"*.ll"},
|
||||
MimeTypes: []string{"text/x-llvm"},
|
||||
},
|
||||
llvmRules,
|
||||
))
|
||||
|
||||
func llvmRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`([-a-zA-Z$._][\w\-$.]*|"[^"]*?")\s*:`, NameLabel, nil},
|
||||
Include("keyword"),
|
||||
{`%([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariable, nil},
|
||||
{`@([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariableGlobal, nil},
|
||||
{`%\d+`, NameVariableAnonymous, nil},
|
||||
{`@\d+`, NameVariableGlobal, nil},
|
||||
{`#\d+`, NameVariableGlobal, nil},
|
||||
{`!([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariable, nil},
|
||||
{`!\d+`, NameVariableAnonymous, nil},
|
||||
{`c?"[^"]*?"`, LiteralString, nil},
|
||||
{`0[xX][a-fA-F0-9]+`, LiteralNumber, nil},
|
||||
{`-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?`, LiteralNumber, nil},
|
||||
{`[=<>{}\[\]()*.,!]|x\b`, Punctuation, nil},
|
||||
},
|
||||
"whitespace": {
|
||||
{`(\n|\s)+`, Text, nil},
|
||||
{`;.*?\n`, Comment, nil},
|
||||
},
|
||||
"keyword": {
|
||||
{Words(``, `\b`, `begin`, `end`, `true`, `false`, `declare`, `define`, `global`, `constant`, `private`, `linker_private`, `internal`, `available_externally`, `linkonce`, `linkonce_odr`, `weak`, `weak_odr`, `appending`, `dllimport`, `dllexport`, `common`, `default`, `hidden`, `protected`, `extern_weak`, `external`, `thread_local`, `zeroinitializer`, `undef`, `null`, `to`, `tail`, `target`, `triple`, `datalayout`, `volatile`, `nuw`, `nsw`, `nnan`, `ninf`, `nsz`, `arcp`, `fast`, `exact`, `inbounds`, `align`, `addrspace`, `section`, `alias`, `module`, `asm`, `sideeffect`, `gc`, `dbg`, `linker_private_weak`, `attributes`, `blockaddress`, `initialexec`, `localdynamic`, `localexec`, `prefix`, `unnamed_addr`, `ccc`, `fastcc`, `coldcc`, `x86_stdcallcc`, `x86_fastcallcc`, `arm_apcscc`, `arm_aapcscc`, `arm_aapcs_vfpcc`, `ptx_device`, `ptx_kernel`, `intel_ocl_bicc`, `msp430_intrcc`, `spir_func`, `spir_kernel`, `x86_64_sysvcc`, `x86_64_win64cc`, `x86_thiscallcc`, `cc`, `c`, `signext`, `zeroext`, `inreg`, `sret`, `nounwind`, `noreturn`, `noalias`, `nocapture`, `byval`, `nest`, `readnone`, `readonly`, `inlinehint`, `noinline`, `alwaysinline`, `optsize`, `ssp`, `sspreq`, `noredzone`, `noimplicitfloat`, `naked`, `builtin`, `cold`, `nobuiltin`, `noduplicate`, `nonlazybind`, `optnone`, `returns_twice`, `sanitize_address`, `sanitize_memory`, `sanitize_thread`, `sspstrong`, `uwtable`, `returned`, `type`, `opaque`, `eq`, `ne`, `slt`, `sgt`, `sle`, `sge`, `ult`, `ugt`, `ule`, `uge`, `oeq`, `one`, `olt`, `ogt`, `ole`, `oge`, `ord`, `uno`, `ueq`, `une`, `x`, `acq_rel`, `acquire`, `alignstack`, `atomic`, `catch`, `cleanup`, `filter`, `inteldialect`, `max`, `min`, `monotonic`, `nand`, `personality`, `release`, `seq_cst`, `singlethread`, `umax`, `umin`, `unordered`, `xchg`, `add`, `fadd`, `sub`, `fsub`, `mul`, `fmul`, `udiv`, `sdiv`, `fdiv`, `urem`, `srem`, `frem`, `shl`, `lshr`, `ashr`, `and`, `or`, `xor`, `icmp`, `fcmp`, `phi`, `call`, `trunc`, `zext`, `sext`, `fptrunc`, `fpext`, `uitofp`, `sitofp`, `fptoui`, `fptosi`, `inttoptr`, `ptrtoint`, `bitcast`, `addrspacecast`, `select`, `va_arg`, `ret`, `br`, `switch`, `invoke`, `unwind`, `unreachable`, `indirectbr`, `landingpad`, `resume`, `malloc`, `alloca`, `free`, `load`, `store`, `getelementptr`, `extractelement`, `insertelement`, `shufflevector`, `getresult`, `extractvalue`, `insertvalue`, `atomicrmw`, `cmpxchg`, `fence`, `allocsize`, `amdgpu_cs`, `amdgpu_gs`, `amdgpu_kernel`, `amdgpu_ps`, `amdgpu_vs`, `any`, `anyregcc`, `argmemonly`, `avr_intrcc`, `avr_signalcc`, `caller`, `catchpad`, `catchret`, `catchswitch`, `cleanuppad`, `cleanupret`, `comdat`, `convergent`, `cxx_fast_tlscc`, `deplibs`, `dereferenceable`, `dereferenceable_or_null`, `distinct`, `exactmatch`, `externally_initialized`, `from`, `ghccc`, `hhvm_ccc`, `hhvmcc`, `ifunc`, `inaccessiblemem_or_argmemonly`, `inaccessiblememonly`, `inalloca`, `jumptable`, `largest`, `local_unnamed_addr`, `minsize`, `musttail`, `noduplicates`, `none`, `nonnull`, `norecurse`, `notail`, `preserve_allcc`, `preserve_mostcc`, `prologue`, `safestack`, `samesize`, `source_filename`, `swiftcc`, `swifterror`, `swiftself`, `webkit_jscc`, `within`, `writeonly`, `x86_intrcc`, `x86_vectorcallcc`), Keyword, nil},
|
||||
{Words(``, ``, `void`, `half`, `float`, `double`, `x86_fp80`, `fp128`, `ppc_fp128`, `label`, `metadata`, `token`), KeywordType, nil},
|
||||
{`i[1-9]\d*`, Keyword, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package l
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Lua lexer.
|
||||
var Lua = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Lua",
|
||||
Aliases: []string{"lua"},
|
||||
Filenames: []string{"*.lua", "*.wlua"},
|
||||
MimeTypes: []string{"text/x-lua", "application/x-lua"},
|
||||
},
|
||||
luaRules,
|
||||
))
|
||||
|
||||
func luaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#!.*`, CommentPreproc, nil},
|
||||
Default(Push("base")),
|
||||
},
|
||||
"ws": {
|
||||
{`(?:--\[(=*)\[[\w\W]*?\](\1)\])`, CommentMultiline, nil},
|
||||
{`(?:--.*$)`, CommentSingle, nil},
|
||||
{`(?:\s+)`, Text, nil},
|
||||
},
|
||||
"base": {
|
||||
Include("ws"),
|
||||
{`(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?`, LiteralNumberHex, nil},
|
||||
{`(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`(?i)\d+e[+-]?\d+`, LiteralNumberFloat, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`(?s)\[(=*)\[.*?\]\1\]`, LiteralString, nil},
|
||||
{`::`, Punctuation, Push("label")},
|
||||
{`\.{3}`, Punctuation, nil},
|
||||
{`[=<>|~&+\-*/%#^]+|\.\.`, Operator, nil},
|
||||
{`[\[\]{}().,:;]`, Punctuation, nil},
|
||||
{`(and|or|not)\b`, OperatorWord, nil},
|
||||
{`(break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b`, KeywordReserved, nil},
|
||||
{`goto\b`, KeywordReserved, Push("goto")},
|
||||
{`(local)\b`, KeywordDeclaration, nil},
|
||||
{`(true|false|nil)\b`, KeywordConstant, nil},
|
||||
{`(function)\b`, KeywordReserved, Push("funcname")},
|
||||
{`[A-Za-z_]\w*(\.[A-Za-z_]\w*)?`, Name, nil},
|
||||
{`'`, LiteralStringSingle, Combined("stringescape", "sqs")},
|
||||
{`"`, LiteralStringDouble, Combined("stringescape", "dqs")},
|
||||
},
|
||||
"funcname": {
|
||||
Include("ws"),
|
||||
{`[.:]`, Punctuation, nil},
|
||||
{`(?:[^\W\d]\w*)(?=(?:(?:--\[(=*)\[[\w\W]*?\](\2)\])|(?:--.*$)|(?:\s+))*[.:])`, NameClass, nil},
|
||||
{`(?:[^\W\d]\w*)`, NameFunction, Pop(1)},
|
||||
{`\(`, Punctuation, Pop(1)},
|
||||
},
|
||||
"goto": {
|
||||
Include("ws"),
|
||||
{`(?:[^\W\d]\w*)`, NameLabel, Pop(1)},
|
||||
},
|
||||
"label": {
|
||||
Include("ws"),
|
||||
{`::`, Punctuation, Pop(1)},
|
||||
{`(?:[^\W\d]\w*)`, NameLabel, nil},
|
||||
},
|
||||
"stringescape": {
|
||||
{`\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|u\{[0-9a-fA-F]+\})`, LiteralStringEscape, nil},
|
||||
},
|
||||
"sqs": {
|
||||
{`'`, LiteralStringSingle, Pop(1)},
|
||||
{`[^\\']+`, LiteralStringSingle, nil},
|
||||
},
|
||||
"dqs": {
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
{`[^\\"]+`, LiteralStringDouble, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// Package lexers contains the registry of all lexers.
|
||||
//
|
||||
// Sub-packages contain lexer implementations.
|
||||
package lexers
|
||||
|
||||
// nolint
|
||||
import (
|
||||
"github.com/alecthomas/chroma"
|
||||
_ "github.com/alecthomas/chroma/lexers/a"
|
||||
_ "github.com/alecthomas/chroma/lexers/b"
|
||||
_ "github.com/alecthomas/chroma/lexers/c"
|
||||
_ "github.com/alecthomas/chroma/lexers/circular"
|
||||
_ "github.com/alecthomas/chroma/lexers/d"
|
||||
_ "github.com/alecthomas/chroma/lexers/e"
|
||||
_ "github.com/alecthomas/chroma/lexers/f"
|
||||
_ "github.com/alecthomas/chroma/lexers/g"
|
||||
_ "github.com/alecthomas/chroma/lexers/h"
|
||||
_ "github.com/alecthomas/chroma/lexers/i"
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
_ "github.com/alecthomas/chroma/lexers/j"
|
||||
_ "github.com/alecthomas/chroma/lexers/k"
|
||||
_ "github.com/alecthomas/chroma/lexers/l"
|
||||
_ "github.com/alecthomas/chroma/lexers/m"
|
||||
_ "github.com/alecthomas/chroma/lexers/n"
|
||||
_ "github.com/alecthomas/chroma/lexers/o"
|
||||
_ "github.com/alecthomas/chroma/lexers/p"
|
||||
_ "github.com/alecthomas/chroma/lexers/q"
|
||||
_ "github.com/alecthomas/chroma/lexers/r"
|
||||
_ "github.com/alecthomas/chroma/lexers/s"
|
||||
_ "github.com/alecthomas/chroma/lexers/t"
|
||||
_ "github.com/alecthomas/chroma/lexers/v"
|
||||
_ "github.com/alecthomas/chroma/lexers/w"
|
||||
_ "github.com/alecthomas/chroma/lexers/x"
|
||||
_ "github.com/alecthomas/chroma/lexers/y"
|
||||
_ "github.com/alecthomas/chroma/lexers/z"
|
||||
)
|
||||
|
||||
// Registry of Lexers.
|
||||
var Registry = internal.Registry
|
||||
|
||||
// Names of all lexers, optionally including aliases.
|
||||
func Names(withAliases bool) []string { return internal.Names(withAliases) }
|
||||
|
||||
// Get a Lexer by name, alias or file extension.
|
||||
func Get(name string) chroma.Lexer { return internal.Get(name) }
|
||||
|
||||
// MatchMimeType attempts to find a lexer for the given MIME type.
|
||||
func MatchMimeType(mimeType string) chroma.Lexer { return internal.MatchMimeType(mimeType) }
|
||||
|
||||
// Match returns the first lexer matching filename.
|
||||
func Match(filename string) chroma.Lexer { return internal.Match(filename) }
|
||||
|
||||
// Analyse text content and return the "best" lexer..
|
||||
func Analyse(text string) chroma.Lexer { return internal.Analyse(text) }
|
||||
|
||||
// Register a Lexer with the global registry.
|
||||
func Register(lexer chroma.Lexer) chroma.Lexer { return internal.Register(lexer) }
|
||||
|
||||
// Fallback lexer if no other is found.
|
||||
var Fallback = internal.Fallback
|
|
@ -1,58 +0,0 @@
|
|||
package m
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
. "github.com/alecthomas/chroma/lexers/b" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Makefile lexer.
|
||||
var Makefile = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Base Makefile",
|
||||
Aliases: []string{"make", "makefile", "mf", "bsdmake"},
|
||||
Filenames: []string{"*.mak", "*.mk", "Makefile", "makefile", "Makefile.*", "GNUmakefile"},
|
||||
MimeTypes: []string{"text/x-makefile"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
makefileRules,
|
||||
))
|
||||
|
||||
func makefileRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`^(?:[\t ]+.*\n|\n)+`, Using(Bash), nil},
|
||||
{`\$[<@$+%?|*]`, Keyword, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`#.*?\n`, Comment, nil},
|
||||
{`(export)(\s+)(?=[\w${}\t -]+\n)`, ByGroups(Keyword, Text), Push("export")},
|
||||
{`export\s+`, Keyword, nil},
|
||||
{`([\w${}().-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)`, ByGroups(NameVariable, Text, Operator, Text, Using(Bash)), nil},
|
||||
{`(?s)"(\\\\|\\.|[^"\\])*"`, LiteralStringDouble, nil},
|
||||
{`(?s)'(\\\\|\\.|[^'\\])*'`, LiteralStringSingle, nil},
|
||||
{`([^\n:]+)(:+)([ \t]*)`, ByGroups(NameFunction, Operator, Text), Push("block-header")},
|
||||
{`\$\(`, Keyword, Push("expansion")},
|
||||
},
|
||||
"expansion": {
|
||||
{`[^$a-zA-Z_()]+`, Text, nil},
|
||||
{`[a-zA-Z_]+`, NameVariable, nil},
|
||||
{`\$`, Keyword, nil},
|
||||
{`\(`, Keyword, Push()},
|
||||
{`\)`, Keyword, Pop(1)},
|
||||
},
|
||||
"export": {
|
||||
{`[\w${}-]+`, NameVariable, nil},
|
||||
{`\n`, Text, Pop(1)},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"block-header": {
|
||||
{`[,|]`, Punctuation, nil},
|
||||
{`#.*?\n`, Comment, Pop(1)},
|
||||
{`\\\n`, Text, nil},
|
||||
{`\$\(`, Keyword, Push("expansion")},
|
||||
{`[a-zA-Z_]+`, Name, nil},
|
||||
{`\n`, Text, Pop(1)},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package m
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
. "github.com/alecthomas/chroma/lexers/p" // nolint
|
||||
)
|
||||
|
||||
// Mako lexer.
|
||||
var Mako = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Mako",
|
||||
Aliases: []string{"mako"},
|
||||
Filenames: []string{"*.mao"},
|
||||
MimeTypes: []string{"application/x-mako"},
|
||||
},
|
||||
makoRules,
|
||||
))
|
||||
|
||||
func makoRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`(\s*)(%)(\s*end(?:\w+))(\n|\Z)`, ByGroups(Text, CommentPreproc, Keyword, Other), nil},
|
||||
{`(\s*)(%)([^\n]*)(\n|\Z)`, ByGroups(Text, CommentPreproc, Using(Python), Other), nil},
|
||||
{`(\s*)(##[^\n]*)(\n|\Z)`, ByGroups(Text, CommentPreproc, Other), nil},
|
||||
{`(?s)<%doc>.*?</%doc>`, CommentPreproc, nil},
|
||||
{`(<%)([\w.:]+)`, ByGroups(CommentPreproc, NameBuiltin), Push("tag")},
|
||||
{`(</%)([\w.:]+)(>)`, ByGroups(CommentPreproc, NameBuiltin, CommentPreproc), nil},
|
||||
{`<%(?=([\w.:]+))`, CommentPreproc, Push("ondeftags")},
|
||||
{`(<%(?:!?))(.*?)(%>)(?s)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
|
||||
{`(\$\{)(.*?)(\})`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
|
||||
{`(?sx)
|
||||
(.+?) # anything, followed by:
|
||||
(?:
|
||||
(?<=\n)(?=%|\#\#) | # an eval or comment line
|
||||
(?=\#\*) | # multiline comment
|
||||
(?=</?%) | # a python block
|
||||
# call start or end
|
||||
(?=\$\{) | # a substitution
|
||||
(?<=\n)(?=\s*%) |
|
||||
# - don't consume
|
||||
(\\\n) | # an escaped newline
|
||||
\Z # end of string
|
||||
)
|
||||
`, ByGroups(Other, Operator), nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"ondeftags": {
|
||||
{`<%`, CommentPreproc, nil},
|
||||
{`(?<=<%)(include|inherit|namespace|page)`, NameBuiltin, nil},
|
||||
Include("tag"),
|
||||
},
|
||||
"tag": {
|
||||
{`((?:\w+)\s*=)(\s*)(".*?")`, ByGroups(NameAttribute, Text, LiteralString), nil},
|
||||
{`/?\s*>`, CommentPreproc, Pop(1)},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"attr": {
|
||||
{`".*?"`, LiteralString, Pop(1)},
|
||||
{`'.*?'`, LiteralString, Pop(1)},
|
||||
{`[^\s>]+`, LiteralString, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package m
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
. "github.com/alecthomas/chroma/lexers/h" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
. "github.com/alecthomas/chroma/lexers/p" // nolint
|
||||
)
|
||||
|
||||
// Mason lexer.
|
||||
var Mason = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Mason",
|
||||
Aliases: []string{"mason"},
|
||||
Filenames: []string{"*.m", "*.mhtml", "*.mc", "*.mi", "autohandler", "dhandler"},
|
||||
MimeTypes: []string{"application/x-mason"},
|
||||
Priority: 0.1,
|
||||
},
|
||||
masonRules,
|
||||
))
|
||||
|
||||
func masonRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(<%doc>)(.*?)(</%doc>)(?s)`, ByGroups(NameTag, CommentMultiline, NameTag), nil},
|
||||
{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil},
|
||||
{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Perl), NameTag), nil},
|
||||
{`(<&[^|])(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Perl), NameTag), nil},
|
||||
{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Perl), NameTag), nil},
|
||||
{`</&>`, NameTag, nil},
|
||||
{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Perl), NameTag), nil},
|
||||
{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil},
|
||||
{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Perl), Other), nil},
|
||||
{`(?sx)
|
||||
(.+?) # anything, followed by:
|
||||
(?:
|
||||
(?<=\n)(?=[%#]) | # an eval or comment line
|
||||
(?=</?[%&]) | # a substitution or block or
|
||||
# call start or end
|
||||
# - don't consume
|
||||
(\\\n) | # an escaped newline
|
||||
\Z # end of string
|
||||
)`, ByGroups(Using(HTML), Operator), nil},
|
||||
},
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue