Repository navigation
add Pascal language support #1049
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.