GithubHelp home page GithubHelp logo

Comments (10)

spoenemann avatar spoenemann commented on June 9, 2024

It's the other way around: the right part (diagram) is generated from the left part (DSL text). The code for this transformation is here:
https://github.com/eclipse-sprotty/sprotty-vscode/blob/master/examples/states-langium/language-server/src/diagram-generator.ts

from sprotty.

zrwsmd avatar zrwsmd commented on June 9, 2024

so if i need to achieve my requirement #375 ,to tranform industrial Programming Language LD(Ladder Diagram) to other specific lauguage like C++ or PLC ST (Structured Text)language,LD is similar to right part,C++ or PLC ST (Structured Text)language is similar to left part,i am considering define .langium extesion file to generate left part code template ,or do i have to write left part code by myself

from sprotty.

spoenemann avatar spoenemann commented on June 9, 2024

Langium can be used to create a parser and a language server for your ST language. Serializing text from another format is also on the roadmap, but currently not supported. So you need to generate the text with normal JavaScript / TypeScript templates.

from sprotty.

zrwsmd avatar zrwsmd commented on June 9, 2024

Langium can be used to create a parser and a language server for your ST language. Serializing text from another format is also on the roadmap, but currently not supported. So you need to generate the text with normal JavaScript / TypeScript templates.

can not clealy catch your meaning ,what do you mean by saying "Serializing text from another format",Serializing text means ST language? is my requirements currently can not be achieved by sprotty and langium?
i am thinking use langium as language server,VS Code extensions as language client,vscode webview to render LD diagram,which receive VS Code extensions response,the response from language server via lsp protocol

from sprotty.

spoenemann avatar spoenemann commented on June 9, 2024

Yes you can use Sprotty and Langium for those things. The only step that is currently not done automatically is to generate ST text from a diagram, you would need to implement that yourself. Langium has nice APIs to generate text: https://www.typefox.io/blog/code-generation-for-langium-based-dsls

from sprotty.

zrwsmd avatar zrwsmd commented on June 9, 2024

Yes you can use Sprotty and Langium for those things. The only step that is currently not done automatically is to generate ST text from a diagram, you would need to implement that yourself. Langium has nice APIs to generate text: https://www.typefox.io/blog/code-generation-for-langium-based-dsls

i have seen laugium example like domainmodel or statemachine,also see sprotty document and example ,i probably knows how they works,take domainmodel as an example ,it firstly define a custom language with extension .domainmodel,then generate ast code by langium-cli,then use cli to generate java code with the help of generated ast code ,so if i need to achieve this requirement,i am thinking define a custom lauguage like extension .aaa,i write aaa.langium grammar related to LD language logic(#375 ) ,then generate ast code by langium-cli,then i write example.aaa ,corresponding diagram is generated by extends LangiumDiagramGenerator,then i use cli to generate ST code by using generated ast code,is my idea correct?

from sprotty.

zrwsmd avatar zrwsmd commented on June 9, 2024

the requirement is when right part changed,corresponding left part code is changed too,rather than left part changed,the right part is changed.
image
also,righr part is operated by user on diagram editor,like drage a component or add a component like picture below
image
finally,generate code is also needed a requirement( industrial Programming Language LD(Ladder Diagram) to other specific lauguage like C++ or PLC ST (Structured Text))
i was wondering whether sprotty-langium can achieve this requirements ,or should i use glsp instead

from sprotty.

spoenemann avatar spoenemann commented on June 9, 2024

LD is a graphical language. What format are you using to persist it? If it's a custom text language, you can use Langium to parse that and then generate other formats like ST or C++. But if you use XML or JSON, you don't need Langium; just use plain TypeScript or some template library in that case.

from sprotty.

zrwsmd avatar zrwsmd commented on June 9, 2024

when right part delete a component for example,i found corresponding left part also changed too,how their synchronized,i did not find related code
image

from sprotty.

spoenemann avatar spoenemann commented on June 9, 2024

The code is here: https://github.com/eclipse-sprotty/sprotty-vscode/blob/master/packages/sprotty-vscode-webview/src/lsp/editing/delete-with-workspace-edit.ts

from sprotty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.