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

Feat: BBj Langauge Support #3511

Merged
merged 15 commits into from Jul 29, 2022
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion components.json
Expand Up @@ -225,6 +225,10 @@
},
"owner": "RunDevelopment"
},
"bbj": {
"title": "BBj",
"owner": "hyyan"
},
"bicep": {
"title": "Bicep",
"owner": "johnnyreilly"
Expand Down Expand Up @@ -266,7 +270,7 @@
"oscript": "OneScript"
},
"owner": "Diversus23"
},
},
hyyan marked this conversation as resolved.
Show resolved Hide resolved
"c": {
"title": "C",
"require": "clike",
Expand Down
21 changes: 21 additions & 0 deletions components/prism-bbj.js
@@ -0,0 +1,21 @@
(function (Prism) {
Prism.languages.bbj = {
'comment': [
{
pattern: /(^|[^\\:])rem\s+.*/i,
lookbehind: true,
greedy: true
}
],
hyyan marked this conversation as resolved.
Show resolved Hide resolved
'string': {
pattern: /"(?:""|[!#$%&'()*,\/:;<=>?^\w +\-.])*"/,
greedy: true
},
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
'keyword': /\b(?:abstract|all|argc|auto|begin|boolean|break|bye|case|catch|char|chn|class|classend|continue|ctl|day|declare|delete|dom|double|dread|dsz|else|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|new|next|on|opts|pfx|private|process_events|protected|psz|public|read_resource|remove_callback|restore|return|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|step|strictfp|super|swend|sys|then|this|throws|tim|to|try|unt|until|use|void|volatile|wend|where|while)\b/i,
hyyan marked this conversation as resolved.
Show resolved Hide resolved
'function': /\b\w+(?=\()/,
'boolean': /\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,
'punctuation': /[,;:()]/
hyyan marked this conversation as resolved.
Show resolved Hide resolved
};
}(Prism));
1 change: 1 addition & 0 deletions components/prism-bbj.min.js

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

83 changes: 83 additions & 0 deletions examples/prism-bbj.html
@@ -0,0 +1,83 @@
<h2>Comments</h2>
<pre><code>rem Single line comment
rem /**
rem * This file is part of the X plugin.
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */</code></pre>
hyyan marked this conversation as resolved.
Show resolved Hide resolved

<h2>Strings</h2>
<pre><code>"foo \"bar\" baz";</code></pre>

<h2>Numbers</h2>
<pre><code>123
123.456
-123.456
0xaf
0xAF
</code></pre>

<h2>Routines example</h2>
<pre><code>
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use com.basiscomponents.db.ResultSet
use com.basiscomponents.bc.SqlQueryBC

declare auto BBjTopLevelWindow wnd!
wnd! = BBjAPI().openSysGui("X0").addWindow(10, 10, 800, 600, "My First Grid")
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye")

gosub main
process_events

rem Retrieve the data from the database and configure the grid
main:
declare SqlQueryBC sbc!
declare ResultSet rs!
declare BBjGridExWidget grid!

sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT * FROM CDINVENTORY")

grid! = new BBjGridExWidget(wnd!, 100, 0, 0, 800, 600)
grid!.setData(rs!)
return

byebye:
bye
</code></pre>

<h2>OOP example</h2>
<pre><code>
use java.util.Arrays
use java.util.ArrayList
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget

rem /**
rem * This file is part of the MyPackage.
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
rem /**

class public Employee
field public BBjNumber ID
field public BBjString Name$
classend

class public Salaried extends Employee implements Payable
field public BBjNumber MonthlySalary
method public BBjNumber pay()
methodret #MonthlySalary
methodend
method public void print()
print "Employee",#getID(),": ",#getName()
print #pay():"($###,###.00)"
methodend
method public BBjNumber account()
methodret 11111
methodend
classend
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -56,6 +56,7 @@
"gawk": "GAWK",
"basic": "BASIC",
"bbcode": "BBcode",
"bbj": "BBj",
"bnf": "BNF",
"rbnf": "RBNF",
"bsl": "BSL (1C:Enterprise)",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

13 changes: 13 additions & 0 deletions tests/languages/bbj/boolean_feature.test
@@ -0,0 +1,13 @@
BBjAPI.FALSE
BBjAPI.TRUE

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

[
["boolean", "BBjAPI.FALSE"],
["boolean", "BBjAPI.TRUE"]
]

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

Checks for booleans.
25 changes: 25 additions & 0 deletions tests/languages/bbj/comment_feature.test
@@ -0,0 +1,25 @@
rem Single line comment

rem /**
rem * This file is part of the X plugin.
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */

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

[
["comment", "rem Single line comment"],

["comment", "rem /**"],
["comment", "rem * This file is part of the X plugin."],
["comment", "rem *"],
["comment", "rem * For the full copyright and license information, please view the LICENSE"],
["comment", "rem * file that was distributed with this source code."],
["comment", "rem */"]
]

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

Checks for comments.
112 changes: 112 additions & 0 deletions tests/languages/bbj/keyword_feature.test
@@ -0,0 +1,112 @@
abstract all argc auto begin boolean break bye case catch char chn class classend continue ctl day declare
delete dom double dread dsz else endif err exitto extends extends fi field field for from gosub goto if implements
implements interface interfaceend iol iolist let list load method methodend methodret new new next on opts
pfx private private process_events protected psz public read_resource remove_callback restore return rev
seterr setesc sqlchn sqlunt ssn start static step strictfp super swend sys then this throws tim to try
unt until use void volatile wend where while

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

[
["keyword", "abstract"],
["keyword", "all"],
["keyword", "argc"],
["keyword", "auto"],
["keyword", "begin"],
["keyword", "boolean"],
["keyword", "break"],
["keyword", "bye"],
["keyword", "case"],
["keyword", "catch"],
["keyword", "char"],
["keyword", "chn"],
["keyword", "class"],
["keyword", "classend"],
["keyword", "continue"],
["keyword", "ctl"],
["keyword", "day"],
["keyword", "declare"],

["keyword", "delete"],
["keyword", "dom"],
["keyword", "double"],
["keyword", "dread"],
["keyword", "dsz"],
["keyword", "else"],
["keyword", "endif"],
["keyword", "err"],
["keyword", "exitto"],
["keyword", "extends"],
["keyword", "extends"],
["keyword", "fi"],
["keyword", "field"],
["keyword", "field"],
["keyword", "for"],
["keyword", "from"],
["keyword", "gosub"],
["keyword", "goto"],
["keyword", "if"],
["keyword", "implements"],

["keyword", "implements"],
["keyword", "interface"],
["keyword", "interfaceend"],
["keyword", "iol"],
["keyword", "iolist"],
["keyword", "let"],
["keyword", "list"],
["keyword", "load"],
["keyword", "method"],
["keyword", "methodend"],
["keyword", "methodret"],
["keyword", "new"],
["keyword", "new"],
["keyword", "next"],
["keyword", "on"],
["keyword", "opts"],

["keyword", "pfx"],
["keyword", "private"],
["keyword", "private"],
["keyword", "process_events"],
["keyword", "protected"],
["keyword", "psz"],
["keyword", "public"],
["keyword", "read_resource"],
["keyword", "remove_callback"],
["keyword", "restore"],
["keyword", "return"],
["keyword", "rev"],

["keyword", "seterr"],
["keyword", "setesc"],
["keyword", "sqlchn"],
["keyword", "sqlunt"],
["keyword", "ssn"],
["keyword", "start"],
["keyword", "static"],
["keyword", "step"],
["keyword", "strictfp"],
["keyword", "super"],
["keyword", "swend"],
["keyword", "sys"],
["keyword", "then"],
["keyword", "this"],
["keyword", "throws"],
["keyword", "tim"],
["keyword", "to"],
["keyword", "try"],

["keyword", "unt"],
["keyword", "until"],
["keyword", "use"],
["keyword", "void"],
["keyword", "volatile"],
["keyword", "wend"],
["keyword", "where"],
["keyword", "while"]
]

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

Checks for keywords.
19 changes: 19 additions & 0 deletions tests/languages/bbj/number_feature.test
@@ -0,0 +1,19 @@
42
3.14159
2e8
3.4E-9
0.7E+12

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

[
["number", "42"],
["number", "3.14159"],
["number", "2e8"],
["number", "3.4E-9"],
["number", "0.7E+12"]
]

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

Checks for numbers.