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 2013/04/26 14:08:24 UTC

svn commit: r1476157 - in /uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast: ExpressionFactory.java FeatureMatchExpression.java

Author: pkluegl
Date: Fri Apr 26 12:08:24 2013
New Revision: 1476157

URL: http://svn.apache.org/r1476157
Log:
UIMA-2758
- added AST element for feature matches

Added:
    uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/FeatureMatchExpression.java
Modified:
    uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java

Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java?rev=1476157&r1=1476156&r2=1476157&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java Fri Apr 26 12:08:24 2013
@@ -341,6 +341,12 @@ public class ExpressionFactory extends A
     return createStringFunction(name, list);
   }
 
+
+  public static Expression createFeatureMatch(Token feature, Expression value) {
+    int bounds[] = getBounds(feature);
+    return new FeatureMatchExpression(bounds[0], value.sourceEnd(), feature, value);
+  }
+
   public static Expression createBooleanFunction(Token id, List<Expression> args) {
     return createFunction(id, args, TMTypeConstants.TM_TYPE_B);
   }

Added: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/FeatureMatchExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/FeatureMatchExpression.java?rev=1476157&view=auto
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/FeatureMatchExpression.java (added)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/FeatureMatchExpression.java Fri Apr 26 12:08:24 2013
@@ -0,0 +1,64 @@
+/*
+ * 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.textmarker.ide.parser.ast;
+
+import org.antlr.runtime.Token;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+
+public class FeatureMatchExpression extends Expression {
+  
+  private final Token feature;
+  private final Expression value;
+
+  public FeatureMatchExpression(int sourceStart, int sourceEnd, Token feature, Expression value) {
+    super(sourceStart, sourceEnd);
+    this.feature = feature;
+    this.value = value;
+  }
+
+
+  @Override
+  public void traverse(ASTVisitor visitor) throws Exception {
+    if (visitor.visit(this)) {
+      if (value != null) {
+        value.traverse(visitor);
+      }
+      visitor.endvisit(this);
+    }
+  }
+
+
+  @Override
+  public int getKind() {
+    return 0;
+  }
+
+
+  public Token getFeature() {
+    return feature;
+  }
+
+
+  public Expression getValue() {
+    return value;
+  }
+
+}