jlex/jlex-1.2.6.static.patch

107 lines
3.1 KiB
Diff
Raw Normal View History

--- Main.java.orig 2000-09-06 16:09:47.000000000 +0200
+++ Main.java 2024-02-21 16:03:00.139049849 +0100
@@ -1068,8 +1068,15 @@
// Added 6/24/98 Raimondas Lencevicius
// May be made more efficient by replacing String operations
// Assumes correctly formed input String. Performs no error checking
+
+ if (Main.staticFlag) { // S.M.Pericas
+ m_outstream.println("\tstatic private int[][] unpackFromString"+
+ "(int size1, int size2, String st) {");
+ }
+ else {
m_outstream.println("\tprivate int[][] unpackFromString"+
"(int size1, int size2, String st) {");
+ }
m_outstream.println("\t\tint colonIndex = -1;");
m_outstream.println("\t\tString lengthString;");
m_outstream.println("\t\tint sequenceLength = 0;");
@@ -1212,13 +1219,23 @@
int[] yy_cmap = new int[m_spec.m_ccls_map.length];
for (i = 0; i < m_spec.m_ccls_map.length; ++i)
yy_cmap[i] = m_spec.m_col_map[m_spec.m_ccls_map[i]];
+ if (Main.staticFlag) {
+ m_outstream.print("\tstatic private int yy_cmap[] = unpackFromString(");
+ }
+ else {
m_outstream.print("\tprivate int yy_cmap[] = unpackFromString(");
+ }
emit_table_as_string(new int[][] { yy_cmap });
m_outstream.println(")[0];");
m_outstream.println();
// CSA: modified yy_rmap to use string packing 9-Aug-1999
+ if (Main.staticFlag) {
+ m_outstream.print("\tstatic private int yy_rmap[] = unpackFromString(");
+ }
+ else {
m_outstream.print("\tprivate int yy_rmap[] = unpackFromString(");
+ }
emit_table_as_string(new int[][] { m_spec.m_row_map });
m_outstream.println(")[0];");
m_outstream.println();
@@ -1233,8 +1250,14 @@
CUtility.assert(dtrans.m_dtrans.length==m_spec.m_dtrans_ncols);
yy_nxt[elem] = dtrans.m_dtrans;
}
+ if (Main.staticFlag) {
+ m_outstream.print
+ ("\tstatic private int yy_nxt[][] = unpackFromString(");
+ }
+ else {
m_outstream.print
("\tprivate int yy_nxt[][] = unpackFromString(");
+ }
emit_table_as_string(yy_nxt);
m_outstream.println(");");
m_outstream.println();
@@ -3821,18 +3844,35 @@
/***************************************************************
Function: main
**************************************************************/
+ public static boolean staticFlag = false;
+
+ public static void printUsage() {
+ System.out.println("Usage: JLex.Main [-static] <filename>");
+ System.exit(1);
+ }
+
public static void main
(
String arg[]
)
throws java.io.IOException
{
+ int i;
CLexGen lg;
- if (arg.length < 1)
- {
- System.out.println("Usage: JLex.Main <filename>");
- return;
+ // Parse options starting with '-'
+ for (i = 0; i < arg.length && arg[i].charAt(0) == '-'; i++) {
+ if (arg[i].equals("-static")) {
+ staticFlag = true;
+ }
+ else {
+ printUsage();
+ }
+ }
+
+ // Enough arguments left ?
+ if (arg.length - i < 1) {
+ printUsage();
}
/* Note: For debuging, it may be helpful to remove the try/catch
@@ -3840,7 +3880,7 @@
This gives more information. */
try
{
- lg = new CLexGen(arg[0]);
+ lg = new CLexGen(arg[i]);
lg.generate();
}
catch (Error e)