Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Enabled via `processors` config:
| C++ (Wasm) | `cpp-wasm`, `clang`, `wasm.cpp` | Clang WASM |
| Objective-C | `objc-wasm`, `objc`, `wasm.m` | Clang WASM |
| Objective-C++ | `objcpp-wasm`, `objcpp`, `wasm.mm` | Clang WASM |
| COBOL (Wasm) | `cobol-wasm`, `cobol`, `cob`, `cbl`, `cpy`, `gnucobol`, `wasm.cobol` | GnuCOBOL (COBOL -> WASM) |
| Java | `java` | Java runtime |
| C# | `csharp-wasm`, `cs`, `cs-wasm`, `wasm.cs` | C# WASM |
| Blazor (Wasm) | `blazor-wasm`, `blazor`, `razor`, `razor-wasm`, `wasm.razor` | Razor components rendered by Blazor (WASM) |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A [feature-rich](https://livecodes.io/docs/features/), open-source, **client-sid
[![LiveCodes: npm version](https://img.shields.io/npm/v/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: npm downloads](https://img.shields.io/npm/dm/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes)
[![LiveCodes: languages](https://img.shields.io/badge/languages-115-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: languages](https://img.shields.io/badge/languages-116-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/)
[![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt)
[![LiveCodes: llms-full.txt](https://img.shields.io/badge/llms--full.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms-full.txt)
Expand Down
156 changes: 156 additions & 0 deletions docs/docs/languages/cobol-wasm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# COBOL (Wasm)

COBOL is a compiled, imperative programming language designed for business data processing.

COBOL in LiveCodes is compiled to WebAssembly by the real [GnuCOBOL](https://gnucobol.sourceforge.io/)
compiler and run in the browser, with no server. The toolchain translates COBOL to C, compiles that
with Clang, links `libcob`, and runs the resulting WebAssembly module.

## Usage

Demo:

import LiveCodes from '../../src/components/LiveCodes.tsx';

export const cobolConfig = {
activeEditor: 'script',
script: {
language: 'cobol-wasm',
content: `IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.`,
},
mode: 'simple',
editor: 'auto',
tools: {
status: 'full',
},
};

<LiveCodes config={cobolConfig}></LiveCodes>

### Communication with JavaScript

The program runs in the context of the result page. A few helpers are available in the browser global
`livecodes.cobol` object:

- `livecodes.cobol.input`: the standard input passed to the program.
- `livecodes.cobol.loaded`: a promise that resolves when the compiler has downloaded and the program
has run, and rejects if the toolchain fails to load. Other helpers should be used after it resolves.
- `livecodes.cobol.output`: the program's output (stdout and stderr combined).
- `livecodes.cobol.error`: the compiler diagnostics, if the code failed to compile.
- `livecodes.cobol.exitCode`: the exit code of the program.
- `livecodes.cobol.run`: compiles and runs the code again with new input, returning a promise that
resolves with `output`, `error` and `exitCode`.

Example:

<LiveCodes template="cobol-wasm" params={{ activeEditor: 'markup' }} height="80vh"></LiveCodes>

```cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.
```

`ACCEPT` reads from the **stdin** pane, in the same way as the other console languages:

```cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. GREET.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(20).
PROCEDURE DIVISION.
ACCEPT WS-NAME
DISPLAY "Hello, " WS-NAME
STOP RUN.
```

## Language Info

### Name

`cobol-wasm`

### Aliases / Extensions

`cobol`, `cob`, `cbl`, `cpy`, `gnucobol`, `wasm.cobol`

### Editor

`script`

## Compiler

[GnuCOBOL](https://gnucobol.sourceforge.io/) 3.2 compiled to WebAssembly, with Clang and LLD for the
generated C.

### Custom Settings

The GnuCOBOL compiler can be configured through the `customSettings` object, under the `cobol-wasm`
key. The following options are supported:

- `sourceFormat`: the COBOL source format, `free` (the default) or `fixed`.
- `compileArgs`: extra GnuCOBOL (`cobc`) flags.
- `cCompileArgs`: extra Clang flags for the generated C.
- `args`: the program's command-line arguments.
- `fileName`: the name the source is compiled under (`main.cob` by default).

Example:

```js
const config = {
activeEditor: 'script',
script: {
language: 'cobol-wasm',
content: '...',
},
customSettings: {
'cobol-wasm': {
sourceFormat: 'fixed',
},
},
};
```

## Code Formatting

Not currently supported.

## Live Reload

By default, new code changes are sent to the result page for re-evaluation without a full page reload. This behavior can be disabled by adding the code comment `*> __livecodes_reload__` to the COBOL code, which forces a full page reload.

This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.mdx#markup) for embedded playgrounds.

## Example Usage

```cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. INVOICE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RATE PIC 9(3)V99 VALUE 25.50.
01 WS-HOURS PIC 9(3) VALUE 40.
01 WS-PAY PIC 9(5)V99.
PROCEDURE DIVISION.
COMPUTE WS-PAY = WS-RATE * WS-HOURS
DISPLAY "Rate: " WS-RATE
DISPLAY "Pay: " WS-PAY
STOP RUN.
```

## Starter Template

https://livecodes.io/?template=cobol-wasm

## Links

- [GnuCOBOL](https://gnucobol.sourceforge.io/)
- [Learn X in Y minutes, where X=COBOL](https://learnxinyminutes.com/docs/cobol/)
- [@live-codes/cobol-wasm](https://www.npmjs.com/package/@live-codes/cobol-wasm)
1 change: 1 addition & 0 deletions docs/src/components/LanguageSliders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function Sliders() {
{ name: 'cpp-wasm', title: 'C++ (Wasm)' },
{ name: 'objc-wasm', title: 'Objective-C (Wasm)' },
{ name: 'objcpp-wasm', title: 'Objective-C++ (Wasm)' },
{ name: 'cobol-wasm', title: 'COBOL (Wasm)' },
{ name: 'fortran', title: 'Fortran' },
{ name: 'rust-wasm', title: 'Rust (Wasm)' },
{ name: 'swift-wasm', title: 'Swift (Wasm)' },
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/TemplateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const templates = [
{ name: 'php-wasm', title: 'PHP (Wasm) Starter', thumbnail: 'php.svg' },
{ name: 'cpp', title: 'C++ Starter', thumbnail: 'cpp.svg' },
{ name: 'c-wasm', title: 'C (Wasm) Starter', thumbnail: 'c.svg' },
{ name: 'cobol-wasm', title: 'COBOL Starter', thumbnail: 'cobol.svg' },
{ name: 'fortran-wasm', title: 'Fortran Starter', thumbnail: 'fortran.svg' },
{ name: 'cpp-wasm', title: 'C++ (Wasm) Starter', thumbnail: 'cpp.svg' },
{ name: 'objc-wasm', title: 'Objective-C (Wasm) Starter', thumbnail: 'objective-c.svg' },
Expand Down
1 change: 1 addition & 0 deletions functions/vendors/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const starterTemplates = {
"c-wasm": "C (Wasm) Starter",
"cpp-wasm": "C++ (Wasm) Starter",
"objc-wasm": "Objective-C (Wasm) Starter",
"cobol-wasm": "COBOL Starter",
"fortran-wasm": "Fortran Starter",
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
Expand Down
1 change: 1 addition & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ const iifeBuild = () =>
'languages/cpp/lang-cpp-script.ts',
'languages/clang-wasm/lang-clang-wasm-script.ts',
'languages/fortran-wasm/lang-fortran-wasm-script.ts',
'languages/cobol-wasm/lang-cobol-wasm-script.ts',
'languages/go-wasm/lang-go-wasm-script.ts',
'languages/csharp-wasm/lang-csharp-wasm-script.ts',
'languages/fanak/lang-fanak-script.ts',
Expand Down
1 change: 1 addition & 0 deletions server/php/inc/starter-templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"c-wasm": "C (Wasm) Starter",
"cpp-wasm": "C++ (Wasm) Starter",
"objc-wasm": "Objective-C (Wasm) Starter",
"cobol-wasm": "COBOL Starter",
"fortran-wasm": "Fortran Starter",
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/UI/command-menu-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export const getCommandMenuActions = ({
'c-wasm',
'cpp-wasm',
'objc-wasm',
'cobol-wasm',
'fortran-wasm',
'rust-wasm',
'swift-wasm',
Expand Down
6 changes: 6 additions & 0 deletions src/livecodes/assets/templates/cobol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/livecodes/html/language-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,36 @@ <h3 data-i18n="language-info:cljsSelfhosted.name">CLJS (self-hosted)</h3>
</li>
</ul>
</section>
<section data-lang="cobol-wasm">
<h3 data-i18n="language-info:cobol-wasm.name">COBOL (Wasm)</h3>
<div data-i18n="language-info:cobol-wasm.desc" data-i18n-prop="innerHTML">
COBOL compiled to WebAssembly by the real
<a href="https://gnucobol.sourceforge.io/" target="_blank" rel="noopener">GnuCOBOL</a> compiler,
running entirely in the browser.
</div>
<ul data-i18n="language-info:cobol-wasm.link" data-i18n-prop="innerHTML">
<li>
<a href="https://gnucobol.sourceforge.io/" target="_blank" rel="noopener"
>GnuCOBOL official website</a
>
</li>
<li>
<a href="https://learnxinyminutes.com/docs/cobol/" target="_blank" rel="noopener"
>Learn X in Y minutes, where X=COBOL</a
>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/cobol-wasm" target="_blank" rel="noopener"
>LiveCodes Documentation</a
>
</li>
<li>
<a href="?template=cobol-wasm" class="button" target="_parent" data-template="cobol-wasm"
>Load starter template</a
>
</li>
</ul>
</section>
<section data-lang="coffeescript">
<h3 data-i18n="language-info:coffeescript.name">CoffeeScript</h3>
<div data-i18n="language-info:coffeescript.desc">Unfancy JavaScript.</div>
Expand Down
9 changes: 9 additions & 0 deletions src/livecodes/i18n/locales/ar/language-info.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
"clojurescript.link": {
"translation": "<tag-1> <tag-2>الموقع الرسمي لـ ClojureScript</tag-2> </tag-1> <tag-3> <tag-4>الموقع الرسمي لـ Clojure</tag-4> </tag-3> <tag-5> <tag-6>مستودع Cherry</tag-6> </tag-5> <tag-7> <tag-8>تعلم X في Y دقائق، حيث X=clojure</tag-8> </tag-7> <tag-9> <tag-10>وثائق LiveCodes</tag-10> </tag-9> <tag-11> <tag-12>تحميل القالب الأولي</tag-12> </tag-11>"
},
"cobol-wasm.desc": {
"translation": "يتم تجميع COBOL الحديثة إلى WebAssembly بواسطة <tag-1>GnuCOBOL</tag-1>، وتعمل بالكامل داخل المتصفح."
},
"cobol-wasm.link": {
"translation": "<tag-1> <tag-2>الموقع الرسمي لـ GnuCOBOL</tag-2> </tag-1> <tag-3> <tag-4>تعلم X في Y دقيقة، حيث X = COBOL</tag-4> </tag-3> <tag-5> <tag-6>وثائق LiveCodes</tag-6> </tag-5> <tag-7> <tag-8>تحميل قالب البدء</tag-8> </tag-7>"
},
"cobol-wasm.name": {
"translation": "COBOL (Wasm)"
},
"coffeescript.desc": {
"translation": "جافاسكريبت بسيطة."
},
Expand Down
5 changes: 5 additions & 0 deletions src/livecodes/i18n/locales/ar/language-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const languageInfo: I18nLangInfoTranslation = {
desc: 'ClojureScript هو مترجم لـ <1>Clojure</1> يستهدف JavaScript. <2></2>في LiveCodes، يعمل في المتصفح باستخدام <3>Cherry</3>.',
link: '<1> <2>الموقع الرسمي لـ ClojureScript</2> </1> <3> <4>الموقع الرسمي لـ Clojure</4> </3> <5> <6>مستودع Cherry</6> </5> <7> <8>تعلم X في Y دقائق، حيث X=clojure</8> </7> <9> <10>وثائق LiveCodes</10> </9> <11> <12>تحميل القالب الأولي</12> </11>',
},
'cobol-wasm': {
desc: 'يتم تجميع COBOL الحديثة إلى WebAssembly بواسطة <1>GnuCOBOL</1>، وتعمل بالكامل داخل المتصفح.',
link: '<1> <2>الموقع الرسمي لـ GnuCOBOL</2> </1> <3> <4>تعلم X في Y دقيقة، حيث X = COBOL</4> </3> <5> <6>وثائق LiveCodes</6> </5> <7> <8>تحميل قالب البدء</8> </7>',
name: 'COBOL (Wasm)',
},
coffeescript: {
desc: 'جافاسكريبت بسيطة.',
link: '<1> <2>الموقع الرسمي لـ CoffeeScript</2> </1> <3> <4>تعلم X في Y دقائق، حيث X=coffeescript</4> </3> <5> <6>تحميل القالب الأولي</6> </5>',
Expand Down
3 changes: 3 additions & 0 deletions src/livecodes/i18n/locales/ar/translation.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@
"templates.starter.clojurescript": {
"translation": "قالب ClojureScript (Cherry)"
},
"templates.starter.cobol-wasm": {
"translation": "قالب COBOL"
},
"templates.starter.coffeescript": {
"translation": "قالب CoffeeScript"
},
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/i18n/locales/ar/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ const translation: I18nTranslation = {
clio: 'قالب Clio',
'cljs-selfhosted': 'قالب CLJS (مستضاف ذاتيًا)',
clojurescript: 'قالب ClojureScript (Cherry)',
'cobol-wasm': 'قالب COBOL',
coffeescript: 'قالب CoffeeScript',
commonlisp: 'قالب Common Lisp',
cpp: 'قالب C++',
Expand Down
9 changes: 9 additions & 0 deletions src/livecodes/i18n/locales/bn/language-info.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
"clojurescript.link": {
"translation": "<tag-1> <tag-2>ClojureScript অফিসিয়াল ওয়েবসাইট</tag-2> </tag-1> <tag-3> <tag-4>Clojure অফিসিয়াল ওয়েবসাইট</tag-4> </tag-3> <tag-5> <tag-6>Cherry রেপো</tag-6> </tag-5> <tag-7> <tag-8>Y মিনিটে X শিখুন, যেখানে X=clojure</tag-8> </tag-7> <tag-9> <tag-10>LiveCodes ডকুমেন্টেশন</tag-10> </tag-9> <tag-11> <tag-12>স্টার্টার টেমপ্লেট লোড করুন</tag-12> </tag-11>"
},
"cobol-wasm.desc": {
"translation": "আধুনিক COBOL <tag-1>GnuCOBOL</tag-1> দ্বারা WebAssembly-তে কম্পাইল করা হয় এবং সম্পূর্ণভাবে ব্রাউজারে চলে।"
},
"cobol-wasm.link": {
"translation": "<tag-1> <tag-2>GnuCOBOL অফিসিয়াল ওয়েবসাইট</tag-2> </tag-1> <tag-3> <tag-4>Y মিনিটে X শিখুন, যেখানে X=COBOL</tag-4> </tag-3> <tag-5> <tag-6>লাইভকোডস ডকুমেন্টেশন</tag-6> </tag-5> <tag-7> <tag-8>স্টার্টার টেমপ্লেট লোড করুন</tag-8> </tag-7>"
},
"cobol-wasm.name": {
"translation": "COBOL (Wasm)"
},
"coffeescript.desc": {
"translation": "সাধারণ JavaScript।"
},
Expand Down
5 changes: 5 additions & 0 deletions src/livecodes/i18n/locales/bn/language-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const languageInfo: I18nLangInfoTranslation = {
desc: 'ClojureScript হলো <1>Clojure</1>-এর জন্য একটি কম্পাইলার যা JavaScript লক্ষ্য করে। <2></2>LiveCodes-এ, এটি <3>Cherry</3> ব্যবহার করে ব্রাউজারে চলে',
link: '<1> <2>ClojureScript অফিসিয়াল ওয়েবসাইট</2> </1> <3> <4>Clojure অফিসিয়াল ওয়েবসাইট</4> </3> <5> <6>Cherry রেপো</6> </5> <7> <8>Y মিনিটে X শিখুন, যেখানে X=clojure</8> </7> <9> <10>LiveCodes ডকুমেন্টেশন</10> </9> <11> <12>স্টার্টার টেমপ্লেট লোড করুন</12> </11>',
},
'cobol-wasm': {
desc: 'আধুনিক COBOL <1>GnuCOBOL</1> দ্বারা WebAssembly-তে কম্পাইল করা হয় এবং সম্পূর্ণভাবে ব্রাউজারে চলে।',
link: '<1> <2>GnuCOBOL অফিসিয়াল ওয়েবসাইট</2> </1> <3> <4>Y মিনিটে X শিখুন, যেখানে X=COBOL</4> </3> <5> <6>লাইভকোডস ডকুমেন্টেশন</6> </5> <7> <8>স্টার্টার টেমপ্লেট লোড করুন</8> </7>',
name: 'COBOL (Wasm)',
},
coffeescript: {
desc: 'সাধারণ JavaScript।',
link: '<1> <2>CoffeeScript অফিসিয়াল ওয়েবসাইট</2> </1> <3> <4>Y মিনিটে X শিখুন, যেখানে X=coffeescript</4> </3> <5> <6>স্টার্টার টেমপ্লেট লোড করুন</6> </5>',
Expand Down
3 changes: 3 additions & 0 deletions src/livecodes/i18n/locales/bn/translation.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@
"templates.starter.clojurescript": {
"translation": "ClojureScript (Cherry) স্টার্টার"
},
"templates.starter.cobol-wasm": {
"translation": "COBOL স্টার্টার"
},
"templates.starter.coffeescript": {
"translation": "CoffeeScript স্টার্টার"
},
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/i18n/locales/bn/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ const translation: I18nTranslation = {
clio: 'Clio স্টার্টার',
'cljs-selfhosted': 'CLJS (স্ব-হোস্টেড) স্টার্টার',
clojurescript: 'ClojureScript (Cherry) স্টার্টার',
'cobol-wasm': 'COBOL স্টার্টার',
coffeescript: 'CoffeeScript স্টার্টার',
commonlisp: 'Common Lisp স্টার্টার',
cpp: 'C++ স্টার্টার',
Expand Down
Loading
Loading