You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2014/02/07 14:30:14 UTC

svn commit: r1565642 - in /uima/ruta/trunk/ruta-ep-ide/src/main: antlr3/org/apache/uima/ruta/ide/core/parser/ antlr3/org/apache/uima/ruta/ide/core/parser/output/ java/org/apache/uima/ruta/ide/parser/ast/

Author: pkluegl
Date: Fri Feb  7 13:30:14 2014
New Revision: 1565642

URL: http://svn.apache.org/r1565642
Log:
UIMA-3533
- adapted grammar, factory and ast

Added:
    uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java   (with props)
Removed:
    uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/output/
Modified:
    uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g
    uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java

Modified: uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g?rev=1565642&r1=1565641&r2=1565642&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g Fri Feb  7 13:30:14 2014
@@ -184,8 +184,10 @@ import org.apache.uima.ruta.ide.parser.a
 		}
 	}
 	
-	  public void addImportTypeSystem(ComponentDeclaration module) {
-	    descriptor.addTypeSystem(module.getName());
+	  public void addImportTypeSystem(ComponentDeclaration ts) {
+	    if(ts != null){
+	     descriptor.addTypeSystem(ts.getName());
+	    }
 	  }
 	
 	  public void addImportScript(ComponentDeclaration module) {
@@ -328,11 +330,14 @@ importStatement returns [Statement stmt 
 	name = dottedComponentDeclaration 
 	{if(name != null) {stmt = StatementFactory.createImportEngine(name,im);addImportUimafitEngine(name);}}
 	 SEMI 
-	| ImportString type = dottedIdentifier (FromString ts = dottedIdentifier2)? (AsString alias = Identifier)? SEMI
-	
-	| ImportString STAR FromString ts = dottedIdentifier2 SEMI
-	
-	| ImportString PackageString pkg = dottedIdentifier (FromString ts = dottedIdentifier2)? (AsString alias = Identifier)? SEMI
+	| ImportString type = dottedId2 (FromString ts = dottedComponentDeclaration)? (AsString alias = Identifier)? SEMI
+	{stmt = StatementFactory.createImportType(im,type,ts,alias);addImportTypeSystem(ts);}
+	| ImportString STAR FromString ts = dottedComponentDeclaration SEMI
+	{stmt = StatementFactory.createImportTypeSystem(ts,im);addImportTypeSystem(ts);}
+	| ImportString PackageString pkg = dottedId2 (FromString ts = dottedComponentDeclaration)? (AsString alias = Identifier)? SEMI
+	{stmt = StatementFactory.createImportPackage(im,pkg,ts,alias);addImportTypeSystem(ts);}
+	| ImportString PackageString STAR FromString ts = dottedComponentDeclaration (AsString alias = Identifier)? SEMI
+	{stmt = StatementFactory.createImportAllPackagew(im,ts,alias);addImportTypeSystem(ts);}
 	
 	;
 	
@@ -2046,7 +2051,7 @@ dottedId2 returns [Token token = null ]
 		ct = new CommonToken(id);
 		}
 	(
-		dot = DOT {ct.setText(ct.getText() + dot.getText());}
+		dot = (DOT| MINUS) {ct.setText(ct.getText() + dot.getText());}
 		id = Identifier {ct.setStopIndex(getBounds(id)[1]);
 		                 ct.setText(ct.getText() + id.getText());}
 	)+

Added: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java?rev=1565642&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java (added)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java Fri Feb  7 13:30:14 2014
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.parser.ast;
+
+import org.antlr.runtime.Token;
+
+/**
+ * AST Node for more compley statement that import type system, their types, or packages and
+ * additionally consider an alias for them
+ * 
+ */
+public class RutaImportTypesStatement extends RutaImportStatement {
+
+  private Token typeToken;
+
+  private Token pkgToken;
+
+  private Token aliasToken;
+
+  public RutaImportTypesStatement(int sourceStart, int sourceEnd, ComponentDeclaration ts,
+          Token typeToken, Token pkgToken, Token aliasToken) {
+    super(sourceStart, sourceEnd, ts, RutaStatementConstants.S_IMPORT_TYPESYSTEM);
+    this.typeToken = typeToken;
+    this.pkgToken = pkgToken;
+    this.aliasToken = aliasToken;
+  }
+
+  public Token getTypeToken() {
+    return typeToken;
+  }
+
+  public void setTypeToken(Token typeToken) {
+    this.typeToken = typeToken;
+  }
+
+  public Token getPkgToken() {
+    return pkgToken;
+  }
+
+  public void setPkgToken(Token pkgToken) {
+    this.pkgToken = pkgToken;
+  }
+
+  public Token getAliasToken() {
+    return aliasToken;
+  }
+
+  public void setAliasToken(Token aliasToken) {
+    this.aliasToken = aliasToken;
+  }
+
+}

Propchange: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaImportTypesStatement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java?rev=1565642&r1=1565641&r2=1565642&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java Fri Feb  7 13:30:14 2014
@@ -38,10 +38,10 @@ public class StatementFactory extends Ab
    *          Antlr-Token (dotted-identifier/id)
    * @return new Import-Statement
    */
-  public static RutaImportStatement createImport(ComponentDeclaration dottedId, Token impString,
+  public static RutaImportStatement createImport(ComponentDeclaration component, Token impString,
           int type) {
-    int bounds[] = getBounds(impString, dottedId);
-    return new RutaImportStatement(bounds[0], bounds[1], dottedId, type);
+    int bounds[] = getBounds(impString, component);
+    return new RutaImportStatement(bounds[0], bounds[1], component, type);
   }
 
   public static ComponentDeclaration createEmptyComponentDeclaration(Token t) {
@@ -57,6 +57,39 @@ public class StatementFactory extends Ab
     return createImport(dottedId, impString, RutaStatementConstants.S_IMPORT_TYPESYSTEM);
   }
 
+  public static Statement createImportType(Token importToken, Token type, ComponentDeclaration ts,
+          Token alias) {
+    int bounds[] = getBounds(importToken, type);
+    if(ts != null) {
+      bounds = getBounds(importToken, ts);
+    }
+    if(alias != null) {
+      bounds = getBounds(importToken, alias);
+    }
+    return new RutaImportTypesStatement(bounds[0], bounds[1], ts, type, null, alias);
+  }
+
+  public static Statement createImportAllPackagew(Token importToken, ComponentDeclaration ts, Token alias) {
+    int bounds[] = getBounds(importToken, ts);
+    if(alias != null) {
+      bounds = getBounds(importToken, alias);
+    }
+    return new RutaImportTypesStatement(bounds[0], bounds[1], ts, null, alias, alias);
+  }
+
+  public static Statement createImportPackage(Token importToken, Token pkg, ComponentDeclaration ts,
+          Token alias) {
+    int bounds[] = getBounds(importToken, pkg);
+    if(ts != null) {
+      bounds = getBounds(importToken, ts);
+    }
+    if(alias != null) {
+      bounds = getBounds(importToken, alias);
+    }
+    return new RutaImportTypesStatement(bounds[0], bounds[1], ts, null, pkg, alias);
+  }
+  
+  
   public static RutaImportStatement createImportScript(ComponentDeclaration dottedId,
           Token impString) {
     if (dottedId != null) {
@@ -337,4 +370,6 @@ public class StatementFactory extends Ab
     return new ComponentDeclaration(nameBounds[0], nameBounds[0] + text.length(), text);
   }
 
+
+
 }