Skip to content

Commit

Permalink
Added support for Birb (#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Calamity210 committed Sep 11, 2020
1 parent bfb3674 commit 4d31e22
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@
},
"owner": "RunDevelopment"
},
"birb": {
"title": "Birb",
"require": "clike",
"owner": "Calamity210"
},
"bison": {
"title": "Bison",
"require": "c",
Expand Down
23 changes: 23 additions & 0 deletions components/prism-birb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Prism.languages.birb = Prism.languages.extend('clike', {
'class-name': [
/\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*[;,=()])/
],
'string': {
pattern: /r?("|')(?:\\.|(?!\1)[^\\])*\1/,
greedy: true
},
'keyword': /\b(?:assert|break|case|class|const|default|else|enum|final|follows|for|grab|if|nest|next|new|noSeeb|return|static|switch|throw|var|void|while)\b/,
'variable': /\b[a-z_]\w*\b/,
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?|:/,
});

Prism.languages.insertBefore('birb','function',{
'metadata': {
pattern: /<\w+>/,
greedy: true,
alias: 'symbol'
}
});
1 change: 1 addition & 0 deletions components/prism-birb.min.js

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

31 changes: 31 additions & 0 deletions examples/prism-birb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h2>Comments</h2>
<pre><code>// Single line comment
/* Block comment
on multiple lines */</code></pre>

<h2>Annotations</h2>
<pre><code>&lt;Supersede&gt; // marks an instance member as overriding a superclass</code></pre>

<h2>Numbers</h2>
<pre><code>int x = 1;
double y = 1.1;
</code></pre>

<h2>Strings</h2>
<pre><code>String s1 = 'Strings allow single quotes';
String s2 = "as well as double quotes";
var s2 = 'Birb strings are
multiline by default';</code></pre>

<h2>Full example</h2>
<pre><code>class Birb {
final String name;
int age = 19;

void construct(String newName){
nest.name = newName;
}
}
Birb.construct('Yoko');
screm(Birb.name);
</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"markup",
"csharp"
],
"birb": "clike",
"bison": "c",
"c": "clike",
"csharp": "clike",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

25 changes: 25 additions & 0 deletions tests/languages/birb/function_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
void foo(int a) {}
foo(0);

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

[
["keyword", "void"],
["function", "foo"],
["punctuation", "("],
["variable", "int"],
["variable", "a"],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],

["function", "foo"],
["punctuation", "("],
["number", "0"],
["punctuation", ")"],
["punctuation", ";"]
]

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

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

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

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

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

Checks for all keywords.
11 changes: 11 additions & 0 deletions tests/languages/birb/metadata_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Supersede>

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

[
["metadata", "<Supersede>"]
]

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

Checks for metadata.
27 changes: 27 additions & 0 deletions tests/languages/birb/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
++ --
* / % ~/
+ - ! ~
<< >> ? :
& ^ |
>= > <= <
== != && ||
= *= /=
%= += -=

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

[
["operator", "++"], ["operator", "--"],
["operator", "*"], ["operator", "/"], ["operator", "%"], ["operator", "~/"],
["operator", "+"], ["operator", "-"], ["operator", "!"], ["operator", "~"],
["operator", "<<"], ["operator", ">>"], ["operator", "?"], ["operator", ":"],
["operator", "&"], ["operator", "^"], ["operator", "|"],
["operator", ">="], ["operator", ">"], ["operator", "<="], ["operator", "<"],
["operator", "=="], ["operator", "!="], ["operator", "&&"], ["operator", "||"],
["operator", "="], ["operator", "*="], ["operator", "/="],
["operator", "%="], ["operator", "+="], ["operator", "-="]
]

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

Checks for all operators.
21 changes: 21 additions & 0 deletions tests/languages/birb/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"" ''
r"" r''
"fo\"o" 'fo\'o'
'foo
bar'
"foo
bar"

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

[
["string", "\"\""], ["string", "''"],
["string", "r\"\""], ["string", "r''"],
["string", "\"fo\\\"o\""], ["string", "'fo\\'o'"],
["string", "'foo\r\nbar'"],
["string", "\"foo\r\nbar\""]
]

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

Checks for single quoted, double quoted, and multiline strings

0 comments on commit 4d31e22

Please sign in to comment.