Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BBj Langauge Support (#3511)
Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
  • Loading branch information
hyyan and RunDevelopment committed Jul 29, 2022
1 parent 342a003 commit 1134bdf
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Expand Up @@ -225,6 +225,10 @@
},
"owner": "RunDevelopment"
},
"bbj": {
"title": "BBj",
"owner": "hyyan"
},
"bicep": {
"title": "Bicep",
"owner": "johnnyreilly"
Expand Down
19 changes: 19 additions & 0 deletions components/prism-bbj.js
@@ -0,0 +1,19 @@
(function (Prism) {
Prism.languages.bbj = {
'comment': {
pattern: /(^|[^\\:])rem\s+.*/i,
lookbehind: true,
greedy: true
},
'string': {
pattern: /"(?:""|[!#$%&'()*,\/:;<=>?^\w +\-.])*"/,
greedy: true
},
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
'keyword': /\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|delete|dom|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|on|opts|pfx|private|process_events|protected|psz|public|read_resource|remove_callback|restore|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,
'function': /\b\w+(?=\()/,
'boolean': /\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,
'punctuation': /[.,;:()]/
};
}(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.

63 changes: 63 additions & 0 deletions examples/prism-bbj.html
@@ -0,0 +1,63 @@
<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.
94 changes: 94 additions & 0 deletions tests/languages/bbj/keyword_feature.test
@@ -0,0 +1,94 @@
abstract all argc begin bye callback case chn class classend ctl day delete dom dread dsz else
endif err exitto extends fi field field for from gosub goto if implements interface interfaceend
iol iolist let list load method methodend methodret on opts pfx private private process_events
protected protected psz public public read_resource remove_callback restore rev seterr setesc sqlchn
sqlunt ssn start static static swend switch sys then tim unt until void void wend where while use

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

[
["keyword", "abstract"],
["keyword", "all"],
["keyword", "argc"],
["keyword", "begin"],
["keyword", "bye"],
["keyword", "callback"],
["keyword", "case"],
["keyword", "chn"],
["keyword", "class"],
["keyword", "classend"],
["keyword", "ctl"],
["keyword", "day"],
["keyword", "delete"],
["keyword", "dom"],
["keyword", "dread"],
["keyword", "dsz"],
["keyword", "else"],

["keyword", "endif"],
["keyword", "err"],
["keyword", "exitto"],
["keyword", "extends"],
["keyword", "fi"],
["keyword", "field"],
["keyword", "field"],
["keyword", "for"],
["keyword", "from"],
["keyword", "gosub"],
["keyword", "goto"],
["keyword", "if"],
["keyword", "implements"],
["keyword", "interface"],
["keyword", "interfaceend"],

["keyword", "iol"],
["keyword", "iolist"],
["keyword", "let"],
["keyword", "list"],
["keyword", "load"],
["keyword", "method"],
["keyword", "methodend"],
["keyword", "methodret"],
["keyword", "on"],
["keyword", "opts"],
["keyword", "pfx"],
["keyword", "private"],
["keyword", "private"],
["keyword", "process_events"],

["keyword", "protected"],
["keyword", "protected"],
["keyword", "psz"],
["keyword", "public"],
["keyword", "public"],
["keyword", "read_resource"],
["keyword", "remove_callback"],
["keyword", "restore"],
["keyword", "rev"],
["keyword", "seterr"],
["keyword", "setesc"],
["keyword", "sqlchn"],

["keyword", "sqlunt"],
["keyword", "ssn"],
["keyword", "start"],
["keyword", "static"],
["keyword", "static"],
["keyword", "swend"],
["keyword", "switch"],
["keyword", "sys"],
["keyword", "then"],
["keyword", "tim"],
["keyword", "unt"],
["keyword", "until"],
["keyword", "void"],
["keyword", "void"],
["keyword", "wend"],
["keyword", "where"],
["keyword", "while"],
["keyword", "use"]
]

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

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.
21 changes: 21 additions & 0 deletions tests/languages/bbj/operator_feature.test
@@ -0,0 +1,21 @@
or xor not and > >= < <= + =*

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

[
["operator", "or"],
["operator", "xor"],
["operator", "not"],
["operator", "and"],
["operator", ">"],
["operator", ">="],
["operator", "<"],
["operator", "<="],
["operator", "+"],
["operator", "="],
["operator", "*"]
]

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

Checks for operators.
12 changes: 12 additions & 0 deletions tests/languages/bbj/punctuation_feature.test
@@ -0,0 +1,12 @@
, ; : ( ) .

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

[
["punctuation", ","],
["punctuation", ";"],
["punctuation", ":"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "."]
]
13 changes: 13 additions & 0 deletions tests/languages/bbj/string_feature.test
@@ -0,0 +1,13 @@
""
"fo""obar"

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

[
["string", "\"\""],
["string", "\"fo\"\"obar\""]
]

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

Checks for strings.

0 comments on commit 1134bdf

Please sign in to comment.