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 3 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
25 changes: 25 additions & 0 deletions components/prism-birb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Prism.languages.birb = Prism.languages.extend('clike', {
'class-name': [
/\b[A-Z](?:\w*[a-zA-Z]\w*)?\b/,
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
/\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
],
'keyword': /\b(?:assert|bool|break|case|class|const|default|double|else|enum|final|follows|for|grab|if|int|nest|next|new|noSeeb|return|static|switch|throw|var|void|while)\b/,
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
'variable': /[a-z_]\w*/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'function': [
Prism.languages.clike.function,
{
pattern: /[a-z_]\w*\(\)/,
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
greedy: true
}
],
'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", "("],
["keyword", "int"],
["variable", "a"],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],

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

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

Checks for functions.
43 changes: 43 additions & 0 deletions tests/languages/birb/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
assert
bool break case
class;
const default double
else enum
final
follows;
for grab
if int List
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
Map nest
next;
new;
noSeeb return Source
static String
StrBuffer switch
throw var
void while

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

[
["keyword", "assert"],
["keyword", "bool"], ["keyword", "break"], ["keyword", "case"],
["keyword", "class"], ["punctuation", ";"],
["keyword", "const"], ["keyword", "default"], ["keyword", "double"],
["keyword", "else"], ["keyword", "enum"],
["keyword", "final"],
["keyword", "follows"], ["punctuation", ";"],
["keyword", "for"], ["keyword", "grab"],
["keyword", "if"], ["keyword", "int"], ["class-name", "List"],
["class-name", "Map"], ["keyword", "nest"],
["keyword", "next"], ["punctuation", ";"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "noSeeb"], ["keyword", "return"], ["class-name", "Source"],
["keyword", "static"], ["class-name", "String"],
["class-name", "StrBuffer"], ["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 @@
++ --
* / % ~/
+ - ! ~
<< >> ?
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
& ^ |
>= > <= <
== != && ||
= *= /=
%= += -=

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

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

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

[
["string", "\"\""], ["string", "''"],
["string", "\"fo\\\"o\""], ["string", "'fo\\'o'"]
]

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

Checks for single and double quoted strings
62 changes: 31 additions & 31 deletions tests/languages/java/function_featrue.test
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
void foo(int a) {}
Calamity210 marked this conversation as resolved.
Show resolved Hide resolved
foo(0);
Bar::foo;

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

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

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

["class-name", "Bar"],
["operator", "::"],
["function", "foo"],
["punctuation", ";"]
]

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

Checks for functions.
void foo(int a) {}
foo(0);
Bar::foo;
----------------------------------------------------
[
["keyword", "void"],
["function", "foo"],
["punctuation", "("],
["keyword", "int"],
" a",
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
["function", "foo"],
["punctuation", "("],
["number", "0"],
["punctuation", ")"],
["punctuation", ";"],
["class-name", "Bar"],
["operator", "::"],
["function", "foo"],
["punctuation", ";"]
]
----------------------------------------------------
Checks for functions.