1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-27 09:11:53 -05:00
forgejo/vendor/github.com/alecthomas/chroma/lexers/v/verilog.go
6543 86e2789960
Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery

* update github.com/alecthomas/chroma

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/go-enry/go-enry/v2

* update github.com/go-git/go-billy/v5

* update github.com/go-git/go-git/v5

* update github.com/go-redis/redis/v8

* update github.com/go-testfixtures/testfixtures/v3

* update github.com/jaytaylor/html2text

* update github.com/json-iterator/go

* update github.com/klauspost/compress

* update github.com/markbates/goth

* update github.com/mattn/go-isatty

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

* update github.com/minio/minio-go/v7

* update github.com/prometheus/client_golang

* update github.com/unrolled/render

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark

* update github.com/yuin/goldmark-highlighting

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-10 16:44:25 +02:00

72 lines
4.6 KiB
Go
Vendored

package v
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Verilog lexer.
var Verilog = internal.Register(MustNewLazyLexer(
&Config{
Name: "verilog",
Aliases: []string{"verilog", "v"},
Filenames: []string{"*.v"},
MimeTypes: []string{"text/x-verilog"},
EnsureNL: true,
},
verilogRules,
))
func verilogRules() Rules {
return Rules{
"root": {
{"^\\s*`define", CommentPreproc, Push("macro")},
{`\n`, Text, nil},
{`\s+`, Text, nil},
{`\\\n`, Text, nil},
{`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil},
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
{`[{}#@]`, Punctuation, nil},
{`L?"`, LiteralString, Push("string")},
{`L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?`, LiteralNumberFloat, nil},
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
{`([0-9]+)|(\'h)[0-9a-fA-F]+`, LiteralNumberHex, nil},
{`([0-9]+)|(\'b)[01]+`, LiteralNumberBin, nil},
{`([0-9]+)|(\'d)[0-9]+`, LiteralNumberInteger, nil},
{`([0-9]+)|(\'o)[0-7]+`, LiteralNumberOct, nil},
{`\'[01xz]`, LiteralNumber, nil},
{`\d+[Ll]?`, LiteralNumberInteger, nil},
{`\*/`, Error, nil},
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
{`[()\[\],.;\']`, Punctuation, nil},
{"`[a-zA-Z_]\\w*", NameConstant, nil},
{`^(\s*)(package)(\s+)`, ByGroups(Text, KeywordNamespace, Text), nil},
{`^(\s*)(import)(\s+)`, ByGroups(Text, KeywordNamespace, Text), Push("import")},
{Words(``, `\b`, `always`, `always_comb`, `always_ff`, `always_latch`, `and`, `assign`, `automatic`, `begin`, `break`, `buf`, `bufif0`, `bufif1`, `case`, `casex`, `casez`, `cmos`, `const`, `continue`, `deassign`, `default`, `defparam`, `disable`, `do`, `edge`, `else`, `end`, `endcase`, `endfunction`, `endgenerate`, `endmodule`, `endpackage`, `endprimitive`, `endspecify`, `endtable`, `endtask`, `enum`, `event`, `final`, `for`, `force`, `forever`, `fork`, `function`, `generate`, `genvar`, `highz0`, `highz1`, `if`, `initial`, `inout`, `input`, `integer`, `join`, `large`, `localparam`, `macromodule`, `medium`, `module`, `nand`, `negedge`, `nmos`, `nor`, `not`, `notif0`, `notif1`, `or`, `output`, `packed`, `parameter`, `pmos`, `posedge`, `primitive`, `pull0`, `pull1`, `pulldown`, `pullup`, `rcmos`, `ref`, `release`, `repeat`, `return`, `rnmos`, `rpmos`, `rtran`, `rtranif0`, `rtranif1`, `scalared`, `signed`, `small`, `specify`, `specparam`, `strength`, `string`, `strong0`, `strong1`, `struct`, `table`, `task`, `tran`, `tranif0`, `tranif1`, `type`, `typedef`, `unsigned`, `var`, `vectored`, `void`, `wait`, `weak0`, `weak1`, `while`, `xnor`, `xor`), Keyword, nil},
{Words("`", `\b`, `accelerate`, `autoexpand_vectornets`, `celldefine`, `default_nettype`, `else`, `elsif`, `endcelldefine`, `endif`, `endprotect`, `endprotected`, `expand_vectornets`, `ifdef`, `ifndef`, `include`, `noaccelerate`, `noexpand_vectornets`, `noremove_gatenames`, `noremove_netnames`, `nounconnected_drive`, `protect`, `protected`, `remove_gatenames`, `remove_netnames`, `resetall`, `timescale`, `unconnected_drive`, `undef`), CommentPreproc, nil},
{Words(`\$`, `\b`, `bits`, `bitstoreal`, `bitstoshortreal`, `countdrivers`, `display`, `fclose`, `fdisplay`, `finish`, `floor`, `fmonitor`, `fopen`, `fstrobe`, `fwrite`, `getpattern`, `history`, `incsave`, `input`, `itor`, `key`, `list`, `log`, `monitor`, `monitoroff`, `monitoron`, `nokey`, `nolog`, `printtimescale`, `random`, `readmemb`, `readmemh`, `realtime`, `realtobits`, `reset`, `reset_count`, `reset_value`, `restart`, `rtoi`, `save`, `scale`, `scope`, `shortrealtobits`, `showscopes`, `showvariables`, `showvars`, `sreadmemb`, `sreadmemh`, `stime`, `stop`, `strobe`, `time`, `timeformat`, `write`), NameBuiltin, nil},
{Words(``, `\b`, `byte`, `shortint`, `int`, `longint`, `integer`, `time`, `bit`, `logic`, `reg`, `supply0`, `supply1`, `tri`, `triand`, `trior`, `tri0`, `tri1`, `trireg`, `uwire`, `wire`, `wand`, `woshortreal`, `real`, `realtime`), KeywordType, nil},
{`[a-zA-Z_]\w*:(?!:)`, NameLabel, nil},
{`\$?[a-zA-Z_]\w*`, Name, nil},
},
"string": {
{`"`, LiteralString, Pop(1)},
{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
{`[^\\"\n]+`, LiteralString, nil},
{`\\\n`, LiteralString, nil},
{`\\`, LiteralString, nil},
},
"macro": {
{`[^/\n]+`, CommentPreproc, nil},
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
{`//.*?\n`, CommentSingle, Pop(1)},
{`/`, CommentPreproc, nil},
{`(?<=\\)\n`, CommentPreproc, nil},
{`\n`, CommentPreproc, Pop(1)},
},
"import": {
{`[\w:]+\*?`, NameNamespace, Pop(1)},
},
}
}