Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Birb: Fixed class name false positives (#3111)
  • Loading branch information
RunDevelopment committed Oct 5, 2021
1 parent 2f7f736 commit d7017be
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 25 deletions.
2 changes: 1 addition & 1 deletion components/prism-birb.js
Expand Up @@ -7,7 +7,7 @@ Prism.languages.birb = Prism.languages.extend('clike', {
/\b[A-Z](?:[\d_]*[a-zA-Z]\w*)?\b/,

// matches variable and function return types (parameters as well).
/\b[A-Z]\w*(?=\s+\w+\s*[;,=()])/
/\b(?:[A-Z]\w*|(?!(?:var|void)\b)[a-z]\w*)(?=\s+\w+\s*[;,=()])/
],
'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/,
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?|:/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-birb.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions tests/languages/birb/class-name_feature.test
@@ -0,0 +1,63 @@
class Birb {
String name = "Birb";
int age = 5;
bool isMale = true;

String getName() {
return name;
}
}

List list = ["Seeb", 10, false];

----------------------------------------------------

[
["keyword", "class"],
["class-name", "Birb"],
["punctuation", "{"],

["class-name", "String"],
["variable", "name"],
["operator", "="],
["string", "\"Birb\""],
["punctuation", ";"],

["class-name", "int"],
["variable", "age"],
["operator", "="],
["number", "5"],
["punctuation", ";"],

["class-name", "bool"],
["variable", "isMale"],
["operator", "="],
["boolean", "true"],
["punctuation", ";"],

["class-name", "String"],
["function", "getName"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],

["class-name", "return"],
["variable", "name"],
["punctuation", ";"],

["punctuation", "}"],

["punctuation", "}"],

["class-name", "List"],
["variable", "list"],
["operator", "="],
["punctuation", "["],
["string", "\"Seeb\""],
["punctuation", ","],
["number", "10"],
["punctuation", ","],
["boolean", "false"],
["punctuation", "]"],
["punctuation", ";"]
]
4 changes: 2 additions & 2 deletions tests/languages/birb/function_feature.test
Expand Up @@ -7,7 +7,7 @@ foo(0);
["keyword", "void"],
["function", "foo"],
["punctuation", "("],
["variable", "int"],
["class-name", "int"],
["variable", "a"],
["punctuation", ")"],
["punctuation", "{"],
Expand All @@ -22,4 +22,4 @@ foo(0);

----------------------------------------------------

Checks for functions.
Checks for functions.
62 changes: 41 additions & 21 deletions tests/languages/birb/keyword_feature.test
@@ -1,37 +1,57 @@
assert break case
assert;
break;
case;
class;
const default
else enum
final
const;
default;
else;
enum;
final;
follows;
for grab
if nest
for;
grab;
if;
nest;
next;
new;
noSeeb return
static switch
throw var
void while
noSeeb;
return;
static;
switch;
throw;
var;
void;
while;

----------------------------------------------------

[
["keyword", "assert"], ["keyword", "break"], ["keyword", "case"],
["keyword", "assert"], ["punctuation", ";"],
["keyword", "break"], ["punctuation", ";"],
["keyword", "case"], ["punctuation", ";"],
["keyword", "class"], ["punctuation", ";"],
["keyword", "const"], ["keyword", "default"],
["keyword", "else"], ["keyword", "enum"],
["keyword", "final"],
["keyword", "const"], ["punctuation", ";"],
["keyword", "default"], ["punctuation", ";"],
["keyword", "else"], ["punctuation", ";"],
["keyword", "enum"], ["punctuation", ";"],
["keyword", "final"], ["punctuation", ";"],
["keyword", "follows"], ["punctuation", ";"],
["keyword", "for"], ["keyword", "grab"],
["keyword", "if"], ["keyword", "nest"],
["keyword", "for"], ["punctuation", ";"],
["keyword", "grab"], ["punctuation", ";"],
["keyword", "if"], ["punctuation", ";"],
["keyword", "nest"], ["punctuation", ";"],
["keyword", "next"], ["punctuation", ";"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "noSeeb"], ["keyword", "return"],
["keyword", "static"], ["keyword", "switch"],
["keyword", "throw"], ["keyword", "var"],
["keyword", "void"], ["keyword", "while"]
["keyword", "noSeeb"], ["punctuation", ";"],
["keyword", "return"], ["punctuation", ";"],
["keyword", "static"], ["punctuation", ";"],
["keyword", "switch"], ["punctuation", ";"],
["keyword", "throw"], ["punctuation", ";"],
["keyword", "var"], ["punctuation", ";"],
["keyword", "void"], ["punctuation", ";"],
["keyword", "while"], ["punctuation", ";"]
]

----------------------------------------------------

Checks for all keywords.
Checks for all keywords.

0 comments on commit d7017be

Please sign in to comment.