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
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-114-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: languages](https://img.shields.io/badge/languages-115-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
125 changes: 125 additions & 0 deletions docs/docs/languages/fortran-wasm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Fortran (Wasm)

Fortran is a compiled, imperative programming language designed for numeric computation and scientific computing.

Fortran in LiveCodes is compiled to WebAssembly by [LFortran](https://lfortran.org/) and run in the
browser, with no server. This is modern Fortran (free form), not a Fortran 77 subset.

## Usage

Demo:

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

export const fortranConfig = {
activeEditor: 'script',
script: {
language: 'fortran-wasm',
content: `program hello
print *, 'Hello, World!'
end program`,
},
mode: 'simple',
editor: 'auto',
tools: {
status: 'full',
},
};

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

### Communication with JavaScript

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

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

Example:

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

```fortran
program hello
print *, 'Hello, World!'
end program
```

Array sections, whole-array arithmetic and intrinsics behave as expected:

```fortran
program slice
real :: a(4)
a = [10.0, 20.0, 30.0, 40.0]
print *, a(2:3) ! 20.0 and 30.0, not all four elements
print *, sum(a) ! 100.0
end program
```

`READ` reads from the **stdin** pane, in the same way as the other console languages.

## Language Info

### Name

`fortran-wasm`

### Aliases / Extensions

`f90`, `f95`, `f03`, `f08`, `f`, `for`, `ftn`, `fortran`, `lfortran`

### Editor

`script`

## Compiler

[LFortran](https://lfortran.org/) compiled to WebAssembly.

### Version

LFortran 0.66.0, with LLVM 22.1.8 and LLD, built with Emscripten 4.0.9.

## 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 Fortran 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

```fortran
program stats
integer :: i
real :: x(5), total
x = [1.0, 2.0, 3.0, 4.0, 5.0]
total = 0.0
do i = 1, 5
total = total + x(i)
end do
print *, 'Sum = ', total
print *, 'Mean = ', total / 5.0
end program
```

## Starter Template

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

## Links

- [LFortran](https://lfortran.org/)
- [Fortran language website](https://fortran-lang.org/)
- [Learn Fortran](https://fortran-lang.org/learn/)
- [@live-codes/lfortran-wasm](https://www.npmjs.com/package/@live-codes/lfortran-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: 'fortran', title: 'Fortran' },
{ name: 'rust-wasm', title: 'Rust (Wasm)' },
{ name: 'swift-wasm', title: 'Swift (Wasm)' },
{ name: 'haskell', title: 'Haskell' },
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: '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' },
{ name: 'rust-wasm', title: 'Rust (Wasm) Starter', thumbnail: 'rust.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",
"fortran-wasm": "Fortran Starter",
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
"zig-wasm": "Zig (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 @@ -228,6 +228,7 @@ const iifeBuild = () =>
'languages/java/lang-java-script.ts',
'languages/cpp/lang-cpp-script.ts',
'languages/clang-wasm/lang-clang-wasm-script.ts',
'languages/fortran-wasm/lang-fortran-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",
"fortran-wasm": "Fortran Starter",
"rust-wasm": "Rust (Wasm) Starter",
"swift-wasm": "Swift (Wasm) Starter",
"zig-wasm": "Zig (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',
'fortran-wasm',
'rust-wasm',
'swift-wasm',
'zig-wasm',
Expand Down
9 changes: 9 additions & 0 deletions src/livecodes/assets/templates/fortran.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions src/livecodes/html/language-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ <h3 data-i18n="language-info:fennel.name">Fennel</h3>
>Getting Started with Fennel</a
>
</li>
<li>
<a href="https://learnxinyminutes.com/fennel/" target="_blank" rel="noopener"
>Learn X in Y minutes, where X=Fennel</a
>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/fennel" target="_blank" rel="noopener"
>LiveCodes Documentations</a
Expand All @@ -769,6 +774,42 @@ <h3 data-i18n="language-info:flow.name">Flow</h3>
</li>
</ul>
</section>
<section data-lang="fortran-wasm">
<h3 data-i18n="language-info:fortran-wasm.name">Fortran (Wasm)</h3>
<div data-i18n="language-info:fortran-wasm.desc" data-i18n-prop="innerHTML">
Modern Fortran compiled to WebAssembly by
<a href="https://lfortran.org/" target="_blank" rel="noopener">LFortran</a>, running entirely in
the browser.
</div>
<ul data-i18n="language-info:fortran-wasm.link" data-i18n-prop="innerHTML">
<li>
<a href="https://fortran-lang.org/learn/" target="_blank" rel="noopener">Learn Fortran</a>
</li>
<li>
<a href="https://lfortran.org/" target="_blank" rel="noopener">LFortran official website</a>
</li>
<li>
<a href="https://fortran-lang.org/" target="_blank" rel="noopener"
>Fortran language website</a
>
</li>
<li>
<a href="https://learnxinyminutes.com/fortran/" target="_blank" rel="noopener"
>Learn X in Y minutes, where X=Fortran</a
>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/fortran-wasm" target="_blank" rel="noopener"
>LiveCodes Documentation</a
>
</li>
<li>
<a href="?template=fortran-wasm" class="button" target="_parent" data-template="fortran-wasm"
>Load starter template</a
>
</li>
</ul>
</section>
<section data-lang="fsharp">
<h3 data-i18n="language-info:fsharp.name">F#</h3>
<div data-i18n="language-info:fsharp.desc1">
Expand All @@ -786,6 +827,11 @@ <h3 data-i18n="language-info:fsharp.name">F#</h3>
<li>
<a href="https://fable.io/" target="_blank" rel="noopener">Fable official website</a>
</li>
<li>
<a href="https://learnxinyminutes.com/fsharp/" target="_blank" rel="noopener"
>Learn X in Y minutes, where X=F#</a
>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/fsharp" target="_blank" rel="noopener"
>LiveCodes Documentations</a
Expand All @@ -812,6 +858,11 @@ <h3 data-i18n="language-info:fsharpWasm.name">F# (Wasm)</h3>
>F# documentation</a
>
</li>
<li>
<a href="https://learnxinyminutes.com/fsharp/" target="_blank" rel="noopener"
>Learn X in Y minutes, where X=F#</a
>
</li>
<li>
<a href="{{DOCS_BASE_URL}}languages/fsharp-wasm" target="_blank" rel="noopener"
>LiveCodes Documentation</a
Expand Down
15 changes: 12 additions & 3 deletions src/livecodes/i18n/locales/ar/language-info.lokalise.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
"translation": "فينل هي لغة برمجة تجمع بين سرعة وبساطة ونطاق لوا مع مرونة بناء جملة ليسب ونظام الماكرو."
},
"fennel.link": {
"translation": "<tag-1> <tag-2>الموقع الرسمي لفينل</tag-2> </tag-1> <tag-3> <tag-4>البدء مع فينل</tag-4> </tag-3> <tag-5> <tag-6>وثائق LiveCodes</tag-6> </tag-5> <tag-7> <tag-8>تحميل قالب البداية</tag-8> </tag-7>"
"translation": "<tag-1> <tag-2>الموقع الرسمي لفينل</tag-2> </tag-1> <tag-3> <tag-4>البدء مع فينل</tag-4> </tag-3> <tag-5> <tag-6>تعلم X في Y دقيقة، حيث X = Fennel</tag-6> </tag-5> <tag-7> <tag-8>وثائق LiveCodes</tag-8> </tag-7> <tag-9> <tag-10>تحميل قالب البداية</tag-10> </tag-9>"
},
"fennel.name": {
"translation": "Fennel"
Expand All @@ -261,14 +261,23 @@
"flow.name": {
"translation": "Flow"
},
"fortran-wasm.desc": {
"translation": "يتم تجميع Fortran الحديثة إلى WebAssembly بواسطة <tag-1>LFortran</tag-1>، وتعمل بالكامل داخل المتصفح."
},
"fortran-wasm.link": {
"translation": "<tag-1> <tag-2>تعلم Fortran</tag-2> </tag-1> <tag-3> <tag-4>الموقع الرسمي لـ LFortran</tag-4> </tag-3> <tag-5> <tag-6>موقع لغة Fortran</tag-6> </tag-5> <tag-7> <tag-8>تعلم X في Y دقيقة، حيث X = Fortran</tag-8> </tag-7> <tag-9> <tag-10>وثائق LiveCodes</tag-10> </tag-9> <tag-11> <tag-12>تحميل قالب البدء</tag-12> </tag-11>"
},
"fortran-wasm.name": {
"translation": "Fortran (Wasm)"
},
"fsharp.desc1": {
"translation": "F# هي لغة برمجة وظيفية مفتوحة المصدر ومتوافقة مع مختلف الأنظمة الأساسية، وتعمل على منصة .NET."
},
"fsharp.desc2": {
"translation": "هنا، يتم تحويله إلى لغة جافا سكريبت باستخدام Fable."
},
"fsharp.link": {
"translation": "<tag-1><tag-2>الموقع الرسمي لـ F#</tag-2></tag-1> <tag-3> <tag-4>وثائق F#</tag-4> </tag-3> <tag-5> <tag-6>الموقع الرسمي لـ Fable</tag-6> </tag-5> <tag-7> <tag-8>وثائق LiveCodes</tag-8> </tag-7> <tag-9> <tag-10>تحميل قالب البداية</tag-10> </tag-9>"
"translation": "<tag-1><tag-2>الموقع الرسمي لـ F#</tag-2></tag-1> <tag-3> <tag-4>وثائق F#</tag-4> </tag-3> <tag-5> <tag-6>الموقع الرسمي لـ Fable</tag-6> </tag-5> <tag-7> <tag-8>تعلم X في Y دقيقة، حيث X = F#</tag-8> </tag-7> <tag-9> <tag-10>وثائق LiveCodes</tag-10> </tag-9> <tag-11> <tag-12>تحميل قالب البداية</tag-12> </tag-11>"
},
"fsharp.name": {
"translation": "F#"
Expand All @@ -277,7 +286,7 @@
"translation": "المُترجم الحقيقي لـ F# وبيئة تشغيل .NET تعملان على WebAssembly. <tag-1></tag-1>وهذا يتطابق مع سلوك المُترجم الرسمي لـ F#. ومع ذلك، يلزم تنزيل بيئة تشغيل .NET WebAssembly في صفحة النتائج، وهو ما قد يستغرق بعض الوقت عند التشغيل لأول مرة."
},
"fsharpWasm.link": {
"translation": "<tag-1><tag-2>الموقع الرسمي لـ F#</tag-2></tag-1> <tag-3> <tag-4>وثائق F#</tag-4> </tag-3> <tag-5> <tag-6>وثائق LiveCodes</tag-6> </tag-5> <tag-7> <tag-8>تحميل قالب البدء</tag-8> </tag-7>"
"translation": "<tag-1><tag-2>الموقع الرسمي لـ F#</tag-2></tag-1> <tag-3> <tag-4>وثائق F#</tag-4> </tag-3> <tag-5> <tag-6>تعلم X في Y دقيقة، حيث X = F#</tag-6> </tag-5> <tag-7> <tag-8>وثائق LiveCodes</tag-8> </tag-7> <tag-9> <tag-10>تحميل قالب البدء</tag-10> </tag-9>"
},
"fsharpWasm.name": {
"translation": "F# (Wasm)"
Expand Down
11 changes: 8 additions & 3 deletions src/livecodes/i18n/locales/ar/language-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,29 @@ const languageInfo: I18nLangInfoTranslation = {
},
fennel: {
desc: 'فينل هي لغة برمجة تجمع بين سرعة وبساطة ونطاق لوا مع مرونة بناء جملة ليسب ونظام الماكرو.',
link: '<1> <2>الموقع الرسمي لفينل</2> </1> <3> <4>البدء مع فينل</4> </3> <5> <6>وثائق LiveCodes</6> </5> <7> <8>تحميل قالب البداية</8> </7>',
link: '<1> <2>الموقع الرسمي لفينل</2> </1> <3> <4>البدء مع فينل</4> </3> <5> <6>تعلم X في Y دقيقة، حيث X = Fennel</6> </5> <7> <8>وثائق LiveCodes</8> </7> <9> <10>تحميل قالب البداية</10> </9>',
name: 'Fennel',
},
flow: {
desc: 'فلو هو مدقق أنواع ثابت لجافا سكريبت.',
link: '<1> <2>الموقع الرسمي لفلو</2> </1> <3> <4>وثائق فلو</4> </3>',
name: 'Flow',
},
'fortran-wasm': {
desc: 'يتم تجميع Fortran الحديثة إلى WebAssembly بواسطة <1>LFortran</1>، وتعمل بالكامل داخل المتصفح.',
link: '<1> <2>تعلم Fortran</2> </1> <3> <4>الموقع الرسمي لـ LFortran</4> </3> <5> <6>موقع لغة Fortran</6> </5> <7> <8>تعلم X في Y دقيقة، حيث X = Fortran</8> </7> <9> <10>وثائق LiveCodes</10> </9> <11> <12>تحميل قالب البدء</12> </11>',
name: 'Fortran (Wasm)',
},
fsharp: {
desc1:
'F# هي لغة برمجة وظيفية مفتوحة المصدر ومتوافقة مع مختلف الأنظمة الأساسية، وتعمل على منصة .NET.',
desc2: 'هنا، يتم تحويله إلى لغة جافا سكريبت باستخدام Fable.',
link: '<1><2>الموقع الرسمي لـ F#</2></1> <3> <4>وثائق F#</4> </3> <5> <6>الموقع الرسمي لـ Fable</6> </5> <7> <8>وثائق LiveCodes</8> </7> <9> <10>تحميل قالب البداية</10> </9>',
link: '<1><2>الموقع الرسمي لـ F#</2></1> <3> <4>وثائق F#</4> </3> <5> <6>الموقع الرسمي لـ Fable</6> </5> <7> <8>تعلم X في Y دقيقة، حيث X = F#</8> </7> <9> <10>وثائق LiveCodes</10> </9> <11> <12>تحميل قالب البداية</12> </11>',
name: 'F#',
},
fsharpWasm: {
desc: 'المُترجم الحقيقي لـ F# وبيئة تشغيل .NET تعملان على WebAssembly. <1></1>وهذا يتطابق مع سلوك المُترجم الرسمي لـ F#. ومع ذلك، يلزم تنزيل بيئة تشغيل .NET WebAssembly في صفحة النتائج، وهو ما قد يستغرق بعض الوقت عند التشغيل لأول مرة.',
link: '<1><2>الموقع الرسمي لـ F#</2></1> <3> <4>وثائق F#</4> </3> <5> <6>وثائق LiveCodes</6> </5> <7> <8>تحميل قالب البدء</8> </7>',
link: '<1><2>الموقع الرسمي لـ F#</2></1> <3> <4>وثائق F#</4> </3> <5> <6>تعلم X في Y دقيقة، حيث X = F#</6> </5> <7> <8>وثائق LiveCodes</8> </7> <9> <10>تحميل قالب البدء</10> </9>',
name: 'F# (Wasm)',
},
gleam: {
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 @@ -1986,6 +1986,9 @@
"templates.starter.fennel": {
"translation": "قالب Fennel"
},
"templates.starter.fortran-wasm": {
"translation": "قالب Fortran"
},
"templates.starter.fsharp": {
"translation": "قالب F#"
},
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 @@ -1001,6 +1001,7 @@ const translation: I18nTranslation = {
elm: 'قالب Elm',
fanak: 'قالب Fanak',
fennel: 'قالب Fennel',
'fortran-wasm': 'قالب Fortran',
fsharp: 'قالب F#',
'fsharp-wasm': 'قالب F# (Wasm)',
gleam: 'قالب Gleam',
Expand Down
Loading
Loading