Revision: 19654 http://sourceforge.net/p/gate/code/19654 Author: markagreenwood Date: 2016-10-09 16:14:13 +0000 (Sun, 09 Oct 2016) Log Message: ----------- pulling in the changes to jape Ian made around quoted strings
Modified Paths: -------------- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.jj gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpslPlain.html Property Changed: ---------------- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ Index: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser 2016-10-09 01:25:17 UTC (rev 19653) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser 2016-10-09 16:14:13 UTC (rev 19654) Property changes on: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser ___________________________________________________________________ Added: svn:mergeinfo ## -0,0 +1,7 ## +/gate/branches/new-ontology-api/plugins/ANNIE/src/main/java/gate/jape/parser:10584-11598 +/gate/branches/release-7.0/plugins/ANNIE/src/main/java/gate/jape/parser:15335-15398 +/gate/branches/release-8.1/plugins/ANNIE/src/main/java/gate/jape/parser:18736-18747 +/gate/branches/sawdust/plugins/ANNIE/src/main/java/gate/jape/parser:17055-17079 +/gate/tags/release-7.0/plugins/ANNIE/src/main/java/gate/jape/parser:15399-15407 +/gate/trunk/plugins/ANNIE/src/main/java/gate/jape/parser:3-390,19180-19294 +/gate/trunk/src/main/gate/jape/parser:19180-19653 \ No newline at end of property Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.java 2016-10-09 01:25:17 UTC (rev 19653) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.java 2016-10-09 16:14:13 UTC (rev 19654) @@ -9,7 +9,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import gate.jape.JapeFactory; +import gate.Factory; import gate.util.*; import gate.jape.*; import gate.jape.constraint.*; @@ -132,6 +132,19 @@ } /** + * Normalise for quoted and unquoted strings - if the token is a string, + * strip the quotes off its image, otherwise return the image as-is. + */ + protected String stringValueOf(Token tok) { + if(tok.kind == string) { + // quoted string - strip the quotes + return tok.image.substring(1, tok.image.length() - 1); + } else { + return tok.image; + } + } + + /** * Append the given string to the end of the given buffer as a Java string * literal. If <code>str</code> is <code>null</code>, we append the four * characters n, u, l, l. Otherwise, we append the contents of str surrounded @@ -551,6 +564,7 @@ label_5: while (true) { switch (jj_nt.kind) { + case string: case ident:{ ; break; @@ -559,8 +573,21 @@ jj_la1[7] = jj_gen; break label_5; } - inputTok = jj_consume_token(ident); -t.addInput(inputTok.image); + switch (jj_nt.kind) { + case ident:{ + inputTok = jj_consume_token(ident); + break; + } + case string:{ + inputTok = jj_consume_token(string); + break; + } + default: + jj_la1[8] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +t.addInput(stringValueOf(inputTok)); } break; } @@ -574,7 +601,7 @@ break; } default: - jj_la1[8] = jj_gen; + jj_la1[9] = jj_gen; break label_6; } optionNameTok = jj_consume_token(ident); @@ -589,7 +616,7 @@ break; } default: - jj_la1[9] = jj_gen; + jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -638,7 +665,7 @@ break; } default: - jj_la1[10] = jj_gen; + jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -653,7 +680,7 @@ break; } default: - jj_la1[11] = jj_gen; + jj_la1[12] = jj_gen; break label_7; } switch (jj_nt.kind) { @@ -671,7 +698,7 @@ break; } default: - jj_la1[12] = jj_gen; + jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -702,7 +729,7 @@ break; } default: - jj_la1[13] = jj_gen; + jj_la1[14] = jj_gen; ; } if(importblock != null) { @@ -763,7 +790,7 @@ break; } default: - jj_la1[14] = jj_gen; + jj_la1[15] = jj_gen; ; } lhs = LeftHandSide(); @@ -819,7 +846,7 @@ break; } default: - jj_la1[15] = jj_gen; + jj_la1[16] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -884,7 +911,7 @@ break; } default: - jj_la1[16] = jj_gen; + jj_la1[17] = jj_gen; break label_8; } } @@ -896,7 +923,7 @@ break; } default: - jj_la1[17] = jj_gen; + jj_la1[18] = jj_gen; break label_9; } jj_consume_token(bar); @@ -914,7 +941,7 @@ break; } default: - jj_la1[18] = jj_gen; + jj_la1[19] = jj_gen; break label_10; } } @@ -962,7 +989,7 @@ break; } default: - jj_la1[19] = jj_gen; + jj_la1[20] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -989,7 +1016,7 @@ break; } default: - jj_la1[20] = jj_gen; + jj_la1[21] = jj_gen; break label_11; } jj_consume_token(comma); @@ -1008,7 +1035,7 @@ break; } default: - jj_la1[21] = jj_gen; + jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1033,7 +1060,7 @@ break; } default: - jj_la1[22] = jj_gen; + jj_la1[23] = jj_gen; ; } switch (jj_nt.kind) { @@ -1049,14 +1076,14 @@ break; } default: - jj_la1[23] = jj_gen; + jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; } default: - jj_la1[24] = jj_gen; + jj_la1[25] = jj_gen; ; } String bindingName = null; @@ -1100,7 +1127,7 @@ break; } default: - jj_la1[25] = jj_gen; + jj_la1[26] = jj_gen; ; } jj_consume_token(rightSquare); @@ -1114,7 +1141,7 @@ break; } default: - jj_la1[26] = jj_gen; + jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1139,12 +1166,24 @@ break; } default: - jj_la1[27] = jj_gen; + jj_la1[28] = jj_gen; ; } - // the annotation type + switch (jj_nt.kind) { + case ident:{ annotTypeTok = jj_consume_token(ident); -c = JapeFactory.getConstraintFactory().createConstraint(annotTypeTok.image); + break; + } + case string:{ + annotTypeTok = jj_consume_token(string); + break; + } + default: + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +c = Factory.getConstraintFactory().createConstraint(stringValueOf(annotTypeTok)); if(negate) c.negate(); switch (jj_nt.kind) { case metaPropOp: @@ -1156,7 +1195,7 @@ opTok = jj_consume_token(attrOp); attrValPair = AttrVal(); opString = opTok.image; - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); break; } case metaPropOp:{ @@ -1164,9 +1203,9 @@ metaPropertyTok = jj_consume_token(ident); opTok = jj_consume_token(attrOp); attrValPair = AttrVal(); -accessor = JapeFactory.getConstraintFactory().createMetaPropertyAccessor(metaPropertyTok.image); +accessor = Factory.getConstraintFactory().createMetaPropertyAccessor(metaPropertyTok.image); opString = opTok.image; - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); break; } case ident:{ @@ -1180,29 +1219,30 @@ break; } case pling: + case string: case ident:{ embeddedConstraint = Constraint(); break; } default: - jj_la1[28] = jj_gen; + jj_la1[30] = jj_gen; jj_consume_token(-1); throw new ParseException(); } opString = opTok.image; accessor = new SimpleAnnotationAccessor(); - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, embeddedConstraint)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, embeddedConstraint)); break; } default: - jj_la1[29] = jj_gen; + jj_la1[31] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; } default: - jj_la1[30] = jj_gen; + jj_la1[32] = jj_gen; ; } {if ("" != null) return c;} @@ -1216,8 +1256,21 @@ final public AnnotationAccessor FeatureAccessor() throws ParseException {Token attrNameTok = null; AnnotationAccessor accessor = null; jj_consume_token(period); - attrNameTok = jj_consume_token(ident); -accessor = JapeFactory.getConstraintFactory().createDefaultAccessor(attrNameTok.image); + switch (jj_nt.kind) { + case ident:{ + attrNameTok = jj_consume_token(ident); + break; + } + case string:{ + attrNameTok = jj_consume_token(string); + break; + } + default: + jj_la1[33] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +accessor = Factory.getConstraintFactory().createDefaultAccessor(stringValueOf(attrNameTok)); {if ("" != null) return accessor;} throw new Error("Missing return statement in function"); } @@ -1254,7 +1307,7 @@ break; } default: - jj_la1[31] = jj_gen; + jj_la1[34] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1309,7 +1362,7 @@ break; } default: - jj_la1[32] = jj_gen; + jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1330,7 +1383,7 @@ break; } default: - jj_la1[33] = jj_gen; + jj_la1[36] = jj_gen; break label_12; } attrNameTok = jj_consume_token(ident); @@ -1343,7 +1396,7 @@ break; } default: - jj_la1[34] = jj_gen; + jj_la1[37] = jj_gen; ; } } @@ -1364,7 +1417,7 @@ break; } default: - jj_la1[35] = jj_gen; + jj_la1[38] = jj_gen; break label_13; } jj_consume_token(comma); @@ -1432,7 +1485,7 @@ break; } default: - jj_la1[36] = jj_gen; + jj_la1[39] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1514,7 +1567,7 @@ break; } default: - jj_la1[37] = jj_gen; + jj_la1[40] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1530,8 +1583,21 @@ annotSetName = block[0] + "Annots"; jj_consume_token(period); - nameTok = jj_consume_token(ident); -newAnnotType = nameTok.image; + switch (jj_nt.kind) { + case ident:{ + nameTok = jj_consume_token(ident); + break; + } + case string:{ + nameTok = jj_consume_token(string); + break; + } + default: + jj_la1[41] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +newAnnotType = stringValueOf(nameTok); // start of the attribute stuff blockBuffer.append(" java.lang.Object val = null;" + nl); @@ -1540,18 +1606,31 @@ label_14: while (true) { switch (jj_nt.kind) { + case string: case ident:{ ; break; } default: - jj_la1[38] = jj_gen; + jj_la1[42] = jj_gen; break label_14; } - // the name of the attribute, and equals sign - nameTok = jj_consume_token(ident); + switch (jj_nt.kind) { + case ident:{ + nameTok = jj_consume_token(ident); + break; + } + case string:{ + nameTok = jj_consume_token(string); + break; + } + default: + jj_la1[43] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } jj_consume_token(assign); -newAttrName = nameTok.image; +newAttrName = stringValueOf(nameTok); switch (jj_nt.kind) { case integer: case string: @@ -1630,9 +1709,22 @@ switch (jj_nt.kind) { case period:{ jj_consume_token(period); - nameTok = jj_consume_token(ident); -existingAnnotType = nameTok.image; switch (jj_nt.kind) { + case ident:{ + nameTok = jj_consume_token(ident); + break; + } + case string:{ + nameTok = jj_consume_token(string); + break; + } + default: + jj_la1[44] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +existingAnnotType = stringValueOf(nameTok); + switch (jj_nt.kind) { case period:{ opTok = jj_consume_token(period); break; @@ -1642,12 +1734,25 @@ break; } default: - jj_la1[39] = jj_gen; + jj_la1[45] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - nameTok = jj_consume_token(ident); -opName = opTok.image; existingAttrName = nameTok.image; + switch (jj_nt.kind) { + case ident:{ + nameTok = jj_consume_token(ident); + break; + } + case string:{ + nameTok = jj_consume_token(string); + break; + } + default: + jj_la1[46] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +opName = opTok.image; existingAttrName = stringValueOf(nameTok); blockBuffer.append( " if (" + existingAnnotSetName + " != null) {" + nl + " gate.AnnotationSet existingAnnots = " + nl + @@ -1730,7 +1835,7 @@ break; } default: - jj_la1[40] = jj_gen; + jj_la1[47] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1740,7 +1845,7 @@ break; } default: - jj_la1[41] = jj_gen; + jj_la1[48] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1750,7 +1855,7 @@ break; } default: - jj_la1[42] = jj_gen; + jj_la1[49] = jj_gen; ; } } @@ -1855,118 +1960,122 @@ finally { jj_save(1, xla); } } - private boolean jj_3R_17() + private boolean jj_3R_27() { - if (jj_scan_token(ident)) return true; + if (jj_scan_token(pling)) return true; return false; } - private boolean jj_3R_22() + private boolean jj_3R_26() { - if (jj_scan_token(leftBrace)) return true; - if (jj_3R_25()) return true; + if (jj_3R_15()) return true; return false; } - private boolean jj_3R_15() + private boolean jj_3R_25() { Token xsp; xsp = jj_scanpos; - if (jj_3R_17()) { + if (jj_3R_27()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(49)) { jj_scanpos = xsp; - if (jj_3R_18()) { - jj_scanpos = xsp; - if (jj_3R_19()) return true; + if (jj_scan_token(47)) return true; } - } return false; } - private boolean jj_3_2() + private boolean jj_3R_23() { - if (jj_3R_16()) return true; + if (jj_scan_token(string)) return true; return false; } - private boolean jj_3R_20() + private boolean jj_3R_21() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_22()) { - jj_scanpos = xsp; - if (jj_3R_23()) return true; - } + if (jj_scan_token(leftBracket)) return true; + if (jj_3R_24()) return true; return false; } - private boolean jj_3_1() + private boolean jj_3R_24() { - if (jj_3R_15()) return true; + Token xsp; + if (jj_3R_26()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_26()) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3R_27() + private boolean jj_3R_19() { - if (jj_scan_token(pling)) return true; + if (jj_3R_21()) return true; return false; } - private boolean jj_3R_26() + private boolean jj_3R_18() { - if (jj_3R_15()) return true; + if (jj_3R_20()) return true; return false; } - private boolean jj_3R_25() + private boolean jj_3R_16() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_27()) jj_scanpos = xsp; + if (jj_scan_token(colon)) return true; if (jj_scan_token(ident)) return true; + if (jj_scan_token(leftBrace)) return true; return false; } - private boolean jj_3R_23() + private boolean jj_3R_17() { - if (jj_scan_token(string)) return true; + if (jj_scan_token(ident)) return true; return false; } - private boolean jj_3R_21() + private boolean jj_3R_22() { - if (jj_scan_token(leftBracket)) return true; - if (jj_3R_24()) return true; + if (jj_scan_token(leftBrace)) return true; + if (jj_3R_25()) return true; return false; } - private boolean jj_3R_24() + private boolean jj_3R_15() { Token xsp; - if (jj_3R_26()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3R_26()) { jj_scanpos = xsp; break; } + xsp = jj_scanpos; + if (jj_3R_17()) { + jj_scanpos = xsp; + if (jj_3R_18()) { + jj_scanpos = xsp; + if (jj_3R_19()) return true; } + } return false; } - private boolean jj_3R_19() + private boolean jj_3_2() { - if (jj_3R_21()) return true; + if (jj_3R_16()) return true; return false; } - private boolean jj_3R_16() + private boolean jj_3R_20() { - if (jj_scan_token(colon)) return true; - if (jj_scan_token(ident)) return true; - if (jj_scan_token(leftBrace)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_22()) { + jj_scanpos = xsp; + if (jj_3R_23()) return true; + } return false; } - private boolean jj_3R_18() + private boolean jj_3_1() { - if (jj_3R_20()) return true; + if (jj_3R_15()) return true; return false; } @@ -1980,7 +2089,7 @@ private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[43]; + final private int[] jj_la1 = new int[50]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; @@ -1990,13 +2099,13 @@ jj_la1_init_2(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x800,0xe00000,0xe00000,0x1000000,0x2000,0x1f01000,0x6000000,0x0,0x0,0x0,0x6000000,0x38000000,0x38000000,0x100000,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_0 = new int[] {0x800,0xe00000,0xe00000,0x1000000,0x2000,0x1f01000,0x6000000,0x0,0x0,0x0,0x0,0x6000000,0x38000000,0x38000000,0x100000,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x20000,0x30000,0x0,0x0,0x0,0x0,0x0,0x2120000,0xa028000,0x800000,0xa028000,0xa028000,0x1000000,0x2008000,0x20000001,0x20008,0x100000,0x1000000,0x20000001,0x0,0x2020000,0x420004,0x420004,0x78008,0x20078008,0x20000,0x1000000,0x1000000,0x2120000,0x100000,0x20000,0x400004,0x400004,0x20178008,0x1000000,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x28000,0x28000,0x20000,0x30000,0x0,0x0,0x0,0x0,0x0,0x2120000,0xa028000,0x800000,0xa028000,0xa028000,0x1000000,0x2008000,0x20000001,0x20008,0x100000,0x1000000,0x20000001,0x0,0x28000,0x2028000,0x420004,0x420004,0x28000,0x78008,0x20078008,0x20000,0x1000000,0x1000000,0x2120000,0x100000,0x28000,0x28000,0x28000,0x28000,0x400004,0x28000,0x400004,0x20178008,0x1000000,}; } private static void jj_la1_init_2() { - jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[2]; private boolean jj_rescan = false; @@ -2013,7 +2122,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2028,7 +2137,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2039,7 +2148,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2050,7 +2159,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2060,7 +2169,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2070,7 +2179,7 @@ token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; - for (int i = 0; i < 43; i++) jj_la1[i] = -1; + for (int i = 0; i < 50; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -2180,7 +2289,7 @@ la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 43; i++) { + for (int i = 0; i < 50; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.jj =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.jj 2016-10-09 01:25:17 UTC (rev 19653) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpsl.jj 2016-10-09 16:14:13 UTC (rev 19654) @@ -35,7 +35,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import gate.jape.JapeFactory; +import gate.Factory; import gate.util.*; import gate.jape.*; import gate.jape.constraint.*; @@ -158,6 +158,19 @@ } /** + * Normalise for quoted and unquoted strings - if the token is a string, + * strip the quotes off its image, otherwise return the image as-is. + */ + protected String stringValueOf(Token tok) { + if(tok.kind == string) { + // quoted string - strip the quotes + return tok.image.substring(1, tok.image.length() - 1); + } else { + return tok.image; + } + } + + /** * Append the given string to the end of the given buffer as a Java string * literal. If <code>str</code> is <code>null</code>, we append the four * characters n, u, l, l. Otherwise, we append the contents of str surrounded @@ -698,7 +711,7 @@ ( ( <input> - (inputTok = <ident> {t.addInput(inputTok.image);})* + ( ( inputTok = <ident> | inputTok = <string> ) {t.addInput(stringValueOf(inputTok));})* ) | ( @@ -1105,9 +1118,9 @@ (<pling> { negate = true; } )? // the annotation type - annotTypeTok=<ident> + ( annotTypeTok=<ident> | annotTypeTok = <string> ) { - c = JapeFactory.getConstraintFactory().createConstraint(annotTypeTok.image); + c = Factory.getConstraintFactory().createConstraint(stringValueOf(annotTypeTok)); if(negate) c.negate(); } @@ -1118,7 +1131,7 @@ accessor=FeatureAccessor() opTok=<attrOp> attrValPair=AttrVal() { opString = opTok.image; - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); } ) | @@ -1126,9 +1139,9 @@ // meta-property name with comparison operator <metaPropOp> metaPropertyTok=<ident> opTok=<attrOp> attrValPair=AttrVal() { - accessor = JapeFactory.getConstraintFactory().createMetaPropertyAccessor(metaPropertyTok.image); + accessor = Factory.getConstraintFactory().createMetaPropertyAccessor(metaPropertyTok.image); opString = opTok.image; - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, attrValPair.second)); } ) | @@ -1144,7 +1157,7 @@ { opString = opTok.image; accessor = new SimpleAnnotationAccessor(); - c.addAttribute(JapeFactory.getConstraintFactory().createPredicate(opString, accessor, embeddedConstraint)); + c.addAttribute(Factory.getConstraintFactory().createPredicate(opString, accessor, embeddedConstraint)); } ) )? @@ -1164,10 +1177,10 @@ } { ( - <period> attrNameTok=<ident> + <period> ( attrNameTok=<ident> | attrNameTok = <string> ) ) { - accessor = JapeFactory.getConstraintFactory().createDefaultAccessor(attrNameTok.image); + accessor = Factory.getConstraintFactory().createDefaultAccessor(stringValueOf(attrNameTok)); return accessor; } } @@ -1430,9 +1443,9 @@ } // the type of the new annotation we want to create - <period> nameTok=<ident> + <period> ( nameTok=<ident> | nameTok = <string> ) { - newAnnotType = nameTok.image; + newAnnotType = stringValueOf(nameTok); // start of the attribute stuff blockBuffer.append(" java.lang.Object val = null;" + nl); @@ -1445,7 +1458,7 @@ ( // the name of the attribute, and equals sign - nameTok=<ident> <assign> { newAttrName = nameTok.image; } + ( nameTok=<ident> | nameTok = <string> ) <assign> { newAttrName = stringValueOf(nameTok); } // the value to assign ( @@ -1525,9 +1538,9 @@ ( ( // WORKING - <period> nameTok=<ident> { existingAnnotType = nameTok.image; } - (opTok=<period> | opTok=<metaPropOp>) nameTok=<ident> - { opName = opTok.image; existingAttrName = nameTok.image; } + <period> ( nameTok=<ident> | nameTok = <string> ) { existingAnnotType = stringValueOf(nameTok); } + (opTok=<period> | opTok=<metaPropOp>) (nameTok=<ident> | nameTok=<string>) + { opName = opTok.image; existingAttrName = stringValueOf(nameTok); } // for each existingAnnotType annotation in existingAnnotSetAnnots // if there is an attribute with existingAttrName Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpslPlain.html =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpslPlain.html 2016-10-09 01:25:17 UTC (rev 19653) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/parser/ParseCpslPlain.html 2016-10-09 16:14:13 UTC (rev 19654) @@ -799,7 +799,7 @@ <TR> <TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod6">SinglePhaseTransducer</A></TD> <TD ALIGN=CENTER VALIGN=BASELINE>::=</TD> -<TD ALIGN=LEFT VALIGN=BASELINE><phase> <ident> ( ( <input> ( <ident> )* ) | ( <option> ( <ident> <assign> ( <ident> | <bool> ) )* ) )* ( ( <A HREF="#prod7">Rule</A> ) | <A HREF="#prod8">MacroDef</A> | <A HREF="#prod9">TemplateDef</A> )*</TD> +<TD ALIGN=LEFT VALIGN=BASELINE><phase> <ident> ( ( <input> ( ( <ident> | <string> ) )* ) | ( <option> ( <ident> <assign> ( <ident> | <bool> ) )* ) )* ( ( <A HREF="#prod7">Rule</A> ) | <A HREF="#prod8">MacroDef</A> | <A HREF="#prod9">TemplateDef</A> )*</TD> </TR> <!-- Special token --> <TR> @@ -961,7 +961,7 @@ <TR> <TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod19">Constraint</A></TD> <TD ALIGN=CENTER VALIGN=BASELINE>::=</TD> -<TD ALIGN=LEFT VALIGN=BASELINE>( <pling> )? <ident> ( ( <A HREF="#prod21">FeatureAccessor</A> <attrOp> <A HREF="#prod15">AttrVal</A> ) | ( <metaPropOp> <ident> <attrOp> <A HREF="#prod15">AttrVal</A> ) | ( <ident> ( ( <leftBrace> <A HREF="#prod19">Constraint</A> <rightBrace> ) | ( <A HREF="#prod19">Constraint</A> ) ) ) )?</TD> +<TD ALIGN=LEFT VALIGN=BASELINE>( <pling> )? ( <ident> | <string> ) ( ( <A HREF="#prod21">FeatureAccessor</A> <attrOp> <A HREF="#prod15">AttrVal</A> ) | ( <metaPropOp> <ident> <attrOp> <A HREF="#prod15">AttrVal</A> ) | ( <ident> ( ( <leftBrace> <A HREF="#prod19">Constraint</A> <rightBrace> ) | ( <A HREF="#prod19">Constraint</A> ) ) ) )?</TD> </TR> <!-- Special token --> <TR> @@ -977,7 +977,7 @@ <TR> <TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod21">FeatureAccessor</A></TD> <TD ALIGN=CENTER VALIGN=BASELINE>::=</TD> -<TD ALIGN=LEFT VALIGN=BASELINE>( <period> <ident> )</TD> +<TD ALIGN=LEFT VALIGN=BASELINE>( <period> ( <ident> | <string> ) )</TD> </TR> <!-- Special token --> <TR> @@ -1078,7 +1078,7 @@ <TR> <TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod25">AssignmentExpression</A></TD> <TD ALIGN=CENTER VALIGN=BASELINE>::=</TD> -<TD ALIGN=LEFT VALIGN=BASELINE>( <colon> | <colonplus> ) <ident> <period> <ident> <assign> <leftBrace> ( <ident> <assign> ( <A HREF="#prod15">AttrVal</A> | ( <colon> <ident> ( ( <period> <ident> ( <period> | <metaPropOp> ) <ident> ) | ( <metaPropOp> <ident> ) ) ) ) ( <comma> )? )* <rightBrace></TD> +<TD ALIGN=LEFT VALIGN=BASELINE>( <colon> | <colonplus> ) <ident> <period> ( <ident> | <string> ) <assign> <leftBrace> ( ( <ident> | <string> ) <assign> ( <A HREF="#prod15">AttrVal</A> | ( <colon> <ident> ( ( <period> ( <ident> | <string> ) ( <period> | <metaPropOp> ) ( <ident> | <string> ) ) | ( <metaPropOp> <ident> ) ) ) ) ( <comma> )? )* <rightBrace></TD> </TR> <!-- Special token --> <TR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs