-
-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted heavily from several of the lexers in this repo, and https://github.com/tsandall/vim-rego/blob/b47bf95996b72d630464b44ca567f2945bd37ac9/syntax/rego.vim
- Loading branch information
1 parent
d7a7dd3
commit 6aefb9b
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<lexer> | ||
<config> | ||
<name>Rego</name> | ||
<alias>rego</alias> | ||
<filename>*.rego</filename> | ||
</config> | ||
<rules> | ||
<state name="root"> | ||
<rule pattern="(package|import|as|not|with|default|else|some|in|if|contains)\b"> | ||
<token type="KeywordDeclaration"/> | ||
</rule> | ||
<!-- importing keywords should then show up as keywords --> | ||
<rule pattern="(import)( future.keywords.)(\w+)"> | ||
<bygroups> | ||
<token type="KeywordDeclaration"/> | ||
<token type="Text"/> | ||
<token type="KeywordDeclaration"/> | ||
</bygroups> | ||
</rule> | ||
<rule pattern="#[^\r\n]*"> | ||
<token type="Comment"/> | ||
</rule> | ||
<rule pattern="(FIXME|TODO|XXX)\b( .*)$"> | ||
<bygroups> | ||
<token type="Error"/> | ||
<token type="CommentSpecial"/> | ||
</bygroups> | ||
</rule> | ||
<rule pattern="(true|false|null)\b"> | ||
<token type="KeywordConstant"/> | ||
</rule> | ||
<!-- TODO numbers --> | ||
|
||
<rule pattern="""".*?""""> | ||
<token type="LiteralStringDouble"/> | ||
</rule> | ||
<rule pattern=""(\\\\|\\"|[^"])*""> | ||
<token type="LiteralStringDouble"/> | ||
</rule> | ||
<rule pattern="\$/((?!/\$).)*/\$"> | ||
<token type="LiteralString"/> | ||
</rule> | ||
<rule pattern="/(\\\\|\\"|[^/])*/"> | ||
<token type="LiteralString"/> | ||
</rule> | ||
<rule pattern="^(\w+)"> | ||
<token type="Name"/> | ||
</rule> | ||
<rule pattern="[a-z_-][\w-]*(?=\()"> | ||
<token type="NameFunction"/> | ||
</rule> | ||
<rule pattern="[\r\n\s]+"> | ||
<token type="TextWhitespace"/> | ||
</rule> | ||
<rule pattern="(package|import)(\s+)"> | ||
<bygroups> | ||
<token type="KeywordDeclaration"/> | ||
<token type="Text"/> | ||
</bygroups> | ||
</rule> | ||
<rule pattern="[=<>!+-/*&|]"> | ||
<token type="Operator"/> | ||
</rule> | ||
<rule pattern=":="> | ||
<token type="Operator"/> | ||
</rule> | ||
</state> | ||
</rules> | ||
</lexer> |