0
votes

I'm following 7 languages tutoiral from XText homepage (http://www.eclipse.org/Xtext/7languages.html)

In the first example "scripting" I've managed to get almost everything running, but there seems to be a problem with identifiers scoping.

I have editor running and code generation for empty script, but trying to write anything useful doesn't work.

I typed code for grammar and model inferer verbatim from tutorial and also tried to use versions from github repo with examples https://github.com/xtext-dev/seven-languages-xtext

demo.script

val i = 1

demo.java generated

public class demo {
    public static void main(final String[] args) {
        final int i = 1;
    }
}

This works fine

Now here is input that causes problems

error.script

println("test")

This reports two errors:

Error 1

Description: Couldn't resolve reference to JvmIdentifiableElement 'println'.
Resource: error.script
Path: /org.xtext.scripting.demo/scripting
Location: line: 3 /org.xtext.scripting.demo/scripting/demo.script
Type: Scripting Problem

Error 2

Description: This expression is not allowed in this context, since it doesn't cause any side effects.
Resource: error.script
Path: /org.xtext.scripting.demo/scripting
Location: line: 1 /org.xtext.scripting.demo/scripting/error.script
Type: Scripting Problem

I'm using XText plugins in version 2.4.0

Any suggestions what to change to make this example working as described in tutorial?

1

1 Answers

2
votes

You have to add a dependency to the xbase.lib to the project that contains the script file.