Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit e6d6a78063ae6ea5d80b25ace7b4416b0e169654 sefftinge committed May 9, 2008
Showing with 2,820 additions and 0 deletions.
  1. +11 −0 .project
  2. +8 −0 devtools/org.eclipse.xtext.bootstrap/.classpath
  3. +34 −0 devtools/org.eclipse.xtext.bootstrap/.project
  4. +7 −0 devtools/org.eclipse.xtext.bootstrap/.settings/org.eclipse.jdt.core.prefs
  5. +10 −0 devtools/org.eclipse.xtext.bootstrap/META-INF/MANIFEST.MF
  6. +5 −0 devtools/org.eclipse.xtext.bootstrap/build.properties
  7. +40 −0 devtools/org.eclipse.xtext.bootstrap/createjar.jardesc
  8. BIN devtools/org.eclipse.xtext.bootstrap/lastversion.jar
  9. +43 −0 devtools/org.eclipse.xtext.bootstrap/src/org/eclipse/xtext/boostrap/DoBootstrapping.java
  10. +7 −0 plugins/org.eclipse.xtext.core/.classpath
  11. +34 −0 plugins/org.eclipse.xtext.core/.project
  12. +7 −0 plugins/org.eclipse.xtext.core/.settings/org.eclipse.jdt.core.prefs
  13. +11 −0 plugins/org.eclipse.xtext.core/META-INF/MANIFEST.MF
  14. +4 −0 plugins/org.eclipse.xtext.core/build.properties
  15. +63 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/AbstractEcoreElementFactory.java
  16. +51 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/AbstractParser.java
  17. +43 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/IElementFactory.java
  18. +17 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/IParseErrorHandler.java
  19. +34 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/IParser.java
  20. +46 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/ParseException.java
  21. +22 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/antlr/AntlrExceptionTool.java
  22. +54 −0 plugins/org.eclipse.xtext.core/src/org/eclipse/xtext/core/parser/antlr/TokenTool.java
  23. +7 −0 plugins/org.eclipse.xtext.generator/.classpath
  24. +34 −0 plugins/org.eclipse.xtext.generator/.project
  25. +7 −0 plugins/org.eclipse.xtext.generator/.settings/org.eclipse.jdt.core.prefs
  26. +14 −0 plugins/org.eclipse.xtext.generator/META-INF/MANIFEST.MF
  27. +4 −0 plugins/org.eclipse.xtext.generator/build.properties
  28. +83 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/GeneratorFacade.java
  29. +24 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/Properties.ext
  30. +87 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/grammargen/AntlrGrammar.xpt
  31. +70 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/grammargen/EPackageAccess.xpt
  32. +33 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/grammargen/Factory.xpt
  33. +40 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/grammargen/GrammarGen.ext
  34. +69 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/grammargen/Parser.xpt
  35. +9 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/util/GenProperties.ext
  36. +27 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/util/GenProperties.java
  37. +55 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/xtext2ecore/FeatureNormalization.ext
  38. +79 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/xtext2ecore/Xtext2Ecore.ext
  39. +20 −0 plugins/org.eclipse.xtext.generator/src/org/eclipse/xtext/xtext2ecore/Xtext2EcoreExtensions.java
  40. +10 −0 plugins/org.eclipse.xtext/.classpath
  41. +34 −0 plugins/org.eclipse.xtext/.project
  42. +7 −0 plugins/org.eclipse.xtext/.settings/org.eclipse.jdt.core.prefs
  43. +21 −0 plugins/org.eclipse.xtext/META-INF/MANIFEST.MF
  44. +14 −0 plugins/org.eclipse.xtext/build.properties
  45. +65 −0 plugins/org.eclipse.xtext/model/xtext.genmodel
  46. +20 −0 plugins/org.eclipse.xtext/model/xtextutil.ecore
  47. +25 −0 plugins/org.eclipse.xtext/model/xtextutil.genmodel
  48. +20 −0 plugins/org.eclipse.xtext/plugin.properties
  49. +20 −0 plugins/org.eclipse.xtext/plugin.xml
  50. +85 −0 plugins/org.eclipse.xtext/src/model/Xtext.xtext
  51. +137 −0 plugins/org.eclipse.xtext/src/org/eclipse/xtext/Extensions.ext
  52. +229 −0 plugins/org.eclipse.xtext/src/org/eclipse/xtext/TypeResolution.ext
  53. +52 −0 plugins/org.eclipse.xtext/src/org/eclipse/xtext/Xtext2.chk
  54. +88 −0 plugins/org.eclipse.xtext/src/org/eclipse/xtext/Xtext2Extensions.java
  55. +61 −0 plugins/org.eclipse.xtext/text/description.txt
  56. +8 −0 tests/org.eclipse.xtext.generator.tests/.classpath
  57. +34 −0 tests/org.eclipse.xtext.generator.tests/.project
  58. +7 −0 tests/org.eclipse.xtext.generator.tests/.settings/org.eclipse.jdt.core.prefs
  59. +19 −0 tests/org.eclipse.xtext.generator.tests/META-INF/MANIFEST.MF
  60. +4 −0 tests/org.eclipse.xtext.generator.tests/build.properties
  61. +86 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/XtextGrammarTest.java
  62. +83 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/XtextGrammarTest.xtext
  63. +80 −0 ...rg.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/tests/AbstractGeneratorTest.java
  64. +48 −0 ....eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/tests/GenerateAllTestGrammars.java
  65. +32 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/tests/Invocation.java
  66. +36 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammargen/tests/SimpleTest.java
  67. +11 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammargen/tests/SimpleTest.xtext
  68. +47 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammargen/tests/SimpleTest2.java
  69. +17 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammargen/tests/SimpleTest2.xtext
  70. +109 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext2ecore/EcoreModelComparator.java
  71. +98 −0 tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext2ecore/TestBootstrapModel.java
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.xtext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry exported="true" kind="lib" path="lastversion.jar" sourcepath="org.eclipse.tmf.xtext2.bootstrapsrc.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.xtext.bootstrap</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,7 @@
+#Fri May 09 14:12:51 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bootstrap Plug-in
+Bundle-SymbolicName: org.eclipse.xtext.bootstrap
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ClassPath: lastversion.jar,
+ .
+Require-Bundle: org.openarchitectureware.dependencies;bundle-version="4.3.0",
+ org.antlr;bundle-version="3.0.0"
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ lastversion_foobar.jar
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<jardesc>
+<jar path="org.eclipse.xtext.bootstrap/lastversion.jar"/>
+<options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.xtext.bootstrap/createjar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
+<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
+<selectedProjects/>
+<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
+<sealing sealJar="false">
+<packagesToSeal/>
+<packagesToUnSeal/>
+</sealing>
+</manifest>
+<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
+<file path="/org.eclipse.xtext/.classpath"/>
+<file path="/org.eclipse.xtext.generator/.classpath"/>
+<folder path="/org.eclipse.xtext.generator/branches"/>
+<javaElement handleIdentifier="=org.eclipse.xtext/emf-gen"/>
+<folder path="/org.eclipse.xtext/text"/>
+<file path="/org.eclipse.xtext/plugin.properties"/>
+<folder path="/org.eclipse.xtext/META-INF"/>
+<folder path="/org.eclipse.xtext.generator/tags"/>
+<file path="/org.eclipse.xtext.generator/build.properties"/>
+<file path="/org.eclipse.xtext/build.properties"/>
+<file path="/org.eclipse.xtext.generator/.project"/>
+<folder path="/org.eclipse.xtext.core/META-INF"/>
+<file path="/org.eclipse.xtext.core/build.properties"/>
+<javaElement handleIdentifier="=org.eclipse.xtext/src-gen"/>
+<file path="/org.eclipse.xtext/plugin.xml"/>
+<file path="/org.eclipse.xtext.core/.project"/>
+<javaElement handleIdentifier="=org.eclipse.xtext.core/src"/>
+<file path="/org.eclipse.xtext/.project"/>
+<folder path="/org.eclipse.xtext.generator/META-INF"/>
+<javaElement handleIdentifier="=org.eclipse.xtext/src"/>
+<javaElement handleIdentifier="=org.eclipse.xtext.generator/src"/>
+<javaElement handleIdentifier="=org.eclipse.xtext/model"/>
+<file path="/org.eclipse.xtext.core/.classpath"/>
+<folder path="/org.eclipse.xtext.generator/trunk"/>
+</selectedElements>
+<fatjar builder="org.eclipse.jdt.ui.plain_jar_builder" launchConfig=""/>
+</jardesc>
Binary file not shown.
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+package org.eclipse.xtext.boostrap;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.xtext.GeneratorFacade;
+import org.eclipse.xtext.Grammar;
+import org.eclipse.xtext.XtextEPackageAccess;
+import org.eclipse.xtext.XtextPackage;
+import org.eclipse.xtext.parser.XtextFactory;
+import org.eclipse.xtext.parser.XtextParser;
+
+/**
+ * @author Sven Efftinge - Initial contribution and API
+ *
+ */
+public class DoBootstrapping {
+
+ public static void main(String[] args) throws Exception {
+
+ String srcGenPath = "../org.eclipse.xtext/src-gen";
+ String filename = "../org.eclipse.xtext/src/model/Xtext.xtext";
+ String languageName = "Xtext";
+ String languageNamespace = "org/eclipse/xtext";
+
+ System.out.println("loading " + filename);
+ InputStream resourceAsStream = new FileInputStream(filename);
+ //TODO make Xtext2Factory manual so one can overwrite 'getEPackages' in order to support generated epackages
+ EPackage.Registry.INSTANCE.put(XtextEPackageAccess.XTEXT_NS_URI, XtextPackage.eINSTANCE);
+ XtextParser xtext2Parser= new XtextParser();
+ Grammar grammarModel = (Grammar) xtext2Parser.parse(resourceAsStream, new XtextFactory());
+ GeneratorFacade.generate(grammarModel, languageName, languageNamespace, srcGenPath);
+ }
+}
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.xtext.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,7 @@
+#Thu May 08 09:49:16 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Xtext2 Runtime Plug-in
+Bundle-SymbolicName: org.eclipse.xtext.core
+Bundle-Version: 1.0.0
+Bundle-Vendor: eclipse.org
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.3.2",
+ org.antlr.runtime;bundle-version="3.0.0"
+Export-Package: org.eclipse.xtext.core.parser,
+ org.eclipse.xtext.core.parser.antlr
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+
+package org.eclipse.xtext.core.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+import org.antlr.runtime.Token;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+/**
+ * @author Sven Efftinge - Initial contribution and API
+ *
+ */
+public abstract class AbstractEcoreElementFactory implements IElementFactory {
+ public Object create(String typeName) {
+ EPackage[] packages = getEPackages();
+ for (EPackage package1 : packages) {
+ EClassifier classifier = package1.getEClassifier(typeName);
+ if (classifier instanceof EClass) {
+ EClass clazz = (EClass) classifier;
+ return clazz.getEPackage().getEFactoryInstance().create(clazz);
+ }
+ }
+ return null;
+ }
+
+ public void set(Object _this, String feature, Object value) {
+ if (value instanceof Token) {
+ value = ((Token)value).getText();
+ }
+ EObject eo = (EObject) _this;
+ EStructuralFeature structuralFeature = eo.eClass().getEStructuralFeature(feature);
+ eo.eSet(structuralFeature, value);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void add(Object _this, String feature, Object value) {
+ EObject eo = (EObject) _this;
+ EStructuralFeature structuralFeature = eo.eClass().getEStructuralFeature(feature);
+ ((Collection)eo.eGet(structuralFeature)).add(value);
+ }
+
+ protected abstract EPackage[] getEPackages();
+
+}
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+package org.eclipse.xtext.core.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.antlr.runtime.ANTLRInputStream;
+import org.eclipse.emf.common.util.WrappedException;
+
+/**
+ * @author Sven Efftinge - Initial contribution and API
+ *
+ */
+public abstract class AbstractParser implements IParser {
+
+ public Object parse(InputStream in, IElementFactory factory,
+ IParseErrorHandler handler) {
+ try {
+ return parse(new ANTLRInputStream(in),factory,handler);
+ } catch (IOException e) {
+ throw new WrappedException(e);
+ }
+ }
+
+ public Object parse(InputStream in, IElementFactory factory) {
+ try {
+ return parse(new ANTLRInputStream(in),factory,getDefaultHandler());
+ } catch (IOException e) {
+ throw new WrappedException(e);
+ }
+ }
+
+
+ protected IParseErrorHandler getDefaultHandler() {
+ return new IParseErrorHandler() {
+
+ public void handleParserError(int offset, int length, String text,
+ String message) {
+ throw new ParseException(offset,length,text,message);
+ }};
+ }
+
+ protected abstract Object parse(ANTLRInputStream in, IElementFactory factory, IParseErrorHandler handler);
+}
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+package org.eclipse.xtext.core.parser;
+
+
+/**
+ * @author svenefftinge
+ *
+ */
+public interface IElementFactory {
+ /**
+ * creates an instance of the given typename
+ *
+ * @param typeName
+ * @return
+ */
+ public Object create(String typeName);
+
+ /**
+ *
+ * sets the value to the feature of _this element
+ *
+ * @param _this
+ * @param feature
+ * @param value
+ */
+ public void set(Object _this, String feature, Object value);
+
+ /**
+ * adds the value to the feature of _this element
+ *
+ * @param _this
+ * @param feature
+ * @param value
+ */
+ public void add(Object _this, String feature, Object value);
+}
Oops, something went wrong.

0 comments on commit e6d6a78

Please sign in to comment.