Skip to content

Commit 16fec8b

Browse files
committed
Merge branch 'add-flexpret-docs' of github.com:magnmaeh/lf-lang.github.io into add-flexpret-docs
2 parents b5f23b8 + a459fbd commit 16fec8b

File tree

365 files changed

+26388
-2088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+26388
-2088
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ In our [deployment workflow](https://github.com/lf-lang/lf-lang.github.io/blob/m
2424
$ yarn build
2525
```
2626
This generates static content in the `build` directory, which gets served using GitHub's static contents hosting service, GitHub Pages.
27+
28+
### Versioning
29+
Instructions for "freezing" the current docs and filing them under a version number, can be found [here](https://docusaurus.io/docs/versioning). Normally, the steps are:
30+
```
31+
git switch main
32+
git pull
33+
git checkout -b v<major>.<minor>.<patch>
34+
yarn docusaurus docs:version <major>.<minor>.<patch>
35+
git add versioned_docs/*
36+
git commit -a -m 'Docs v<major>.<minor>.<patch>'
37+
```

docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const config: Config = {
174174

175175

176176
clientModules: [
177-
"src/components/ShikijiLFHighlighter/shikijiloader.ts"
177+
"src/components/ShikiLFHighlighter/shikiloader.ts"
178178
],
179179
};
180180

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
"@docusaurus/plugin-ideal-image": "^3.1.1",
2222
"@docusaurus/preset-classic": "^3.1.1",
2323
"@mdx-js/react": "^3.0.0",
24-
"clsx": "^1.2.1",
24+
"clsx": "^2.1.1",
2525
"prism-react-renderer": "^2.1.0",
2626
"react": "^18.0.0",
2727
"react-dom": "^18.0.0",
2828
"react-transition-group": "^4.4.5",
29-
"shikiji": "^0.7.4",
29+
"shiki": "^1.5.1",
3030
"unist-util-visit": "^5.0.0"
3131
},
3232
"devDependencies": {
3333
"@docusaurus/eslint-plugin": "^3.1.1",
3434
"@docusaurus/module-type-aliases": "^3.1.1",
3535
"@docusaurus/tsconfig": "^3.1.1",
3636
"@docusaurus/types": "^3.1.1",
37-
"@typescript-eslint/eslint-plugin": "^6.13.1",
38-
"@typescript-eslint/parser": "^6.13.1",
39-
"eslint": "^8.55.0",
37+
"@typescript-eslint/eslint-plugin": "^7.8.0",
38+
"@typescript-eslint/parser": "^7.8.0",
39+
"eslint": "^9.2.0",
4040
"eslint-config-prettier": "^9.1.0",
4141
"eslint-plugin-react-hooks": "^4.6.0",
4242
"eslint-plugin-regexp": "^2.1.1",

src/components/LinguaFrancaMultiTargetUtils/LangSpecific.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import TabItem from "@theme/TabItem";
44
import styles from "./styles.module.css";
55
import CodeBlock from "@theme/CodeBlock";
66
import { ReactNode, useEffect, useState } from "react";
7-
import { ShikijiLFHighlighter } from "../ShikijiLFHighlighter";
7+
import { ShikiLFHighlighter } from "../ShikiLFHighlighter";
88

99
interface WebpackImportedRawModule {
1010
default: Readonly<Record<string, string>>;
@@ -47,7 +47,7 @@ export const NoSelectorTargetCodeBlock = (
4747
string | Promise<WebpackImportedRawModule | null>
4848
>),
4949
): JSX.Element => {
50-
const Component = props.lf ? ShikijiLFHighlighter : CodeBlock;
50+
const Component = props.lf ? ShikiLFHighlighter : CodeBlock;
5151
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5252
const { lf, ...targetToCode } = props;
5353
const newProps: Record<TargetsType, ReactNode> = {} as Record<

src/components/ShikijiLFHighlighter/index.tsx renamed to src/components/ShikiLFHighlighter/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState } from "react";
2-
import { HighlighterGeneric, BuiltinLanguage, BuiltinTheme } from "shikiji";
3-
import { loadShikiji } from "./shikijiloader";
2+
import { HighlighterGeneric, BuiltinLanguage, BuiltinTheme } from "shiki";
3+
import { loadShiki } from "./shikiloader";
44
import { useColorMode } from "@docusaurus/theme-common";
55
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
66

@@ -12,7 +12,7 @@ declare global {
1212
}
1313
}
1414

15-
export const ShikijiLFHighlighter = ({
15+
export const ShikiLFHighlighter = ({
1616
children,
1717
...props
1818
}: { children: string } & Record<string, unknown>) => {
@@ -28,7 +28,7 @@ export const ShikijiLFHighlighter = ({
2828
useEffect(() => {
2929
(async () => {
3030
if (!isBrowser) return;
31-
const shiki = await loadShikiji();
31+
const shiki = await loadShiki();
3232
setCode(
3333
shiki.codeToHtml(children, {
3434
lang: "Lingua Franca",
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
2-
import { LanguageRegistration, getHighlighter } from "shikiji";
2+
import { LanguageRegistration, getHighlighter } from "shiki";
33
import { targets } from "@site/src/components/LinguaFrancaMultiTargetUtils";
44
import LFTextMateLanguageDefinition from "./lflang.tmLanguage.json";
5-
import { HighlighterGeneric, BuiltinLanguage, BuiltinTheme } from "shikiji";
5+
import { HighlighterGeneric, BuiltinLanguage, BuiltinTheme } from "shiki";
66

77
declare global {
88
interface Window {
@@ -12,11 +12,11 @@ declare global {
1212
}
1313
}
1414

15-
export const loadShikiji = async () => {
15+
export const loadShiki = async () => {
1616
if (window.LFWebsite?.shikijiInstance != null) {
1717
return window.LFWebsite.shikijiInstance;
1818
}
19-
const shikiji = await getHighlighter({
19+
const shiki = await getHighlighter({
2020
themes: ["material-theme-lighter", "material-theme-darker"],
2121
langs: [
2222
...targets,
@@ -27,19 +27,19 @@ export const loadShikiji = async () => {
2727
if (window.LFWebsite == null) {
2828
window.LFWebsite = {};
2929
}
30-
window.LFWebsite.shikijiInstance = shikiji;
31-
return shikiji;
30+
window.LFWebsite.shikijiInstance = shiki;
31+
return shiki;
3232
};
3333

3434
if (ExecutionEnvironment.canUseDOM) {
3535
// As soon as the site loads in the browser, check if a Shikiji instance is created. If not, create one and save to global.
3636

3737
// Don't catch. Let it throw~ let it throw~
38-
loadShikiji().then((v) => {
38+
loadShiki().then((v) => {
3939
if (v != null) {
40-
console.log("Shikiji is loaded.");
40+
console.log("Shiki loaded.");
4141
} else {
42-
throw Error("Shikiji not loaded correctly.");
42+
throw Error("Shiki did loaded correctly.");
4343
}
4444
});
4545
}

src/theme/CodeBlock/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React from "react";
22
import CodeBlock from "@theme-original/CodeBlock";
3-
import { ShikijiLFHighlighter } from "@site/src/components/ShikijiLFHighlighter";
3+
import { ShikiLFHighlighter } from "@site/src/components/ShikiLFHighlighter";
44

55
export default function CodeBlockWrapper(props) {
66
return (
77
<>
88
{/* If using <CodeBlock /> then it will contain language="lf-c"; if using ``` it will contain className="language-lf-c". */}
99
{props.language?.startsWith("lf") ||
1010
props.className?.startsWith("language-lf") ? (
11-
<ShikijiLFHighlighter {...props} />
11+
<ShikiLFHighlighter {...props} />
1212
) : (
1313
<CodeBlock {...props} />
1414
)}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin
2+
src-gen
3+
include
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
target C {
2+
timeout: 3 secs
3+
}
4+
5+
main reactor Alignment {
6+
state s: int = 0
7+
timer t1(100 msec, 100 msec)
8+
timer t2(200 msec, 200 msec)
9+
timer t4(400 msec, 400 msec)
10+
11+
reaction(t1) {=
12+
self->s += 1;
13+
=}
14+
15+
reaction(t2) {=
16+
self->s -= 2;
17+
=}
18+
19+
reaction(t4) {=
20+
printf("s = %d\n", self->s);
21+
=}
22+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
target C {
2+
keepalive: true // Do not exit when event queue is empty.
3+
}
4+
5+
preamble {=
6+
#include "platform.h" // Defines lf_sleep() and thread functions.
7+
=}
8+
9+
main reactor {
10+
preamble {=
11+
// Schedule an event roughly every 200 msec.
12+
void* external(void* a) {
13+
while (true) {
14+
lf_sleep(MSEC(200));
15+
lf_schedule(a, 0);
16+
}
17+
}
18+
=}
19+
state thread_id: lf_thread_t = 0
20+
physical action a(100 msec): int
21+
22+
reaction(startup) -> a {=
23+
// Start a thread to schedule physical actions.
24+
lf_thread_create(&self->thread_id, &external, a);
25+
=}
26+
27+
reaction(a) {=
28+
interval_t elapsed_time = lf_time_logical_elapsed();
29+
printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time);
30+
=}
31+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
target C;
2+
preamble {=
3+
int table[] = {4, 3, 2, 1};
4+
=}
5+
reactor A(bank_index:int = 0, value:int = 0) {
6+
reaction (startup) {=
7+
printf("bank_index: %d, value: %d\n", self->bank_index, self->value);
8+
=}
9+
}
10+
main reactor {
11+
a = new[4] A(value = {= table[bank_index] =});
12+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
target C;
2+
3+
reactor Count {
4+
output out:int;
5+
reaction(startup) -> out {=
6+
int count = 0;
7+
while (!lf_check_deadline(self, true)) {
8+
count++;
9+
}
10+
lf_set(out, count);
11+
=} deadline (3 msec) {=
12+
printf("Stopped counting.\n");
13+
=}
14+
}
15+
16+
main reactor {
17+
c = new Count();
18+
reaction(c.out) {=
19+
printf("Counted to %d\n", c.out->value);
20+
=}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
target C;
2+
reactor Child (
3+
bank_index:int = 0
4+
) {
5+
reaction(startup) {=
6+
printf("My bank index: %d.\n", self->bank_index);
7+
=}
8+
}
9+
reactor Parent (
10+
bank_index:int = 0
11+
) {
12+
c = new[2] Child();
13+
}
14+
main reactor {
15+
p = new[2] Parent();
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
target C
2+
3+
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) {
4+
reaction(startup) {=
5+
printf(
6+
"My bank index: %d. My parent's bank index: %d.\n",
7+
self->bank_index, self->parent_bank_index
8+
);
9+
=}
10+
}
11+
12+
reactor Parent(bank_index: int = 0) {
13+
c = new[2] Child(parent_bank_index=bank_index)
14+
}
15+
16+
main reactor {
17+
p = new[2] Parent()
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
target C
2+
3+
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) {
4+
output out: int
5+
6+
reaction(startup) -> out {=
7+
lf_set(out, self->parent_bank_index * 2 + self->bank_index);
8+
=}
9+
}
10+
11+
reactor Parent(bank_index: int = 0) {
12+
c = new[2] Child(parent_bank_index=bank_index)
13+
14+
reaction(c.out) {=
15+
for (int i=0; i < c_width; i++) {
16+
printf("Received %d from child %d.\n", c[i].out->value, i);
17+
}
18+
=}
19+
}
20+
21+
main reactor {
22+
p = new[2] Parent()
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
target C
2+
3+
import Overwriting from "Overwriting.lf"
4+
5+
main reactor {
6+
s = new Overwriting()
7+
8+
reaction(s.y) {=
9+
if (s.y->value != 0 && s.y->value != 1) {
10+
lf_print_error_and_exit("Outputs should only be 0 or 1!");
11+
}
12+
=}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
target C
2+
3+
reactor Count {
4+
state count: int = 0
5+
output y: int
6+
timer t(0, 100 msec)
7+
8+
reaction(t) -> y {=
9+
lf_set(y, self->count++);
10+
=}
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target C;
2+
reactor A {
3+
input x:int;
4+
output y:int;
5+
reaction(x) -> y {=
6+
// ... something here ...
7+
=}
8+
}
9+
reactor B {
10+
input x:int;
11+
output y:int;
12+
reaction(x) {=
13+
// ... something here ...
14+
=}
15+
reaction(startup) -> y {=
16+
// ... something here ...
17+
=}
18+
}
19+
main reactor {
20+
a = new A();
21+
b = new B();
22+
a.y -> b.x;
23+
b.y -> a.x;
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target C;
2+
reactor A {
3+
input x:int;
4+
output y:int;
5+
reaction(x) -> y {=
6+
// ... something here ...
7+
=}
8+
}
9+
reactor B {
10+
input x:int;
11+
output y:int;
12+
reaction(startup) -> y {=
13+
// ... something here ...
14+
=}
15+
reaction(x) {=
16+
// ... something here ...
17+
=}
18+
}
19+
main reactor {
20+
a = new A();
21+
b = new B();
22+
a.y -> b.x;
23+
b.y -> a.x;
24+
}

0 commit comments

Comments
 (0)