Skip to content

Commit d7017be

Browse files
authoredOct 5, 2021
Birb: Fixed class name false positives (#3111)
1 parent 2f7f736 commit d7017be

File tree

5 files changed

+108
-25
lines changed

5 files changed

+108
-25
lines changed
 

‎components/prism-birb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Prism.languages.birb = Prism.languages.extend('clike', {
77
/\b[A-Z](?:[\d_]*[a-zA-Z]\w*)?\b/,
88

99
// matches variable and function return types (parameters as well).
10-
/\b[A-Z]\w*(?=\s+\w+\s*[;,=()])/
10+
/\b(?:[A-Z]\w*|(?!(?:var|void)\b)[a-z]\w*)(?=\s+\w+\s*[;,=()])/
1111
],
1212
'keyword': /\b(?:assert|break|case|class|const|default|else|enum|final|follows|for|grab|if|nest|new|next|noSeeb|return|static|switch|throw|var|void|while)\b/,
1313
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?|:/,

‎components/prism-birb.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
class Birb {
2+
String name = "Birb";
3+
int age = 5;
4+
bool isMale = true;
5+
6+
String getName() {
7+
return name;
8+
}
9+
}
10+
11+
List list = ["Seeb", 10, false];
12+
13+
----------------------------------------------------
14+
15+
[
16+
["keyword", "class"],
17+
["class-name", "Birb"],
18+
["punctuation", "{"],
19+
20+
["class-name", "String"],
21+
["variable", "name"],
22+
["operator", "="],
23+
["string", "\"Birb\""],
24+
["punctuation", ";"],
25+
26+
["class-name", "int"],
27+
["variable", "age"],
28+
["operator", "="],
29+
["number", "5"],
30+
["punctuation", ";"],
31+
32+
["class-name", "bool"],
33+
["variable", "isMale"],
34+
["operator", "="],
35+
["boolean", "true"],
36+
["punctuation", ";"],
37+
38+
["class-name", "String"],
39+
["function", "getName"],
40+
["punctuation", "("],
41+
["punctuation", ")"],
42+
["punctuation", "{"],
43+
44+
["class-name", "return"],
45+
["variable", "name"],
46+
["punctuation", ";"],
47+
48+
["punctuation", "}"],
49+
50+
["punctuation", "}"],
51+
52+
["class-name", "List"],
53+
["variable", "list"],
54+
["operator", "="],
55+
["punctuation", "["],
56+
["string", "\"Seeb\""],
57+
["punctuation", ","],
58+
["number", "10"],
59+
["punctuation", ","],
60+
["boolean", "false"],
61+
["punctuation", "]"],
62+
["punctuation", ";"]
63+
]

‎tests/languages/birb/function_feature.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ foo(0);
77
["keyword", "void"],
88
["function", "foo"],
99
["punctuation", "("],
10-
["variable", "int"],
10+
["class-name", "int"],
1111
["variable", "a"],
1212
["punctuation", ")"],
1313
["punctuation", "{"],
@@ -22,4 +22,4 @@ foo(0);
2222

2323
----------------------------------------------------
2424

25-
Checks for functions.
25+
Checks for functions.
+41-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
1-
assert break case
1+
assert;
2+
break;
3+
case;
24
class;
3-
const default
4-
else enum
5-
final
5+
const;
6+
default;
7+
else;
8+
enum;
9+
final;
610
follows;
7-
for grab
8-
if nest
11+
for;
12+
grab;
13+
if;
14+
nest;
915
next;
1016
new;
11-
noSeeb return
12-
static switch
13-
throw var
14-
void while
17+
noSeeb;
18+
return;
19+
static;
20+
switch;
21+
throw;
22+
var;
23+
void;
24+
while;
1525

1626
----------------------------------------------------
1727

1828
[
19-
["keyword", "assert"], ["keyword", "break"], ["keyword", "case"],
29+
["keyword", "assert"], ["punctuation", ";"],
30+
["keyword", "break"], ["punctuation", ";"],
31+
["keyword", "case"], ["punctuation", ";"],
2032
["keyword", "class"], ["punctuation", ";"],
21-
["keyword", "const"], ["keyword", "default"],
22-
["keyword", "else"], ["keyword", "enum"],
23-
["keyword", "final"],
33+
["keyword", "const"], ["punctuation", ";"],
34+
["keyword", "default"], ["punctuation", ";"],
35+
["keyword", "else"], ["punctuation", ";"],
36+
["keyword", "enum"], ["punctuation", ";"],
37+
["keyword", "final"], ["punctuation", ";"],
2438
["keyword", "follows"], ["punctuation", ";"],
25-
["keyword", "for"], ["keyword", "grab"],
26-
["keyword", "if"], ["keyword", "nest"],
39+
["keyword", "for"], ["punctuation", ";"],
40+
["keyword", "grab"], ["punctuation", ";"],
41+
["keyword", "if"], ["punctuation", ";"],
42+
["keyword", "nest"], ["punctuation", ";"],
2743
["keyword", "next"], ["punctuation", ";"],
2844
["keyword", "new"], ["punctuation", ";"],
29-
["keyword", "noSeeb"], ["keyword", "return"],
30-
["keyword", "static"], ["keyword", "switch"],
31-
["keyword", "throw"], ["keyword", "var"],
32-
["keyword", "void"], ["keyword", "while"]
45+
["keyword", "noSeeb"], ["punctuation", ";"],
46+
["keyword", "return"], ["punctuation", ";"],
47+
["keyword", "static"], ["punctuation", ";"],
48+
["keyword", "switch"], ["punctuation", ";"],
49+
["keyword", "throw"], ["punctuation", ";"],
50+
["keyword", "var"], ["punctuation", ";"],
51+
["keyword", "void"], ["punctuation", ";"],
52+
["keyword", "while"], ["punctuation", ";"]
3353
]
3454

3555
----------------------------------------------------
3656

37-
Checks for all keywords.
57+
Checks for all keywords.

0 commit comments

Comments
 (0)
Please sign in to comment.