Changes for page Code Generation with Xtend
Last modified by Richard Kreissig on 2025/01/30 12:03
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -20,33 +20,15 @@ 20 20 * The Imperative Programming Language metamodel you downloaded in the previous tutorial. 21 21 * The Turing-Machine-to-Imperative-Programming-Language transformation you developed in the previous tutorial. 22 22 23 - Thistutorial will makextendsiveuse of [[template expressions>>url:http://www.eclipse.org/xtend/documentation.html#templates||shape="rect"]],so be sureto read up onthose.23 += Generating Code with Xtext = 24 24 25 -= Generating Code with Xtend = 26 - 27 27 We will of course need a new Xtend class that will take care of the code generation. 28 28 29 29 1. Add a new //Xtend Class// to the compiler project, preferrably in a new package called {{code language="none"}}de.cau.cs.rtprak.login.compiler.codegen{{/code}}. 30 -1. ((( 31 -Add a method to your class that starts the code generation. It can look something like this: 32 32 33 -{{code}} 34 - /** 35 - * Generates Java code for the given imperative program. 36 - * 37 - * @param program the imperative program to generate code for. 38 - * @return code that implements the imperative program. 39 - */ 40 - def String generateCode(Program program) ''' 41 - YOUR CODE GENERATION 42 - ''' 43 -{{/code}} 44 -))) 45 -1. Decide, which programming language to generate code for. The easiest will probably be Java, but other languages should be fine too. Your code is supposed to generate code that is complete and compilable in your target language. 46 - 47 47 = Making the Code Generation Available = 48 48 49 -As in the previous tutorial, add a menu contribution to the {{code language="none"}}...compiler.ui{{/code}} plug-in to make the code generation available in the interface. Since your code generation implementation is expected to work for arbitrary (valid) instances of the programming language model, your menu contribution should be available for all programming language models and their textual representations. (".imperative" and ".pseudo" files) As in the previous tutorial, your handler should create a new file in the same directory as the input file and refresh the folder afterwards to have the file show up in the project explorer.31 +As in the previous tutorial, add a menu contribution to the {{code language="none"}}...compiler.ui{{/code}} plug-in to make the code generation available in the interface. Since your code generation implementation is expected to work for arbitrary (valid) instances of the programming language model, your menu contribution should be available for all programming language models and their textual representations. (".imperative" and ".pseudo" files) 50 50 51 51 == Testing Your Implementation == 52 52
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -36047 101 +3604700 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/36047 10/Code Generation with Xtend1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/3604700/Code Generation with Xtend