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

Added support for Birb #2542

Merged
merged 6 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/,
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
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/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>:]=?|\?/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
});

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.
19 changes: 19 additions & 0 deletions tests/languages/birb/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"" ''
"fo\"o" 'fo\'o'
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
'foo
bar'
"foo
bar"

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

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

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

Checks for single quoted, double quoted, and multiline strings