summaryrefslogtreecommitdiff
path: root/tests/snippets/systemverilog
diff options
context:
space:
mode:
Diffstat (limited to 'tests/snippets/systemverilog')
-rw-r--r--tests/snippets/systemverilog/test_basic.txt181
-rw-r--r--tests/snippets/systemverilog/test_classes.txt95
-rw-r--r--tests/snippets/systemverilog/test_numbers.txt168
-rw-r--r--tests/snippets/systemverilog/test_operators.txt213
4 files changed, 657 insertions, 0 deletions
diff --git a/tests/snippets/systemverilog/test_basic.txt b/tests/snippets/systemverilog/test_basic.txt
new file mode 100644
index 00000000..9307538d
--- /dev/null
+++ b/tests/snippets/systemverilog/test_basic.txt
@@ -0,0 +1,181 @@
+# Examine tokens emitted by the SV lexer for a trivial module.
+# Not intended to stress any particular corner of the language.
+
+---input---
+// Adder flops the sum of its inputs
+module Adder #(
+ parameter int N = 42
+) (
+ output logic [N-1:0] y,
+ output logic co,
+
+ input logic [N-1:0] a,
+ input logic [N-1:0] b,
+ input logic ci,
+
+ input logic clk
+);
+ always_ff @(posedge clk) begin
+ {co, y} <= a + b + ci;
+ end
+endmodule : Adder
+
+---tokens---
+'// Adder flops the sum of its inputs\n' Comment.Single
+
+'module' Keyword
+' ' Text
+'Adder' Name
+' ' Text
+'#' Punctuation
+'(' Punctuation
+'\n' Text
+
+' ' Text
+'parameter' Keyword
+' ' Text
+'int' Keyword.Type
+' ' Text
+'N' Name
+' ' Text
+'=' Operator
+' ' Text
+'42' Literal.Number.Integer
+'\n' Text
+
+')' Punctuation
+' ' Text
+'(' Punctuation
+'\n' Text
+
+' ' Text
+'output' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'[' Punctuation
+'N' Name
+'-' Operator
+'1' Literal.Number.Integer
+':' Operator
+'0' Literal.Number.Integer
+']' Punctuation
+' ' Text
+'y' Name
+',' Punctuation
+'\n' Text
+
+' ' Text
+'output' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'co' Name
+',' Punctuation
+'\n' Text
+
+'\n' Text
+
+' ' Text
+'input' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'[' Punctuation
+'N' Name
+'-' Operator
+'1' Literal.Number.Integer
+':' Operator
+'0' Literal.Number.Integer
+']' Punctuation
+' ' Text
+'a' Name
+',' Punctuation
+'\n' Text
+
+' ' Text
+'input' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'[' Punctuation
+'N' Name
+'-' Operator
+'1' Literal.Number.Integer
+':' Operator
+'0' Literal.Number.Integer
+']' Punctuation
+' ' Text
+'b' Name
+',' Punctuation
+'\n' Text
+
+' ' Text
+'input' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'ci' Name
+',' Punctuation
+'\n' Text
+
+'\n' Text
+
+' ' Text
+'input' Keyword
+' ' Text
+'logic' Keyword.Type
+' ' Text
+'clk' Name
+'\n' Text
+
+')' Punctuation
+';' Punctuation
+'\n' Text
+
+' ' Text
+'always_ff' Keyword
+' ' Text
+'@' Punctuation
+'(' Punctuation
+'posedge' Keyword
+' ' Text
+'clk' Name
+')' Punctuation
+' ' Text
+'begin' Keyword
+'\n' Text
+
+' ' Text
+'{' Punctuation
+'co' Name
+',' Punctuation
+' ' Text
+'y' Name
+'}' Punctuation
+' ' Text
+'<' Operator
+'=' Operator
+' ' Text
+'a' Name
+' ' Text
+'+' Operator
+' ' Text
+'b' Name
+' ' Text
+'+' Operator
+' ' Text
+'ci' Name
+';' Punctuation
+'\n' Text
+
+' ' Text
+'end' Keyword
+'\n' Text
+
+'endmodule' Keyword
+' ' Text
+':' Operator
+' ' Text
+'Adder' Name
+'\n' Text
diff --git a/tests/snippets/systemverilog/test_classes.txt b/tests/snippets/systemverilog/test_classes.txt
new file mode 100644
index 00000000..fce86a72
--- /dev/null
+++ b/tests/snippets/systemverilog/test_classes.txt
@@ -0,0 +1,95 @@
+# Most of the interesting types of class declarations
+
+---input---
+class Foo;
+endclass
+
+class Bar;
+endclass : Bar
+
+class Fiz extends Buz;
+endclass : Fiz
+
+class Free #(parameter type T = byte) extends Beer #(T);
+endclass : Free
+
+---tokens---
+'class' Keyword.Declaration
+' ' Text
+'Foo' Name.Class
+';' Punctuation
+'\n' Text
+
+'endclass' Keyword.Declaration
+'\n' Text
+
+'\n' Text
+
+'class' Keyword.Declaration
+' ' Text
+'Bar' Name.Class
+';' Punctuation
+'\n' Text
+
+'endclass' Keyword.Declaration
+' ' Text
+':' Punctuation
+' ' Text
+'Bar' Name.Class
+'\n' Text
+
+'\n' Text
+
+'class' Keyword.Declaration
+' ' Text
+'Fiz' Name.Class
+' ' Text
+'extends' Keyword.Declaration
+' ' Text
+'Buz' Name.Class
+';' Punctuation
+'\n' Text
+
+'endclass' Keyword.Declaration
+' ' Text
+':' Punctuation
+' ' Text
+'Fiz' Name.Class
+'\n' Text
+
+'\n' Text
+
+'class' Keyword.Declaration
+' ' Text
+'Free' Name.Class
+' ' Text
+'#' Punctuation
+'(' Punctuation
+'parameter' Keyword
+' ' Text
+'type' Keyword.Type
+' ' Text
+'T' Name
+' ' Text
+'=' Operator
+' ' Text
+'byte' Keyword.Type
+')' Punctuation
+' ' Text
+'extends' Keyword.Declaration
+' ' Text
+'Beer' Name.Class
+' ' Text
+'#' Punctuation
+'(' Punctuation
+'T' Name
+')' Punctuation
+';' Punctuation
+'\n' Text
+
+'endclass' Keyword.Declaration
+' ' Text
+':' Punctuation
+' ' Text
+'Free' Name.Class
+'\n' Text
diff --git a/tests/snippets/systemverilog/test_numbers.txt b/tests/snippets/systemverilog/test_numbers.txt
new file mode 100644
index 00000000..fa0ee5f6
--- /dev/null
+++ b/tests/snippets/systemverilog/test_numbers.txt
@@ -0,0 +1,168 @@
+# Believe it or not, SystemVerilog supports spaces before and after the base
+# specifier (ie 'b, 'd, 'h). See IEEE 1800-2017 Section 5.7.1 for examples.
+
+---input---
+8'b10101010
+8 'b10101010
+8'b 10101010
+8'sb10101010
+8'Sb10101010
+8'B10101010
+8'b1010_1010
+8'b10xXzZ?10
+
+24'o01234567
+24 'o01234567
+24'o 01234567
+24'so01234567
+24'So01234567
+24'O01234567
+24'o0123_4567
+24'o01xXzZ?7
+
+32'd27182818
+32 'd27182818
+32'd 27182818
+32'sd27182818
+32'Sd27182818
+32'D27182818
+32'd2718_2818
+32'd27xXzZ?8
+
+32'hdeadbeef
+32 'hdeadbeef
+32'h deadbeef
+32'shdeadbeef
+32'Shdeadbeef
+32'Hdeadbeef
+32'hdead_beef
+32'hdexXzZ?f
+
+'0 '1 'x 'X 'z 'Z
+
+42 1234_5678
+
+---tokens---
+"8'b10101010" Literal.Number.Bin
+'\n' Text
+
+"8 'b10101010" Literal.Number.Bin
+'\n' Text
+
+"8'b 10101010" Literal.Number.Bin
+'\n' Text
+
+"8'sb10101010" Literal.Number.Bin
+'\n' Text
+
+"8'Sb10101010" Literal.Number.Bin
+'\n' Text
+
+"8'B10101010" Literal.Number.Bin
+'\n' Text
+
+"8'b1010_1010" Literal.Number.Bin
+'\n' Text
+
+"8'b10xXzZ?10" Literal.Number.Bin
+'\n' Text
+
+'\n' Text
+
+"24'o01234567" Literal.Number.Oct
+'\n' Text
+
+"24 'o01234567" Literal.Number.Oct
+'\n' Text
+
+"24'o 01234567" Literal.Number.Oct
+'\n' Text
+
+"24'so01234567" Literal.Number.Oct
+'\n' Text
+
+"24'So01234567" Literal.Number.Oct
+'\n' Text
+
+"24'O01234567" Literal.Number.Oct
+'\n' Text
+
+"24'o0123_4567" Literal.Number.Oct
+'\n' Text
+
+"24'o01xXzZ?7" Literal.Number.Oct
+'\n' Text
+
+'\n' Text
+
+"32'd27182818" Literal.Number.Integer
+'\n' Text
+
+"32 'd27182818" Literal.Number.Integer
+'\n' Text
+
+"32'd 27182818" Literal.Number.Integer
+'\n' Text
+
+"32'sd27182818" Literal.Number.Integer
+'\n' Text
+
+"32'Sd27182818" Literal.Number.Integer
+'\n' Text
+
+"32'D27182818" Literal.Number.Integer
+'\n' Text
+
+"32'd2718_2818" Literal.Number.Integer
+'\n' Text
+
+"32'd27xXzZ?8" Literal.Number.Integer
+'\n' Text
+
+'\n' Text
+
+"32'hdeadbeef" Literal.Number.Hex
+'\n' Text
+
+"32 'hdeadbeef" Literal.Number.Hex
+'\n' Text
+
+"32'h deadbeef" Literal.Number.Hex
+'\n' Text
+
+"32'shdeadbeef" Literal.Number.Hex
+'\n' Text
+
+"32'Shdeadbeef" Literal.Number.Hex
+'\n' Text
+
+"32'Hdeadbeef" Literal.Number.Hex
+'\n' Text
+
+"32'hdead_beef" Literal.Number.Hex
+'\n' Text
+
+"32'hdexXzZ?f" Literal.Number.Hex
+'\n' Text
+
+'\n' Text
+
+"'0" Literal.Number
+' ' Text
+"'1" Literal.Number
+' ' Text
+"'x" Literal.Number
+' ' Text
+"'X" Literal.Number
+' ' Text
+"'z" Literal.Number
+' ' Text
+"'Z" Literal.Number
+'\n' Text
+
+'\n' Text
+
+'42' Literal.Number.Integer
+' ' Text
+'1234_5678' Literal.Number.Integer
+'\n' Text
diff --git a/tests/snippets/systemverilog/test_operators.txt b/tests/snippets/systemverilog/test_operators.txt
new file mode 100644
index 00000000..5c8dc2e1
--- /dev/null
+++ b/tests/snippets/systemverilog/test_operators.txt
@@ -0,0 +1,213 @@
+# See 1800-2017 Table 11-2: Operator Precedence and Associativity
+# Note that the duplicates (unary/binary) have been removed,
+# ie '+', '-', '&', '|', '^', '~^', '^~'
+# Note: This is a inconsistent mix of operator and punctuation
+# Note: Operators would ideally be represented as one token: ':' ':' -> '::', '~' '&' -> '~&'
+
+---input---
+() [] :: .
++ - ! ~ & ~& | ~| ^ ~^ ^~ ++ --
+**
+* / %
+<< >> <<< >>>
+< <= > >= inside dist
+== != === !== ==? !=?
+&&
+||
+?:
+-> <->
+= += -= *= /= %= &= ^= |= <<= >>= <<<= >>>= := :/ <=
+{} {{}}
+
+---tokens---
+'(' Punctuation
+')' Punctuation
+' ' Text
+'[' Punctuation
+']' Punctuation
+' ' Text
+':' Operator
+':' Operator
+' ' Text
+'.' Punctuation
+'\n' Text
+
+'+' Operator
+' ' Text
+'-' Operator
+' ' Text
+'!' Operator
+' ' Text
+'~' Operator
+' ' Text
+'&' Operator
+' ' Text
+'~' Operator
+'&' Operator
+' ' Text
+'|' Operator
+' ' Text
+'~' Operator
+'|' Operator
+' ' Text
+'^' Operator
+' ' Text
+'~' Operator
+'^' Operator
+' ' Text
+'^' Operator
+'~' Operator
+' ' Text
+'+' Operator
+'+' Operator
+' ' Text
+'-' Operator
+'-' Operator
+'\n' Text
+
+'*' Operator
+'*' Operator
+'\n' Text
+
+'*' Operator
+' ' Text
+'/' Operator
+' ' Text
+'%' Operator
+'\n' Text
+
+'<' Operator
+'<' Operator
+' ' Text
+'>' Operator
+'>' Operator
+' ' Text
+'<' Operator
+'<' Operator
+'<' Operator
+' ' Text
+'>' Operator
+'>' Operator
+'>' Operator
+'\n' Text
+
+'<' Operator
+' ' Text
+'<' Operator
+'=' Operator
+' ' Text
+'>' Operator
+' ' Text
+'>' Operator
+'=' Operator
+' ' Text
+'inside' Operator.Word
+' ' Text
+'dist' Operator.Word
+'\n' Text
+
+'=' Operator
+'=' Operator
+' ' Text
+'!' Operator
+'=' Operator
+' ' Text
+'=' Operator
+'=' Operator
+'=' Operator
+' ' Text
+'!' Operator
+'=' Operator
+'=' Operator
+' ' Text
+'=' Operator
+'=' Operator
+'?' Operator
+' ' Text
+'!' Operator
+'=' Operator
+'?' Operator
+'\n' Text
+
+'&' Operator
+'&' Operator
+'\n' Text
+
+'|' Operator
+'|' Operator
+'\n' Text
+
+'?' Operator
+':' Operator
+'\n' Text
+
+'-' Operator
+'>' Operator
+' ' Text
+'<' Operator
+'-' Operator
+'>' Operator
+'\n' Text
+
+'=' Operator
+' ' Text
+'+' Operator
+'=' Operator
+' ' Text
+'-' Operator
+'=' Operator
+' ' Text
+'*' Operator
+'=' Operator
+' ' Text
+'/' Operator
+'=' Operator
+' ' Text
+'%' Operator
+'=' Operator
+' ' Text
+'&' Operator
+'=' Operator
+' ' Text
+'^' Operator
+'=' Operator
+' ' Text
+'|' Operator
+'=' Operator
+' ' Text
+'<' Operator
+'<' Operator
+'=' Operator
+' ' Text
+'>' Operator
+'>' Operator
+'=' Operator
+' ' Text
+'<' Operator
+'<' Operator
+'<' Operator
+'=' Operator
+' ' Text
+'>' Operator
+'>' Operator
+'>' Operator
+'=' Operator
+' ' Text
+':' Operator
+'=' Operator
+' ' Text
+':' Operator
+'/' Operator
+' ' Text
+'<' Operator
+'=' Operator
+'\n' Text
+
+'{' Punctuation
+'}' Punctuation
+' ' Text
+'{' Punctuation
+'{' Punctuation
+'}' Punctuation
+'}' Punctuation
+'\n' Text