xtext

Translate ANTLR grammar into XText grammar: how to remove syntactic predicates

本秂侑毒 提交于 2019-12-05 20:25:13
I'm new to both Xtext and ANTLR. I need to translate an ANTLR (.g) grammar into an XTEXT (.xtext) grammar. In the ANTLR grammar there are syntactic predicates which are not supported by Xtext. Is there a way to remove/translate these predicates? Thanks EDIT The ANTLR grammar which I'm trying to translate can be found here: /* * Copyright 2009, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright

Accessing Xtext's runtime EMF model

橙三吉。 提交于 2019-12-05 19:00:33
I created a DSL via Xtext and now I need to transform the models created in the editor into another model(s). I suppose the most straightforward way is to employ some kind of M2M transformation framework, but i need to access the model behind the textual file. Question: how can I get a reference to the model? The models created by Xtext have also a resource factory created for them. If you try to load the textual file as an EMF model, EMF will look for resource factories available for the extension of your textual file. From there, Xtext will transform the textual file in an EMF model and give

Writing a custom Xtext/ANTLR lexer without a grammar file

那年仲夏 提交于 2019-12-05 18:34:42
问题 I'm writing an Eclipse/Xtext plugin for CoffeeScript, and I realized I'll probably need to write a lexer for it by hand. CoffeeScript parser also uses a hand-written lexer to handle indentation and other tricks in the grammar. Xtext generates a class that extends org.eclipse.xtext.parser.antlr.Lexer which in turn extends org.antlr.runtime.Lexer . So I suppose I'll have extend it. I can see two ways to do that Override mTokens() . This is done by the generated code, changing the internal state

Convert simple Antlr grammar to Xtext

元气小坏坏 提交于 2019-12-05 16:56:15
问题 I want to convert a very simple Antlr grammar to Xtext, so no syntactic predicates, no fancy features of Antlr not provided by Xtext. Consider this grammar grammar simple; // Antlr3 foo: number+; number: NUMBER; NUMBER: '0'..'9'+; and its Xtext counterpart grammar Simple; // Xtext import "http://www.eclipse.org/emf/2002/Ecore" as ecore generate Simple "http://www.example.org/Simple" Foo: dummy=Number+; Number: NUMBER_TOKEN; terminal NUMBER_TOKEN: '0'..'9'+; Xtext uses Antlr behind the scenes,

Linking Xtext with StringTemplate code generator

霸气de小男生 提交于 2019-12-04 14:34:56
问题 In my current project, I am trying to link the DSL specification written in xtext and code generator written in StringTemplate. for instance, the syntax of my DSL specification is as follows. I am entering this information through nice editor facilities provided by xText. structs: TempStruct tempValue : double; unitOfMeasurement : String; abilities : sensors: TemperatureSensor generate tempMeasurement : TempStruct; attribute responseFormat : String; The grammar of above mentioned DSL

terminal/datatype/parser rules in xtext

人盡茶涼 提交于 2019-12-04 13:52:49
I'm using xtext 2.4. What I want to do is a SQL-like syntax. The things confuse me are I'm not sure which things should be treated as terminal/datatype/parser rules. So far my grammar related to MyTerm is: Model: (terms += MyTerm ';')* ; MyTerm: constant=MyConstant | variable?='?'| collection_literal=CollectionLiteral ; MyConstant : string=STRING | number=MyNumber | date=MYDATE | uuid=UUID | boolean=MYBOOLEAN | hex=BLOB ; MyNumber: int=SIGNINT | float=SIGNFLOAT ; SIGNINT returns ecore::EInt: '-'? INT ; SIGNFLOAT returns ecore::EFloat: '-'? INT '.' INT; ; CollectionLiteral: => MapLiteral |

Interpreter vs. Code Generator Xtext

无人久伴 提交于 2019-12-04 08:53:11
I've a DSL written using Xtext. What I want is to execute that DSL to perform something good out of it. I wrote myDslGenerator class implementing the interface IGenerator in xtend to generate java code and it's working fine. I've two questions; What is the difference between Interpreter and Code Generator? Aren't both for executing DSL? How to write an interpreter? Any step by step tutorial link? I found many tutorial to generate code using xtend but couldn't find any for writing an interpreter. Thank you, Salman Basically, interpreters and code generators work really differently. Code

Writing a custom Xtext/ANTLR lexer without a grammar file

夙愿已清 提交于 2019-12-04 03:49:27
I'm writing an Eclipse/Xtext plugin for CoffeeScript, and I realized I'll probably need to write a lexer for it by hand. CoffeeScript parser also uses a hand-written lexer to handle indentation and other tricks in the grammar. Xtext generates a class that extends org.eclipse.xtext.parser.antlr.Lexer which in turn extends org.antlr.runtime.Lexer . So I suppose I'll have extend it. I can see two ways to do that Override mTokens() . This is done by the generated code, changing the internal state. Override nextToken() which seems a natural approach, but then I'll have to keep track of the internal

Unparse AST < O(exp(n))?

梦想的初衷 提交于 2019-12-04 01:20:13
Abstract problem description: The way I see it, unparsing means to create a token stream from an AST, which when parsed again produces an equal AST. So parse(unparse(AST)) = AST holds. This is the equal to finding a valid parse tree which would produce the same AST. The language is described by a context free S-attributed grammar using a eBNF variant. So the unparser has to find a valid 'path' through the traversed nodes in which all grammar constraints hold. This bascially means to find a valid allocation of AST nodes to grammar production rules. This is a constraint satisfaction problem (CSP

ClassNotFoundException: junit.framework.TestCase cannot be found by org.eclipse.xtext.junit_2.4.3.v201309030823

时光总嘲笑我的痴心妄想 提交于 2019-12-03 23:56:17
I'm puzzled by this error: java.lang.NoClassDefFoundError: junit/framework/TestCase at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:792) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638) ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)