Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Birb: Fixed class name false positives #3111

Merged
merged 1 commit into from Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.