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 @@ -126,6 +126,8 @@ Enabled via `processors` config:
| Java | `java` | Java runtime |
| C# | `csharp-wasm`, `cs`, `cs-wasm`, `wasm.cs` | C# WASM |
| VB.NET | `vb-wasm`, `vb`, `vbnet`, `wasm.vb` | VB.NET WASM |
| F# | `fsharp`, `fs`, `fsx` | Fable (F# -> JS) |
| F# (Wasm) | `fsharp-wasm`, `fs-wasm`, `wasm.fs` | .NET WASM |
| R | `r`, `rlang`, `rstats`, `r-wasm` | R WASM |
| Lua | `lua`, `lua-wasm`, `luawasm`, `wasm.lua` | Lua WASM |
| Teal | `teal`, `tl` | Typed Lua |
Expand All @@ -136,10 +138,14 @@ Enabled via `processors` config:
| ClojureScript (Cherry) | `clojurescript-cherry`, `cljs-cherry` | Cherry transpiler; imports npm packages as ES modules |
| ClojureScript (self-hosted) | `clojurescript-selfhosted`, `cljs-selfhosted` | Official ClojureScript compiler; no npm imports |
| Perl | `perl`, `pl`, `pm` | Perl runtime |
| Pascal | `pascal`, `pas`, `pp`, `pas2js` | pas2js (Pascal -> JS, WASM) |
| Gleam | `gleam` | Gleam language |
| Elm | `elm` | Elm compiler (WASM) |
| Haskell | `haskell`, `hs`, `lhs` | MicroHs (not GHC) |
| Haskell (Wasm) | `haskell-wasm`, `hs-wasm`, `wasm.hs`, `hswasm` | GHC WASM |
| Rust (Wasm) | `rust-wasm`, `rs-wasm`, `wasm.rs` | Rust WASM |
| Swift (Wasm) | `swift-wasm`, `swift`, `wasm.swift` | Swift WASM |
| Zig (Wasm) | `zig-wasm`, `zig` | Zig WASM |
| Tcl | `tcl` | Tcl interpreter |
| WebAssembly | `wat`, `wast`, `wasm`, `webassembly` | WAT format |

Expand Down Expand Up @@ -237,3 +243,4 @@ When loading files, extensions map to languages:
| `.go` | Go |
| `.php` | PHP |
| `.java` | Java |
| `.pas`, `.pp` | Pascal |
104 changes: 104 additions & 0 deletions docs/docs/languages/pascal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Pascal

[Pascal](https://www.freepascal.org/) is a procedural and object-oriented programming
language, designed by Niklaus Wirth in 1970 and still widely used for teaching and for
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
pullfrog[bot] marked this conversation as resolved.
building native applications.

LiveCodes runs Pascal in the browser using the [Free Pascal](https://www.freepascal.org/)
team's [pas2js](https://www.freepascal.org/_new/docs/tools/pas2js/) transpiler, compiled
to [WebAssembly](https://webassembly.org/). It transpiles Object Pascal to JavaScript,
which then runs in the result page. No server is involved.

## Usage

Write a Pascal program in the script editor and press **Run**. Anything written with
`Writeln` appears in the console.

Because the compiled output is plain JavaScript, the program can use the DOM and other
browser APIs. `uses web` brings the browser API into scope:

```pascal
program app;

{$mode objfpc}{$H+}

uses
web, sysutils;

var
Count: Integer = 0;

function HandleClick(Event: TJSEvent): boolean;
var
Counter: TJSElement;
begin
Count := Count + 1;
Counter := document.getElementById('counter');
if (Counter <> nil) then
Counter.innerHTML := 'You clicked ' + IntToStr(Count) + ' times.';
end;

var
Title: TJSElement;
Button: TJSElement;
begin
Writeln('Hello from Pascal!');

Title := document.getElementById('title');
if (Title <> nil) then
Title.innerHTML := 'Pascal';

Button := document.getElementById('counter-button');
if (Button <> nil) then
Button.addEventListener('click', @HandleClick);
end.
```

That is the starter template:

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

<LiveCodes template="pascal" height="80vh"></LiveCodes>

Uncaught exceptions are reported in the console; `ExitCode` may be set to signal a
non-zero exit code.

## Language Info

### Name

`pascal`

### Aliases

`pas`, `pp`, `pas2js`

### Extension

`.pas`, `.pp`

### Editor

`script`

## Compiler

[pas2js](https://www.freepascal.org/_new/docs/tools/pas2js/), the Free Pascal compiler
targeting JavaScript.

### Version

pas2js 3.3.1

## Limitations

- There is no `Readln` in the pas2js runtime, so programs cannot read from standard
input.

## Links

- [Pascal](https://www.freepascal.org/)
- [Free Pascal documentation](https://www.freepascal.org/docs.html)
- [pas2js documentation](https://www.freepascal.org/_new/docs/tools/pas2js/)
- [pas2js wiki](https://wiki.freepascal.org/pas2js)
- [WebAssembly](https://webassembly.org/) in LiveCodes
1 change: 1 addition & 0 deletions docs/src/components/LanguageSliders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default function Sliders() {
{ name: 'haskell', title: 'Haskell' },
{ name: 'haskell-wasm', title: 'Haskell (Wasm)' },
{ name: 'zig-wasm', title: 'Zig (Wasm)' },
{ name: 'pascal', title: 'Pascal' },
{ name: 'java', title: 'Java' },
{ name: 'csharp-wasm', title: 'C# (Wasm)' },
{ name: 'vb-wasm', title: 'VB.NET (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 @@ -55,6 +55,7 @@ const templates = [
{ name: 'haskell', title: 'Haskell Starter', thumbnail: 'haskell.svg' },
{ name: 'haskell-wasm', title: 'Haskell (Wasm) Starter', thumbnail: 'haskell.svg' },
{ name: 'zig-wasm', title: 'Zig (Wasm) Starter', thumbnail: 'zig.svg' },
{ name: 'pascal', title: 'Pascal Starter', thumbnail: 'pascal.png' },
{ name: 'java', title: 'Java Starter', thumbnail: 'java.svg' },
{ name: 'csharp-wasm', title: 'C# (Wasm)', thumbnail: 'csharp.svg' },
{ name: 'vb-wasm', title: 'VB.NET (Wasm)', thumbnail: 'vb.svg' },
Expand Down
27 changes: 27 additions & 0 deletions e2e/specs/starter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ test.describe('Starter Templates from UI', () => {
expect(counterText).toBe('You clicked 3 times.');
});

test('Pascal Starter', async ({ page, getTestUrl, editor }) => {
// the ~9 MB compiler is downloaded on the first run
test.slow();

await page.goto(getTestUrl());

const { app, getResult, waitForResultUpdate } = await getLoadedApp(page);

await app.click('[aria-label="Project"]');
await app.click('text=New');
await app.click('text=Pascal Starter');

await waitForEditorFocus(app);
await waitForResultUpdate();
await app.waitForTimeout(30_000);

await getResult().click('text=Click me');
await getResult().click('text=Click me');
await getResult().click('text=Click me');

const titleText = await getResult().innerText('h1');
expect(titleText).toBe('Hello, Pascal!');

const counterText = await getResult().innerText('text=You clicked');
expect(counterText).toBe('You clicked 3 times.');
});

test('rust-wasm Starter', async ({ page, getTestUrl, editor }) => {
// the interpreter and the stdlib sysroot are downloaded on the first run
test.slow();
Expand Down
1 change: 1 addition & 0 deletions functions/vendors/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const starterTemplates = {
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
"zig-wasm": "Zig (Wasm) Starter",
"pascal": "Pascal Starter",
"java": "Java Starter",
"csharp-wasm": "C# (Wasm) Starter",
"vb-wasm": "VB.NET (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 @@ -254,6 +254,7 @@ const iifeBuild = () =>
'languages/minizinc/lang-minizinc-script.ts',
'languages/mustache/lang-mustache-compiler.ts',
'languages/nunjucks/lang-nunjucks-compiler.ts',
'languages/pascal/lang-pascal-compiler.ts',
'languages/perl/lang-perl-script.ts',
'languages/php-wasm/lang-php-wasm-script.ts',
'languages/prolog/lang-prolog-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 @@ -53,6 +53,7 @@
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
"zig-wasm": "Zig (Wasm) Starter",
"pascal": "Pascal Starter",
"java": "Java Starter",
"csharp-wasm": "C# (Wasm) Starter",
"vb-wasm": "VB.NET (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 @@ -309,6 +309,7 @@ export const getCommandMenuActions = ({
'rust-wasm',
'swift-wasm',
'zig-wasm',
'pascal',
'java',
'csharp-wasm',
'vb-wasm',
Expand Down
Binary file added src/livecodes/assets/templates/pascal.png
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 @@ -559,6 +559,36 @@ <h3 data-i18n="language-info:zigWasm.name">Zig (Wasm)</h3>
</ul>
</section>

<section data-lang="pascal">
<h3 data-i18n="language-info:pascal.name">Pascal</h3>
<div data-i18n="language-info:pascal.desc" data-i18n-prop="innerHTML">
Pascal running in the browser using pas2js (by the Free Pascal team) compiled to WebAssembly.
</div>
<ul data-i18n="language-info:pascal.link" data-i18n-prop="innerHTML">
<li>
<a href="https://www.freepascal.org/" target="_blank" rel="noopener">Free Pascal website</a>
</li>
<li>
<a href="https://www.freepascal.org/_new/docs/tools/pas2js/" target="_blank" rel="noopener"
>pas2js documentation</a
>
</li>
<li>
<a href="https://wiki.freepascal.org/pas2js" target="_blank" rel="noopener">pas2js wiki</a>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/pascal" target="_blank" rel="noopener"
>LiveCodes Documentation</a
>
</li>
<li>
<a href="?template=pascal" class="button" target="_parent" data-template="pascal"
>Load starter template</a
>
</li>
</ul>
</section>

<section data-lang="diagrams">
<h3 data-i18n="language-info:diagrams.name">Diagrams</h3>
<div data-i18n="language-info:diagrams.desc1" class="description warn">(Experimental)</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 @@ -519,6 +519,15 @@
"ocaml.name": {
"translation": "OCaml"
},
"pascal.desc": {
"translation": "Pascal يعمل في المتصفح باستخدام pas2js (من فريق Free Pascal) ومُجمَّع إلى WebAssembly."
},
"pascal.link": {
"translation": "<tag-1> <tag-2>الموقع الرسمي لـ Free Pascal</tag-2> </tag-1> <tag-3> <tag-4>وثائق pas2js</tag-4> </tag-3> <tag-5> <tag-6>pas2js wiki</tag-6> </tag-5> <tag-7> <tag-8>وثائق LiveCodes</tag-8> </tag-7> <tag-9> <tag-10>تحميل القالب الأولي</tag-10> </tag-9>"
},
"pascal.name": {
"translation": "Pascal"
},
"perl.desc": {
"translation": "بيرل تعمل في المتصفح باستخدام Perlito."
},
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 @@ -292,6 +292,11 @@ const languageInfo: I18nLangInfoTranslation = {
link: '<1><2>موقع OCaml</2></1> <3> <4>وثائق OCaml</4> </3> <5> <6>موقع ReScript</6> </5> <7> <8>تعلم X في Y دقائق، حيث X=OCaml</8> </7> <9> <10>تحميل القالب الأولي</10> </9>',
name: 'OCaml',
},
pascal: {
desc: 'Pascal يعمل في المتصفح باستخدام pas2js (من فريق Free Pascal) ومُجمَّع إلى WebAssembly.',
link: '<1> <2>الموقع الرسمي لـ Free Pascal</2> </1> <3> <4>وثائق pas2js</4> </3> <5> <6>pas2js wiki</6> </5> <7> <8>وثائق LiveCodes</8> </7> <9> <10>تحميل القالب الأولي</10> </9>',
name: 'Pascal',
},
perl: {
desc: 'بيرل تعمل في المتصفح باستخدام Perlito.',
link: '<1> <2>الموقع الرسمي لـ Perl</2> </1> <3> <4>وثائق Perl</4> </3> <5> <6>ملف README لـ Perlito5</6> </5> <7> <8>تعلم X في Y دقائق، حيث X=perl</8> </7> <9> <10>تحميل القالب الأولي</10> </9>',
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 @@ -2058,6 +2058,9 @@
"templates.starter.ocaml": {
"translation": "قالب Ocaml"
},
"templates.starter.pascal": {
"translation": "قالب Pascal"
},
"templates.starter.perl": {
"translation": "قالب Perl"
},
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 @@ -1025,6 +1025,7 @@ const translation: I18nTranslation = {
minizinc: 'قالب MiniZinc',
'objc-wasm': 'قالب Objective-C (Wasm)',
ocaml: 'قالب Ocaml',
pascal: 'قالب Pascal',
perl: 'قالب Perl',
phaser: 'قالب Phaser',
php: 'قالب PHP',
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 @@ -519,6 +519,15 @@
"ocaml.name": {
"translation": "OCaml"
},
"pascal.desc": {
"translation": "Free Pascal দলের pas2js ব্যবহার করে ব্রাউজারে Pascal চলছে, যা WebAssembly-তে কম্পাইল করা।"
},
"pascal.link": {
"translation": "<tag-1> <tag-2>Free Pascal অফিসিয়াল ওয়েবসাইট</tag-2> </tag-1> <tag-3> <tag-4>pas2js ডকুমেন্টেশন</tag-4> </tag-3> <tag-5> <tag-6>pas2js wiki</tag-6> </tag-5> <tag-7> <tag-8>LiveCodes ডকুমেন্টেশন</tag-8> </tag-7> <tag-9> <tag-10>স্টার্টার টেমপ্লেট লোড করুন</tag-10> </tag-9>"
},
"pascal.name": {
"translation": "Pascal"
},
"perl.desc": {
"translation": "Perlito ব্যবহার করে ব্রাউজারে চলমান Perl।"
},
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 @@ -294,6 +294,11 @@ const languageInfo: I18nLangInfoTranslation = {
link: '<1><2>OCaml ওয়েবসাইট</2></1> <3> <4>OCaml ডকুমেন্টেশন</4> </3> <5> <6>ReScript ওয়েবসাইট</6> </5> <7> <8>Y মিনিটে X শিখুন, যেখানে X=OCaml</8> </7> <9> <10>স্টার্টার টেমপ্লেট লোড করুন</10> </9>',
name: 'OCaml',
},
pascal: {
desc: 'Free Pascal দলের pas2js ব্যবহার করে ব্রাউজারে Pascal চলছে, যা WebAssembly-তে কম্পাইল করা।',
link: '<1> <2>Free Pascal অফিসিয়াল ওয়েবসাইট</2> </1> <3> <4>pas2js ডকুমেন্টেশন</4> </3> <5> <6>pas2js wiki</6> </5> <7> <8>LiveCodes ডকুমেন্টেশন</8> </7> <9> <10>স্টার্টার টেমপ্লেট লোড করুন</10> </9>',
name: 'Pascal',
},
perl: {
desc: 'Perlito ব্যবহার করে ব্রাউজারে চলমান Perl।',
link: '<1> <2>Perl অফিসিয়াল ওয়েবসাইট</2> </1> <3> <4>Perl ডকুমেন্টেশন</4> </3> <5> <6>Perlito5 Readme</6> </5> <7> <8>Y মিনিটে X শিখুন, যেখানে X=perl</8> </7> <9> <10>স্টার্টার টেমপ্লেট লোড করুন</10> </9>',
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 @@ -2058,6 +2058,9 @@
"templates.starter.ocaml": {
"translation": "Ocaml স্টার্টার"
},
"templates.starter.pascal": {
"translation": "Pascal স্টার্টার"
},
"templates.starter.perl": {
"translation": "Perl স্টার্টার"
},
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 @@ -1025,6 +1025,7 @@ const translation: I18nTranslation = {
minizinc: 'MiniZinc স্টার্টার',
'objc-wasm': 'Objective-C (Wasm) স্টার্টার',
ocaml: 'Ocaml স্টার্টার',
pascal: 'Pascal স্টার্টার',
perl: 'Perl স্টার্টার',
phaser: 'Phaser স্টার্টার',
php: 'PHP স্টার্টার',
Expand Down
9 changes: 9 additions & 0 deletions src/livecodes/i18n/locales/de/language-info.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,15 @@
"ocaml.name": {
"translation": "OCaml"
},
"pascal.desc": {
"translation": "Pascal läuft im Browser mit pas2js (vom Free Pascal-Team) und wird zu WebAssembly kompiliert."
},
"pascal.link": {
"translation": "<tag-1> <tag-2>Offizielle Free Pascal-Website</tag-2> </tag-1> <tag-3> <tag-4>pas2js-Dokumentation</tag-4> </tag-3> <tag-5> <tag-6>pas2js wiki</tag-6> </tag-5> <tag-7> <tag-8>LiveCodes-Dokumentationen</tag-8> </tag-7> <tag-9> <tag-10>Starter-Vorlage laden</tag-10> </tag-9>"
},
"pascal.name": {
"translation": "Pascal"
},
"perl.desc": {
"translation": "Perl läuft im Browser mit Perlito."
},
Expand Down
5 changes: 5 additions & 0 deletions src/livecodes/i18n/locales/de/language-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ const languageInfo: I18nLangInfoTranslation = {
link: '<1><2>OCaml Website</2></1> <3> <4>OCaml Dokumentation</4> </3> <5> <6>ReScript Website</6> </5> <7> <8>Lerne X in Y Minuten, wobei X=OCaml</8> </7> <9> <10>Starter-Vorlage laden</10> </9>',
name: 'OCaml',
},
pascal: {
desc: 'Pascal läuft im Browser mit pas2js (vom Free Pascal-Team) und wird zu WebAssembly kompiliert.',
link: '<1> <2>Offizielle Free Pascal-Website</2> </1> <3> <4>pas2js-Dokumentation</4> </3> <5> <6>pas2js wiki</6> </5> <7> <8>LiveCodes-Dokumentationen</8> </7> <9> <10>Starter-Vorlage laden</10> </9>',
name: 'Pascal',
},
perl: {
desc: 'Perl läuft im Browser mit Perlito.',
link: '<1> <2>Perl offizielle Website</2> </1> <3> <4>Perl Dokumentation</4> </3> <5> <6>Perlito5 Readme</6> </5> <7> <8>Lerne X in Y Minuten, wobei X=Perl</8> </7> <9> <10>Starter-Vorlage laden</10> </9>',
Expand Down
3 changes: 3 additions & 0 deletions src/livecodes/i18n/locales/de/translation.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,9 @@
"templates.starter.ocaml": {
"translation": "OCaml-Starter"
},
"templates.starter.pascal": {
"translation": "Pascal-Starter"
},
"templates.starter.perl": {
"translation": "Perl-Starter"
},
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/i18n/locales/de/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ const translation: I18nTranslation = {
minizinc: 'MiniZink-Starter',
'objc-wasm': 'Objective-C (Wasm)-Starter',
ocaml: 'OCaml-Starter',
pascal: 'Pascal-Starter',
perl: 'Perl-Starter',
phaser: 'Phaser-Starter',
php: 'PHP-Starter',
Expand Down
Loading
Loading