]> source.dussan.org Git - aspectj.git/commitdiff
Tests and fix for pr98646: "Parser cannot parse varargs correctly". Fix is to make...
authoraclement <aclement>
Tue, 7 Jun 2005 13:12:51 +0000 (13:12 +0000)
committeraclement <aclement>
Tue, 7 Jun 2005 13:12:51 +0000 (13:12 +0000)
weaver/src/org/aspectj/weaver/patterns/BasicTokenSource.java
weaver/src/org/aspectj/weaver/patterns/PatternParser.java
weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java

index dad3bccd4edd7299a112622a9a60a2b07984fbc7..a1141353913fcc6ee8324ebc2f8a450ff0d051ef 100644 (file)
@@ -95,7 +95,6 @@ public class BasicTokenSource implements ITokenSource {
                                case '\r':
                                        continue;
                                case '*':
-                               case '.':
                                case '(':
                                case ')':
                                case '+':
@@ -107,6 +106,22 @@ public class BasicTokenSource implements ITokenSource {
                                case '@':
                                    tokens.add(BasicToken.makeOperator(makeString(ch), i-1, i-1));
                                    continue;
+                               case '.':
+                                       if ((i+2)<=chars.length) {
+                                               // could be '...'
+                                               char nextChar1 = chars[i];
+                                               char nextChar2 = chars[i+1];
+                                               if (ch==nextChar1 && ch==nextChar2) {
+                                                       // '...'
+                                                       tokens.add(BasicToken.makeIdentifier("...",i-1,i+1));
+                                                       i=i+2;
+                                               } else {
+                                                       tokens.add(BasicToken.makeOperator(makeString(ch), i-1, i-1));
+                                               }
+                                       } else {
+                                               tokens.add(BasicToken.makeOperator(makeString(ch), i-1, i-1));
+                                       }
+                                       continue;
                                case '&':
                                case '|':
                                    if (i == chars.length) {
index 211fdbb5824de4ef0b055f46f1da845e3afc31e7..32ff9d1a9ec8ea45032383da25141b291d195ecb 100644 (file)
@@ -639,21 +639,6 @@ public class PatternParser {
                        dim++;
                }
 
-        // FIXME AV for Adrian - varargs need special handling since Token are 3x"." and not "..."
-        // the following works for 'call(* *(int, Integer...))' but not in the general case (see testAJDKExamples test f.e.)
-        // and the current code does not work for 'call(* *(int, Integer...))'
-//        int varargDot = 0;
-//        while (maybeEat(".")) {
-//            varargDot++;
-//        }
-//        boolean isVarArgs = false;
-//        if (varargDot > 0) {
-//            if (varargDot == 3) {
-//                isVarArgs = true;
-//            } else {
-//                throw new ParserException("Invalid varargs", tokenSource.peek());
-//            }
-//        }
         boolean isVarArgs = maybeEat("...");
 
                boolean includeSubtypes = maybeEat("+");
@@ -785,8 +770,10 @@ public class PatternParser {
                                if (previous != null) {
                                        if (!isAdjacent(previous, tok)) break;
                                }
-                               if (tok.getString() == "*" || tok.isIdentifier()) {
+                               if (tok.getString() == "*" || (tok.isIdentifier() && tok.getString()!="...")) {
                                        buf.append(tok.getString());
+                               } else if (tok.getString()=="...") {
+                                       break;
                                } else if (tok.getLiteralKind() != null) {
                                        //System.err.println("literal kind: " + tok.getString());
                                        String s = tok.getString();
@@ -829,19 +816,6 @@ public class PatternParser {
                        
                        if (afterDot == null) {
                                buf.setLength(0);
-//                //FIXME AV for Adrian - the following does not works in the general case
-//                //varargs lookahead
-//                IToken next_1 = tokenSource.peek();
-//                if (!IToken.EOF.equals(next_1) && next_1.getString().equals(".")) {
-//                    IToken next_2 = tokenSource.peek(1);
-//                    if (!IToken.EOF.equals(next_2) && next_2.getString().equals(".")) {
-//                        IToken next_3 = tokenSource.peek(2);
-//                        if (!IToken.EOF.equals(next_3) && next_3.getString().equals(".")) {
-//                            // happens to be a varargs
-//                            break;
-//                        }
-//                    }
-//                }
                                // no elipsis or dotted name part
                 if (!maybeEat(".")) break;
                 // go on
index 1280a6a3d6a530e557b618cae6b105096de8f13a..f7b90f1a5ea11ba8aac156d9757e998f1f1e4ee1 100644 (file)
@@ -47,9 +47,9 @@ public class VisitorTestCase extends TestCase {
         //empty so that JUnit does not complain about no test cases in there - this one beeing already in the suite
     }
 
-//    public void testTemp() {
-//        Pointcut.fromString("call(* *(int, Integer...))");
-//    }
+    public void testTemp() {
+        Pointcut.fromString("call(* *(int, Integer...))");
+    }
 
 //    public void testPointcuts() {
 //        if (pointcuts.isEmpty()) {