Skip to content

Commit 9de599f

Browse files
committed
squash and rebase
1 parent a365a85 commit 9de599f

Some content is hidden

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

58 files changed

+3280
-10712
lines changed

.github/workflows/deploy.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Hugo site to Pages
2+
3+
on:
4+
# Run on pushes targeting the default branch
5+
push:
6+
branches: main
7+
# Allow to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
17+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Use Node.js
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: '18'
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
- name: Setup Pages
37+
id: pages
38+
uses: actions/configure-pages@v3
39+
- name: Build
40+
env:
41+
# For maximum backward compatibility with Hugo modules
42+
HUGO_ENVIRONMENT: production
43+
HUGO_ENV: production
44+
run: |
45+
npm install
46+
npm run build
47+
- name: Upload artifact
48+
uses: actions/upload-pages-artifact@v1
49+
with:
50+
path: ./public
51+
52+
deploy:
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
runs-on: ubuntu-latest
57+
needs: build
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v2
62+

.github/workflows/preview.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy PR previews
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
11+
concurrency: preview-${{ github.ref }}
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
deploy-preview:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Use Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '18'
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Build
28+
run: |
29+
npm install
30+
npm run build
31+
- name: Deploy preview
32+
uses: rossjrw/pr-preview-action@v1
33+
with:
34+
source-dir: ./public

hugo/assets/scripts/arithmetics/arithmetics-tools.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { monaco } from "monaco-editor-wrapper/.";
2-
import { AstNode, Diagnostic, Pos } from "../langium-utils/langium-ast";
2+
import { Pos } from "../langium-utils/langium-ast";
33

44
export interface Evaluation {
55
range: {
@@ -30,7 +30,7 @@ Root(D, 3);
3030
Root(64, 3);
3131
Sqrt(81);`,
3232

33-
`MODULE priceCalculator
33+
`MODULE priceCalculator
3434
3535
DEF materialPerUnit: 100;
3636
@@ -58,33 +58,34 @@ DEF calcGrossListPrice(net, tax):
5858
calcGrossListPrice(netPrice, vat);`
5959
]
6060

61-
62-
61+
/**
62+
* Monarch grammar for arithmetics
63+
*/
6364
export const syntaxHighlighting = {
6465
ignoreCase: true,
6566
keywords: [
66-
'def','module'
67+
'def', 'module'
6768
],
6869
operators: [
69-
'*','+',',','-','/',':',';'
70+
'*', '+', ',', '-', '/', ':', ';'
7071
],
71-
symbols: /\(|\)|\*|\+|,|-|\/|:|;/,
72+
symbols: /\(|\)|\*|\+|,|-|\/|:|;/,
7273
tokenizer: {
7374
initial: [
74-
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"ID"} }} },
75-
{ regex: /[0-9]+(\.[0-9]*)?/, action: {"token":"number"} },
75+
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': { "token": "keyword" }, '@default': { "token": "ID" } } } },
76+
{ regex: /[0-9]+(\.[0-9]*)?/, action: { "token": "number" } },
7677
{ include: '@whitespace' },
77-
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
78+
{ regex: /@symbols/, action: { cases: { '@operators': { "token": "operator" }, '@default': { "token": "" } } } },
7879
],
7980
whitespace: [
80-
{ regex: /\s+/, action: {"token":"white"} },
81-
{ regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
82-
{ regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
81+
{ regex: /\s+/, action: { "token": "white" } },
82+
{ regex: /\/\*/, action: { "token": "comment", "next": "@comment" } },
83+
{ regex: /\/\/[^\n\r]*/, action: { "token": "comment" } },
8384
],
8485
comment: [
85-
{ regex: /[^\/\*]+/, action: {"token":"comment"} },
86-
{ regex: /\*\//, action: {"token":"comment","next":"@pop"} },
87-
{ regex: /[\/\*]/, action: {"token":"comment"} },
86+
{ regex: /[^\/\*]+/, action: { "token": "comment" } },
87+
{ regex: /\*\//, action: { "token": "comment", "next": "@pop" } },
88+
{ regex: /[\/\*]/, action: { "token": "comment" } },
8889
],
8990
}
9091
} as monaco.languages.IMonarchLanguage;

hugo/assets/scripts/arithmetics/arithmetics.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import {
2-
MonacoEditorReactComp,
3-
addMonacoStyles,
4-
} from "@typefox/monaco-editor-react/bundle";
1+
import { MonacoEditorReactComp } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
52
import { buildWorkerDefinition } from "monaco-editor-workers";
63
import React from "react";
74
import { createRoot } from "react-dom/client";
85
import { Diagnostic, DocumentChangeResponse } from "../langium-utils/langium-ast";
96
import { Evaluation, examples, syntaxHighlighting } from "./arithmetics-tools";
10-
7+
import { UserConfig } from "monaco-editor-wrapper";
8+
import { createUserConfig } from "../utils";
9+
1110
buildWorkerDefinition(
1211
"../../libs/monaco-editor-workers/workers",
1312
new URL("", window.location.href).href,
1413
false
1514
);
16-
addMonacoStyles("monaco-editor-styles");
17-
1815

1916
interface PreviewProps {
2017
evaluations?: Evaluation[];
2118
diagnostics?: Diagnostic[];
2219
focusLine: (line: number) => void;
23-
2420
}
21+
22+
let userConfig: UserConfig;
23+
24+
2525
class Preview extends React.Component<PreviewProps, PreviewProps> {
2626
constructor(props: PreviewProps) {
2727
super(props);
@@ -143,7 +143,7 @@ class App extends React.Component<{}, AppState> {
143143

144144
setExample(index: number) {
145145
this.setState({ exampleIndex: index });
146-
this.monacoEditor.current?.getEditorWrapper()?.getEditor()?.setValue(examples[this.state.exampleIndex]);
146+
this.monacoEditor.current?.getEditorWrapper()?.getEditor()?.setValue(examples[index]);
147147
}
148148

149149
render() {
@@ -166,12 +166,7 @@ class App extends React.Component<{}, AppState> {
166166
<MonacoEditorReactComp
167167
ref={this.monacoEditor}
168168
onLoad={this.onMonacoLoad}
169-
webworkerUri="../showcase/libs/worker/arithmeticsServerWorker.js"
170-
workerName="LS"
171-
workerType="classic"
172-
languageId="arithmetics"
173-
text={examples[this.state.exampleIndex]}
174-
syntax={syntaxHighlighting}
169+
userConfig={userConfig}
175170
style={style}
176171
/>
177172
</div>
@@ -193,5 +188,13 @@ class App extends React.Component<{}, AppState> {
193188
}
194189
}
195190

191+
// setup config & render
192+
userConfig = createUserConfig({
193+
languageId: 'arithmetics',
194+
code: examples[0],
195+
htmlElement: document.getElementById('root')!,
196+
worker: '/showcase/libs/worker/arithmeticsServerWorker.js',
197+
monarchGrammar: syntaxHighlighting
198+
});
196199
const root = createRoot(document.getElementById("root") as HTMLElement);
197200
root.render(<App />);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { monaco } from "monaco-editor-wrapper/.";
2+
3+
4+
export const example = `// Define all datatypes
5+
datatype String
6+
datatype Int
7+
datatype Decimal
8+
9+
package big {
10+
datatype Int
11+
datatype Decimal
12+
}
13+
14+
package complex {
15+
datatype Date
16+
}
17+
18+
// Define all entities
19+
entity Blog {
20+
title: String
21+
date: complex.Date
22+
many posts: Post
23+
}
24+
25+
entity HasAuthor {
26+
author: String
27+
}
28+
29+
entity Post extends HasAuthor {
30+
title: String
31+
content: String
32+
many comments: Comment
33+
}
34+
35+
entity Comment extends HasAuthor {
36+
content: String
37+
}
38+
`;
39+
40+
export const syntaxHighlighting = {
41+
keywords: [
42+
'datatype','entity','extends','many','package'
43+
],
44+
operators: [
45+
'.',':'
46+
],
47+
symbols: /\.|:|\{|\}/,
48+
49+
tokenizer: {
50+
initial: [
51+
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"ID"} }} },
52+
{ include: '@whitespace' },
53+
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
54+
],
55+
whitespace: [
56+
{ regex: /\s+/, action: {"token":"white"} },
57+
{ regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
58+
{ regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
59+
],
60+
comment: [
61+
{ regex: /[^\/\*]+/, action: {"token":"comment"} },
62+
{ regex: /\*\//, action: {"token":"comment","next":"@pop"} },
63+
{ regex: /[\/\*]/, action: {"token":"comment"} },
64+
],
65+
}
66+
} as monaco.languages.IMonarchLanguage;

0 commit comments

Comments
 (0)