Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » TortoiseShell - is there simple way to run the interpreter to run a program ?
TortoiseShell - is there simple way to run the interpreter to run a program ? [message #1807243] Sat, 25 May 2019 17:22 Go to next message
Andrea Bigi is currently offline Andrea BigiFriend
Messages: 2
Registered: May 2019
Junior Member

can someone please help me ??

is there a simple way to run the interpreter and have a look at commands execution ?

what I have to do to have the following code running ?

(now I'm getting a a null pointer exception at the line indicated below, inside the method)

import java.text.ParseException;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.parser.IParser;
import org.xtext.tortoiseshell.TortoiseShellStandaloneSetup;
import org.xtext.tortoiseshell.interpreter.TortoiseShellInterpeter;
import org.xtext.tortoiseshell.lib.Tortoise;


public class XtextParser {

private IParser parser;

public XtextParser() {

private void setupParser() {
Injector injector = new TortoiseShellStandaloneSetup().createInjectorAndDoEMFRegistration();

* Parses data provided by an input reader using Xtext and returns the root node of the resulting object tree.
* @param reader Input reader
* @return root object node
* @throws IOException when errors occur during the parsing process
public EObject parse(Reader reader) throws IOException, ParseException
IParseResult result = parser.parse(reader);
throw new ParseException("Provided input contains syntax errors.", 0);
return result.getRootASTElement();
public static void main(String[] args) throws IOException, ParseException {
XtextParser xtp=new XtextParser();
FileReader reader=new FileReader("c:\\\Nikolaus.tortoiseshell");
EObject program = xtp.parse(reader);

TortoiseShellInterpeter tsi = new TortoiseShellInterpeter();
Tortoise tortoise= new Tortoise();, program, 1000); <<<<<NPE INSIDE THIS METHOD>>>>


Thanks in advance
Re: TortoiseShell - is there simple way to run the interpreter to run a program ? [message #1807244 is a reply to message #1807243] Sat, 25 May 2019 17:24 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13151
Registered: July 2009
Senior Member
The usual way to load a model I showed here

With no specifics about the npe?
i cannot help!

Maybe there are injects in the interpreter and you should create it with the injector

you also may have a look at the prjects unit tests

 * Copyright (c) 2019 itemis AG ( and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
package org.xtext.tortoiseshell;


import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.util.StringInputStream;
import org.xtext.tortoiseshell.interpreter.TortoiseShellInterpeter;
import org.xtext.tortoiseshell.lib.Tortoise;


 * @author dietrich - Initial contribution and API
public class Main {
	public static void main(String[] args) throws IOException {
		Injector i = new TortoiseShellStandaloneSetup().createInjectorAndDoEMFRegistration();
		ResourceSet rs = i.getInstance(ResourceSet.class);
		Resource r = rs.getResource(URI.createURI("file:/home/dietrich/Downloads/2019-03-RC1/wswm22/org.xtext.tortoiseshell.examples/src/org/xtext/tortoiseshell/example/Pentgram.tortoiseshell"), true);
		TortoiseShellInterpeter interpreter = i.getInstance(TortoiseShellInterpeter.class);
		Tortoise tortoise = new Tortoise();
		EObject program = r.getContents().get(0);
		System.out.println(program);, program, -100);


Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :

[Updated on: Sat, 25 May 2019 18:44]

Report message to a moderator

Previous Topic:Deployed xText IDE does not work
Next Topic:Xtext - how to extend XtextDocument class
Goto Forum:

Current Time: Tue Oct 15 13:41:16 GMT 2019

Powered by FUDForum. Page generated in 0.01407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top