You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/11/26 19:19:44 UTC
svn commit: r1206528 - in /incubator/jena/Jena2/IRI/trunk:
src-dev/buildlexer/ src/main/java/com/hp/hpl/jena/iri/
src/main/java/com/hp/hpl/jena/iri/impl/
Author: andy
Date: Sat Nov 26 18:19:42 2011
New Revision: 1206528
URL: http://svn.apache.org/viewvc?rev=1206528&view=rev
Log:
Move code to build Java lexers from the main codebase into it's own area under src-dev. Now not part of the IRI library build.
Added:
incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/
incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/AbsLexerBuilder.java
incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/Expansion.java
- copied, changed from r1202088, incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/Expansion.java
incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/GenerateLexers.java
incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/PatternCompilerBuilder.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/VarPattern.java
Removed:
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AFS_Build.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/Expansion.java
Modified:
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/ViolationCodes.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AbsLexer.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerHost.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPath.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPort.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerQuery.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerScheme.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerUserinfo.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerXHost.java
incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/PatternCompiler.java
Added: incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/AbsLexerBuilder.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/AbsLexerBuilder.java?rev=1206528&view=auto
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/AbsLexerBuilder.java (added)
+++ incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/AbsLexerBuilder.java Sat Nov 26 18:19:42 2011
@@ -0,0 +1,98 @@
+/**
+ * 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 buildlexer;
+
+import java.io.* ;
+import java.lang.reflect.Method ;
+
+public class AbsLexerBuilder
+{
+ static private long start;
+ static public void main(String args[]) throws IOException {
+ start = System.currentTimeMillis();
+ // out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex");
+ // copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
+ outRules("scheme");
+ outRules("userinfo");
+ outRules("xhost");
+ outRules("port");
+ outRules("path");
+ outRules("query");
+ // outRules("fragment");
+ // out.close();
+ //
+ // JFlex.Main.main(new
+ // String[]{"src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex"});
+ System.out.println(System.currentTimeMillis() - start);
+ }
+
+ private static void copy(String fname) throws IOException {
+ Reader in = new FileReader(fname);
+ char buf[] = new char[2048];
+ while (true) {
+ int sz = in.read(buf);
+ if (sz == -1)
+ break;
+ out.write(buf, 0, sz);
+ }
+ in.close();
+ }
+ // static int count;
+
+ static Writer out;
+
+ static private void outRules(String name) throws IOException {
+ // count = 0;
+ String jflexFile = "src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex";
+
+ if (name.equals("scheme")|| name.equals("port")) {
+
+ } else {
+ out = new FileWriter("tmp.jflex");
+ copy(jflexFile);
+ jflexFile = "tmp.jflex";
+ copy("src/main/java/com/hp/hpl/jena/iri/impl/xchar.jflex");
+ out.close();
+ }
+ runJFlex(new String[] { "-d", "src/main/java/com/hp/hpl/jena/iri/impl", jflexFile });
+ System.out.println(System.currentTimeMillis() - start);
+
+ }
+ static void runJFlex(String[] strings) {
+ Method main = null;
+ try {
+ Class<?> jflex = Class.forName("JFlex.Main");
+ main = jflex.getMethod("main", new Class[]{
+ strings.getClass()});
+ } catch (Exception e) {
+ System.err.println("Please include JFlex.jar on the classpath.");
+ System.exit(1);
+ }
+ try {
+ main.invoke(null, new Object[]{strings});
+ } catch (Exception e) {
+ System.err.println("Problem interacting with JFlex");
+ e.printStackTrace();
+ System.exit(2);
+ }
+
+ }
+
+}
+
Copied: incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/Expansion.java (from r1202088, incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/Expansion.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/Expansion.java?p2=incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/Expansion.java&p1=incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/Expansion.java&r1=1202088&r2=1206528&rev=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/Expansion.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/Expansion.java Sat Nov 26 18:19:42 2011
@@ -16,11 +16,14 @@
* limitations under the License.
*/
-package com.hp.hpl.jena.iri.impl;
+package buildlexer;
import java.util.HashMap;
import java.util.Map;
+import com.hp.hpl.jena.iri.impl.PatternCompiler ;
+import com.hp.hpl.jena.iri.impl.VarPattern ;
+
abstract public class Expansion {
int errors[] = new int[100];
@@ -34,9 +37,9 @@ abstract public class Expansion {
Map<String, String> doing = new HashMap<String, String>();
- abstract void doIt(String regex, int eCount, int eCodes[], int cCount, String coms[]);
+ abstract public void doIt(String regex, int eCount, int eCodes[], int cCount, String coms[]);
- void expand(String data) {
+ public void expand(String data) {
int at;
at = data.indexOf("@{labelI");
Added: incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/GenerateLexers.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/GenerateLexers.java?rev=1206528&view=auto
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/GenerateLexers.java (added)
+++ incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/GenerateLexers.java Sat Nov 26 18:19:42 2011
@@ -0,0 +1,98 @@
+/**
+ * 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 buildlexer;
+
+import java.lang.reflect.Method ;
+import java.util.Iterator ;
+
+import com.hp.hpl.jena.iri.IRI ;
+import com.hp.hpl.jena.iri.IRIFactory ;
+import com.hp.hpl.jena.iri.Violation ;
+import com.hp.hpl.jena.iri.impl.BuildViolationCodes ;
+
+/** Misc support for building the java files with JFlex.
+ * The distribution includes pre-built files - you do not need to perform this
+ * stage to rebuild the IRI library from it's source.
+ */
+public class GenerateLexers
+{
+ static public void main(String args[]) throws Exception
+ {
+ /* File built:
+ LexerHost.java
+ LexerPath.java
+ LexerPort.java
+ LexerQuery.java
+ LexerScheme.java
+ LexerUserinfo.java
+ LexerXHost.java
+ */
+
+ // violation.xml ==> ViolationCodes
+ BuildViolationCodes.main(args) ;
+
+ // host.jflex
+ PatternCompilerBuilder.main(args) ;
+
+ // Other jflex files
+ AbsLexerBuilder.main(args) ;
+
+ // Now refresh and rebuild.
+ // Need to edit result to remove "private" on yytext in each subparser
+ // Then add all the @Overrides (Eclipse quick fix) to remove warnings.
+ }
+
+ static void checkOne(String s)
+ {
+ IRI iri = IRIFactory.iriImplementation().create(s) ;
+ System.out.println(">> "+iri) ;
+ for ( Iterator<Violation> iter = iri.violations(true) ; iter.hasNext() ; )
+ {
+ Violation v = iter.next();
+ System.out.println(v.getShortMessage()) ;
+ }
+ System.out.println("<< "+iri) ;
+ System.out.println() ;
+ }
+
+ public static void runJFlex(String[] strings)
+ {
+ Method main = null ;
+ try
+ {
+ Class<? > jflex = Class.forName("JFlex.Main") ;
+ main = jflex.getMethod("main", new Class[]{strings.getClass()}) ;
+ } catch (Exception e)
+ {
+ System.err.println("Please include JFlex.jar on the classpath.") ;
+ System.exit(1) ;
+ }
+
+ try
+ {
+ main.invoke(null, new Object[]{strings}) ;
+ } catch (Exception e)
+ {
+ System.err.println("Problem interacting with JFlex") ;
+ e.printStackTrace() ;
+ System.exit(2) ;
+ }
+ }
+}
+
Added: incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/PatternCompilerBuilder.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/PatternCompilerBuilder.java?rev=1206528&view=auto
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/PatternCompilerBuilder.java (added)
+++ incubator/jena/Jena2/IRI/trunk/src-dev/buildlexer/PatternCompilerBuilder.java Sat Nov 26 18:19:42 2011
@@ -0,0 +1,275 @@
+/*
+ * 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.
+ */
+
+// TODO e-mail uri list about . at end of domain name
+// TODO e-mail uri list about IPv4 vs host:
+// If host matches the rule for IPv4address, then it should be considered an IPv4 address literal and not a reg-name.
+
+package buildlexer;
+
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.Field;
+
+import com.hp.hpl.jena.iri.ViolationCodes;
+
+public class PatternCompilerBuilder implements ViolationCodes {
+
+ private static final class ExpandAndOutput extends Expansion {
+ int exc[];
+ int sub[];
+ boolean incExc;
+ /**
+ * output those for which no errors in exclude,
+ * and all errors in sub[] occur
+ * or the inverse: at least one error in exclude
+ * occurs, and at least one error in sub doesn't
+ * @param exclude
+ */
+ ExpandAndOutput(int exclude[], int subset[], boolean incExc ) {
+ exc = exclude;
+ sub = subset;
+ this.incExc = incExc;
+ }
+ int ruleCount = 1;
+
+ @Override
+ public void doIt(String regex, int eCount, int[] eCodes, int cCount,
+ String c[]) {
+
+ if (incExc ==
+ ( (!overlap(exc,eCount, eCodes)) &&
+ subset(sub,eCount, eCodes) ) )
+ try {
+ out.write("/*\n");
+ for (int j = 0; j < cCount; j++) {
+ out.write(c[j]);
+ out.write('\n');
+ }
+ out.write("*/\n");
+
+ out.write(regex);
+ out.write(" {\n");
+ count++;
+ out.write("rule("+count+"); ");
+ for (int i = 0; i < eCount; i++)
+ out.write("error(" + errorCodeName(eCodes[i]) + ");");
+ out.write("}\n");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ private boolean subset(int ee[], int el, int[]eCodes) {
+ for (int i=0;i<ee.length;i++)
+ if (!in(ee[i],el,eCodes))
+ return false;
+ return true;
+ }
+ private boolean overlap(int ee[], int el, int[]eCodes) {
+ for (int i=0;i<ee.length;i++)
+ if (in(ee[i],el,eCodes))
+ return true;
+ return false;
+ }
+ private boolean in(int e0, int eCount, int[] eCodes) {
+ for (int i=0; i<eCount; i++)
+ if (eCodes[i]==e0)
+ return true;
+ return false;
+ }
+ }
+
+ static long start;
+
+ static public void main(String args[]) throws IOException {
+ start = System.currentTimeMillis();
+ // out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex");
+ // copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
+// outRules("scheme");
+// outRules("userinfo");
+ outRules("host");
+// outRules("port");
+// outRules("path");
+// outRules("query");
+// outRules("fragment");
+ // out.close();
+ //
+ // JFlex.Main.main(new
+ // String[]{"src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex"});
+ System.out.println(System.currentTimeMillis() - start);
+ }
+
+ private static void copy(String fname) throws IOException {
+ Reader in = new FileReader(fname);
+ char buf[] = new char[2048];
+ while (true) {
+ int sz = in.read(buf);
+ if (sz == -1)
+ break;
+ out.write(buf, 0, sz);
+ }
+ in.close();
+ }
+
+ static String eCodeNames[];
+
+ static String errorCodeName(int j) {
+ if (eCodeNames == null) {
+ eCodeNames = constantsFromClass(ViolationCodes.class, 200);
+ }
+ return eCodeNames[j];
+ }
+
+ static String[] constantsFromClass(Class<?> cl, int cnt) {
+ String[] names;
+ names = new String[cnt];
+ Field f[] = cl.getDeclaredFields();
+ for (int i = 0; i < f.length; i++)
+ try {
+ names[f[i].getInt(null)] = f[i].getName();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ return names;
+ }
+
+ static int count;
+
+ static Writer out;
+
+ static private void outRules(String name) throws IOException {
+ count = 0;
+ // if (true) throw new RuntimeException();
+ out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex");
+ copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
+ out.write("%class Lexer");
+ out.write(name.substring(0, 1).toUpperCase());
+ out.write(name.substring(1));
+ out.write("\n%%\n");
+ int exc1[]=
+ new int[]{DOUBLE_DASH_IN_REG_NAME,NOT_DNS_NAME};
+ int empty[]= new int[0];
+ int sub1[] = new int[]{ACE_PREFIX};
+ // int sub2[] = new int[]{DOUBLE_DASH_IN_REG_NAME,ACE_PREFIX};
+ int sub4[] = new int[]{DOUBLE_DASH_IN_REG_NAME};
+ int sub3[] = new int[]{NOT_DNS_NAME};
+
+ new ExpandAndOutput(exc1,empty,true).expand("@{" + name + "}");
+ // new ExpandAndOutput(empty,sub2,true).expand("@{" + name + "}");
+ new ExpandAndOutput(sub1,sub4,true).expand("@{" + name + "}");
+ new ExpandAndOutput(empty,sub3,true).expand("@{" + name + "}");
+
+ out.write("\n");
+ System.out.println(name + ": " + count + " expansions");
+ out.close();
+
+ GenerateLexers.runJFlex(new String[] { "src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex" });
+ System.out.println(System.currentTimeMillis() - start);
+
+ }
+ /*
+ *
+ * Unicode LTR stuff:
+ *
+ * 200E ????-??- ????? ???? 200F ?????-??-???? ???? 202A ????-??-?????
+ * ????????? 202B ?????-??-???? ????????? 202C ??? ??????????? ??????????
+ * 202D ????-??-????? ???????? 202E ?????-??-???? ????????
+ *
+ * XSD preserve No normalization is done, the value is not changed (this is
+ * the behavior required by [XML 1.0 (Second Edition)] for element content)
+ * replace All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage
+ * return) are replaced with #x20 (space) collapse After the processing
+ * implied by replace, contiguous sequences of #x20's are collapsed to a
+ * single #x20, and leading and trailing #x20's are removed.
+ *
+ *
+ * <xs:simpleType name="anyURI" id="anyURI"> <xs:annotation> <xs:appinfo>
+ * <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/>
+ * <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/>
+ * <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/>
+ * <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty
+ * name="bounded" value="false"/> <hfp:hasProperty name="cardinality"
+ * value="countably infinite"/> <hfp:hasProperty name="numeric"
+ * value="false"/> </xs:appinfo> <xs:documentation
+ * source="http://www.w3.org/TR/xmlschema-2/#anyURI"/> </xs:annotation>
+ * <xs:restriction base="xs:anySimpleType"> <xs:whiteSpace fixed="true"
+ * value="collapse" id="anyURI.whiteSpace"/> </xs:restriction>
+ * </xs:simpleType>
+ *
+ * XML 1.0
+ *
+ * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] |
+ * [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate
+ * blocks, FFFE, and FFFF.
+ *
+ *
+ * Note:
+ *
+ * Document authors are encouraged to avoid "compatibility characters", as
+ * defined in section 6.8 of [Unicode] (see also D21 in section 3.6 of
+ * [Unicode3]). The characters defined in the following ranges are also
+ * discouraged. They are either control characters or permanently undefined
+ * Unicode characters:
+ *
+ * [#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDDF], [#1FFFE-#x1FFFF],
+ * [#2FFFE-#x2FFFF], [#3FFFE-#x3FFFF], [#4FFFE-#x4FFFF], [#5FFFE-#x5FFFF],
+ * [#6FFFE-#x6FFFF], [#7FFFE-#x7FFFF], [#8FFFE-#x8FFFF], [#9FFFE-#x9FFFF],
+ * [#AFFFE-#xAFFFF], [#BFFFE-#xBFFFF], [#CFFFE-#xCFFFF], [#DFFFE-#xDFFFF],
+ * [#EFFFE-#xEFFFF], [#FFFFE-#xFFFFF], [#10FFFE-#x10FFFF].
+ *
+ *
+ * XML 1.1 [Definition: A parsed entity contains text, a sequence of
+ * characters, which may represent markup or character data.] [Definition: A
+ * character is an atomic unit of text as specified by ISO/IEC 10646
+ * [ISO/IEC 10646]. Legal characters are tab, carriage return, line feed,
+ * and the legal characters of Unicode and ISO/IEC 10646. The versions of
+ * these standards cited in A.1 Normative References were current at the
+ * time this document was prepared. New characters may be added to these
+ * standards by amendments or new editions. Consequently, XML processors
+ * MUST accept any character in the range specified for Char.] Character
+ * Range [2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /*
+ * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. * /
+ * [2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] |
+ * [#x86-#x9F]
+ *
+ * The mechanism for encoding character code points into bit patterns MAY
+ * vary from entity to entity. All XML processors MUST accept the UTF-8 and
+ * UTF-16 encodings of Unicode [Unicode]; the mechanisms for signaling which
+ * of the two is in use, or for bringing other encodings into play, are
+ * discussed later, in 4.3.3 Character Encoding in Entities.
+ *
+ * Note:
+ *
+ * Document authors are encouraged to avoid "compatibility characters", as
+ * defined in Unicode [Unicode]. The characters defined in the following
+ * ranges are also discouraged. They are either control characters or
+ * permanently undefined Unicode characters:
+ *
+ * [#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDDF], [#1FFFE-#x1FFFF],
+ * [#2FFFE-#x2FFFF], [#3FFFE-#x3FFFF], [#4FFFE-#x4FFFF], [#5FFFE-#x5FFFF],
+ * [#6FFFE-#x6FFFF], [#7FFFE-#x7FFFF], [#8FFFE-#x8FFFF], [#9FFFE-#x9FFFF],
+ * [#AFFFE-#xAFFFF], [#BFFFE-#xBFFFF], [#CFFFE-#xCFFFF], [#DFFFE-#xDFFFF],
+ * [#EFFFE-#xEFFFF], [#FFFFE-#xFFFFF], [#10FFFE-#x10FFFF].
+ */
+
+}
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/ViolationCodes.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/ViolationCodes.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/ViolationCodes.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/ViolationCodes.java Sat Nov 26 18:19:42 2011
@@ -1,22 +1,12 @@
-/*
- * 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.
- */
+
+
+
/*
+ * (c) Copyright 2006 Hewlett-Packard Development Company, LP
+ * [See end of file]
+ */
+ /*
AUTOGENERATED FILE: DO NOT EDIT
*/
@@ -7607,7 +7597,7 @@ For instance, the "foo" tree would allow
int SCHEME_PREFERS_LOWERCASE = 60;
-/**The scheme specific syntax rules are violared.
+/**The scheme specific syntax rules are violated.
<p>This does not violate any of the supported IRI, URI or scheme specifications.</p>
<p>This violation has <a href="http://www.apps.ietf.org/rfc/rfc2119.html#sec-1">MUST</a> force.</p>
@@ -7626,3 +7616,32 @@ For instance, the "foo" tree would allow
}
+
+
+/*
+ * (c) Copyright 2006 Hewlett-Packard Development Company, LP
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
\ No newline at end of file
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AbsLexer.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AbsLexer.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AbsLexer.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/AbsLexer.java Sat Nov 26 18:19:42 2011
@@ -18,18 +18,11 @@
package com.hp.hpl.jena.iri.impl;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.*;
-
-import com.hp.hpl.jena.iri.ViolationCodes;
-import com.ibm.icu.lang.UCharacter;
-import com.ibm.icu.lang.UCharacterCategory;
-import com.ibm.icu.lang.UProperty;
-import com.ibm.icu.text.Normalizer;
+import com.hp.hpl.jena.iri.ViolationCodes ;
+import com.ibm.icu.lang.UCharacter ;
+import com.ibm.icu.lang.UCharacterCategory ;
+import com.ibm.icu.lang.UProperty ;
+import com.ibm.icu.text.Normalizer ;
abstract class AbsLexer implements ViolationCodes {
@@ -184,7 +177,6 @@ abstract class AbsLexer implements Viola
}
-
private boolean isCompatibilityChar(int codePoint) {
switch (UCharacter.getIntPropertyValue(codePoint,UProperty.DECOMPOSITION_TYPE)) {
case UCharacter.DecompositionType.CANONICAL:
@@ -228,82 +220,7 @@ abstract class AbsLexer implements Viola
}
-
protected void difficultChar() {
difficultCodePoint(yytext().charAt(0),yytext());
}
- static private long start;
- static public void main(String args[]) throws IOException {
- start = System.currentTimeMillis();
- // out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex");
- // copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
- outRules("scheme");
- outRules("userinfo");
- outRules("xhost");
- outRules("port");
- outRules("path");
- outRules("query");
-// outRules("fragment");
- // out.close();
- //
- // JFlex.Main.main(new
- // String[]{"src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex"});
- System.out.println(System.currentTimeMillis() - start);
- }
-
- private static void copy(String fname) throws IOException {
- Reader in = new FileReader(fname);
- char buf[] = new char[2048];
- while (true) {
- int sz = in.read(buf);
- if (sz == -1)
- break;
- out.write(buf, 0, sz);
- }
- in.close();
- }
-// static int count;
-
- static Writer out;
-
- static private void outRules(String name) throws IOException {
-// count = 0;
- String jflexFile = "src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex";
-
- if (name.equals("scheme")|| name.equals("port")) {
-
- } else {
- out = new FileWriter("tmp.jflex");
- copy(jflexFile);
- jflexFile = "tmp.jflex";
- copy("src/main/java/com/hp/hpl/jena/iri/impl/xchar.jflex");
- out.close();
- }
- runJFlex(new String[] { "-d", "src/main/java/com/hp/hpl/jena/iri/impl", jflexFile });
- System.out.println(System.currentTimeMillis() - start);
-
- }
- static void runJFlex(String[] strings) {
- Method main = null;
- try {
- Class<?> jflex = Class.forName("JFlex.Main");
- main = jflex.getMethod("main", new Class[]{
- strings.getClass()});
- } catch (Exception e) {
- System.err.println("Please include JFlex.jar on the classpath.");
- System.exit(1);
- }
- try {
- main.invoke(null, new Object[]{strings});
- } catch (Exception e) {
- System.err.println("Problem interacting with JFlex");
- e.printStackTrace();
- System.exit(2);
- }
-
- }
-
-
-
-
}
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerHost.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerHost.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerHost.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerHost.java Sat Nov 26 18:19:42 2011
@@ -1,28 +1,13 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
- * <tt>src/com/hp/hpl/jena/iri/impl/host.jflex</tt>
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
+ * <tt>src/main/java/com/hp/hpl/jena/iri/impl/host.jflex</tt>
*/
class LexerHost implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -35,6 +20,16 @@ class LexerHost implements com.hp.hpl.je
/** lexical states */
private static final int YYINITIAL = 0;
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0
+ };
+
/**
* Translates characters to character classes
*/
@@ -1198,9 +1193,6 @@ class LexerHost implements com.hp.hpl.je
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -1231,6 +1223,9 @@ class LexerHost implements com.hp.hpl.je
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
private Parser parser;
private int range;
@@ -1348,7 +1343,6 @@ class LexerHost implements com.hp.hpl.je
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -1364,13 +1358,23 @@ class LexerHost implements com.hp.hpl.je
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -1400,8 +1404,9 @@ class LexerHost implements com.hp.hpl.je
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -1507,8 +1512,7 @@ class LexerHost implements com.hp.hpl.je
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
-private int yylex() throws java.io.IOException {
+ private int yylex() throws java.io.IOException {
int zzInput;
int zzAction;
@@ -1532,7 +1536,7 @@ private int yylex() throws java.io.IOExc
zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
- zzState = zzLexicalState;
+ zzState = ZZ_LEXSTATE[zzLexicalState];
zzForAction: {
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPath.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPath.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPath.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPath.java Sat Nov 26 18:19:42 2011
@@ -1,27 +1,12 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
* <tt>tmp.jflex</tt>
*/
class LexerPath extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -215,9 +200,6 @@ class LexerPath extends AbsLexer impleme
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -248,6 +230,9 @@ class LexerPath extends AbsLexer impleme
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -324,7 +309,6 @@ class LexerPath extends AbsLexer impleme
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -340,13 +324,23 @@ class LexerPath extends AbsLexer impleme
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -376,8 +370,9 @@ class LexerPath extends AbsLexer impleme
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -405,7 +400,7 @@ class LexerPath extends AbsLexer impleme
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -484,8 +479,7 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
-@Override
+ @Override
public int yylex() throws java.io.IOException {
int zzInput;
int zzAction;
@@ -591,136 +585,136 @@ public int yylex() throws java.io.IOExce
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 8:
- { rule(-90);
- if (yychar==lastChar)
- error(DOUBLE_WHITESPACE);
- else
- error(WHITESPACE);
+ case 17:
+ { rule(-70);
+ error(DOUBLE_WHITESPACE);
}
case 26: break;
- case 7:
- { rule(-60);
- error(ILLEGAL_PERCENT_ENCODING);
+ case 11:
+ { rule(-115);
+ error(DISCOURAGED_XML_CHARACTER);
+ error(CONTROL_CHARACTER);
}
case 27: break;
- case 18:
- { rule(-130);
- surrogatePair();
+ case 14:
+ { /*
+xxxx,xxxx,xxxx,xxxx xxxx,xxxx,xxxx,xxxx
+000u,uuuu,xxxx,xxxx,xxxx,xxxx 110110wwww,xxxx,xx 110111xx,xxxx,xxxx
+
+wwww = uuuuu - 1.
+*/
+
+ rule(-150);
+ difficultChar();
}
case 28: break;
- case 21:
- { rule(-40);
- error(PERCENT);
- }
- case 29: break;
case 20:
{ rule(5); error(NON_INITIAL_DOT_SEGMENT);
}
+ case 29: break;
+ case 18:
+ { rule(-130);
+ surrogatePair();
+ }
case 30: break;
case 25:
{ rule(4); error(NON_INITIAL_DOT_SEGMENT);
}
case 31: break;
- case 12:
- { rule(-120);
- error(UNWISE_CHARACTER);
+ case 4:
+ { rule(3);
}
case 32: break;
- case 14:
- { /*
-xxxx,xxxx,xxxx,xxxx xxxx,xxxx,xxxx,xxxx
-000u,uuuu,xxxx,xxxx,xxxx,xxxx 110110wwww,xxxx,xx 110111xx,xxxx,xxxx
-
-wwww = uuuuu - 1.
-*/
-
- rule(-150);
- difficultChar();
+ case 21:
+ { rule(-40);
+ error(PERCENT);
}
case 33: break;
+ case 13:
+ { rule(-140);
+ error(LONE_SURROGATE);
+ difficultChar();
+ }
+ case 34: break;
case 15:
{ rule(-80);
error(DOUBLE_WHITESPACE);
}
- case 34: break;
- case 4:
- { rule(3);
- }
case 35: break;
- case 22:
- { rule(-30);
- error(PERCENT_20);
+ case 23:
+ { rule(-50);
+ error(PERCENT);
+ error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
}
case 36: break;
- case 17:
- { rule(-70);
- error(DOUBLE_WHITESPACE);
+ case 8:
+ { rule(-90);
+ if (yychar==lastChar)
+ error(DOUBLE_WHITESPACE);
+ else
+ error(WHITESPACE);
}
case 37: break;
- case 13:
- { rule(-140);
- error(LONE_SURROGATE);
- difficultChar();
+ case 12:
+ { rule(-120);
+ error(UNWISE_CHARACTER);
}
case 38: break;
- case 2:
- { rule(-100);
+ case 10:
+ { rule(-113);
error(CONTROL_CHARACTER);
- error(NOT_XML_SCHEMA_WHITESPACE);
}
case 39: break;
- case 1:
- { rule(-160);
- error(ILLEGAL_CHARACTER);
- }
- case 40: break;
case 19:
{ rule(7); if (yychar == lastChar-2) error(NON_INITIAL_DOT_SEGMENT);
}
- case 41: break;
+ case 40: break;
case 5:
{ rule(-10);
}
- case 42: break;
+ case 41: break;
case 24:
{ rule(2);
}
+ case 42: break;
+ case 22:
+ { rule(-30);
+ error(PERCENT_20);
+ }
case 43: break;
- case 23:
- { rule(-50);
- error(PERCENT);
- error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
+ case 7:
+ { rule(-60);
+ error(ILLEGAL_PERCENT_ENCODING);
}
case 44: break;
case 16:
{ rule(8); if (yychar == lastChar-1) error(NON_INITIAL_DOT_SEGMENT);
}
case 45: break;
- case 11:
- { rule(-115);
- error(DISCOURAGED_XML_CHARACTER);
- error(CONTROL_CHARACTER);
- }
- case 46: break;
case 6:
{ rule(-20);
}
- case 47: break;
- case 9:
- { rule(-110);
- error(NON_XML_CHARACTER);
+ case 46: break;
+ case 2:
+ { rule(-100);
error(CONTROL_CHARACTER);
+ error(NOT_XML_SCHEMA_WHITESPACE);
}
- case 48: break;
- case 10:
- { rule(-113);
- error(CONTROL_CHARACTER);
+ case 47: break;
+ case 1:
+ { rule(-160);
+ error(ILLEGAL_CHARACTER);
}
- case 49: break;
+ case 48: break;
case 3:
{ rule(6);
}
+ case 49: break;
+ case 9:
+ { rule(-110);
+ error(NON_XML_CHARACTER);
+ error(CONTROL_CHARACTER);
+ }
case 50: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPort.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPort.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPort.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerPort.java Sat Nov 26 18:19:42 2011
@@ -1,28 +1,13 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
- * <tt>src/com/hp/hpl/jena/iri/impl/port.jflex</tt>
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
+ * <tt>src/main/java/com/hp/hpl/jena/iri/impl/port.jflex</tt>
*/
class LexerPort extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -194,9 +179,6 @@ class LexerPort extends AbsLexer impleme
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -227,6 +209,9 @@ class LexerPort extends AbsLexer impleme
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -304,7 +289,6 @@ class LexerPort extends AbsLexer impleme
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -320,13 +304,23 @@ class LexerPort extends AbsLexer impleme
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -356,8 +350,9 @@ class LexerPort extends AbsLexer impleme
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -385,7 +380,7 @@ class LexerPort extends AbsLexer impleme
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -464,7 +459,6 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
@Override
public int yylex() throws java.io.IOException {
int zzInput;
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerQuery.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerQuery.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerQuery.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerQuery.java Sat Nov 26 18:19:42 2011
@@ -1,27 +1,12 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
* <tt>tmp.jflex</tt>
*/
class LexerQuery extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -210,9 +195,6 @@ class LexerQuery extends AbsLexer implem
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -243,6 +225,9 @@ class LexerQuery extends AbsLexer implem
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -319,7 +304,6 @@ class LexerQuery extends AbsLexer implem
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -335,13 +319,23 @@ class LexerQuery extends AbsLexer implem
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -371,8 +365,9 @@ class LexerQuery extends AbsLexer implem
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -400,7 +395,7 @@ class LexerQuery extends AbsLexer implem
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -479,7 +474,6 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
@Override
public int yylex() throws java.io.IOException {
int zzInput;
@@ -586,38 +580,17 @@ public int yylex() throws java.io.IOExce
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 7:
- { rule(-90);
- if (yychar==lastChar)
- error(DOUBLE_WHITESPACE);
- else
- error(WHITESPACE);
+ case 16:
+ { rule(-70);
+ error(DOUBLE_WHITESPACE);
}
case 21: break;
- case 6:
- { rule(-60);
- error(ILLEGAL_PERCENT_ENCODING);
+ case 11:
+ { rule(-115);
+ error(DISCOURAGED_XML_CHARACTER);
+ error(CONTROL_CHARACTER);
}
case 22: break;
- case 17:
- { rule(-130);
- surrogatePair();
- }
- case 23: break;
- case 18:
- { rule(-40);
- error(PERCENT);
- }
- case 24: break;
- case 2:
- { rule(1);
- }
- case 25: break;
- case 12:
- { rule(-120);
- error(UNWISE_CHARACTER);
- }
- case 26: break;
case 14:
{ /*
xxxx,xxxx,xxxx,xxxx xxxx,xxxx,xxxx,xxxx
@@ -629,73 +602,94 @@ wwww = uuuuu - 1.
rule(-150);
difficultChar();
}
+ case 23: break;
+ case 2:
+ { rule(1);
+ }
+ case 24: break;
+ case 17:
+ { rule(-130);
+ surrogatePair();
+ }
+ case 25: break;
+ case 18:
+ { rule(-40);
+ error(PERCENT);
+ }
+ case 26: break;
+ case 13:
+ { rule(-140);
+ error(LONE_SURROGATE);
+ difficultChar();
+ }
case 27: break;
case 15:
{ rule(-80);
error(DOUBLE_WHITESPACE);
}
case 28: break;
- case 19:
- { rule(-30);
- error(PERCENT_20);
+ case 20:
+ { rule(-50);
+ error(PERCENT);
+ error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
}
case 29: break;
- case 16:
- { rule(-70);
- error(DOUBLE_WHITESPACE);
+ case 7:
+ { rule(-90);
+ if (yychar==lastChar)
+ error(DOUBLE_WHITESPACE);
+ else
+ error(WHITESPACE);
}
case 30: break;
- case 13:
- { rule(-140);
- error(LONE_SURROGATE);
- difficultChar();
+ case 12:
+ { rule(-120);
+ error(UNWISE_CHARACTER);
}
case 31: break;
- case 8:
- { rule(-100);
+ case 10:
+ { rule(-113);
error(CONTROL_CHARACTER);
- error(NOT_XML_SCHEMA_WHITESPACE);
}
case 32: break;
- case 1:
- { rule(-160);
- error(ILLEGAL_CHARACTER);
- }
- case 33: break;
case 4:
{ rule(-10);
}
- case 34: break;
+ case 33: break;
case 3:
{ rule(2);
}
+ case 34: break;
+ case 19:
+ { rule(-30);
+ error(PERCENT_20);
+ }
case 35: break;
- case 20:
- { rule(-50);
- error(PERCENT);
- error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
+ case 6:
+ { rule(-60);
+ error(ILLEGAL_PERCENT_ENCODING);
}
case 36: break;
- case 11:
- { rule(-115);
- error(DISCOURAGED_XML_CHARACTER);
- error(CONTROL_CHARACTER);
- }
- case 37: break;
case 5:
{ rule(-20);
}
+ case 37: break;
+ case 8:
+ { rule(-100);
+ error(CONTROL_CHARACTER);
+ error(NOT_XML_SCHEMA_WHITESPACE);
+ }
case 38: break;
+ case 1:
+ { rule(-160);
+ error(ILLEGAL_CHARACTER);
+ }
+ case 39: break;
case 9:
{ rule(-110);
error(NON_XML_CHARACTER);
error(CONTROL_CHARACTER);
}
- case 39: break;
- case 10:
- { rule(-113);
- error(CONTROL_CHARACTER);
- }
case 40: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerScheme.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerScheme.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerScheme.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerScheme.java Sat Nov 26 18:19:42 2011
@@ -1,28 +1,13 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
- * <tt>src/com/hp/hpl/jena/iri/impl/scheme.jflex</tt>
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
+ * <tt>src/main/java/com/hp/hpl/jena/iri/impl/scheme.jflex</tt>
*/
class LexerScheme extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -197,9 +182,6 @@ class LexerScheme extends AbsLexer imple
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -230,6 +212,9 @@ class LexerScheme extends AbsLexer imple
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -307,7 +292,6 @@ class LexerScheme extends AbsLexer imple
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -323,13 +307,23 @@ class LexerScheme extends AbsLexer imple
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -359,8 +353,9 @@ class LexerScheme extends AbsLexer imple
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -388,7 +383,7 @@ class LexerScheme extends AbsLexer imple
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -467,7 +462,6 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
@Override
public int yylex() throws java.io.IOException {
int zzInput;
@@ -574,29 +568,29 @@ public int yylex() throws java.io.IOExce
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 7:
- { rule(4);
- if (yychar==0) error(SCHEME_MUST_START_WITH_LETTER);
- error(SCHEME_INCLUDES_DASH);
- }
- case 8: break;
case 5:
{ rule(5); error(SCHEME_INCLUDES_DASH);
}
- case 9: break;
+ case 8: break;
case 4:
{ rule(6);
}
- case 10: break;
+ case 9: break;
case 1:
{ rule(7);
error(ILLEGAL_CHARACTER);
}
- case 11: break;
+ case 10: break;
case 6:
{ rule(3);
if (yychar==0) error(SCHEME_MUST_START_WITH_LETTER);
}
+ case 11: break;
+ case 7:
+ { rule(4);
+ if (yychar==0) error(SCHEME_MUST_START_WITH_LETTER);
+ error(SCHEME_INCLUDES_DASH);
+ }
case 12: break;
case 3:
{ rule(2);
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerUserinfo.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerUserinfo.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerUserinfo.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerUserinfo.java Sat Nov 26 18:19:42 2011
@@ -1,27 +1,12 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
* <tt>tmp.jflex</tt>
*/
class LexerUserinfo extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -210,9 +195,6 @@ class LexerUserinfo extends AbsLexer imp
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -243,6 +225,9 @@ class LexerUserinfo extends AbsLexer imp
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -319,7 +304,6 @@ class LexerUserinfo extends AbsLexer imp
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -335,13 +319,23 @@ class LexerUserinfo extends AbsLexer imp
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -371,8 +365,9 @@ class LexerUserinfo extends AbsLexer imp
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -400,7 +395,7 @@ class LexerUserinfo extends AbsLexer imp
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -479,8 +474,7 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
-@Override
+ @Override
public int yylex() throws java.io.IOException {
int zzInput;
int zzAction;
@@ -586,34 +580,17 @@ public int yylex() throws java.io.IOExce
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 6:
- { rule(-90);
- if (yychar==lastChar)
- error(DOUBLE_WHITESPACE);
- else
- error(WHITESPACE);
+ case 15:
+ { rule(-70);
+ error(DOUBLE_WHITESPACE);
}
case 20: break;
- case 5:
- { rule(-60);
- error(ILLEGAL_PERCENT_ENCODING);
+ case 10:
+ { rule(-115);
+ error(DISCOURAGED_XML_CHARACTER);
+ error(CONTROL_CHARACTER);
}
case 21: break;
- case 16:
- { rule(-130);
- surrogatePair();
- }
- case 22: break;
- case 17:
- { rule(-40);
- error(PERCENT);
- }
- case 23: break;
- case 11:
- { rule(-120);
- error(UNWISE_CHARACTER);
- }
- case 24: break;
case 13:
{ /*
xxxx,xxxx,xxxx,xxxx xxxx,xxxx,xxxx,xxxx
@@ -625,71 +602,88 @@ wwww = uuuuu - 1.
rule(-150);
difficultChar();
}
+ case 22: break;
+ case 16:
+ { rule(-130);
+ surrogatePair();
+ }
+ case 23: break;
+ case 17:
+ { rule(-40);
+ error(PERCENT);
+ }
+ case 24: break;
+ case 12:
+ { rule(-140);
+ error(LONE_SURROGATE);
+ difficultChar();
+ }
case 25: break;
case 14:
{ rule(-80);
error(DOUBLE_WHITESPACE);
}
case 26: break;
- case 18:
- { rule(-30);
- error(PERCENT_20);
+ case 19:
+ { rule(-50);
+ error(PERCENT);
+ error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
}
case 27: break;
- case 15:
- { rule(-70);
- error(DOUBLE_WHITESPACE);
+ case 6:
+ { rule(-90);
+ if (yychar==lastChar)
+ error(DOUBLE_WHITESPACE);
+ else
+ error(WHITESPACE);
}
case 28: break;
- case 12:
- { rule(-140);
- error(LONE_SURROGATE);
- difficultChar();
+ case 11:
+ { rule(-120);
+ error(UNWISE_CHARACTER);
}
case 29: break;
- case 7:
- { rule(-100);
+ case 9:
+ { rule(-113);
error(CONTROL_CHARACTER);
- error(NOT_XML_SCHEMA_WHITESPACE);
}
case 30: break;
- case 1:
- { rule(-160);
- error(ILLEGAL_CHARACTER);
- }
- case 31: break;
case 3:
{ rule(-10);
}
+ case 31: break;
+ case 18:
+ { rule(-30);
+ error(PERCENT_20);
+ }
case 32: break;
- case 19:
- { rule(-50);
- error(PERCENT);
- error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
+ case 5:
+ { rule(-60);
+ error(ILLEGAL_PERCENT_ENCODING);
}
case 33: break;
- case 10:
- { rule(-115);
- error(DISCOURAGED_XML_CHARACTER);
- error(CONTROL_CHARACTER);
- }
- case 34: break;
case 4:
{ rule(-20);
}
- case 35: break;
- case 8:
- { rule(-110);
- error(NON_XML_CHARACTER);
+ case 34: break;
+ case 7:
+ { rule(-100);
error(CONTROL_CHARACTER);
+ error(NOT_XML_SCHEMA_WHITESPACE);
+ }
+ case 35: break;
+ case 1:
+ { rule(-160);
+ error(ILLEGAL_CHARACTER);
}
case 36: break;
case 2:
{ rule(1); error(HAS_PASSWORD);
}
case 37: break;
- case 9:
- { rule(-113);
+ case 8:
+ { rule(-110);
+ error(NON_XML_CHARACTER);
error(CONTROL_CHARACTER);
}
case 38: break;
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerXHost.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerXHost.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerXHost.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/LexerXHost.java Sat Nov 26 18:19:42 2011
@@ -1,27 +1,12 @@
-/*
- * 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.
- */
+/* The following code was generated by JFlex 1.4.3 on 26/11/11 18:12 */
+
package com.hp.hpl.jena.iri.impl;
/**
* This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
- * on 15/04/09 12:28 from the specification file
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 26/11/11 18:12 from the specification file
* <tt>tmp.jflex</tt>
*/
class LexerXHost extends AbsLexer implements com.hp.hpl.jena.iri.ViolationCodes, com.hp.hpl.jena.iri.IRIComponents, Lexer {
@@ -210,9 +195,6 @@ class LexerXHost extends AbsLexer implem
/** the textposition at the last accepting state */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
- private int zzPushbackPos;
-
/** the current text position in the buffer */
private int zzCurrentPos;
@@ -243,6 +225,9 @@ class LexerXHost extends AbsLexer implem
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
/* user code: */
@@ -330,7 +315,6 @@ class LexerXHost extends AbsLexer implem
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
- zzPushbackPos-= zzStartRead;
zzStartRead = 0;
}
@@ -346,13 +330,23 @@ class LexerXHost extends AbsLexer implem
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
- if (numRead < 0) {
- return true;
- }
- else {
+ if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
}
@@ -382,8 +376,9 @@ class LexerXHost extends AbsLexer implem
zzReader = reader;
zzAtBOL = true;
zzAtEOF = false;
+ zzEOFDone = false;
zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
+ zzCurrentPos = zzMarkedPos = 0;
yyline = yychar = yycolumn = 0;
zzLexicalState = YYINITIAL;
}
@@ -411,7 +406,7 @@ class LexerXHost extends AbsLexer implem
* Returns the text matched by the current regular expression.
*/
@Override
-protected final String yytext() {
+final String yytext() {
return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
}
@@ -490,7 +485,6 @@ protected final String yytext() {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
@Override
public int yylex() throws java.io.IOException {
int zzInput;
@@ -597,34 +591,17 @@ public int yylex() throws java.io.IOExce
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 6:
- { rule(-90);
- if (yychar==lastChar)
- error(DOUBLE_WHITESPACE);
- else
- error(WHITESPACE);
+ case 15:
+ { rule(-70);
+ error(DOUBLE_WHITESPACE);
}
case 20: break;
- case 5:
- { rule(-60);
- error(ILLEGAL_PERCENT_ENCODING);
+ case 10:
+ { rule(-115);
+ error(DISCOURAGED_XML_CHARACTER);
+ error(CONTROL_CHARACTER);
}
case 21: break;
- case 16:
- { rule(-130);
- surrogatePair();
- }
- case 22: break;
- case 17:
- { rule(-40);
- error(PERCENT);
- }
- case 23: break;
- case 11:
- { rule(-120);
- error(UNWISE_CHARACTER);
- }
- case 24: break;
case 13:
{ /*
xxxx,xxxx,xxxx,xxxx xxxx,xxxx,xxxx,xxxx
@@ -636,74 +613,91 @@ wwww = uuuuu - 1.
rule(-150);
difficultChar();
}
+ case 22: break;
+ case 16:
+ { rule(-130);
+ surrogatePair();
+ }
+ case 23: break;
+ case 2:
+ { rule(1);
+ error(LOWERCASE_PREFERRED);
+ }
+ case 24: break;
+ case 17:
+ { rule(-40);
+ error(PERCENT);
+ }
case 25: break;
+ case 12:
+ { rule(-140);
+ error(LONE_SURROGATE);
+ difficultChar();
+ }
+ case 26: break;
case 14:
{ rule(-80);
error(DOUBLE_WHITESPACE);
}
- case 26: break;
- case 18:
- { rule(-30);
- error(PERCENT_20);
- }
case 27: break;
- case 15:
- { rule(-70);
- error(DOUBLE_WHITESPACE);
+ case 19:
+ { rule(-50);
+ error(PERCENT);
+ error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
}
case 28: break;
- case 12:
- { rule(-140);
- error(LONE_SURROGATE);
- difficultChar();
+ case 6:
+ { rule(-90);
+ if (yychar==lastChar)
+ error(DOUBLE_WHITESPACE);
+ else
+ error(WHITESPACE);
}
case 29: break;
- case 7:
- { rule(-100);
- error(CONTROL_CHARACTER);
- error(NOT_XML_SCHEMA_WHITESPACE);
+ case 11:
+ { rule(-120);
+ error(UNWISE_CHARACTER);
}
case 30: break;
- case 1:
- { rule(-160);
- error(ILLEGAL_CHARACTER);
+ case 9:
+ { rule(-113);
+ error(CONTROL_CHARACTER);
}
case 31: break;
case 3:
{ rule(-10);
}
case 32: break;
- case 19:
- { rule(-50);
- error(PERCENT);
- error(PERCENT_ENCODING_SHOULD_BE_UPPERCASE);
+ case 18:
+ { rule(-30);
+ error(PERCENT_20);
}
case 33: break;
- case 2:
- { rule(1);
- error(LOWERCASE_PREFERRED);
+ case 5:
+ { rule(-60);
+ error(ILLEGAL_PERCENT_ENCODING);
}
case 34: break;
- case 10:
- { rule(-115);
- error(DISCOURAGED_XML_CHARACTER);
- error(CONTROL_CHARACTER);
- }
- case 35: break;
case 4:
{ rule(-20);
}
+ case 35: break;
+ case 7:
+ { rule(-100);
+ error(CONTROL_CHARACTER);
+ error(NOT_XML_SCHEMA_WHITESPACE);
+ }
case 36: break;
+ case 1:
+ { rule(-160);
+ error(ILLEGAL_CHARACTER);
+ }
+ case 37: break;
case 8:
{ rule(-110);
error(NON_XML_CHARACTER);
error(CONTROL_CHARACTER);
}
- case 37: break;
- case 9:
- { rule(-113);
- error(CONTROL_CHARACTER);
- }
case 38: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
Modified: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/PatternCompiler.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/PatternCompiler.java?rev=1206528&r1=1206527&r2=1206528&view=diff
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/PatternCompiler.java (original)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/PatternCompiler.java Sat Nov 26 18:19:42 2011
@@ -22,13 +22,9 @@
package com.hp.hpl.jena.iri.impl;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
import java.lang.reflect.Field;
+
import com.hp.hpl.jena.iri.ViolationCodes;
public class PatternCompiler implements ViolationCodes {
@@ -208,71 +204,6 @@ public class PatternCompiler implements
new VarPattern("[^]*", ILLEGAL_CHARACTER), };
*/
-
- private static final class ExpandAndOutput extends Expansion {
- int exc[];
- int sub[];
- boolean incExc;
- /**
- * output those for which no errors in exclude,
- * and all errors in sub[] occur
- * or the inverse: at least one error in exclude
- * occurs, and at least one error in sub doesn't
- * @param exclude
- */
- ExpandAndOutput(int exclude[], int subset[], boolean incExc ) {
- exc = exclude;
- sub = subset;
- this.incExc = incExc;
- }
- int ruleCount = 1;
-
- @Override
- void doIt(String regex, int eCount, int[] eCodes, int cCount,
- String c[]) {
-
- if (incExc ==
- ( (!overlap(exc,eCount, eCodes)) &&
- subset(sub,eCount, eCodes) ) )
- try {
- out.write("/*\n");
- for (int j = 0; j < cCount; j++) {
- out.write(c[j]);
- out.write('\n');
- }
- out.write("*/\n");
-
- out.write(regex);
- out.write(" {\n");
- count++;
- out.write("rule("+count+"); ");
- for (int i = 0; i < eCount; i++)
- out.write("error(" + errorCodeName(eCodes[i]) + ");");
- out.write("}\n");
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- private boolean subset(int ee[], int el, int[]eCodes) {
- for (int i=0;i<ee.length;i++)
- if (!in(ee[i],el,eCodes))
- return false;
- return true;
- }
- private boolean overlap(int ee[], int el, int[]eCodes) {
- for (int i=0;i<ee.length;i++)
- if (in(ee[i],el,eCodes))
- return true;
- return false;
- }
- private boolean in(int e0, int eCount, int[] eCodes) {
- for (int i=0; i<eCount; i++)
- if (eCodes[i]==e0)
- return true;
- return false;
- }
- }
-
static VarPattern ipLiteral[] = {
new VarPattern("\\[@{ipVFuture}\\]"),
new VarPattern("\\[@{ipV6Address}\\]"),
@@ -393,39 +324,7 @@ static VarPattern unreservedDNSLabel[] =
NON_URI_CHARACTER)
};
- static long start;
-
- static public void main(String args[]) throws IOException {
- start = System.currentTimeMillis();
- // out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex");
- // copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
-// outRules("scheme");
-// outRules("userinfo");
- outRules("host");
-// outRules("port");
-// outRules("path");
-// outRules("query");
-// outRules("fragment");
- // out.close();
- //
- // JFlex.Main.main(new
- // String[]{"src/main/java/com/hp/hpl/jena/iri/impl/iri2.jflex"});
- System.out.println(System.currentTimeMillis() - start);
- }
-
- private static void copy(String fname) throws IOException {
- Reader in = new FileReader(fname);
- char buf[] = new char[2048];
- while (true) {
- int sz = in.read(buf);
- if (sz == -1)
- break;
- out.write(buf, 0, sz);
- }
- in.close();
- }
-
- static VarPattern[] lookup(String name) {
+ public static VarPattern[] lookup(String name) {
try {
Field f = PatternCompiler.class.getDeclaredField(name);
return (VarPattern[]) f.get(null);
@@ -438,7 +337,7 @@ static VarPattern unreservedDNSLabel[] =
static String eCodeNames[];
- static String errorCodeName(int j) {
+ public static String errorCodeName(int j) {
if (eCodeNames == null) {
eCodeNames = constantsFromClass(ViolationCodes.class, 200);
}
@@ -477,41 +376,6 @@ static VarPattern unreservedDNSLabel[] =
}
}
-
- static int count;
-
- static Writer out;
-
- static private void outRules(String name) throws IOException {
- count = 0;
- // if (true) throw new RuntimeException();
- out = new FileWriter("src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex");
- copy("src/main/java/com/hp/hpl/jena/iri/impl/iri.jflex");
- out.write("%class Lexer");
- out.write(name.substring(0, 1).toUpperCase());
- out.write(name.substring(1));
- out.write("\n%%\n");
- int exc1[]=
- new int[]{DOUBLE_DASH_IN_REG_NAME,NOT_DNS_NAME};
- int empty[]= new int[0];
- int sub1[] = new int[]{ACE_PREFIX};
- // int sub2[] = new int[]{DOUBLE_DASH_IN_REG_NAME,ACE_PREFIX};
- int sub4[] = new int[]{DOUBLE_DASH_IN_REG_NAME};
- int sub3[] = new int[]{NOT_DNS_NAME};
-
- new ExpandAndOutput(exc1,empty,true).expand("@{" + name + "}");
- // new ExpandAndOutput(empty,sub2,true).expand("@{" + name + "}");
- new ExpandAndOutput(sub1,sub4,true).expand("@{" + name + "}");
- new ExpandAndOutput(empty,sub3,true).expand("@{" + name + "}");
-
- out.write("\n");
- System.out.println(name + ": " + count + " expansions");
- out.close();
-
- AbsLexer.runJFlex(new String[] { "src/main/java/com/hp/hpl/jena/iri/impl/"+name+".jflex" });
- System.out.println(System.currentTimeMillis() - start);
-
- }
/*
*
* Unicode LTR stuff:
Added: incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/VarPattern.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/VarPattern.java?rev=1206528&view=auto
==============================================================================
--- incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/VarPattern.java (added)
+++ incubator/jena/Jena2/IRI/trunk/src/main/java/com/hp/hpl/jena/iri/impl/VarPattern.java Sat Nov 26 18:19:42 2011
@@ -0,0 +1,40 @@
+/*
+ * 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 com.hp.hpl.jena.iri.impl;
+
+public class VarPattern {
+ public final String pattern;
+ public final int[] errors;
+
+ public VarPattern(String string) {
+ pattern = string;
+ errors = new int[0];
+ }
+
+ public VarPattern(String string, int eCode) {
+ pattern = string;
+ errors = new int[]{eCode};
+ }
+
+ public VarPattern(String string, int[] is) {
+ pattern = string;
+ errors = is;
+ }
+
+}