|
| 1 | +package p |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/alecthomas/chroma" // nolint |
| 5 | + "github.com/alecthomas/chroma/lexers/internal" |
| 6 | +) |
| 7 | + |
| 8 | +// Pony lexer. |
| 9 | +var Pony = internal.Register(MustNewLexer( |
| 10 | + &Config{ |
| 11 | + Name: "Pony", |
| 12 | + Aliases: []string{"pony"}, |
| 13 | + Filenames: []string{"*.pony"}, |
| 14 | + MimeTypes: []string{}, |
| 15 | + }, |
| 16 | + Rules{ |
| 17 | + "root": { |
| 18 | + {`\n`, Text, nil}, |
| 19 | + {`[^\S\n]+`, Text, nil}, |
| 20 | + {`//.*\n`, CommentSingle, nil}, |
| 21 | + {`/\*`, CommentMultiline, Push("nested_comment")}, |
| 22 | + {`"""(?:.|\n)*?"""`, LiteralStringDoc, nil}, |
| 23 | + {`"`, LiteralString, Push("string")}, |
| 24 | + {`\'.*\'`, LiteralStringChar, nil}, |
| 25 | + {`=>|[]{}:().~;,|&!^?[]`, Punctuation, nil}, |
| 26 | + {Words(``, `\b`, `addressof`, `and`, `as`, `consume`, `digestof`, `is`, `isnt`, `not`, `or`), OperatorWord, nil}, |
| 27 | + {`!=|==|<<|>>|[-+/*%=<>]`, Operator, nil}, |
| 28 | + {Words(``, `\b`, `box`, `break`, `compile_error`, `compile_intrinsic`, `continue`, `do`, `else`, `elseif`, `embed`, `end`, `error`, `for`, `if`, `ifdef`, `in`, `iso`, `lambda`, `let`, `match`, `object`, `recover`, `ref`, `repeat`, `return`, `tag`, `then`, `this`, `trn`, `try`, `until`, `use`, `var`, `val`, `where`, `while`, `with`, `#any`, `#read`, `#send`, `#share`), Keyword, nil}, |
| 29 | + {`(actor|class|struct|primitive|interface|trait|type)((?:\s)+)`, ByGroups(Keyword, Text), Push("typename")}, |
| 30 | + {`(new|fun|be)((?:\s)+)`, ByGroups(Keyword, Text), Push("methodname")}, |
| 31 | + {Words(``, `\b`, `U8`, `U16`, `U32`, `U64`, `ULong`, `USize`, `U128`, `Unsigned`, `Stringable`, `String`, `StringBytes`, `StringRunes`, `InputNotify`, `InputStream`, `Stdin`, `ByteSeq`, `ByteSeqIter`, `OutStream`, `StdStream`, `SourceLoc`, `I8`, `I16`, `I32`, `I64`, `ILong`, `ISize`, `I128`, `Signed`, `Seq`, `RuntimeOptions`, `Real`, `Integer`, `SignedInteger`, `UnsignedInteger`, `FloatingPoint`, `Number`, `Int`, `ReadSeq`, `ReadElement`, `Pointer`, `Platform`, `NullablePointer`, `None`, `Iterator`, `F32`, `F64`, `Float`, `Env`, `DoNotOptimise`, `DisposableActor`, `Less`, `Equal`, `Greater`, `Compare`, `HasEq`, `Equatable`, `Comparable`, `Bool`, `AsioEventID`, `AsioEventNotify`, `AsioEvent`, `Array`, `ArrayKeys`, `ArrayValues`, `ArrayPairs`, `Any`, `AmbientAuth`), KeywordType, nil}, |
| 32 | + {`_?[A-Z]\w*`, NameClass, nil}, |
| 33 | + {`string\(\)`, NameOther, nil}, |
| 34 | + {`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+`, LiteralNumberFloat, nil}, |
| 35 | + {`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, |
| 36 | + {`\d+`, LiteralNumberInteger, nil}, |
| 37 | + {`(true|false)\b`, Keyword, nil}, |
| 38 | + {`_\d*`, Name, nil}, |
| 39 | + {`_?[a-z][\w\'_]*`, Name, nil}, |
| 40 | + }, |
| 41 | + "typename": { |
| 42 | + {`(iso|trn|ref|val|box|tag)?((?:\s)*)(_?[A-Z]\w*)`, ByGroups(Keyword, Text, NameClass), Pop(1)}, |
| 43 | + }, |
| 44 | + "methodname": { |
| 45 | + {`(iso|trn|ref|val|box|tag)?((?:\s)*)(_?[a-z]\w*)`, ByGroups(Keyword, Text, NameFunction), Pop(1)}, |
| 46 | + }, |
| 47 | + "nested_comment": { |
| 48 | + {`[^*/]+`, CommentMultiline, nil}, |
| 49 | + {`/\*`, CommentMultiline, Push()}, |
| 50 | + {`\*/`, CommentMultiline, Pop(1)}, |
| 51 | + {`[*/]`, CommentMultiline, nil}, |
| 52 | + }, |
| 53 | + "string": { |
| 54 | + {`"`, LiteralString, Pop(1)}, |
| 55 | + {`\\"`, LiteralString, nil}, |
| 56 | + {`[^\\"]+`, LiteralString, nil}, |
| 57 | + }, |
| 58 | + }, |
| 59 | +)) |
0 commit comments