summaryrefslogtreecommitdiff
path: root/tests/examplefiles
diff options
context:
space:
mode:
authoramitkummer <49096391+amitkummer@users.noreply.github.com>2022-01-06 13:05:25 +0200
committerGitHub <noreply@github.com>2022-01-06 12:05:25 +0100
commitbd6d6826bd19faac9d30016e2fd42a5f7996df15 (patch)
treea55360acfdbdd3e0f31683fa1af2e0cab421d788 /tests/examplefiles
parent8fdd6b9879a6c34b908fa03a6ff15f764192a54e (diff)
downloadpygments-git-bd6d6826bd19faac9d30016e2fd42a5f7996df15.tar.gz
CFamily: improve label detection (#2022)
* Remove unused variable This variable is unused since the first commit to this file in the commit history, so it's probably safe to remove it. * Lex identifier as label only if it's at line start * Stop matching identifiers that begin with a digit This is so we don't match numbers as labels with the new labels rule. * Add label tests * Fix existing tests
Diffstat (limited to 'tests/examplefiles')
-rw-r--r--tests/examplefiles/c/ceval.c.output4
-rw-r--r--tests/examplefiles/c/example.c.output4
-rw-r--r--tests/examplefiles/c/labels.c14
-rw-r--r--tests/examplefiles/c/labels.c.output94
-rw-r--r--tests/examplefiles/charmci/Charmci.ci.output4
-rw-r--r--tests/examplefiles/ec/test.ec.output64
-rw-r--r--tests/examplefiles/objective-c/objc_example.m.output8
-rw-r--r--tests/examplefiles/swig/swig_java.swg.output12
8 files changed, 156 insertions, 48 deletions
diff --git a/tests/examplefiles/c/ceval.c.output b/tests/examplefiles/c/ceval.c.output
index 627bc4d8..a866c23c 100644
--- a/tests/examplefiles/c/ceval.c.output
+++ b/tests/examplefiles/c/ceval.c.output
@@ -15726,9 +15726,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'Py_True' Name.Label
+'Py_True' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'Py_False' Name
';' Punctuation
diff --git a/tests/examplefiles/c/example.c.output b/tests/examplefiles/c/example.c.output
index 7c23cc26..3def82e7 100644
--- a/tests/examplefiles/c/example.c.output
+++ b/tests/examplefiles/c/example.c.output
@@ -13441,8 +13441,8 @@
'(' Punctuation
')' Punctuation
'?' Operator
-'sort_1' Name.Label
-':' Punctuation
+'sort_1' Name
+':' Operator
'sort_2' Name
',' Punctuation
' ' Text.Whitespace
diff --git a/tests/examplefiles/c/labels.c b/tests/examplefiles/c/labels.c
new file mode 100644
index 00000000..04e7f76c
--- /dev/null
+++ b/tests/examplefiles/c/labels.c
@@ -0,0 +1,14 @@
+int id() {
+ id:
+ int i = true ? 1 : 2;
+ default_value:
+
+ switch (2) {
+ case Qfalse:
+ break;
+ case Qnil:
+ return Qnil;
+ default:
+ return 0;
+ }
+}
diff --git a/tests/examplefiles/c/labels.c.output b/tests/examplefiles/c/labels.c.output
new file mode 100644
index 00000000..8eddeb47
--- /dev/null
+++ b/tests/examplefiles/c/labels.c.output
@@ -0,0 +1,94 @@
+'int' Keyword.Type
+' ' Text.Whitespace
+'id' Name.Function
+'(' Punctuation
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'id' Name.Label
+':' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'int' Keyword.Type
+' ' Text.Whitespace
+'i' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'true' Name.Builtin
+' ' Text.Whitespace
+'?' Operator
+' ' Text.Whitespace
+'1' Literal.Number.Integer
+' ' Text.Whitespace
+':' Operator
+' ' Text.Whitespace
+'2' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'default_value' Name.Label
+':' Punctuation
+'\n' Text.Whitespace
+
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'switch' Keyword
+' ' Text.Whitespace
+'(' Punctuation
+'2' Literal.Number.Integer
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'case' Keyword
+' ' Text.Whitespace
+'Qfalse' Name.Label
+':' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'break' Keyword
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'case' Keyword
+' ' Text.Whitespace
+'Qnil' Name.Label
+':' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'return' Keyword
+' ' Text.Whitespace
+'Qnil' Name
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'default' Keyword
+':' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'return' Keyword
+' ' Text.Whitespace
+'0' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'}' Punctuation
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/examplefiles/charmci/Charmci.ci.output b/tests/examplefiles/charmci/Charmci.ci.output
index 1fc2afbc..8a4fbbab 100644
--- a/tests/examplefiles/charmci/Charmci.ci.output
+++ b/tests/examplefiles/charmci/Charmci.ci.output
@@ -94,9 +94,9 @@
'migratable' Keyword
']' Punctuation
' ' Text.Whitespace
-'ckcallback_group' Name.Label
+'ckcallback_group' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'IrrGroup' Name
' ' Text.Whitespace
diff --git a/tests/examplefiles/ec/test.ec.output b/tests/examplefiles/ec/test.ec.output
index 14d13dec..9cdcc6fe 100644
--- a/tests/examplefiles/ec/test.ec.output
+++ b/tests/examplefiles/ec/test.ec.output
@@ -2544,9 +2544,9 @@
' ' Text.Whitespace
'class' Keyword
' ' Text.Whitespace
-'AnchorButton' Name.Label
+'AnchorButton' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'Button' Name
'\n' Text.Whitespace
@@ -2897,9 +2897,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
';' Punctuation
@@ -2928,9 +2928,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
';' Punctuation
@@ -2959,9 +2959,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
';' Punctuation
@@ -2990,9 +2990,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
';' Punctuation
@@ -4123,9 +4123,9 @@
' ' Text.Whitespace
'class' Keyword
' ' Text.Whitespace
-'AnchorRelButton' Name.Label
+'AnchorRelButton' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'Button' Name
'\n' Text.Whitespace
@@ -4736,9 +4736,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'relative' Name.Label
+'relative' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'(' Punctuation
'anchor' Name
@@ -4749,9 +4749,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
')' Punctuation
@@ -4781,9 +4781,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'relative' Name.Label
+'relative' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'(' Punctuation
'anchor' Name
@@ -4794,9 +4794,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
')' Punctuation
@@ -4826,9 +4826,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'relative' Name.Label
+'relative' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'(' Punctuation
'anchor' Name
@@ -4839,9 +4839,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
')' Punctuation
@@ -4871,9 +4871,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'relative' Name.Label
+'relative' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'(' Punctuation
'anchor' Name
@@ -4884,9 +4884,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'offset' Name.Label
+'offset' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'none' Name
')' Punctuation
@@ -5911,9 +5911,9 @@
' ' Text.Whitespace
'class' Keyword
' ' Text.Whitespace
-'AnchorEditor' Name.Label
+'AnchorEditor' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'Window' Name
'\n' Text.Whitespace
@@ -6019,9 +6019,9 @@
' ' Text.Whitespace
'class' Keyword
' ' Text.Whitespace
-'AnchorDropBox' Name.Label
+'AnchorDropBox' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'DropBox' Name
'\n' Text.Whitespace
diff --git a/tests/examplefiles/objective-c/objc_example.m.output b/tests/examplefiles/objective-c/objc_example.m.output
index 96d6ce12..2ab4cd35 100644
--- a/tests/examplefiles/objective-c/objc_example.m.output
+++ b/tests/examplefiles/objective-c/objc_example.m.output
@@ -951,8 +951,8 @@
'[' Punctuation
'NSDictionary' Name.Builtin.Pseudo
' ' Text.Whitespace
-'dictionaryWithObjectsAndKeys' Name.Label
-':' Punctuation
+'dictionaryWithObjectsAndKeys' Name
+':' Operator
'\n' Text.Whitespace
' ' Text.Whitespace
@@ -1030,8 +1030,8 @@
'[' Punctuation
'dictionary' Name
' ' Text.Whitespace
-'valueForKey' Name.Label
-':' Punctuation
+'valueForKey' Name
+':' Operator
'key' Name
']' Punctuation
')' Punctuation
diff --git a/tests/examplefiles/swig/swig_java.swg.output b/tests/examplefiles/swig/swig_java.swg.output
index cfeee793..0b51207a 100644
--- a/tests/examplefiles/swig/swig_java.swg.output
+++ b/tests/examplefiles/swig/swig_java.swg.output
@@ -12527,9 +12527,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'null' Name.Label
+'null' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'new' Keyword
' ' Text.Whitespace
@@ -12589,9 +12589,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'null' Name.Label
+'null' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'new' Keyword
' ' Text.Whitespace
@@ -12717,9 +12717,9 @@
' ' Text.Whitespace
'?' Operator
' ' Text.Whitespace
-'null' Name.Label
+'null' Name
' ' Text.Whitespace
-':' Punctuation
+':' Operator
' ' Text.Whitespace
'new' Keyword
' ' Text.Whitespace