Skip to content

Commit

Permalink
Merge branch 'practice-6' into practice-6-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
arminzavada committed Oct 17, 2024
2 parents 23e0096 + 24b4502 commit 3b995f6
Show file tree
Hide file tree
Showing 20 changed files with 3,007 additions and 129 deletions.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ include(
"similarity",
"diversity",
"workflow",
"workflow-ide",
)
1 change: 1 addition & 0 deletions similarity/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/src/gen/
model.json
31 changes: 31 additions & 0 deletions similarity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import com.github.gradle.node.task.NodeTask
import com.pswidersk.gradle.python.VenvTask

plugins {
id("hu.bme.mit.ase.shingler.gradle.application")
id("com.pswidersk.python-plugin") version "2.7.2"
id("com.github.node-gradle.node") version "7.1.0"
}

application {
mainClass = "hu.bme.mit.ase.shingler.similarity.SimilarityApp"
}

val cliOutput by configurations.creating {
isCanBeResolved = true
}

dependencies {
cliOutput(project(":workflow-ide", configuration = cliOutput.name))
}

val srcGenJava = "src/gen/java"

sourceSets.main {
Expand All @@ -29,6 +39,26 @@ dependencies {
testRuntimeOnly(libs.junit.jupiter.engine)
}

val cloneCliOutput by tasks.registering(Sync::class) {
inputs.files(cliOutput)

from(cliOutput.files)
into("build/cli")
}

val generateDomainModel by tasks.registering(NodeTask::class) {
inputs.files(cloneCliOutput.get().outputs)
inputs.file("model.wfl")
outputs.file("model.json")

script.set(File("build/cli/main.js"))

args = listOf(
"generate",
"model.wfl",
)
}

val installPythonPackages by tasks.registering(VenvTask::class) {
venvExec = "pip3"

Expand All @@ -40,6 +70,7 @@ val installPythonPackages by tasks.registering(VenvTask::class) {

val generateSimilarityWorkflow by tasks.registering(VenvTask::class) {
dependsOn(installPythonPackages)
inputs.files(generateDomainModel.get().outputs)

inputs.files(
"src/main/python/generate.py",
Expand Down
129 changes: 0 additions & 129 deletions similarity/model.json

This file was deleted.

33 changes: 33 additions & 0 deletions similarity/model.wfl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
workflow Similarity(granularity: boolean, size: int) {
in tokenizerA.input

worker tokenizerA : Tokenizer(granularity)
tokenizerA.output -> shinglerA.input
worker shinglerA : Shingler(size)

in tokenizerB.input

worker tokenizerB : Tokenizer(granularity)
tokenizerB.output -> shinglerB.input
worker shinglerB : Shingler(size)

shinglerA.output -> vectorAA.a
shinglerA.output -> vectorAA.b
shinglerA.output -> vectorAB.a

shinglerB.output -> vectorAB.b
shinglerB.output -> vectorBB.a
shinglerB.output -> vectorBB.b

worker vectorAA : VectorMultiplier
worker vectorAB : VectorMultiplier
worker vectorBB : VectorMultiplier

vectorAA.output -> cosine.aa
vectorAB.output -> cosine.ab
vectorBB.output -> cosine.bb

worker cosine : CosineSimilarity

out cosine.output
}
13 changes: 13 additions & 0 deletions workflow-ide/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
10 changes: 10 additions & 0 deletions workflow-ide/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vscode/*
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/tasks.json
node_modules/
out/
dist/
src/language/generated/
syntaxes/
bin/
40 changes: 40 additions & 0 deletions workflow-ide/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import com.github.gradle.node.npm.task.NpmTask

plugins {
id("com.github.node-gradle.node") version "7.1.0"
}

val cliOutput by configurations.creating {
isCanBeConsumed = true
}

val npmCI by tasks.registering(NpmTask::class) {
inputs.file("package-lock.json")
outputs.dir("node_modules")

args = listOf(
"ci",
)
}

val npmBuild by tasks.registering(NpmTask::class) {
inputs.dir("src")
inputs.file("esbuild.js")
inputs.file("package.json")
inputs.files(npmCI.get().outputs)
outputs.dir("dist")

args = listOf(
"run",
"package",
)
}

//val collectCliOutput by tasks.registering(Sync::class) {
// from("dist")
// into("build/cli")
//}

artifacts {
add(cliOutput.name, npmBuild)
}
23 changes: 23 additions & 0 deletions workflow-ide/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//@ts-check
import * as esbuild from 'esbuild';

const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');

const ctx = await esbuild.context({
entryPoints: ['src/cli/main.ts'],
outdir: 'dist',
bundle: true,
target: "es2023",
loader: { '.ts': 'ts' },
platform: 'node', // VSCode extensions run in a node process
sourcemap: !minify,
minify
});

if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
ctx.dispose();
}
12 changes: 12 additions & 0 deletions workflow-ide/langium-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"projectName": "Workflow",
"languages": [{
"id": "workflow",
"grammar": "src/language/workflow.langium",
"fileExtensions": [".wfl"],
"textMate": {
"out": "syntaxes/workflow.tmLanguage.json"
}
}],
"out": "src/language/generated"
}
40 changes: 40 additions & 0 deletions workflow-ide/langium-quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Welcome to your Langium VS Code Extension

## What's in the folder

This folder contains all necessary files for your language extension.
* `package.json` - the manifest file in which you declare your language support.
* `language-configuration.json` - the language configuration used in the VS Code editor, defining the tokens that are used for comments and brackets.
* `src/extension/main.ts` - the main code of the extension, which is responsible for launching a language server and client.
* `src/language/workflow.langium` - the grammar definition of your language.
* `src/language/main.ts` - the entry point of the language server process.
* `src/language/workflow-module.ts` - the dependency injection module of your language implementation. Use this to register overridden and added services.
* `src/language/workflow-validator.ts` - an example validator. You should change it to reflect the semantics of your language.
* `src/cli/main.ts` - the entry point of the command line interface (CLI) of your language.
* `src/cli/generator.ts` - the code generator used by the CLI to write output files from DSL documents.
* `src/cli/cli-util.ts` - utility code for the CLI.

## Get up and running straight away

* Run `npm run langium:generate` to generate TypeScript code from the grammar definition.
* Run `npm run build` to compile all TypeScript code.
* Press `F5` to open a new window with your extension loaded.
* Create a new file with a file name suffix matching your language.
* Verify that syntax highlighting, validation, completion etc. are working as expected.
* Run `node ./bin/cli` to see options for the CLI; `node ./bin/cli generate <file>` generates code for a given DSL file.

## Make changes

* Run `npm run watch` to have the TypeScript compiler run automatically after every change of the source files.
* Run `npm run langium:watch` to have the Langium generator run automatically after every change of the grammar declaration.
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.

## Install your extension

* To start using your extension with VS Code, copy it into the `<user home>/.vscode/extensions` folder and restart Code.
* To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension.

## To Go Further

Documentation about the Langium framework is available at https://langium.org
Loading

0 comments on commit 3b995f6

Please sign in to comment.