Closed zrwsmd closed 1 year ago
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
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
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.
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
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
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?
the requirement is when right part changed,corresponding left part code is changed too,rather than left part changed,the right part is changed. also,righr part is operated by user on diagram editor,like drage a component or add a component like picture below 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
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.
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
the demo example https://github.com/eclipse-sprotty/sprotty-vscode have MrsGrantsSecretCompartment.sm,i am a little confused how this file generated from corresponding diagram,that is to say how should right part tranform to left part ,i did not see any code related to it since my requirement is #375