Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install Eclipse. For what we do, we recommend installing the Eclipse Modeling Tools, with a few extras. Our Wiki page on getting Eclipse has the details: simply follow the instructions for downloading and installing Eclipse and you should be set.
  2. Open your eclipse instance and install the complete Xtext SDK 2.7.3 from the itemis updatesite: http://download.itemis.de/updates/
    Image Added

Recommended Tutorials

We recommend that you have completed the following tutorials before diving into this one.

...

An Xtext grammar is always related to a specific EMF meta model. The grammar defines a concrete syntax in which instances of the meta model (the abstract syntax) can be serialized and stored. Xtext supports two ways of linking a grammar with a meta model: either creating a grammar for an existing meta model, or creating a grammar first and generating a meta model out of it. Here we will use the former approach, reusing the meta model for Turing Machines that you already defined earlier.

...

  1. File → New → Project... → Xtext → Xtext Project From Existing Meta Models → Next → Add... → turing.genmodel → OK
  2. Select your top-level model element as "Entry rule", e.g. TuringMachine → Next → enter the following values:
    • Project name: de.cau.cs.rtprak.login.turing.text (like in previous tutorials, replace "login" by your login name)
    • Location: your repository path
    • Name: de.cau.cs.rtprak.login.turing.text.Turing
    • Extensions: tuxt (the file extension under which your text files will be stored)
    • Uncheck Create SDK feature project (not required)
  3. Finish → an editor is opened with a predefined grammar (Turing.xtext). The fourth line should contain an import statement followed by the namespace URI of your meta model, which is probably marked with an error. The problem here is that the meta model is not loaded in the Eclipse instance you are using for development. Fix this problem by replacing the URI by the workspace path of your Turing Machines ecore model, e.g. "platform:/resource/de.cau.cs.rtprak.login.turingmodel/model/turing.ecore"
  4. The Turing.xtext file is located in the package de.cau.cs.rtprak.login.turing.text together with a Modeling Workflow Engine file, which can be used to configure code generation. Right-click GenerateTuring.mwe2 and select Run As → MWE2 Workflow. If you get an error message like "*ATTENTION* It is recommended to use the ANTLR 3 parser generator" in the console, type n and install Antlr from the update site.
  5. Now a great amount of Java code should have been generated. Add the new plugins to your Eclipse run configuration and start it.
  6. In the new Eclipse instance: File → New → File and name it test.tuxt (when asked to add the Xtext nature, hit Yes).
  7. Use ctrl + space for getting content assist to create a valid model following the predefined grammar. The syntax will probably look similar to this:

    Code Block
    languagetext
    TuringMachine {
        states {
            State blub {
            },
            State blah {
                outgoing {
                    Transition {
                        target blub
                    }
                }
            }
        }
    }

...