From 7d6e9e9a29f1b0c2a1951ebecf304787257f13ac Mon Sep 17 00:00:00 2001 From: Katja Date: Sun, 14 May 2023 20:33:04 +0200 Subject: [PATCH] Fixed CS_UNICODE_ESCAPE = true; --- csjavacc/parser/CSJavaFiles.java | 22 ++++++++++----------- csjavacc/parser/LexGen.java | 4 ++-- csjavacc/parser/NfaState.java | 34 ++++++++++++++++---------------- csjavacc/parser/ParseGen.java | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/csjavacc/parser/CSJavaFiles.java b/csjavacc/parser/CSJavaFiles.java index 4f509ec..2277e6a 100644 --- a/csjavacc/parser/CSJavaFiles.java +++ b/csjavacc/parser/CSJavaFiles.java @@ -184,7 +184,7 @@ public class CSJavaFiles ostr.println(" case 'e' : case 'E' : return 14;"); ostr.println(" case 'f' : case 'F' : return 15;"); ostr.println(" }\n"); - ostr.println(" throw Exception(); // Should never come here"); + ostr.println(" throw new Exception(); // Should never come here"); ostr.println(" }"); ostr.println(""); ostr.println(prefix + "public int bufpos = -1;"); @@ -193,8 +193,8 @@ public class CSJavaFiles ostr.println(prefix + "int tokenBegin;"); if (OtherFilesGen.keepLineCol){ - ostr.println(prefix + "protected int bufline[];"); - ostr.println(prefix + "protected int bufcolumn[];"); + ostr.println(prefix + "protected int[] bufline;"); + ostr.println(prefix + "protected int[] bufcolumn;"); ostr.println(""); ostr.println(prefix + "protected int column = 0;"); ostr.println(prefix + "protected int line = 1;"); @@ -221,8 +221,8 @@ public class CSJavaFiles ostr.println(" char[] newbuffer = new char[bufsize + 2048];"); if (OtherFilesGen.keepLineCol){ - ostr.println(" int newbufline[] = new int[bufsize + 2048];"); - ostr.println(" int newbufcolumn[] = new int[bufsize + 2048];"); + ostr.println(" int[] newbufline = new int[bufsize + 2048];"); + ostr.println(" int[] newbufcolumn = new int[bufsize + 2048];"); } ostr.println(""); @@ -263,7 +263,7 @@ public class CSJavaFiles ostr.println(" }"); ostr.println(" }"); ostr.println(" catch (System.Exception t){"); - ostr.println(" throw e;"); + ostr.println(" throw t;"); ostr.println(" }"); ostr.println(""); ostr.println(" available = (bufsize += 2048);"); @@ -586,10 +586,10 @@ public class CSJavaFiles ostr.println(" nextCharBuf = new char[4096];"); ostr.println(" }"); ostr.println(""); - ostr.println(" public JavaCharStream(System.IO.TextReader dstream, int startline, int startcolumn)"); + ostr.println(" public CSCharStream(System.IO.TextReader dstream, int startline, int startcolumn)"); ostr.println(" : this(dstream, startline, startcolumn, 4096){}"); ostr.println(""); - ostr.println(" public JavaCharStream(System.IO.TextReader dstream)"); + ostr.println(" public CSCharStream(System.IO.TextReader dstream)"); ostr.println(" : this(dstream, 1, 1, 4096){}"); ostr.println(""); ostr.println(" public void ReInit(System.IO.TextReader dstream, int startline, int startcolumn, int buffersize){"); @@ -632,19 +632,19 @@ public class CSJavaFiles //ostr.println(" : this(encoding == null ? new System.IO.StreamReader(dstream) : "); //ostr.println(" new System.IO.StreamReader(dstream, encoding), startline, startcolumn, buffersize){}"); //ostr.println(""); - ostr.println(" public JavaCharStream(System.IO.Stream dstream, int startline, int startcolumn, int buffersize)"); + ostr.println(" public CSCharStream(System.IO.Stream dstream, int startline, int startcolumn, int buffersize)"); ostr.println(" : this(new System.IO.StreamReader(dstream), startline, startcolumn, 4096){}"); ostr.println(""); //ostr.println(" public JavaCharStream(System.IO.Stream dstream, String encoding, int startline, int startcolumn)"); //ostr.println(" : this(dstream, encoding, startline, startcolumn, 4096){}"); //ostr.println(""); - ostr.println(" public JavaCharStream(System.IO.Stream dstream, int startline, int startcolumn)"); + ostr.println(" public CSCharStream(System.IO.Stream dstream, int startline, int startcolumn)"); ostr.println(" : this(dstream, startline, startcolumn, 4096){}"); ostr.println(""); //ostr.println(" public JavaCharStream(System.IO.Stream dstream, String encoding)"); //ostr.println(" : this(dstream, encoding, 1, 1, 4096){}"); //ostr.println(""); - ostr.println(" public JavaCharStream(System.IO.Stream dstream)"); + ostr.println(" public CSCharStream(System.IO.Stream dstream)"); ostr.println(" : this(dstream, 1, 1, 4096){}"); ostr.println(""); //ostr.println(" public void ReInit(System.IO.Stream dstream, String encoding, int startline, int startcolumn, int buffersize){"); diff --git a/csjavacc/parser/LexGen.java b/csjavacc/parser/LexGen.java index 1686344..03c736e 100644 --- a/csjavacc/parser/LexGen.java +++ b/csjavacc/parser/LexGen.java @@ -712,7 +712,7 @@ public class LexGen extends CSJavaCCGlobals implements CSJavaCCParserConstants{ else { if (Options.getCSUnicodeEscape()) - charStreamName = "JavaCharStream"; + charStreamName = "CSCharStream"; else charStreamName = "SimpleCharStream"; } @@ -748,7 +748,7 @@ public class LexGen extends CSJavaCCGlobals implements CSJavaCCParserConstants{ else if (!Options.getUserCharStream()) { if (Options.getCSUnicodeEscape()) - ostr.println(" if (JavaCharStream.staticFlag)"); + ostr.println(" if (CSCharStream.staticFlag)"); else ostr.println(" if (SimpleCharStream.staticFlag)"); diff --git a/csjavacc/parser/NfaState.java b/csjavacc/parser/NfaState.java index a9a4491..c5ed833 100644 --- a/csjavacc/parser/NfaState.java +++ b/csjavacc/parser/NfaState.java @@ -942,31 +942,31 @@ public class NfaState Integer ind; String tmp; - tmp = "{\n 0x" + Long.toHexString(common[0]) + "L, " + - "0x" + Long.toHexString(common[1]) + "L, " + - "0x" + Long.toHexString(common[2]) + "L, " + - "0x" + Long.toHexString(common[3]) + "L\n};"; + tmp = "{\n unchecked((long)0x" + Long.toHexString(common[0]) + "L), " + + "unchecked((long)0x" + Long.toHexString(common[1]) + "L), " + + "unchecked((long)0x" + Long.toHexString(common[2]) + "L), " + + "unchecked((long)0x" + Long.toHexString(common[3]) + "L)\n};"; if ((ind = (Integer)lohiByteTab.get(tmp)) == null) { allBitVectors.addElement(tmp); if (!AllBitsSet(tmp)) - ostr.println("static ulong[] jjbitVec" + lohiByteCnt + " = " + tmp); + ostr.println("static long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } tmpIndices[cnt++] = ind.intValue(); - tmp = "{\n 0x" + Long.toHexString(loBytes[i][0]) + "L, " + - "0x" + Long.toHexString(loBytes[i][1]) + "L, " + - "0x" + Long.toHexString(loBytes[i][2]) + "L, " + - "0x" + Long.toHexString(loBytes[i][3]) + "L\n};"; + tmp = "{\n unchecked((long)0x" + Long.toHexString(loBytes[i][0]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][1]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][2]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][3]) + "L)\n};"; if ((ind = (Integer)lohiByteTab.get(tmp)) == null) { allBitVectors.addElement(tmp); if (!AllBitsSet(tmp)) - ostr.println("static ulong[] jjbitVec" + lohiByteCnt + " = " + tmp); + ostr.println("static long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } @@ -999,17 +999,17 @@ public class NfaState String tmp; Integer ind; - tmp = "{\n 0x" + Long.toHexString(loBytes[i][0]) + "L, " + - "0x" + Long.toHexString(loBytes[i][1]) + "L, " + - "0x" + Long.toHexString(loBytes[i][2]) + "L, " + - "0x" + Long.toHexString(loBytes[i][3]) + "L\n};"; + tmp = "{\n unchecked((long)0x" + Long.toHexString(loBytes[i][0]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][1]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][2]) + "L), " + + "unchecked((long)0x" + Long.toHexString(loBytes[i][3]) + "L)\n};"; if ((ind = (Integer)lohiByteTab.get(tmp)) == null) { allBitVectors.addElement(tmp); if (!AllBitsSet(tmp)) - ostr.println("static ulong[] jjbitVec" + lohiByteCnt + " = " + tmp); + ostr.println("static long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } @@ -1608,11 +1608,11 @@ public class NfaState { ostr.println(" int hiByte = (int)(curChar >> 8);"); ostr.println(" int i1 = hiByte >> 6;"); - ostr.println(" ulong l1 = 1UL << (hiByte & 0x3F);"); + ostr.println(" long l1 = (long)(1UL << (hiByte & 0x3F));"); } ostr.println(" int i2 = (curChar & 0xff) >> 6;"); - ostr.println(" ulong l2 = 1UL << (curChar & 0x3F);"); + ostr.println(" long l2 = (long)(1UL << (curChar & 0x3F));"); } ostr.println(" MatchLoop: do"); diff --git a/csjavacc/parser/ParseGen.java b/csjavacc/parser/ParseGen.java index 2babdaa..120fcc2 100644 --- a/csjavacc/parser/ParseGen.java +++ b/csjavacc/parser/ParseGen.java @@ -272,7 +272,7 @@ public class ParseGen extends CSJavaCCGlobals implements CSJavaCCParserConstants ostr.println(" jj_initialized_once = true;"); } if (Options.getCSUnicodeEscape()) { - ostr.println(" jj_input_stream = new JavaCharStream(stream, 1, 1);"); + ostr.println(" jj_input_stream = new CSCharStream(stream, 1, 1);"); } else { ostr.println(" jj_input_stream = new SimpleCharStream(stream, 1, 1);"); }