From 7b659589a19e598d5881d1b727c39f1389efc5df Mon Sep 17 00:00:00 2001 From: droy Date: Mon, 7 Jul 2003 16:09:46 +0000 Subject: [PATCH] javacup adding --- .../java_cup/CUP$parser$actions.class | Bin 0 -> 17138 bytes Repair/RepairCompiler/java_cup/Main.class | Bin 0 -> 14748 bytes Repair/RepairCompiler/java_cup/Main.java | 854 ++++++++ .../RepairCompiler/java_cup/action_part.class | Bin 0 -> 1105 bytes .../RepairCompiler/java_cup/action_part.java | 93 + .../java_cup/action_production.class | Bin 0 -> 604 bytes .../java_cup/action_production.java | 39 + Repair/RepairCompiler/java_cup/assoc.class | Bin 0 -> 333 bytes Repair/RepairCompiler/java_cup/assoc.java | 16 + Repair/RepairCompiler/java_cup/emit.class | Bin 0 -> 13983 bytes Repair/RepairCompiler/java_cup/emit.java | 900 ++++++++ .../java_cup/internal_error.class | Bin 0 -> 580 bytes .../java_cup/internal_error.java | 22 + .../RepairCompiler/java_cup/lalr_item.class | Bin 0 -> 3779 bytes Repair/RepairCompiler/java_cup/lalr_item.java | 330 +++ .../java_cup/lalr_item_set.class | Bin 0 -> 3865 bytes .../java_cup/lalr_item_set.java | 371 ++++ .../RepairCompiler/java_cup/lalr_state.class | Bin 0 -> 9792 bytes .../RepairCompiler/java_cup/lalr_state.java | 884 ++++++++ .../java_cup/lalr_transition.class | Bin 0 -> 1505 bytes .../java_cup/lalr_transition.java | 93 + Repair/RepairCompiler/java_cup/lexer.class | Bin 0 -> 5185 bytes Repair/RepairCompiler/java_cup/lexer.java | 543 +++++ .../java_cup/lr_item_core.class | Bin 0 -> 3152 bytes .../RepairCompiler/java_cup/lr_item_core.java | 280 +++ .../java_cup/non_terminal.class | Bin 0 -> 3801 bytes .../RepairCompiler/java_cup/non_terminal.java | 301 +++ .../java_cup/nonassoc_action.class | Bin 0 -> 675 bytes .../java_cup/nonassoc_action.java | 71 + .../java_cup/parse_action.class | Bin 0 -> 740 bytes .../RepairCompiler/java_cup/parse_action.java | 92 + .../java_cup/parse_action_row.class | Bin 0 -> 1035 bytes .../java_cup/parse_action_row.java | 106 + .../java_cup/parse_action_table.class | Bin 0 -> 2261 bytes .../java_cup/parse_action_table.java | 143 ++ .../java_cup/parse_reduce_row.class | Bin 0 -> 529 bytes .../java_cup/parse_reduce_row.java | 41 + .../java_cup/parse_reduce_table.class | Bin 0 -> 1292 bytes .../java_cup/parse_reduce_table.java | 99 + Repair/RepairCompiler/java_cup/parser.class | Bin 0 -> 7471 bytes Repair/RepairCompiler/java_cup/parser.java | 1849 +++++++++++++++++ .../RepairCompiler/java_cup/production.class | Bin 0 -> 8088 bytes .../RepairCompiler/java_cup/production.java | 756 +++++++ .../java_cup/production_part.class | Bin 0 -> 964 bytes .../java_cup/production_part.java | 94 + .../java_cup/reduce_action.class | Bin 0 -> 1215 bytes .../java_cup/reduce_action.java | 84 + .../java_cup/shift_action.class | Bin 0 -> 1196 bytes .../RepairCompiler/java_cup/shift_action.java | 82 + Repair/RepairCompiler/java_cup/sym.class | Bin 0 -> 1111 bytes Repair/RepairCompiler/java_cup/sym.java | 43 + Repair/RepairCompiler/java_cup/symbol.class | Bin 0 -> 925 bytes Repair/RepairCompiler/java_cup/symbol.java | 107 + .../RepairCompiler/java_cup/symbol_part.class | Bin 0 -> 1428 bytes .../RepairCompiler/java_cup/symbol_part.java | 100 + .../RepairCompiler/java_cup/symbol_set.class | Bin 0 -> 2621 bytes .../RepairCompiler/java_cup/symbol_set.java | 231 ++ Repair/RepairCompiler/java_cup/terminal.class | Bin 0 -> 2198 bytes Repair/RepairCompiler/java_cup/terminal.java | 169 ++ .../java_cup/terminal_set.class | Bin 0 -> 2472 bytes .../RepairCompiler/java_cup/terminal_set.java | 253 +++ Repair/RepairCompiler/java_cup/version.class | Bin 0 -> 549 bytes Repair/RepairCompiler/java_cup/version.java | 55 + 63 files changed, 9101 insertions(+) create mode 100755 Repair/RepairCompiler/java_cup/CUP$parser$actions.class create mode 100755 Repair/RepairCompiler/java_cup/Main.class create mode 100755 Repair/RepairCompiler/java_cup/Main.java create mode 100755 Repair/RepairCompiler/java_cup/action_part.class create mode 100755 Repair/RepairCompiler/java_cup/action_part.java create mode 100755 Repair/RepairCompiler/java_cup/action_production.class create mode 100755 Repair/RepairCompiler/java_cup/action_production.java create mode 100755 Repair/RepairCompiler/java_cup/assoc.class create mode 100755 Repair/RepairCompiler/java_cup/assoc.java create mode 100755 Repair/RepairCompiler/java_cup/emit.class create mode 100755 Repair/RepairCompiler/java_cup/emit.java create mode 100755 Repair/RepairCompiler/java_cup/internal_error.class create mode 100755 Repair/RepairCompiler/java_cup/internal_error.java create mode 100755 Repair/RepairCompiler/java_cup/lalr_item.class create mode 100755 Repair/RepairCompiler/java_cup/lalr_item.java create mode 100755 Repair/RepairCompiler/java_cup/lalr_item_set.class create mode 100755 Repair/RepairCompiler/java_cup/lalr_item_set.java create mode 100755 Repair/RepairCompiler/java_cup/lalr_state.class create mode 100755 Repair/RepairCompiler/java_cup/lalr_state.java create mode 100755 Repair/RepairCompiler/java_cup/lalr_transition.class create mode 100755 Repair/RepairCompiler/java_cup/lalr_transition.java create mode 100755 Repair/RepairCompiler/java_cup/lexer.class create mode 100755 Repair/RepairCompiler/java_cup/lexer.java create mode 100755 Repair/RepairCompiler/java_cup/lr_item_core.class create mode 100755 Repair/RepairCompiler/java_cup/lr_item_core.java create mode 100755 Repair/RepairCompiler/java_cup/non_terminal.class create mode 100755 Repair/RepairCompiler/java_cup/non_terminal.java create mode 100755 Repair/RepairCompiler/java_cup/nonassoc_action.class create mode 100755 Repair/RepairCompiler/java_cup/nonassoc_action.java create mode 100755 Repair/RepairCompiler/java_cup/parse_action.class create mode 100755 Repair/RepairCompiler/java_cup/parse_action.java create mode 100755 Repair/RepairCompiler/java_cup/parse_action_row.class create mode 100755 Repair/RepairCompiler/java_cup/parse_action_row.java create mode 100755 Repair/RepairCompiler/java_cup/parse_action_table.class create mode 100755 Repair/RepairCompiler/java_cup/parse_action_table.java create mode 100755 Repair/RepairCompiler/java_cup/parse_reduce_row.class create mode 100755 Repair/RepairCompiler/java_cup/parse_reduce_row.java create mode 100755 Repair/RepairCompiler/java_cup/parse_reduce_table.class create mode 100755 Repair/RepairCompiler/java_cup/parse_reduce_table.java create mode 100755 Repair/RepairCompiler/java_cup/parser.class create mode 100755 Repair/RepairCompiler/java_cup/parser.java create mode 100755 Repair/RepairCompiler/java_cup/production.class create mode 100755 Repair/RepairCompiler/java_cup/production.java create mode 100755 Repair/RepairCompiler/java_cup/production_part.class create mode 100755 Repair/RepairCompiler/java_cup/production_part.java create mode 100755 Repair/RepairCompiler/java_cup/reduce_action.class create mode 100755 Repair/RepairCompiler/java_cup/reduce_action.java create mode 100755 Repair/RepairCompiler/java_cup/shift_action.class create mode 100755 Repair/RepairCompiler/java_cup/shift_action.java create mode 100755 Repair/RepairCompiler/java_cup/sym.class create mode 100755 Repair/RepairCompiler/java_cup/sym.java create mode 100755 Repair/RepairCompiler/java_cup/symbol.class create mode 100755 Repair/RepairCompiler/java_cup/symbol.java create mode 100755 Repair/RepairCompiler/java_cup/symbol_part.class create mode 100755 Repair/RepairCompiler/java_cup/symbol_part.java create mode 100755 Repair/RepairCompiler/java_cup/symbol_set.class create mode 100755 Repair/RepairCompiler/java_cup/symbol_set.java create mode 100755 Repair/RepairCompiler/java_cup/terminal.class create mode 100755 Repair/RepairCompiler/java_cup/terminal.java create mode 100755 Repair/RepairCompiler/java_cup/terminal_set.class create mode 100755 Repair/RepairCompiler/java_cup/terminal_set.java create mode 100755 Repair/RepairCompiler/java_cup/version.class create mode 100755 Repair/RepairCompiler/java_cup/version.java diff --git a/Repair/RepairCompiler/java_cup/CUP$parser$actions.class b/Repair/RepairCompiler/java_cup/CUP$parser$actions.class new file mode 100755 index 0000000000000000000000000000000000000000..7d10b66c2779ce583d07215d6ba1358e1d732c9d GIT binary patch literal 17138 zcmeHud3;nw)^=^TZZEf!PItCWI!O~*!z!p?Kx8qMUW8zx7TqUS5_4_bjAU3bX?w3x2ijRo0~Y_Z|3{{`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X<=UQ0jxF{+_OXBz1rAzL`}*8g<%dRJtBrI9tKSER_fEg9?XM z;WfzLMSlqXQNGHhLvU>eL@FPm^1fGjABTWH1pfp)?N0|)x^0G3Y8v6sK)}{i*h_V= zuHGe|dJk^#L#kH4r&{$#s#AYLXz^E?s{Tf&s*mY(^>_(E}ie}UWcHTh;`B?QQu#$VC@F!A(%laFrtxQqTSGJj;`>Y~H7 zW#?KQI<}Kk#~$K6%s_nPz>yyCG1(9E4t^qC%=XPWx{Kjn7f2xeql^C8yNeOMyHLEx z$3W~pMi>8*E~aDVZ>d3o<;cwPlCjj3p{HslbTG8Mi@A$&2kJwun$aSv#*lo|5z3!2 zw7jOGi-A(5JZf~Yr;J6eo&!h1 z22faHahy`f*Ox3`KkDZjK(l;7T8i%tzJZv$8VdUc(>C7_O8SP;?Y>%i0N;=MM$pr~ zk@SLZG=0xkN3Z(E&`*40xu5SuuJMiII^TG1^iAaTsE2*^9QD<4+SkYz_$C#_ah3Ax zZ?ll-UW8+E?2UBOQ%}(C%Mdaz&(gq?ypVatL?oN;sb2$tj+YVGLooq8v00jk!~$Z; zyUEsItOtpxB-_9S(g%o=O91x+M_wxoeyXfq-zntxHBn#RY#QR5L!1C93idgP9l4@3!UgN)VGQ%eXA+xI}<0s zwRr}=b{RyGpYkImGaAn@JfrZe#IqXD0z9+ujKeb*c;zV9;8|CRWGtS3c!GEa;TeNx zD4xA|uElc`o&$Ie;u(qO{(@NN(J&}{HP+%;IGV17Ce~Ab`ZNusvuOxzrr~rhIkW{H zxP`{kR;s6M$h9PB8j_i(&<>hKyJ#+5h?M8Ww3sfT<+K~zE(NE{z~zg`&|CoySAzO# MXlot%QoR2E14v|=-T(jq literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/Main.java b/Repair/RepairCompiler/java_cup/Main.java new file mode 100755 index 0000000..50811b5 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/Main.java @@ -0,0 +1,854 @@ + +package java_cup; + +import java.util.Enumeration; +import java.io.*; + +/** This class serves as the main driver for the JavaCup system. + * It accepts user options and coordinates overall control flow. + * The main flow of control includes the following activities: + *
    + *
  • Parse user supplied arguments and options. + *
  • Open output files. + *
  • Parse the specification from standard input. + *
  • Check for unused terminals, non-terminals, and productions. + *
  • Build the state machine, tables, etc. + *
  • Output the generated code. + *
  • Close output files. + *
  • Print a summary if requested. + *
+ * + * Options to the main program include:
+ *
-package name + *
specify package generated classes go in [default none] + *
-parser name + *
specify parser class name [default "parser"] + *
-symbols name + *
specify name for symbol constant class [default "sym"] + *
-interface + *
emit symbol constant interface, rather than class + *
-nonterms + *
put non terminals in symbol constant class + *
-expect # + *
number of conflicts expected/allowed [default 0] + *
-compact_red + *
compact tables by defaulting to most frequent reduce + *
-nowarn + *
don't warn about useless productions, etc. + *
-nosummary + *
don't print the usual summary of parse states, etc. + *
-progress + *
print messages to indicate progress of the system + *
-time + *
print time usage summary + *
-dump_grammar + *
produce a dump of the symbols and grammar + *
-dump_states + *
produce a dump of parse state machine + *
-dump_tables + *
produce a dump of the parse tables + *
-dump + *
produce a dump of all of the above + *
-debug + *
turn on debugging messages within JavaCup + *
-nopositions + *
don't generate the positions code + *
-noscanner + *
don't refer to java_cup.runtime.Scanner in the parser + * (for compatibility with old runtimes) + *
-version + *
print version information for JavaCUP and halt. + *
+ * + * @version last updated: 7/3/96 + * @author Frank Flannery + */ + +public class Main { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + /** Only constructor is private, so we do not allocate any instances of this + class. */ + private Main() { } + + /*-------------------------*/ + /* Options set by the user */ + /*-------------------------*/ + /** User option -- do we print progress messages. */ + protected static boolean print_progress = true; + /** User option -- do we produce a dump of the state machine */ + protected static boolean opt_dump_states = false; + /** User option -- do we produce a dump of the parse tables */ + protected static boolean opt_dump_tables = false; + /** User option -- do we produce a dump of the grammar */ + protected static boolean opt_dump_grammar = false; + /** User option -- do we show timing information as a part of the summary */ + protected static boolean opt_show_timing = false; + /** User option -- do we run produce extra debugging messages */ + protected static boolean opt_do_debug = false; + /** User option -- do we compact tables by making most common reduce the + default action */ + protected static boolean opt_compact_red = false; + /** User option -- should we include non terminal symbol numbers in the + symbol constant class. */ + protected static boolean include_non_terms = false; + /** User option -- do not print a summary. */ + protected static boolean no_summary = false; + /** User option -- number of conflicts to expect */ + protected static int expect_conflicts = 0; + + /* frankf added this 6/18/96 */ + /** User option -- should generator generate code for left/right values? */ + protected static boolean lr_values = true; + + /** User option -- should symbols be put in a class or an interface? [CSA]*/ + protected static boolean sym_interface = false; + + /** User option -- should generator suppress references to + * java_cup.runtime.Scanner for compatibility with old runtimes? */ + protected static boolean suppress_scanner = false; + + /*----------------------------------------------------------------------*/ + /* Timing data (not all of these time intervals are mutually exclusive) */ + /*----------------------------------------------------------------------*/ + /** Timing data -- when did we start */ + protected static long start_time = 0; + /** Timing data -- when did we end preliminaries */ + protected static long prelim_end = 0; + /** Timing data -- when did we end parsing */ + protected static long parse_end = 0; + /** Timing data -- when did we end checking */ + protected static long check_end = 0; + /** Timing data -- when did we end dumping */ + protected static long dump_end = 0; + /** Timing data -- when did we end state and table building */ + protected static long build_end = 0; + /** Timing data -- when did we end nullability calculation */ + protected static long nullability_end = 0; + /** Timing data -- when did we end first set calculation */ + protected static long first_end = 0; + /** Timing data -- when did we end state machine construction */ + protected static long machine_end = 0; + /** Timing data -- when did we end table construction */ + protected static long table_end = 0; + /** Timing data -- when did we end checking for non-reduced productions */ + protected static long reduce_check_end = 0; + /** Timing data -- when did we finish emitting code */ + protected static long emit_end = 0; + /** Timing data -- when were we completely done */ + protected static long final_time = 0; + + /* Additional timing information is also collected in emit */ + + /*-----------------------------------------------------------*/ + /*--- Main Program ------------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** The main driver for the system. + * @param argv an array of strings containing command line arguments. + */ + public static void main(String argv[]) + throws internal_error, java.io.IOException, java.lang.Exception + { + boolean did_output = false; + + start_time = System.currentTimeMillis(); + + /* process user options and arguments */ + parse_args(argv); + + /* frankf 6/18/96 + hackish, yes, but works */ + emit.set_lr_values(lr_values); + /* open output files */ + if (print_progress) System.err.println("Opening files..."); + /* use a buffered version of standard input */ + input_file = new BufferedInputStream(System.in); + + prelim_end = System.currentTimeMillis(); + + /* parse spec into internal data structures */ + if (print_progress) + System.err.println("Parsing specification from standard input..."); + parse_grammar_spec(); + + parse_end = System.currentTimeMillis(); + + /* don't proceed unless we are error free */ + if (lexer.error_count == 0) + { + /* check for unused bits */ + if (print_progress) System.err.println("Checking specification..."); + check_unused(); + + check_end = System.currentTimeMillis(); + + /* build the state machine and parse tables */ + if (print_progress) System.err.println("Building parse tables..."); + build_parser(); + + build_end = System.currentTimeMillis(); + + /* output the generated code, if # of conflicts permits */ + if (lexer.error_count != 0) { + // conflicts! don't emit code, don't dump tables. + opt_dump_tables = false; + } else { // everything's okay, emit parser. + if (print_progress) System.err.println("Writing parser..."); + open_files(); + emit_parser(); + did_output = true; + } + } + /* fix up the times to make the summary easier */ + emit_end = System.currentTimeMillis(); + + /* do requested dumps */ + if (opt_dump_grammar) dump_grammar(); + if (opt_dump_states) dump_machine(); + if (opt_dump_tables) dump_tables(); + + dump_end = System.currentTimeMillis(); + + /* close input/output files */ + if (print_progress) System.err.println("Closing files..."); + close_files(); + + /* produce a summary if desired */ + if (!no_summary) emit_summary(did_output); + + /* If there were errors during the run, + * exit with non-zero status (makefile-friendliness). --CSA */ + if (lexer.error_count != 0) + System.exit(100); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Print a "usage message" that described possible command line options, + * then exit. + * @param message a specific error message to preface the usage message by. + */ + protected static void usage(String message) + { + System.err.println(); + System.err.println(message); + System.err.println(); + System.err.println( +"Usage: " + version.program_name + " [options] [filename]\n" + +" and expects a specification file on standard input if no filename is given.\n" + +" Legal options include:\n" + +" -package name specify package generated classes go in [default none]\n" + +" -parser name specify parser class name [default \"parser\"]\n" + +" -symbols name specify name for symbol constant class [default \"sym\"]\n"+ +" -interface put symbols in an interface, rather than a class\n" + +" -nonterms put non terminals in symbol constant class\n" + +" -expect # number of conflicts expected/allowed [default 0]\n" + +" -compact_red compact tables by defaulting to most frequent reduce\n" + +" -nowarn don't warn about useless productions, etc.\n" + +" -nosummary don't print the usual summary of parse states, etc.\n" + +" -nopositions don't propagate the left and right token position values\n" + +" -noscanner don't refer to java_cup.runtime.Scanner\n" + +" -progress print messages to indicate progress of the system\n" + +" -time print time usage summary\n" + +" -dump_grammar produce a human readable dump of the symbols and grammar\n"+ +" -dump_states produce a dump of parse state machine\n"+ +" -dump_tables produce a dump of the parse tables\n"+ +" -dump produce a dump of all of the above\n"+ +" -version print the version information for CUP and exit\n" + ); + System.exit(1); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Parse command line options and arguments to set various user-option + * flags and variables. + * @param argv the command line arguments to be parsed. + */ + protected static void parse_args(String argv[]) + { + int len = argv.length; + int i; + + /* parse the options */ + for (i=0; i= len || argv[i].startsWith("-") || + argv[i].endsWith(".cup")) + usage("-package must have a name argument"); + + /* record the name */ + emit.package_name = argv[i]; + } + else if (argv[i].equals("-parser")) + { + /* must have an arg */ + if (++i >= len || argv[i].startsWith("-") || + argv[i].endsWith(".cup")) + usage("-parser must have a name argument"); + + /* record the name */ + emit.parser_class_name = argv[i]; + } + else if (argv[i].equals("-symbols")) + { + /* must have an arg */ + if (++i >= len || argv[i].startsWith("-") || + argv[i].endsWith(".cup")) + usage("-symbols must have a name argument"); + + /* record the name */ + emit.symbol_const_class_name = argv[i]; + } + else if (argv[i].equals("-nonterms")) + { + include_non_terms = true; + } + else if (argv[i].equals("-expect")) + { + /* must have an arg */ + if (++i >= len || argv[i].startsWith("-") || + argv[i].endsWith(".cup")) + usage("-expect must have a name argument"); + + /* record the number */ + try { + expect_conflicts = Integer.parseInt(argv[i]); + } catch (NumberFormatException e) { + usage("-expect must be followed by a decimal integer"); + } + } + else if (argv[i].equals("-compact_red")) opt_compact_red = true; + else if (argv[i].equals("-nosummary")) no_summary = true; + else if (argv[i].equals("-nowarn")) emit.nowarn = true; + else if (argv[i].equals("-dump_states")) opt_dump_states = true; + else if (argv[i].equals("-dump_tables")) opt_dump_tables = true; + else if (argv[i].equals("-progress")) print_progress = true; + else if (argv[i].equals("-dump_grammar")) opt_dump_grammar = true; + else if (argv[i].equals("-dump")) + opt_dump_states = opt_dump_tables = opt_dump_grammar = true; + else if (argv[i].equals("-time")) opt_show_timing = true; + else if (argv[i].equals("-debug")) opt_do_debug = true; + /* frankf 6/18/96 */ + else if (argv[i].equals("-nopositions")) lr_values = false; + /* CSA 12/21/97 */ + else if (argv[i].equals("-interface")) sym_interface = true; + /* CSA 23-Jul-1999 */ + else if (argv[i].equals("-noscanner")) suppress_scanner = true; + /* CSA 23-Jul-1999 */ + else if (argv[i].equals("-version")) { + System.out.println(version.title_str); + System.exit(1); + } + /* CSA 24-Jul-1999; suggestion by Jean Vaucher */ + else if (!argv[i].startsWith("-") && i==len-1) { + /* use input from file. */ + try { + System.setIn(new FileInputStream(argv[i])); + } catch (java.io.FileNotFoundException e) { + usage("Unable to open \"" + argv[i] +"\" for input"); + } + } + else + { + usage("Unrecognized option \"" + argv[i] + "\""); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /*-------*/ + /* Files */ + /*-------*/ + + /** Input file. This is a buffered version of System.in. */ + protected static BufferedInputStream input_file; + + /** Output file for the parser class. */ + protected static PrintWriter parser_class_file; + + /** Output file for the symbol constant class. */ + protected static PrintWriter symbol_class_file; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Open various files used by the system. */ + protected static void open_files() + { + File fil; + String out_name; + + /* open each of the output files */ + + /* parser class */ + out_name = emit.parser_class_name + ".java"; + fil = new File(out_name); + try { + parser_class_file = new PrintWriter( + new BufferedOutputStream(new FileOutputStream(fil), 4096)); + } catch(Exception e) { + System.err.println("Can't open \"" + out_name + "\" for output"); + System.exit(3); + } + + /* symbol constants class */ + out_name = emit.symbol_const_class_name + ".java"; + fil = new File(out_name); + try { + symbol_class_file = new PrintWriter( + new BufferedOutputStream(new FileOutputStream(fil), 4096)); + } catch(Exception e) { + System.err.println("Can't open \"" + out_name + "\" for output"); + System.exit(4); + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Close various files used by the system. */ + protected static void close_files() throws java.io.IOException + { + if (input_file != null) input_file.close(); + if (parser_class_file != null) parser_class_file.close(); + if (symbol_class_file != null) symbol_class_file.close(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Parse the grammar specification from standard input. This produces + * sets of terminal, non-terminals, and productions which can be accessed + * via static variables of the respective classes, as well as the setting + * of various variables (mostly in the emit class) for small user supplied + * items such as the code to scan with. + */ + protected static void parse_grammar_spec() throws java.lang.Exception + { + parser parser_obj; + + /* create a parser and parse with it */ + parser_obj = new parser(); + try { + if (opt_do_debug) + parser_obj.debug_parse(); + else + parser_obj.parse(); + } catch (Exception e) + { + /* something threw an exception. catch it and emit a message so we + have a line number to work with, then re-throw it */ + lexer.emit_error("Internal error: Unexpected exception"); + throw e; + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Check for unused symbols. Unreduced productions get checked when + * tables are created. + */ + protected static void check_unused() + { + terminal term; + non_terminal nt; + + /* check for unused terminals */ + for (Enumeration t = terminal.all(); t.hasMoreElements(); ) + { + term = (terminal)t.nextElement(); + + /* don't issue a message for EOF */ + if (term == terminal.EOF) continue; + + /* or error */ + if (term == terminal.error) continue; + + /* is this one unused */ + if (term.use_count() == 0) + { + /* count it and warn if we are doing warnings */ + emit.unused_term++; + if (!emit.nowarn) + { + System.err.println("Warning: Terminal \"" + term.name() + + "\" was declared but never used"); + lexer.warning_count++; + } + } + } + + /* check for unused non terminals */ + for (Enumeration n = non_terminal.all(); n.hasMoreElements(); ) + { + nt = (non_terminal)n.nextElement(); + + /* is this one unused */ + if (nt.use_count() == 0) + { + /* count and warn if we are doing warnings */ + emit.unused_term++; + if (!emit.nowarn) + { + System.err.println("Warning: Non terminal \"" + nt.name() + + "\" was declared but never used"); + lexer.warning_count++; + } + } + } + + } + + /* . . . . . . . . . . . . . . . . . . . . . . . . .*/ + /* . . Internal Results of Generating the Parser . .*/ + /* . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Start state in the overall state machine. */ + protected static lalr_state start_state; + + /** Resulting parse action table. */ + protected static parse_action_table action_table; + + /** Resulting reduce-goto table. */ + protected static parse_reduce_table reduce_table; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Build the (internal) parser from the previously parsed specification. + * This includes:
    + *
  • Computing nullability of non-terminals. + *
  • Computing first sets of non-terminals and productions. + *
  • Building the viable prefix recognizer machine. + *
  • Filling in the (internal) parse tables. + *
  • Checking for unreduced productions. + *
+ */ + protected static void build_parser() throws internal_error + { + /* compute nullability of all non terminals */ + if (opt_do_debug || print_progress) + System.err.println(" Computing non-terminal nullability..."); + non_terminal.compute_nullability(); + + nullability_end = System.currentTimeMillis(); + + /* compute first sets of all non terminals */ + if (opt_do_debug || print_progress) + System.err.println(" Computing first sets..."); + non_terminal.compute_first_sets(); + + first_end = System.currentTimeMillis(); + + /* build the LR viable prefix recognition machine */ + if (opt_do_debug || print_progress) + System.err.println(" Building state machine..."); + start_state = lalr_state.build_machine(emit.start_production); + + machine_end = System.currentTimeMillis(); + + /* build the LR parser action and reduce-goto tables */ + if (opt_do_debug || print_progress) + System.err.println(" Filling in tables..."); + action_table = new parse_action_table(); + reduce_table = new parse_reduce_table(); + for (Enumeration st = lalr_state.all(); st.hasMoreElements(); ) + { + lalr_state lst = (lalr_state)st.nextElement(); + lst.build_table_entries( + action_table, reduce_table); + } + + table_end = System.currentTimeMillis(); + + /* check and warn for non-reduced productions */ + if (opt_do_debug || print_progress) + System.err.println(" Checking for non-reduced productions..."); + action_table.check_reductions(); + + reduce_check_end = System.currentTimeMillis(); + + /* if we have more conflicts than we expected issue a message and die */ + if (emit.num_conflicts > expect_conflicts) + { + System.err.println("*** More conflicts encountered than expected " + + "-- parser generation aborted"); + lexer.error_count++; // indicate the problem. + // we'll die on return, after clean up. + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Call the emit routines necessary to write out the generated parser. */ + protected static void emit_parser() throws internal_error + { + emit.symbols(symbol_class_file, include_non_terms, sym_interface); + emit.parser(parser_class_file, action_table, reduce_table, + start_state.index(), emit.start_production, opt_compact_red, + suppress_scanner); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Helper routine to optionally return a plural or non-plural ending. + * @param val the numerical value determining plurality. + */ + protected static String plural(int val) + { + if (val == 1) + return ""; + else + return "s"; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit a long summary message to standard error (System.err) which + * summarizes what was found in the specification, how many states were + * produced, how many conflicts were found, etc. A detailed timing + * summary is also produced if it was requested by the user. + * @param output_produced did the system get far enough to generate code. + */ + protected static void emit_summary(boolean output_produced) + { + final_time = System.currentTimeMillis(); + + if (no_summary) return; + + System.err.println("------- " + version.title_str + + " Parser Generation Summary -------"); + + /* error and warning count */ + System.err.println(" " + lexer.error_count + " error" + + plural(lexer.error_count) + " and " + lexer.warning_count + + " warning" + plural(lexer.warning_count)); + + /* basic stats */ + System.err.print(" " + terminal.number() + " terminal" + + plural(terminal.number()) + ", "); + System.err.print(non_terminal.number() + " non-terminal" + + plural(non_terminal.number()) + ", and "); + System.err.println(production.number() + " production" + + plural(production.number()) + " declared, "); + System.err.println(" producing " + lalr_state.number() + + " unique parse states."); + + /* unused symbols */ + System.err.println(" " + emit.unused_term + " terminal" + + plural(emit.unused_term) + " declared but not used."); + System.err.println(" " + emit.unused_non_term + " non-terminal" + + plural(emit.unused_term) + " declared but not used."); + + /* productions that didn't reduce */ + System.err.println(" " + emit.not_reduced + " production" + + plural(emit.not_reduced) + " never reduced."); + + /* conflicts */ + System.err.println(" " + emit.num_conflicts + " conflict" + + plural(emit.num_conflicts) + " detected" + + " (" + expect_conflicts + " expected)."); + + /* code location */ + if (output_produced) + System.err.println(" Code written to \"" + emit.parser_class_name + + ".java\", and \"" + emit.symbol_const_class_name + ".java\"."); + else + System.err.println(" No code produced."); + + if (opt_show_timing) show_times(); + + System.err.println( + "---------------------------------------------------- (" + + version.version_str + ")"); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce the optional timing summary as part of an overall summary. */ + protected static void show_times() + { + long total_time = final_time - start_time; + + System.err.println(". . . . . . . . . . . . . . . . . . . . . . . . . "); + System.err.println(" Timing Summary"); + System.err.println(" Total time " + + timestr(final_time-start_time, total_time)); + System.err.println(" Startup " + + timestr(prelim_end-start_time, total_time)); + System.err.println(" Parse " + + timestr(parse_end-prelim_end, total_time) ); + if (check_end != 0) + System.err.println(" Checking " + + timestr(check_end-parse_end, total_time)); + if (check_end != 0 && build_end != 0) + System.err.println(" Parser Build " + + timestr(build_end-check_end, total_time)); + if (nullability_end != 0 && check_end != 0) + System.err.println(" Nullability " + + timestr(nullability_end-check_end, total_time)); + if (first_end != 0 && nullability_end != 0) + System.err.println(" First sets " + + timestr(first_end-nullability_end, total_time)); + if (machine_end != 0 && first_end != 0) + System.err.println(" State build " + + timestr(machine_end-first_end, total_time)); + if (table_end != 0 && machine_end != 0) + System.err.println(" Table build " + + timestr(table_end-machine_end, total_time)); + if (reduce_check_end != 0 && table_end != 0) + System.err.println(" Checking " + + timestr(reduce_check_end-table_end, total_time)); + if (emit_end != 0 && build_end != 0) + System.err.println(" Code Output " + + timestr(emit_end-build_end, total_time)); + if (emit.symbols_time != 0) + System.err.println(" Symbols " + + timestr(emit.symbols_time, total_time)); + if (emit.parser_time != 0) + System.err.println(" Parser class " + + timestr(emit.parser_time, total_time)); + if (emit.action_code_time != 0) + System.err.println(" Actions " + + timestr(emit.action_code_time, total_time)); + if (emit.production_table_time != 0) + System.err.println(" Prod table " + + timestr(emit.production_table_time, total_time)); + if (emit.action_table_time != 0) + System.err.println(" Action tab " + + timestr(emit.action_table_time, total_time)); + if (emit.goto_table_time != 0) + System.err.println(" Reduce tab " + + timestr(emit.goto_table_time, total_time)); + + System.err.println(" Dump Output " + + timestr(dump_end-emit_end, total_time)); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Helper routine to format a decimal based display of seconds and + * percentage of total time given counts of milliseconds. Note: this + * is broken for use with some instances of negative time (since we don't + * use any negative time here, we let if be for now). + * @param time_val the value being formatted (in ms). + * @param total_time total time percentages are calculated against (in ms). + */ + protected static String timestr(long time_val, long total_time) + { + boolean neg; + long ms = 0; + long sec = 0; + long percent10; + String pad; + + /* work with positives only */ + neg = time_val < 0; + if (neg) time_val = -time_val; + + /* pull out seconds and ms */ + ms = time_val % 1000; + sec = time_val / 1000; + + /* construct a pad to blank fill seconds out to 4 places */ + if (sec < 10) + pad = " "; + else if (sec < 100) + pad = " "; + else if (sec < 1000) + pad = " "; + else + pad = ""; + + /* calculate 10 times the percentage of total */ + percent10 = (time_val*1000)/total_time; + + /* build and return the output string */ + return (neg ? "-" : "") + pad + sec + "." + + ((ms%1000)/100) + ((ms%100)/10) + (ms%10) + "sec" + + " (" + percent10/10 + "." + percent10%10 + "%)"; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a human readable dump of the grammar. */ + public static void dump_grammar() throws internal_error + { + System.err.println("===== Terminals ====="); + for (int tidx=0, cnt=0; tidx < terminal.number(); tidx++, cnt++) + { + System.err.print("["+tidx+"]"+terminal.find(tidx).name()+" "); + if ((cnt+1) % 5 == 0) System.err.println(); + } + System.err.println(); + System.err.println(); + + System.err.println("===== Non terminals ====="); + for (int nidx=0, cnt=0; nidx < non_terminal.number(); nidx++, cnt++) + { + System.err.print("["+nidx+"]"+non_terminal.find(nidx).name()+" "); + if ((cnt+1) % 5 == 0) System.err.println(); + } + System.err.println(); + System.err.println(); + + + System.err.println("===== Productions ====="); + for (int pidx=0; pidx < production.number(); pidx++) + { + production prod = production.find(pidx); + System.err.print("["+pidx+"] "+prod.lhs().the_symbol().name() + " ::= "); + for (int i=0; iu=Z94uF7ilGLP>#wGLKZacSFXSjGNr8NLXi3YmH9Rto0n*Y9BBpcaDrVM!99Q z56Zhm3!BF{fe!cNy4Q`ra{QhJ; zZ6tac;#{XVjf5=E+Xy(9^k2wn`T)W)(t00JjlMo&$B?2YhzenrO^;E-Wd8DRNWuveUqt-<8H-=*Gs>oQ p3DDI5z48sp-hf6hfZE4oa*B-4FqxbtzmG(?!Fxop!rO!^{{SAa%}oFR literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/action_part.java b/Repair/RepairCompiler/java_cup/action_part.java new file mode 100755 index 0000000..69e98f5 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/action_part.java @@ -0,0 +1,93 @@ + +package java_cup; + +/** + * This class represents a part of a production which contains an + * action. These are eventually eliminated from productions and converted + * to trailing actions by factoring out with a production that derives the + * empty string (and ends with this action). + * + * @see java_cup.production + * @version last update: 11/25/95 + * @author Scott Hudson + */ + +public class action_part extends production_part { + + /*-----------------------------------------------------------*/ + /*--- Constructors ------------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Simple constructor. + * @param code_str string containing the actual user code. + */ + public action_part(String code_str) + { + super(/* never have a label on code */null); + _code_string = code_str; + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** String containing code for the action in question. */ + protected String _code_string; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** String containing code for the action in question. */ + public String code_string() {return _code_string;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Set the code string. */ + public void set_code_string(String new_str) {_code_string = new_str;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Override to report this object as an action. */ + public boolean is_action() { return true; } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison for properly typed object. */ + public boolean equals(action_part other) + { + /* compare the strings */ + return other != null && super.equals(other) && + other.code_string().equals(code_string()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof action_part)) + return false; + else + return equals((action_part)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a hash code. */ + public int hashCode() + { + return super.hashCode() ^ + (code_string()==null ? 0 : code_string().hashCode()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() + { + return super.toString() + "{" + code_string() + "}"; + } + + /*-----------------------------------------------------------*/ +} diff --git a/Repair/RepairCompiler/java_cup/action_production.class b/Repair/RepairCompiler/java_cup/action_production.class new file mode 100755 index 0000000000000000000000000000000000000000..78d21f91f005091f3121b80b05503fa321738633 GIT binary patch literal 604 zcmbtR!AiqG5Pcid#>Q%@wJnMjyhvNM^&aseibC;H@gfqo=~A||o3Ks9&r(nX4}O3j zB~F4gh4$tlvomjIU*^62{`vd@&_>OMiOm95uw|iaVVj}k_4!nIp$-PIAIU&5RJtSn z#63R_I~nXU&=aZn*nP_kvja;z}k&Ri0{{ zlif}<7h$1VL=Jg|-I)msvkc`~Gn2$no1s#Xd=l>otpm+)J?GfJ%)tRYo=J~ME+u9WnmCgcHr+;Xvb$n7WcXA(Kt)q7sujw6|;s!AQd$3W5gMF+~WfDh`zIE!dl&4N7 YqfV~%2IGYia*$#^1rI4YR2eA!0#5j!V*mgE literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/action_production.java b/Repair/RepairCompiler/java_cup/action_production.java new file mode 100755 index 0000000..3c0845f --- /dev/null +++ b/Repair/RepairCompiler/java_cup/action_production.java @@ -0,0 +1,39 @@ + +package java_cup; + +/** A specialized version of a production used when we split an existing + * production in order to remove an embedded action. Here we keep a bit + * of extra bookkeeping so that we know where we came from. + * @version last updated: 11/25/95 + * @author Scott Hudson + */ + +public class action_production extends production { + + /** Constructor. + * @param base the production we are being factored out of. + * @param lhs_sym the LHS symbol for this production. + * @param rhs_parts array of production parts for the RHS. + * @param rhs_len how much of the rhs_parts array is valid. + * @param action_str the trailing reduce action for this production. + */ + public action_production( + production base, + non_terminal lhs_sym, + production_part rhs_parts[], + int rhs_len, + String action_str) + throws internal_error + { + super(lhs_sym, rhs_parts, rhs_len, action_str); + _base_production = base; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The production we were taken out of. */ + protected production _base_production; + + /** The production we were taken out of. */ + public production base_production() {return _base_production;} +} diff --git a/Repair/RepairCompiler/java_cup/assoc.class b/Repair/RepairCompiler/java_cup/assoc.class new file mode 100755 index 0000000000000000000000000000000000000000..6ecb7a2474faf4461768bbbe0eb1b7f31015f2de GIT binary patch literal 333 zcmYk1zfQw25XQetnxurbDgVX5zy=J>3m}$CNJv#X6m_i}V~VR_SBb-WbwXm`0eC3j zoGF%kcfZfR&*z`tuWtYoT%-tbn&2$KIiXjoS4W^H!fQT4Q8cw$2LkuuNMi}{eEt_559udY~$V*{1`J&h=>2QsJKLPY`$vfgXV?PlR=6;6{ pn9~j)G7maD4B!I=k`NL=KxC6$L)j!O0>v;SlVo5r6K5uD)~(W7 ztx^?hh1LbNjjcP_80%7(O10ItT9ol+T^M)Wrc#*97WDu)1YCc^IF9+bUGq88-6Bmwb6SvPG-ow;Xx=7!ZI_`Pns;j6 zrTJXVpVEAu=JPdQp!q`07is>q=8HA&*8CaGpVfSc=Fe%qRP$w;KdV<|cYQ9$Um*fo;Tqnm6xw+?i3L4dYk62YyO7j+cn>z`A*GuX}(+YJ(}+o(1Srf#P@0braZfZ z!TU9LYkolUw=_Q}SU|-?njhBuh~{r=epK^gnjhCZSMw8^zoYp{&4)FASMyVvpVs_6 zkuSHrFW4ZDNnUqGuuWA+0DyUV7Rw1nhXf;r)L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9Eqtnq^Fmd@XR0<{t&+S!r8uhExka7BZ7R(fd=0lzjp897}z-vKyZ5Mv%Z2aX&T-;4wtt!m5h-AF*RDsF7hD93@_ zzHwlo?ZA+Qk!nYnLD3y%hOLws=Ku7d8;Gz_}C6uP?{y4wTYT}7kS z)l{Lb!4J~EL^IWX=gt~#w!q`@IGi_71&~EiLx>9x0SFq+bbvxaGQ{F*!Cv~g4 z=n-`{eMj9x-&2R^2kJh00q*!S)kUwWZhAvK0N2J>wyxwgBws86uqu4Np|u;4$eLx% z9$q!>kN_-BJxR;dVOp)e3rl~B66$G6t7j1So~6ss{}Nyhs2?HVJqM}aJ3L1! zvA8Vi5rQQmJg;Qx6r8S@@{$*acFHPl~h}$6T0ZJwJ_nwiw_)m2eC`0 zpXg`Wk70>^J@vwD+S)mzk|-loqeIf~Ea zc}~9Y#lSp{;?`hsXTRes|I_JPG7QSET(tfUI6p{FM!?l!oYy@^786r3)kWVuaO8Ps z$EQR+xus8IY2TCn_q-tAH`r0F7Kfif?7+vo9A`8B%^Ckl~-2w$8iiXWmsmFRTh*CQxSW zFU+b}O#7;7e`(rZnfBMFJ;SuWG3{&8<|O#K;Qy^#_5RL--yD7A$N{?E@UD0hK*J@m zzU6^_+Y9k~OdO;?xF^~C(?x&p3wn^=JxpU9 zar{FTh5u<Ar+pS~iTq{Bs zSwrXsYbf1n9Y>E_!|1RzoSv~p(A(At^k>VacdU{0o;8YxT4TA~s^C#pC6BeLdAv2A zms&M^rZth*T9bIAbuu?vllfw63SVkXNqueFwVZ?6vJ3IW*Au8fS z6bv6ZM8m_MK16=JO~K~_eBQ<9U-g1#FZ@4J literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/emit.java b/Repair/RepairCompiler/java_cup/emit.java new file mode 100755 index 0000000..f124dd0 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/emit.java @@ -0,0 +1,900 @@ +package java_cup; + +import java.io.PrintWriter; +import java.util.Stack; +import java.util.Enumeration; +import java.util.Date; + +/** + * This class handles emitting generated code for the resulting parser. + * The various parse tables must be constructed, etc. before calling any + * routines in this class.

+ * + * Three classes are produced by this code: + *

+ *
symbol constant class + *
this contains constant declarations for each terminal (and + * optionally each non-terminal). + *
action class + *
this non-public class contains code to invoke all the user actions + * that were embedded in the parser specification. + *
parser class + *
the specialized parser class consisting primarily of some user + * supplied general and initialization code, and the parse tables. + *

+ * + * Three parse tables are created as part of the parser class: + *

+ *
production table + *
lists the LHS non terminal number, and the length of the RHS of + * each production. + *
action table + *
for each state of the parse machine, gives the action to be taken + * (shift, reduce, or error) under each lookahead symbol.
+ *
reduce-goto table + *
when a reduce on a given production is taken, the parse stack is + * popped back a number of elements corresponding to the RHS of the + * production. This reveals a prior state, which we transition out + * of under the LHS non terminal symbol for the production (as if we + * had seen the LHS symbol rather than all the symbols matching the + * RHS). This table is indexed by non terminal numbers and indicates + * how to make these transitions. + *

+ * + * In addition to the method interface, this class maintains a series of + * public global variables and flags indicating how misc. parts of the code + * and other output is to be produced, and counting things such as number of + * conflicts detected (see the source code and public variables below for + * more details).

+ * + * This class is "static" (contains only static data and methods).

+ * + * @see java_cup.main + * @version last update: 11/25/95 + * @author Scott Hudson + */ + +/* Major externally callable routines here include: + symbols - emit the symbol constant class + parser - emit the parser class + + In addition the following major internal routines are provided: + emit_package - emit a package declaration + emit_action_code - emit the class containing the user's actions + emit_production_table - emit declaration and init for the production table + do_action_table - emit declaration and init for the action table + do_reduce_table - emit declaration and init for the reduce-goto table + + Finally, this class uses a number of public instance variables to communicate + optional parameters and flags used to control how code is generated, + as well as to report counts of various things (such as number of conflicts + detected). These include: + + prefix - a prefix string used to prefix names that would + otherwise "pollute" someone else's name space. + package_name - name of the package emitted code is placed in + (or null for an unnamed package. + symbol_const_class_name - name of the class containing symbol constants. + parser_class_name - name of the class for the resulting parser. + action_code - user supplied declarations and other code to be + placed in action class. + parser_code - user supplied declarations and other code to be + placed in parser class. + init_code - user supplied code to be executed as the parser + is being initialized. + scan_code - user supplied code to get the next Symbol. + start_production - the start production for the grammar. + import_list - list of imports for use with action class. + num_conflicts - number of conflicts detected. + nowarn - true if we are not to issue warning messages. + not_reduced - count of number of productions that never reduce. + unused_term - count of unused terminal symbols. + unused_non_term - count of unused non terminal symbols. + *_time - a series of symbols indicating how long various + sub-parts of code generation took (used to produce + optional time reports in main). +*/ + +public class emit { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Only constructor is private so no instances can be created. */ + private emit() { } + + /*-----------------------------------------------------------*/ + /*--- Static (Class) Variables ------------------------------*/ + /*-----------------------------------------------------------*/ + + /** The prefix placed on names that pollute someone else's name space. */ + public static String prefix = "CUP$"; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Package that the resulting code goes into (null is used for unnamed). */ + public static String package_name = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Name of the generated class for symbol constants. */ + public static String symbol_const_class_name = "sym"; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Name of the generated parser class. */ + public static String parser_class_name = "parser"; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** User declarations for direct inclusion in user action class. */ + public static String action_code = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** User declarations for direct inclusion in parser class. */ + public static String parser_code = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** User code for user_init() which is called during parser initialization. */ + public static String init_code = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** User code for scan() which is called to get the next Symbol. */ + public static String scan_code = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The start production of the grammar. */ + public static production start_production = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** List of imports (Strings containing class names) to go with actions. */ + public static Stack import_list = new Stack(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Number of conflict found while building tables. */ + public static int num_conflicts = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Do we skip warnings? */ + public static boolean nowarn = false; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Count of the number on non-reduced productions found. */ + public static int not_reduced = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Count of unused terminals. */ + public static int unused_term = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Count of unused non terminals. */ + public static int unused_non_term = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /* Timing values used to produce timing report in main.*/ + + /** Time to produce symbol constant class. */ + public static long symbols_time = 0; + + /** Time to produce parser class. */ + public static long parser_time = 0; + + /** Time to produce action code class. */ + public static long action_code_time = 0; + + /** Time to produce the production table. */ + public static long production_table_time = 0; + + /** Time to produce the action table. */ + public static long action_table_time = 0; + + /** Time to produce the reduce-goto table. */ + public static long goto_table_time = 0; + + /* frankf 6/18/96 */ + protected static boolean _lr_values; + + /** whether or not to emit code for left and right values */ + public static boolean lr_values() {return _lr_values;} + protected static void set_lr_values(boolean b) { _lr_values = b;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Build a string with the standard prefix. + * @param str string to prefix. + */ + protected static String pre(String str) { + return prefix + parser_class_name + "$" + str; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit a package spec if the user wants one. + * @param out stream to produce output on. + */ + protected static void emit_package(PrintWriter out) + { + /* generate a package spec if we have a name for one */ + if (package_name != null) { + out.println("package " + package_name + ";"); out.println(); + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit code for the symbol constant class, optionally including non terms, + * if they have been requested. + * @param out stream to produce output on. + * @param emit_non_terms do we emit constants for non terminals? + * @param sym_interface should we emit an interface, rather than a class? + */ + public static void symbols(PrintWriter out, + boolean emit_non_terms, boolean sym_interface) + { + terminal term; + non_terminal nt; + String class_or_interface = (sym_interface)?"interface":"class"; + + long start_time = System.currentTimeMillis(); + + /* top of file */ + out.println(); + out.println("//----------------------------------------------------"); + out.println("// The following code was generated by " + + version.title_str); + out.println("// " + new Date()); + out.println("//----------------------------------------------------"); + out.println(); + emit_package(out); + + /* class header */ + out.println("/** CUP generated " + class_or_interface + + " containing symbol constants. */"); + out.println("public " + class_or_interface + " " + + symbol_const_class_name + " {"); + + out.println(" /* terminals */"); + + /* walk over the terminals */ /* later might sort these */ + for (Enumeration e = terminal.all(); e.hasMoreElements(); ) + { + term = (terminal)e.nextElement(); + + /* output a constant decl for the terminal */ + out.println(" public static final int " + term.name() + " = " + + term.index() + ";"); + } + + /* do the non terminals if they want them (parser doesn't need them) */ + if (emit_non_terms) + { + out.println(); + out.println(" /* non terminals */"); + + /* walk over the non terminals */ /* later might sort these */ + for (Enumeration e = non_terminal.all(); e.hasMoreElements(); ) + { + nt = (non_terminal)e.nextElement(); + + /* output a constant decl for the terminal */ + out.println(" static final int " + nt.name() + " = " + + nt.index() + ";"); + } + } + + /* end of class */ + out.println("}"); + out.println(); + + symbols_time = System.currentTimeMillis() - start_time; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit code for the non-public class holding the actual action code. + * @param out stream to produce output on. + * @param start_prod the start production of the grammar. + */ + protected static void emit_action_code(PrintWriter out, production start_prod) + throws internal_error + { + production prod; + + long start_time = System.currentTimeMillis(); + + /* class header */ + out.println(); + out.println( + "/** Cup generated class to encapsulate user supplied action code.*/" + ); + out.println("class " + pre("actions") + " {"); + + /* user supplied code */ + if (action_code != null) + { + out.println(); + out.println(action_code); + } + + /* field for parser object */ + out.println(" private final "+parser_class_name+" parser;"); + + /* constructor */ + out.println(); + out.println(" /** Constructor */"); + out.println(" " + pre("actions") + "("+parser_class_name+" parser) {"); + out.println(" this.parser = parser;"); + out.println(" }"); + + /* action method head */ + out.println(); + out.println(" /** Method with the actual generated action code. */"); + out.println(" public final java_cup.runtime.Symbol " + + pre("do_action") + "("); + out.println(" int " + pre("act_num,")); + out.println(" java_cup.runtime.lr_parser " + pre("parser,")); + out.println(" java.util.Stack " + pre("stack,")); + out.println(" int " + pre("top)")); + out.println(" throws java.lang.Exception"); + out.println(" {"); + + /* declaration of result symbol */ + /* New declaration!! now return Symbol + 6/13/96 frankf */ + out.println(" /* Symbol object for return from actions */"); + out.println(" java_cup.runtime.Symbol " + pre("result") + ";"); + out.println(); + + /* switch top */ + out.println(" /* select the action based on the action number */"); + out.println(" switch (" + pre("act_num") + ")"); + out.println(" {"); + + /* emit action code for each production as a separate case */ + for (Enumeration p = production.all(); p.hasMoreElements(); ) + { + prod = (production)p.nextElement(); + + /* case label */ + out.println(" /*. . . . . . . . . . . . . . . . . . . .*/"); + out.println(" case " + prod.index() + ": // " + + prod.to_simple_string()); + + /* give them their own block to work in */ + out.println(" {"); + + /* create the result symbol */ + /*make the variable RESULT which will point to the new Symbol (see below) + and be changed by action code + 6/13/96 frankf */ + out.println(" " + prod.lhs().the_symbol().stack_type() + + " RESULT = null;"); + + /* create the PRODSTRING variable, useful for debugging */ + out.println(" String PRODSTRING = \"" + prod.to_simple_string() + "\";"); + + /* Add code to propagate RESULT assignments that occur in + * action code embedded in a production (ie, non-rightmost + * action code). 24-Mar-1998 CSA + */ + for (int i=0; ireduce_goto table. */"); + out.println(" protected static final short[][] _reduce_table = "); + out.print (" unpackFromStrings("); + do_table_as_string(out, reduce_goto_table); + out.println(");"); + + /* do the public accessor method */ + out.println(); + out.println(" /** Access to reduce_goto table. */"); + out.println(" public short[][] reduce_table() {return _reduce_table;}"); + out.println(); + + goto_table_time = System.currentTimeMillis() - start_time; + } + + // print a string array encoding the given short[][] array. + protected static void do_table_as_string(PrintWriter out, short[][] sa) { + out.println("new String[] {"); + out.print(" \""); + int nchar=0, nbytes=0; + nbytes+=do_escaped(out, (char)(sa.length>>16)); + nchar =do_newline(out, nchar, nbytes); + nbytes+=do_escaped(out, (char)(sa.length&0xFFFF)); + nchar =do_newline(out, nchar, nbytes); + for (int i=0; i>16)); + nchar =do_newline(out, nchar, nbytes); + nbytes+=do_escaped(out, (char)(sa[i].length&0xFFFF)); + nchar =do_newline(out, nchar, nbytes); + for (int j=0; j 65500) { out.println("\", "); out.print(" \""); } + else if (nchar > 11) { out.println("\" +"); out.print(" \""); } + else return nchar+1; + return 0; + } + // output an escape sequence for the given character code. + protected static int do_escaped(PrintWriter out, char c) { + StringBuffer escape = new StringBuffer(); + if (c <= 0xFF) { + escape.append(Integer.toOctalString(c)); + while(escape.length() < 3) escape.insert(0, '0'); + } else { + escape.append(Integer.toHexString(c)); + while(escape.length() < 4) escape.insert(0, '0'); + escape.insert(0, 'u'); + } + escape.insert(0, '\\'); + out.print(escape.toString()); + + // return number of bytes this takes up in UTF-8 encoding. + if (c == 0) return 2; + if (c >= 0x01 && c <= 0x7F) return 1; + if (c >= 0x80 && c <= 0x7FF) return 2; + return 3; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit the parser subclass with embedded tables. + * @param out stream to produce output on. + * @param action_table internal representation of the action table. + * @param reduce_table internal representation of the reduce-goto table. + * @param start_st start state of the parse machine. + * @param start_prod start production of the grammar. + * @param compact_reduces do we use most frequent reduce as default? + * @param suppress_scanner should scanner be suppressed for compatibility? + */ + public static void parser( + PrintWriter out, + parse_action_table action_table, + parse_reduce_table reduce_table, + int start_st, + production start_prod, + boolean compact_reduces, + boolean suppress_scanner) + throws internal_error + { + long start_time = System.currentTimeMillis(); + + /* top of file */ + out.println(); + out.println("//----------------------------------------------------"); + out.println("// The following code was generated by " + + version.title_str); + out.println("// " + new Date()); + out.println("//----------------------------------------------------"); + out.println(); + emit_package(out); + + /* user supplied imports */ + for (int i = 0; i < import_list.size(); i++) + out.println("import " + import_list.elementAt(i) + ";"); + + /* class header */ + out.println(); + out.println("/** "+version.title_str+" generated parser."); + out.println(" * @version " + new Date()); + out.println(" */"); + out.println("public class " + parser_class_name + + " extends java_cup.runtime.lr_parser {"); + + /* constructors [CSA/davidm, 24-jul-99] */ + out.println(); + out.println(" /** Default constructor. */"); + out.println(" public " + parser_class_name + "() {super();}"); + if (!suppress_scanner) { + out.println(); + out.println(" /** Constructor which sets the default scanner. */"); + out.println(" public " + parser_class_name + + "(java_cup.runtime.Scanner s) {super(s);}"); + } + + /* emit the various tables */ + emit_production_table(out); + do_action_table(out, action_table, compact_reduces); + do_reduce_table(out, reduce_table); + + /* instance of the action encapsulation class */ + out.println(" /** Instance of action encapsulation class. */"); + out.println(" protected " + pre("actions") + " action_obj;"); + out.println(); + + /* action object initializer */ + out.println(" /** Action encapsulation object initializer. */"); + out.println(" protected void init_actions()"); + out.println(" {"); + out.println(" action_obj = new " + pre("actions") + "(this);"); + out.println(" }"); + out.println(); + + /* access to action code */ + out.println(" /** Invoke a user supplied parse action. */"); + out.println(" public java_cup.runtime.Symbol do_action("); + out.println(" int act_num,"); + out.println(" java_cup.runtime.lr_parser parser,"); + out.println(" java.util.Stack stack,"); + out.println(" int top)"); + out.println(" throws java.lang.Exception"); + out.println(" {"); + out.println(" /* call code in generated class */"); + out.println(" return action_obj." + pre("do_action(") + + "act_num, parser, stack, top);"); + out.println(" }"); + out.println(""); + + + /* method to tell the parser about the start state */ + out.println(" /** Indicates start state. */"); + out.println(" public int start_state() {return " + start_st + ";}"); + + /* method to indicate start production */ + out.println(" /** Indicates start production. */"); + out.println(" public int start_production() {return " + + start_production.index() + ";}"); + out.println(); + + /* methods to indicate EOF and error symbol indexes */ + out.println(" /** EOF Symbol index. */"); + out.println(" public int EOF_sym() {return " + terminal.EOF.index() + + ";}"); + out.println(); + out.println(" /** error Symbol index. */"); + out.println(" public int error_sym() {return " + terminal.error.index() + + ";}"); + out.println(); + + /* user supplied code for user_init() */ + if (init_code != null) + { + out.println(); + out.println(" /** User initialization code. */"); + out.println(" public void user_init() throws java.lang.Exception"); + out.println(" {"); + out.println(init_code); + out.println(" }"); + } + + /* user supplied code for scan */ + if (scan_code != null) + { + out.println(); + out.println(" /** Scan to get the next Symbol. */"); + out.println(" public java_cup.runtime.Symbol scan()"); + out.println(" throws java.lang.Exception"); + out.println(" {"); + out.println(scan_code); + out.println(" }"); + } + + /* user supplied code */ + if (parser_code != null) + { + out.println(); + out.println(parser_code); + } + + /* end of class */ + out.println("}"); + + /* put out the action code class */ + emit_action_code(out, start_prod); + + parser_time = System.currentTimeMillis() - start_time; + } + + /*-----------------------------------------------------------*/ +} diff --git a/Repair/RepairCompiler/java_cup/internal_error.class b/Repair/RepairCompiler/java_cup/internal_error.class new file mode 100755 index 0000000000000000000000000000000000000000..1447962af9a6862e37df36f7988b3465b96deafc GIT binary patch literal 580 zcmZWn+fD*86r3)X#j=WAz3X}hP2>YGzMv)=H72O9q$~|qmt9hd(a+KcH9q(Oew6Vn zYKXB-&S_`o%;~iI@%i=+UTrtG!VOug}PE;Vz2Hlp_7oz18lJK&7G;9wC;4C}{))i2N8Lt%vP9{m)!2T_5$FOBq!Y};@h zEF1<^C+qDX- z=VaNCaVfgBUzxu!gWZcrJ_+)UG^euP7aj6jC|CYp9^KiH-7vztz0krVVqD%UL#cdJ zxguXFdZlPsAVH)lI<#A%y+t{>wfzG2NGpbMihPK2B!pT4rHlyj%J?zi~?p+B&kWlEo8p{U^;x8 literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/internal_error.java b/Repair/RepairCompiler/java_cup/internal_error.java new file mode 100755 index 0000000..4d3e7c2 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/internal_error.java @@ -0,0 +1,22 @@ + +package java_cup; + +/** Exception subclass for reporting internal errors in JavaCup. */ +public class internal_error extends Exception + { + /** Constructor with a message */ + public internal_error(String msg) + { + super(msg); + } + + /** Method called to do a forced error exit on an internal error + for cases when we can't actually throw the exception. */ + public void crash() + { + System.err.println("JavaCUP Fatal Internal Error Detected"); + System.err.println(getMessage()); + printStackTrace(); + System.exit(-1); + } + } diff --git a/Repair/RepairCompiler/java_cup/lalr_item.class b/Repair/RepairCompiler/java_cup/lalr_item.class new file mode 100755 index 0000000000000000000000000000000000000000..9dd7ce863e3446a2b53735bfecfd85212035b7ba GIT binary patch literal 3779 zcmaJ@?Q>jJ8ULN^Zg#W1&0EtZp^0vw)MPiwwoOYRX$t8ZZAn|OUo;rXRt!MA1kP5`gV_qzdnFM#g{Fy+S&6oRotDmA8$8v2kz zeg852xE_n=(oxIEjGIY45z87@k3w}Uok^wj5#2Ikre%z06>4neXwEVd(Sw#AA0t~$ z(lCayMP4(NR8Ws7ly5PUrnOaJU2Dk%H4f$C7MXhXl&JFzw|!2*yFE2zC{*>ENn?L* ze9*`|s1GJc3GO@*H_{?cZ=y>p{sg@ZOG}8!3Ku4gt!+0^LZ23avcln>56g0WXs8GZ zJ+F6}PUwk@4QY>9t}AIQ`oQRJaS1E}$d?^8hb@IwZcj^U6)NL;BJR$!I}7vG-89si zqC2tUX4bS5;Aw4>+!~MP^aP!}NmOK6S#Up^(32z41B1tmxYZ+~fl)m>T1YQ-?IFQR z9keoLa)e0CA!!R0sI0Ky!Bj32H+Gp)0hPrlJEd?n?8O@zc3>w{BLr6#>s`Z-@M8_fbi>!jPIM6#Ppurot?sFuHm4;vAEk7=4$cwLa zMPIWg#|Kl1SX$3m8fNgeAHUJ?j_}kJdFBd6V3~D8m`o*OrOV$6aK94>FN^CjT#@Cd zhC##?z;YFhg_0;_cUx|F*vM$Oig!6R9@Q`e=D4gq#M3DazsGwT{($#2TobwqY4|`? zsi!%f_CM6$AL>7F;J&`yJNtIDw2*w*?VHnMv3M#&*+y48xu=kHAPbSJH=WClDy&_q zaP1zMSIY`M$>>Q+v(rDRU0L)MM#303l2#vEc4h0H!gN`n&YLx#q@Tf|loivh7;8g# zU51^05LYX$QA37{GfSlpT@$Nx!RGOczI2Mcx}uoQ5(B-@jPkB|&MEsLDBas-K`jkS z$l7;|&CJGhd!*BO@vBf!wCDDzK%^$SNo^~0e9Nd{u8w4)EuKgA;HVfjGg(XCCeDmx zE|G9v1o|IK7|9WfxpU7*RP3q%JWqHzmy7&*EnlCi?kHRa1iaW0iCHu>{#BU{ggTo1B=;vvN%?UJx zBTX|<;f_lv3(vwcFaz%;_`+PuFOpATAJ)UY`}g}z2vF0bsuna zuOZFDn?N|?X`g|=q$fxYU<>@{T_AhEBO9hA;i;tTECO_=VhIhqu$-~Et#h8z2Z^ki zUk(Ds@D|E0a8n4O+$KK2l>?XSLRQ~G)&VkcCOWK9dL@2UQL8VKNAS=Bh$`)nM^J%L zLTyrvliLaEHGaJme%RAX@$yMjMXn)8Ez2h0y~w>5&O_sQd2iDsg2FR_jH!k#`D^eVl>~98&7hG< z>JKx5TOuVK3so~gWs|7E>#UzC{*`=Vp3z6~m}B%W1hAY&PgCRSIisviF>2SrK3+6? zj}nmkx%(6W`E<9p(VItT5y$sJ#51JxEt45 zh#&Gf|0C<_BOJxY7{i}1PQFw4E1t#Q=7oD0N1Sk9;8$uwVu?(^=bh%J-43sdyABDj zpYAZYP^1vszIHn@pJ%$g7=dTniJ;St;JSCZ==)mMBJdBc|HKOX3r+Ypeg6+4_%Al% z2JRt!zw*xWk1wfH@U8SuYCwy809p)3W)Lmuwi{Vhp4P# zglkjn9bEF*?52fhaOYxb?OhIyaBJ5v>{in4TzPuWBP#bzdGt)6#l_R~Hn!x^OUBx* z4)>WdMe5yCH$HOl)!yUWo=3f#+~<(pv~3Q})kNK#CQu#lsP(8<8_=P;(5E(Hx4Hw5 jsm;*Uok*y=aE|*|R5$-e_Tq}#ijUR31ZtQ7m0{%n)`*Jg literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/lalr_item.java b/Repair/RepairCompiler/java_cup/lalr_item.java new file mode 100755 index 0000000..fe92054 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/lalr_item.java @@ -0,0 +1,330 @@ +package java_cup; + +import java.util.Stack; +import java.util.Enumeration; + +/** This class represents an LALR item. Each LALR item consists of + * a production, a "dot" at a position within that production, and + * a set of lookahead symbols (terminal). (The first two of these parts + * are provide by the super class). An item is designed to represent a + * configuration that the parser may be in. For example, an item of the + * form:

+ *    [A ::= B * C d E  , {a,b,c}]
+ *  
+ * indicates that the parser is in the middle of parsing the production
+ *    A ::= B C d E
+ *  
+ * that B has already been parsed, and that we will expect to see a lookahead + * of either a, b, or c once the complete RHS of this production has been + * found.

+ * + * Items may initially be missing some items from their lookahead sets. + * Links are maintained from each item to the set of items that would need + * to be updated if symbols are added to its lookahead set. During + * "lookahead propagation", we add symbols to various lookahead sets and + * propagate these changes across these dependency links as needed. + * + * @see java_cup.lalr_item_set + * @see java_cup.lalr_state + * @version last updated: 11/25/95 + * @author Scott Hudson + */ +public class lalr_item extends lr_item_core { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Full constructor. + * @param prod the production for the item. + * @param pos the position of the "dot" within the production. + * @param look the set of lookahead symbols. + */ + public lalr_item(production prod, int pos, terminal_set look) + throws internal_error + { + super(prod, pos); + _lookahead = look; + _propagate_items = new Stack(); + needs_propagation = true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor with default position (dot at start). + * @param prod the production for the item. + * @param look the set of lookahead symbols. + */ + public lalr_item(production prod, terminal_set look) throws internal_error + { + this(prod,0,look); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor with default position and empty lookahead set. + * @param prod the production for the item. + */ + public lalr_item(production prod) throws internal_error + { + this(prod,0,new terminal_set()); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The lookahead symbols of the item. */ + protected terminal_set _lookahead; + + /** The lookahead symbols of the item. */ + public terminal_set lookahead() {return _lookahead;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Links to items that the lookahead needs to be propagated to. */ + protected Stack _propagate_items; + + /** Links to items that the lookahead needs to be propagated to */ + public Stack propagate_items() {return _propagate_items;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Flag to indicate that this item needs to propagate its lookahead + * (whether it has changed or not). + */ + protected boolean needs_propagation; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Add a new item to the set of items we propagate to. */ + public void add_propagate(lalr_item prop_to) + { + _propagate_items.push(prop_to); + needs_propagation = true; + } + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Propagate incoming lookaheads through this item to others need to + * be changed. + * @params incoming symbols to potentially be added to lookahead of this item. + */ + public void propagate_lookaheads(terminal_set incoming) throws internal_error + { + boolean change = false; + + /* if we don't need to propagate, then bail out now */ + if (!needs_propagation && (incoming == null || incoming.empty())) + return; + + /* if we have null incoming, treat as an empty set */ + if (incoming != null) + { + /* add the incoming to the lookahead of this item */ + change = lookahead().add(incoming); + } + + /* if we changed or need it anyway, propagate across our links */ + if (change || needs_propagation) + { + /* don't need to propagate again */ + needs_propagation = false; + + /* propagate our lookahead into each item we are linked to */ + for (int i = 0; i < propagate_items().size(); i++) + ((lalr_item)propagate_items().elementAt(i)) + .propagate_lookaheads(lookahead()); + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce the new lalr_item that results from shifting the dot one position + * to the right. + */ + public lalr_item shift() throws internal_error + { + lalr_item result; + + /* can't shift if we have dot already at the end */ + if (dot_at_end()) + throw new internal_error("Attempt to shift past end of an lalr_item"); + + /* create the new item w/ the dot shifted by one */ + result = new lalr_item(the_production(), dot_pos()+1, + new terminal_set(lookahead())); + + /* change in our lookahead needs to be propagated to this item */ + add_propagate(result); + + return result; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Calculate lookahead representing symbols that could appear after the + * symbol that the dot is currently in front of. Note: this routine must + * not be invoked before first sets and nullability has been calculated + * for all non terminals. + */ + public terminal_set calc_lookahead(terminal_set lookahead_after) + throws internal_error + { + terminal_set result; + int pos; + production_part part; + symbol sym; + + /* sanity check */ + if (dot_at_end()) + throw new internal_error( + "Attempt to calculate a lookahead set with a completed item"); + + /* start with an empty result */ + result = new terminal_set(); + + /* consider all nullable symbols after the one to the right of the dot */ + for (pos = dot_pos()+1; pos < the_production().rhs_length(); pos++) + { + part = the_production().rhs(pos); + + /* consider what kind of production part it is -- skip actions */ + if (!part.is_action()) + { + sym = ((symbol_part)part).the_symbol(); + + /* if its a terminal add it in and we are done */ + if (!sym.is_non_term()) + { + result.add((terminal)sym); + return result; + } + else + { + /* otherwise add in first set of the non terminal */ + result.add(((non_terminal)sym).first_set()); + + /* if its nullable we continue adding, if not, we are done */ + if (!((non_terminal)sym).nullable()) + return result; + } + } + } + + /* if we get here everything past the dot was nullable + we add in the lookahead for after the production and we are done */ + result.add(lookahead_after); + return result; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Determine if everything from the symbol one beyond the dot all the + * way to the end of the right hand side is nullable. This would indicate + * that the lookahead of this item must be included in the lookaheads of + * all items produced as a closure of this item. Note: this routine should + * not be invoked until after first sets and nullability have been + * calculated for all non terminals. + */ + public boolean lookahead_visible() throws internal_error + { + production_part part; + symbol sym; + + /* if the dot is at the end, we have a problem, but the cleanest thing + to do is just return true. */ + if (dot_at_end()) return true; + + /* walk down the rhs and bail if we get a non-nullable symbol */ + for (int pos = dot_pos() + 1; pos < the_production().rhs_length(); pos++) + { + part = the_production().rhs(pos); + + /* skip actions */ + if (!part.is_action()) + { + sym = ((symbol_part)part).the_symbol(); + + /* if its a terminal we fail */ + if (!sym.is_non_term()) return false; + + /* if its not nullable we fail */ + if (!((non_terminal)sym).nullable()) return false; + } + } + + /* if we get here its all nullable */ + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison -- here we only require the cores to be equal since + * we need to do sets of items based only on core equality (ignoring + * lookahead sets). + */ + public boolean equals(lalr_item other) + { + if (other == null) return false; + return super.equals(other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof lalr_item)) + return false; + else + return equals((lalr_item)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return a hash code -- here we only hash the core since we only test core + * matching in LALR items. + */ + public int hashCode() + { + return super.hashCode(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to string. */ + public String toString() + { + String result = ""; + + // additional output for debugging: + // result += "(" + obj_hash() + ")"; + result += "["; + result += super.toString(); + result += ", "; + if (lookahead() != null) + { + result += "{"; + for (int t = 0; t < terminal.number(); t++) + if (lookahead().contains(t)) + result += terminal.find(t).name() + " "; + result += "}"; + } + else + result += "NULL LOOKAHEAD!!"; + result += "]"; + + // additional output for debugging: + // result += " -> "; + // for (int i = 0; iCGvUo{`Pm48?tivlZ`;4r8Hi*wf5XWg5UJc^42rqUjgv;{062j-@`GpX^ zD9Sp*OWlb8%l%AR~6xKS1 z8Qq-j9X9jEw2`G*^+4K8=MO6Qy1I|i=^#%i)Q_Z1W2`VcVPu~Ye+q3~_VHw@FxQ*W zGudQ1Z_FlhM!sK;MTX9&jJbT;GIR7~<7(~d_8=QF3$sR67YhdU=hDy9CqoV^gi@B7 z*VA&cWwjvv-6wcrDs4_G#8x+01sbDh>0B~bm>|ZaHT8dQzyNi&@tlz@nfvrf2CU8+ zv(`Ccy$>|rJvc1^OxiTNSFR+9NJ6HSPnrcgUCs^2A=7YV;*61U7_3iOvvY+!vz4)O zg)F^Q8_yN=3|VPf?Fb=>DF|4?|DZ|?u7H~wvPjEoP({jUc3@J3o zDJSo4`Dys6Y}oLe4JTcP3sX}DFIe?LM8nT;i?jB2nZ2W+xO5x|PF_-2Q+DY{iG|WN zECm^$j6{-^YH;;N=@=Pf)-dx_S52w>9yczqBq?TvZL2BH(>|8{*i1OR$5Y{SY8vPB zLrx5K6AE?I${Oy1w1_S#>Tt%g&gwIU&O$4-3!7{&t<>&%Pt{j!i4z~IMq&Rdi2oO` z+mXDrx1zkXBT-xrsWu#m};Wc_aNXn=B?*qfWI6GgGrgQqVo~MQasVo}}MZ*F- zre_LVs@CV`3~9(cUfxUOd5HH4nmkpQyDIV~rNSH?d_nHxTfPc@={}tKr2+A|7K(*- zfa5{_>gT%Rvn93&6#V<+S&(c1YG z*rAy1F?5S_2WPdtzLz6=E5}u=!wV~{57Lf})wS;6J>(`~@lDu~mF8mjD2840PS;#> z&1-H$TM6d~ZP~AB=}=V#9|Oc3Qi`Y@okvr==RMRZ@N^ON*AVb6aAA$YwR<1<%Lp8* zjw67RsKqI4#4~t+^DaDFLDk4|wCygw8arA%RzySDoqVAIXXx&1#c{qvT(C2QDq#0I zU>!>2j-x$y(9lyvloUmaSUcWx%a)8y1J@eI<7FB)BSaq;80ST*=VdhEA|-l>pLeek z`ep3Fm5TU$eYx@XyYL&G_##S|=%(?qf*f_ePXAXC!F7uKMuor8Wu1=FpWJ7wLx)3t zL(D^d^LUB)f0hF@(>3^l3*aVsf1C2WiB7(&yz(4d4l?2f>GTF!;|aF~ILphr6t) zKTtq_q=5eH3F4QJ6gNmOxe|rc$M2$c3F{Kk)Fad$sSQu5fAiLbJG4$xHV8jM_+Ir zhgyT~%{KRimY^kCIc`a`RxhG+5nIP%JBn!T^EZXBBHYu;F0-xGzvC^076YpT0~0e-=_UE(n^A+p;Pzk@o#z^rY5Q>t7f(y$;Lbomx&-N4q` zVz;~HwySm#)n2ryeMGgNHczwNI<0LF{YrwO@!z7&?i#W9ZL}59T`qDvN9r(wY7k*1 zO_3i}?)fY;Cyo8EZ-8YLxXU`1lJFg5M{4sFMeNeRD?U{c?FW2Q#1n0c=yA%CN!n44 zw+TUZW9m~q$#}=HRwb~R&z + * + * This class provides fairly conventional set oriented operations (union, + * sub/super-set tests, etc.), as well as an LALR "closure" operation (see + * compute_closure()). + * + * @see java_cup.lalr_item + * @see java_cup.lalr_state + * @version last updated: 3/6/96 + * @author Scott Hudson + */ + +public class lalr_item_set { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Constructor for an empty set. */ + public lalr_item_set() { } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor for cloning from another set. + * @param other indicates set we should copy from. + */ + public lalr_item_set(lalr_item_set other) + throws internal_error + { + not_null(other); + _all = (Hashtable)other._all.clone(); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** A hash table to implement the set. We store the items using themselves + * as keys. + */ + protected Hashtable _all = new Hashtable(11); + + /** Access to all elements of the set. */ + public Enumeration all() {return _all.elements();} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Cached hashcode for this set. */ + protected Integer hashcode_cache = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Size of the set */ + public int size() {return _all.size();} + + /*-----------------------------------------------------------*/ + /*--- Set Operation Methods ---------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Does the set contain a particular item? + * @param itm the item in question. + */ + public boolean contains(lalr_item itm) {return _all.containsKey(itm);} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return the item in the set matching a particular item (or null if not + * found) + * @param itm the item we are looking for. + */ + public lalr_item find(lalr_item itm) {return (lalr_item)_all.get(itm);} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Is this set an (improper) subset of another? + * @param other the other set in question. + */ + public boolean is_subset_of(lalr_item_set other) throws internal_error + { + not_null(other); + + /* walk down our set and make sure every element is in the other */ + for (Enumeration e = all(); e.hasMoreElements(); ) + if (!other.contains((lalr_item)e.nextElement())) + return false; + + /* they were all there */ + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Is this set an (improper) superset of another? + * @param other the other set in question. + */ + public boolean is_superset_of(lalr_item_set other) throws internal_error + { + not_null(other); + return other.is_subset_of(this); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Add a singleton item, merging lookahead sets if the item is already + * part of the set. returns the element of the set that was added or + * merged into. + * @param itm the item being added. + */ + public lalr_item add(lalr_item itm) throws internal_error + { + lalr_item other; + + not_null(itm); + + /* see if an item with a matching core is already there */ + other = (lalr_item)_all.get(itm); + + /* if so, merge this lookahead into the original and leave it */ + if (other != null) + { + other.lookahead().add(itm.lookahead()); + return other; + } + /* otherwise we just go in the set */ + else + { + /* invalidate cached hashcode */ + hashcode_cache = null; + + _all.put(itm,itm); + return itm; + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Remove a single item if it is in the set. + * @param itm the item to remove. + */ + public void remove(lalr_item itm) throws internal_error + { + not_null(itm); + + /* invalidate cached hashcode */ + hashcode_cache = null; + + /* remove it from hash table implementing set */ + _all.remove(itm); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Add a complete set, merging lookaheads where items are already in + * the set + * @param other the set to be added. + */ + public void add(lalr_item_set other) throws internal_error + { + not_null(other); + + /* walk down the other set and do the adds individually */ + for (Enumeration e = other.all(); e.hasMoreElements(); ) + add((lalr_item)e.nextElement()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Remove (set subtract) a complete set. + * @param other the set to remove. + */ + public void remove(lalr_item_set other) throws internal_error + { + not_null(other); + + /* walk down the other set and do the removes individually */ + for (Enumeration e = other.all(); e.hasMoreElements(); ) + remove((lalr_item)e.nextElement()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Remove and return one item from the set (done in hash order). */ + public lalr_item get_one() throws internal_error + { + Enumeration the_set; + lalr_item result; + + the_set = all(); + if (the_set.hasMoreElements()) + { + result = (lalr_item)the_set.nextElement(); + remove(result); + return result; + } + else + return null; + } + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Helper function for null test. Throws an interal_error exception if its + * parameter is null. + * @param obj the object we are testing. + */ + protected void not_null(Object obj) throws internal_error + { + if (obj == null) + throw new internal_error("Null object used in set operation"); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Compute the closure of the set using the LALR closure rules. Basically + * for every item of the form:

+   *    [L ::= a *N alpha, l] 
+   *  
+ * (where N is a a non terminal and alpha is a string of symbols) make + * sure there are also items of the form:
+   *    [N ::= *beta, first(alpha l)] 
+   *  
+ * corresponding to each production of N. Items with identical cores but + * differing lookahead sets are merged by creating a new item with the same + * core and the union of the lookahead sets (the LA in LALR stands for + * "lookahead merged" and this is where the merger is). This routine + * assumes that nullability and first sets have been computed for all + * productions before it is called. + */ + public void compute_closure() + throws internal_error + { + lalr_item_set consider; + lalr_item itm, new_itm, add_itm; + non_terminal nt; + terminal_set new_lookaheads; + Enumeration p; + production prod; + boolean need_prop; + + + + /* invalidate cached hashcode */ + hashcode_cache = null; + + /* each current element needs to be considered */ + consider = new lalr_item_set(this); + + /* repeat this until there is nothing else to consider */ + while (consider.size() > 0) + { + /* get one item to consider */ + itm = consider.get_one(); + + /* do we have a dot before a non terminal */ + nt = itm.dot_before_nt(); + if (nt != null) + { + /* create the lookahead set based on first after dot */ + new_lookaheads = itm.calc_lookahead(itm.lookahead()); + + /* are we going to need to propagate our lookahead to new item */ + need_prop = itm.lookahead_visible(); + + /* create items for each production of that non term */ + for (p = nt.productions(); p.hasMoreElements(); ) + { + prod = (production)p.nextElement(); + + /* create new item with dot at start and that lookahead */ + new_itm = new lalr_item(prod, + new terminal_set(new_lookaheads)); + + /* add/merge item into the set */ + add_itm = add(new_itm); + /* if propagation is needed link to that item */ + if (need_prop) + itm.add_propagate(add_itm); + + /* was this was a new item*/ + if (add_itm == new_itm) + { + /* that may need further closure, consider it also */ + consider.add(new_itm); + } + } + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison. */ + public boolean equals(lalr_item_set other) + { + if (other == null || other.size() != size()) return false; + + /* once we know they are the same size, then improper subset does test */ + try { + return is_subset_of(other); + } catch (internal_error e) { + /* can't throw error from here (because superclass doesn't) so crash */ + e.crash(); + return false; + } + + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof lalr_item_set)) + return false; + else + return equals((lalr_item_set)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return hash code. */ + public int hashCode() + { + int result = 0; + Enumeration e; + int cnt; + + /* only compute a new one if we don't have it cached */ + if (hashcode_cache == null) + { + /* hash together codes from at most first 5 elements */ + // CSA fix! we'd *like* to hash just a few elements, but + // that means equal sets will have inequal hashcodes, which + // we're not allowed (by contract) to do. So hash them all. + for (e = all(), cnt=0 ; e.hasMoreElements() /*&& cnt<5*/; cnt++) + result ^= ((lalr_item)e.nextElement()).hashCode(); + + hashcode_cache = new Integer(result); + } + + return hashcode_cache.intValue(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to string. */ + public String toString() + { + StringBuffer result = new StringBuffer(); + + result.append("{\n"); + for (Enumeration e=all(); e.hasMoreElements(); ) + { + result.append(" " + (lalr_item)e.nextElement() + "\n"); + } + result.append("}"); + + return result.toString(); + } + /*-----------------------------------------------------------*/ +} + diff --git a/Repair/RepairCompiler/java_cup/lalr_state.class b/Repair/RepairCompiler/java_cup/lalr_state.class new file mode 100755 index 0000000000000000000000000000000000000000..b610fd79cda48c168bd9b4d711221dbb4a58a643 GIT binary patch literal 9792 zcmb7K34B!5x&OXut-#j6vL3*kb%j}I18IAisDwa zZf)X*3&sUE#6eBns)E{Tty`_O>eKqP&uX9VJzs6D(*Jkvow+v&`gmUuGkNos^8UG>lz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HXBzF8a3cW4t_LFSQfW>%1~lzKV8Ul=Zq zmMXeIyMu0)QQWri4yq9g4X;(tiBe`ZHG6gx_ir1xe`aqIVl9 zPY&;;vl02{U|qF==gNVh#Da_iAtT)!qC5e6MxM5GA;aqNexcy0((sHv$=^dm>#C8ftzGE$>t%M) z7C-(&gQ_B*iVO-g=cMIA^eCh~ONRD5)o3r#NbO}Bt-VSO+G})-_9o5L-ljR)y9kT- z=p^j}YSBI<6Z=W+6Uu3y(mC3n5gMN$ES{xq?Js>yg3q;~L**opQ2cU*ww0LqhH=ybqxS|r0?BY zb*+NEPVQIN?WF5vyxuYA5^3tRuSwJX0aJcMhid<%3EHd-y3 zQTNhTykD*Rsap@wZF-O%)=TM0y^QwgmGp`}h~Cnx`j`|SzipEag-NAC?SW7QgZ}J? z4f=D4UI;nd6&8fN#gJ>L+fLIEPF>wJ2}5_pBP9(7%UBsR!?)2W7aw>;V)2H;HDRz& zQjzt53+hH}OZm*xO+`Sl;LSg1!Rb^%q>rKD`XMw%Ka?8vaTL+(XpY`UC+UaNQhg$< zcNA^G`W5oZ)|V)^Ke%CQSpngFXwOERo(4^@i|;AXTYw{(#Y zVdQbuM^zK_dBDSOIyUx18@sCR8LI3iufC(U4!v}qwmEfGwf*`c^685ypf3R?zP8)= zVT^Jk@mtov)xom3Eypf?>9e7)05_>us|s#)-xY6zDdkd|r`xOUu*}*7s+|jZXuJ&% z)oKvFw + * [A ::= B * C d E , {a,b,c}] + * + * this indicates that when the parser is in this state it is currently + * looking for an A of the given form, has already seen the B, and would + * expect to see an a, b, or c after this sequence is complete. Note that + * the parser is normally looking for several things at once (represented + * by several items). In our example above, the state would also include + * items such as:
+ *    [C ::= * X e Z, {d}]
+ *    [X ::= * f, {e}]
+ *  
+ * to indicate that it was currently looking for a C followed by a d (which + * would be reduced into a C, matching the first symbol in our production + * above), and the terminal f followed by e.

+ * + * At runtime, the parser uses a viable prefix recognition machine made up + * of these states to parse. The parser has two operations, shift and reduce. + * In a shift, it consumes one Symbol and makes a transition to a new state. + * This corresponds to "moving the dot past" a terminal in one or more items + * in the state (these new shifted items will then be found in the state at + * the end of the transition). For a reduce operation, the parser is + * signifying that it is recognizing the RHS of some production. To do this + * it first "backs up" by popping a stack of previously saved states. It + * pops off the same number of states as are found in the RHS of the + * production. This leaves the machine in the same state is was in when the + * parser first attempted to find the RHS. From this state it makes a + * transition based on the non-terminal on the LHS of the production. This + * corresponds to placing the parse in a configuration equivalent to having + * replaced all the symbols from the the input corresponding to the RHS with + * the symbol on the LHS. + * + * @see java_cup.lalr_item + * @see java_cup.lalr_item_set + * @see java_cup.lalr_transition + * @version last updated: 7/3/96 + * @author Frank Flannery + * + */ + +public class lalr_state { + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Constructor for building a state from a set of items. + * @param itms the set of items that makes up this state. + */ + public lalr_state(lalr_item_set itms) throws internal_error + { + /* don't allow null or duplicate item sets */ + if (itms == null) + throw new internal_error( + "Attempt to construct an LALR state from a null item set"); + + if (find_state(itms) != null) + throw new internal_error( + "Attempt to construct a duplicate LALR state"); + + /* assign a unique index */ + _index = next_index++; + + /* store the items */ + _items = itms; + + /* add to the global collection, keyed with its item set */ + _all.put(_items,this); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Static (Class) Variables ------------------*/ + /*-----------------------------------------------------------*/ + + /** Collection of all states. */ + protected static Hashtable _all = new Hashtable(); + + /** Collection of all states. */ + public static Enumeration all() {return _all.elements();} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Indicate total number of states there are. */ + public static int number() {return _all.size();} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Hash table to find states by their kernels (i.e, the original, + * unclosed, set of items -- which uniquely define the state). This table + * stores state objects using (a copy of) their kernel item sets as keys. + */ + protected static Hashtable _all_kernels = new Hashtable(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Find and return state with a given a kernel item set (or null if not + * found). The kernel item set is the subset of items that were used to + * originally create the state. These items are formed by "shifting the + * dot" within items of other states that have a transition to this one. + * The remaining elements of this state's item set are added during closure. + * @param itms the kernel set of the state we are looking for. + */ + public static lalr_state find_state(lalr_item_set itms) + { + if (itms == null) + return null; + else + return (lalr_state)_all.get(itms); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Static counter for assigning unique state indexes. */ + protected static int next_index = 0; + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The item set for this state. */ + protected lalr_item_set _items; + + /** The item set for this state. */ + public lalr_item_set items() {return _items;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** List of transitions out of this state. */ + protected lalr_transition _transitions = null; + + /** List of transitions out of this state. */ + public lalr_transition transitions() {return _transitions;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Index of this state in the parse tables */ + protected int _index; + + /** Index of this state in the parse tables */ + public int index() {return _index;} + + /*-----------------------------------------------------------*/ + /*--- Static Methods ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Helper routine for debugging -- produces a dump of the given state + * onto System.out. + */ + protected static void dump_state(lalr_state st) throws internal_error + { + lalr_item_set itms; + lalr_item itm; + production_part part; + + if (st == null) + { + System.out.println("NULL lalr_state"); + return; + } + + System.out.println("lalr_state [" + st.index() + "] {"); + itms = st.items(); + for (Enumeration e = itms.all(); e.hasMoreElements(); ) + { + itm = (lalr_item)e.nextElement(); + System.out.print(" ["); + System.out.print(itm.the_production().lhs().the_symbol().name()); + System.out.print(" ::= "); + for (int i = 0; i + * [A ::= a b * X c, {d,e}] + * [B ::= a b * X d, {a,b}] + * + * in some state, then we would be making a transition under X to a new + * state. This new state would be formed by a "kernel" of items + * corresponding to moving the dot past the X. In this case:

+   *    [A ::= a b X * c, {d,e}]
+   *    [B ::= a b X * Y, {a,b}]
+   *  
+ * The full state would then be formed by "closing" this kernel set of + * items so that it included items that represented productions of things + * the parser was now looking for. In this case we would items + * corresponding to productions of Y, since various forms of Y are expected + * next when in this state (see lalr_item_set.compute_closure() for details + * on closure).

+ * + * The process of building the viable prefix recognizer terminates when no + * new states can be added. However, in order to build a smaller number of + * states (i.e., corresponding to LALR rather than canonical LR) the state + * building process does not maintain full loookaheads in all items. + * Consequently, after the machine is built, we go back and propagate + * lookaheads through the constructed machine using a call to + * propagate_all_lookaheads(). This makes use of propagation links + * constructed during the closure and transition process. + * + * @param start_prod the start production of the grammar + * @see java_cup.lalr_item_set#compute_closure + * @see java_cup.lalr_state#propagate_all_lookaheads + */ + + public static lalr_state build_machine(production start_prod) + throws internal_error + { + lalr_state start_state; + lalr_item_set start_items; + lalr_item_set new_items; + lalr_item_set linked_items; + lalr_item_set kernel; + Stack work_stack = new Stack(); + lalr_state st, new_st; + symbol_set outgoing; + lalr_item itm, new_itm, existing, fix_itm; + symbol sym, sym2; + Enumeration i, s, fix; + + /* sanity check */ + if (start_prod == null) + throw new internal_error( + "Attempt to build viable prefix recognizer using a null production"); + + /* build item with dot at front of start production and EOF lookahead */ + start_items = new lalr_item_set(); + + itm = new lalr_item(start_prod); + itm.lookahead().add(terminal.EOF); + + start_items.add(itm); + + /* create copy the item set to form the kernel */ + kernel = new lalr_item_set(start_items); + + /* create the closure from that item set */ + start_items.compute_closure(); + + /* build a state out of that item set and put it in our work set */ + start_state = new lalr_state(start_items); + work_stack.push(start_state); + + /* enter the state using the kernel as the key */ + _all_kernels.put(kernel, start_state); + + /* continue looking at new states until we have no more work to do */ + while (!work_stack.empty()) + { + /* remove a state from the work set */ + st = (lalr_state)work_stack.pop(); + + /* gather up all the symbols that appear before dots */ + outgoing = new symbol_set(); + for (i = st.items().all(); i.hasMoreElements(); ) + { + itm = (lalr_item)i.nextElement(); + + /* add the symbol before the dot (if any) to our collection */ + sym = itm.symbol_after_dot(); + if (sym != null) outgoing.add(sym); + } + + /* now create a transition out for each individual symbol */ + for (s = outgoing.all(); s.hasMoreElements(); ) + { + sym = (symbol)s.nextElement(); + + /* will be keeping the set of items with propagate links */ + linked_items = new lalr_item_set(); + + /* gather up shifted versions of all the items that have this + symbol before the dot */ + new_items = new lalr_item_set(); + for (i = st.items().all(); i.hasMoreElements();) + { + itm = (lalr_item)i.nextElement(); + + /* if this is the symbol we are working on now, add to set */ + sym2 = itm.symbol_after_dot(); + if (sym.equals(sym2)) + { + /* add to the kernel of the new state */ + new_items.add(itm.shift()); + + /* remember that itm has propagate link to it */ + linked_items.add(itm); + } + } + + /* use new items as state kernel */ + kernel = new lalr_item_set(new_items); + + /* have we seen this one already? */ + new_st = (lalr_state)_all_kernels.get(kernel); + + /* if we haven't, build a new state out of the item set */ + if (new_st == null) + { + /* compute closure of the kernel for the full item set */ + new_items.compute_closure(); + + /* build the new state */ + new_st = new lalr_state(new_items); + + /* add the new state to our work set */ + work_stack.push(new_st); + + /* put it in our kernel table */ + _all_kernels.put(kernel, new_st); + } + /* otherwise relink propagation to items in existing state */ + else + { + /* walk through the items that have links to the new state */ + for (fix = linked_items.all(); fix.hasMoreElements(); ) + { + fix_itm = (lalr_item)fix.nextElement(); + + /* look at each propagate link out of that item */ + for (int l =0; l < fix_itm.propagate_items().size(); l++) + { + /* pull out item linked to in the new state */ + new_itm = + (lalr_item)fix_itm.propagate_items().elementAt(l); + + /* find corresponding item in the existing state */ + existing = new_st.items().find(new_itm); + + /* fix up the item so it points to the existing set */ + if (existing != null) + fix_itm.propagate_items().setElementAt(existing ,l); + } + } + } + + /* add a transition from current state to that state */ + st.add_transition(sym, new_st); + } + } + + /* all done building states */ + + /* propagate complete lookahead sets throughout the states */ + propagate_all_lookaheads(); + + return start_state; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Propagate lookahead sets out of this state. This recursively + * propagates to all items that have propagation links from some item + * in this state. + */ + protected void propagate_lookaheads() throws internal_error + { + /* recursively propagate out from each item in the state */ + for (Enumeration itm = items().all(); itm.hasMoreElements(); ) + ((lalr_item)itm.nextElement()).propagate_lookaheads(null); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Fill in the parse table entries for this state. There are two + * parse tables that encode the viable prefix recognition machine, an + * action table and a reduce-goto table. The rows in each table + * correspond to states of the machine. The columns of the action table + * are indexed by terminal symbols and correspond to either transitions + * out of the state (shift entries) or reductions from the state to some + * previous state saved on the stack (reduce entries). All entries in the + * action table that are not shifts or reduces, represent errors. The + * reduce-goto table is indexed by non terminals and represents transitions + * out of a state on that non-terminal.

+ * Conflicts occur if more than one action needs to go in one entry of the + * action table (this cannot happen with the reduce-goto table). Conflicts + * are resolved by always shifting for shift/reduce conflicts and choosing + * the lowest numbered production (hence the one that appeared first in + * the specification) in reduce/reduce conflicts. All conflicts are + * reported and if more conflicts are detected than were declared by the + * user, code generation is aborted. + * + * @param act_table the action table to put entries in. + * @param reduce_table the reduce-goto table to put entries in. + */ + public void build_table_entries( + parse_action_table act_table, + parse_reduce_table reduce_table) + throws internal_error + { + parse_action_row our_act_row; + parse_reduce_row our_red_row; + lalr_item itm; + parse_action act, other_act; + symbol sym; + terminal_set conflict_set = new terminal_set(); + + /* pull out our rows from the tables */ + our_act_row = act_table.under_state[index()]; + our_red_row = reduce_table.under_state[index()]; + + /* consider each item in our state */ + for (Enumeration i = items().all(); i.hasMoreElements(); ) + { + itm = (lalr_item)i.nextElement(); + + + /* if its completed (dot at end) then reduce under the lookahead */ + if (itm.dot_at_end()) + { + act = new reduce_action(itm.the_production()); + + /* consider each lookahead symbol */ + for (int t = 0; t < terminal.number(); t++) + { + /* skip over the ones not in the lookahead */ + if (!itm.lookahead().contains(t)) continue; + + /* if we don't already have an action put this one in */ + if (our_act_row.under_term[t].kind() == + parse_action.ERROR) + { + our_act_row.under_term[t] = act; + } + else + { + /* we now have at least one conflict */ + terminal term = terminal.find(t); + other_act = our_act_row.under_term[t]; + + /* if the other act was not a shift */ + if ((other_act.kind() != parse_action.SHIFT) && + (other_act.kind() != parse_action.NONASSOC)) + { + /* if we have lower index hence priority, replace it*/ + if (itm.the_production().index() < + ((reduce_action)other_act).reduce_with().index()) + { + /* replace the action */ + our_act_row.under_term[t] = act; + } + } else { + /* Check precedences,see if problem is correctable */ + if(fix_with_precedence(itm.the_production(), + t, our_act_row, act)) { + term = null; + } + } + if(term!=null) { + + conflict_set.add(term); + } + } + } + } + } + + /* consider each outgoing transition */ + for (lalr_transition trans=transitions(); trans!=null; trans=trans.next()) + { + /* if its on an terminal add a shift entry */ + sym = trans.on_symbol(); + if (!sym.is_non_term()) + { + act = new shift_action(trans.to_state()); + + /* if we don't already have an action put this one in */ + if ( our_act_row.under_term[sym.index()].kind() == + parse_action.ERROR) + { + our_act_row.under_term[sym.index()] = act; + } + else + { + /* we now have at least one conflict */ + production p = ((reduce_action)our_act_row.under_term[sym.index()]).reduce_with(); + + /* shift always wins */ + if (!fix_with_precedence(p, sym.index(), our_act_row, act)) { + our_act_row.under_term[sym.index()] = act; + conflict_set.add(terminal.find(sym.index())); + } + } + } + else + { + /* for non terminals add an entry to the reduce-goto table */ + our_red_row.under_non_term[sym.index()] = trans.to_state(); + } + } + + /* if we end up with conflict(s), report them */ + if (!conflict_set.empty()) + report_conflicts(conflict_set); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + + /** Procedure that attempts to fix a shift/reduce error by using + * precedences. --frankf 6/26/96 + * + * if a production (also called rule) or the lookahead terminal + * has a precedence, then the table can be fixed. if the rule + * has greater precedence than the terminal, a reduce by that rule + * in inserted in the table. If the terminal has a higher precedence, + * it is shifted. if they have equal precedence, then the associativity + * of the precedence is used to determine what to put in the table: + * if the precedence is left associative, the action is to reduce. + * if the precedence is right associative, the action is to shift. + * if the precedence is non associative, then it is a syntax error. + * + * @param p the production + * @param term_index the index of the lokahead terminal + * @param parse_action_row a row of the action table + * @param act the rule in conflict with the table entry + */ + + protected boolean fix_with_precedence( + production p, + int term_index, + parse_action_row table_row, + parse_action act) + + throws internal_error { + + terminal term = terminal.find(term_index); + + /* if the production has a precedence number, it can be fixed */ + if (p.precedence_num() > assoc.no_prec) { + + /* if production precedes terminal, put reduce in table */ + if (p.precedence_num() > term.precedence_num()) { + table_row.under_term[term_index] = + insert_reduce(table_row.under_term[term_index],act); + return true; + } + + /* if terminal precedes rule, put shift in table */ + else if (p.precedence_num() < term.precedence_num()) { + table_row.under_term[term_index] = + insert_shift(table_row.under_term[term_index],act); + return true; + } + else { /* they are == precedence */ + + /* equal precedences have equal sides, so only need to + look at one: if it is right, put shift in table */ + if (term.precedence_side() == assoc.right) { + table_row.under_term[term_index] = + insert_shift(table_row.under_term[term_index],act); + return true; + } + + /* if it is left, put reduce in table */ + else if (term.precedence_side() == assoc.left) { + table_row.under_term[term_index] = + insert_reduce(table_row.under_term[term_index],act); + return true; + } + + /* if it is nonassoc, we're not allowed to have two nonassocs + of equal precedence in a row, so put in NONASSOC */ + else if (term.precedence_side() == assoc.nonassoc) { + table_row.under_term[term_index] = new nonassoc_action(); + return true; + } else { + /* something really went wrong */ + throw new internal_error("Unable to resolve conflict correctly"); + } + } + } + /* check if terminal has precedence, if so, shift, since + rule does not have precedence */ + else if (term.precedence_num() > assoc.no_prec) { + table_row.under_term[term_index] = + insert_shift(table_row.under_term[term_index],act); + return true; + } + + /* otherwise, neither the rule nor the terminal has a precedence, + so it can't be fixed. */ + return false; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + + /* given two actions, and an action type, return the + action of that action type. give an error if they are of + the same action, because that should never have tried + to be fixed + + */ + protected parse_action insert_action( + parse_action a1, + parse_action a2, + int act_type) + throws internal_error + { + if ((a1.kind() == act_type) && (a2.kind() == act_type)) { + throw new internal_error("Conflict resolution of bogus actions"); + } else if (a1.kind() == act_type) { + return a1; + } else if (a2.kind() == act_type) { + return a2; + } else { + throw new internal_error("Conflict resolution of bogus actions"); + } + } + + /* find the shift in the two actions */ + protected parse_action insert_shift( + parse_action a1, + parse_action a2) + throws internal_error + { + return insert_action(a1, a2, parse_action.SHIFT); + } + + /* find the reduce in the two actions */ + protected parse_action insert_reduce( + parse_action a1, + parse_action a2) + throws internal_error + { + return insert_action(a1, a2, parse_action.REDUCE); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce warning messages for all conflicts found in this state. */ + protected void report_conflicts(terminal_set conflict_set) + throws internal_error + { + lalr_item itm, compare; + symbol shift_sym; + + boolean after_itm; + + /* consider each element */ + for (Enumeration itms = items().all(); itms.hasMoreElements(); ) + { + itm = (lalr_item)itms.nextElement(); + + /* clear the S/R conflict set for this item */ + + /* if it results in a reduce, it could be a conflict */ + if (itm.dot_at_end()) + { + /* not yet after itm */ + after_itm = false; + + /* compare this item against all others looking for conflicts */ + for (Enumeration comps = items().all(); comps.hasMoreElements(); ) + { + compare = (lalr_item)comps.nextElement(); + + /* if this is the item, next one is after it */ + if (itm == compare) after_itm = true; + + /* only look at it if its not the same item */ + if (itm != compare) + { + /* is it a reduce */ + if (compare.dot_at_end()) + { + /* only look at reduces after itm */ + if (after_itm) + /* does the comparison item conflict? */ + if (compare.lookahead().intersects(itm.lookahead())) + /* report a reduce/reduce conflict */ + report_reduce_reduce(itm, compare); + } + } + } + /* report S/R conflicts under all the symbols we conflict under */ + for (int t = 0; t < terminal.number(); t++) + if (conflict_set.contains(t)) + report_shift_reduce(itm,t); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a warning message for one reduce/reduce conflict. + * + * @param itm1 first item in conflict. + * @param itm2 second item in conflict. + */ + protected void report_reduce_reduce(lalr_item itm1, lalr_item itm2) + throws internal_error + { + boolean comma_flag = false; + + System.err.println("*** Reduce/Reduce conflict found in state #"+index()); + System.err.print (" between "); + System.err.println(itm1.to_simple_string()); + System.err.print (" and "); + System.err.println(itm2.to_simple_string()); + System.err.print(" under symbols: {" ); + for (int t = 0; t < terminal.number(); t++) + { + if (itm1.lookahead().contains(t) && itm2.lookahead().contains(t)) + { + if (comma_flag) System.err.print(", "); else comma_flag = true; + System.err.print(terminal.find(t).name()); + } + } + System.err.println("}"); + System.err.print(" Resolved in favor of "); + if (itm1.the_production().index() < itm2.the_production().index()) + System.err.println("the first production.\n"); + else + System.err.println("the second production.\n"); + + /* count the conflict */ + emit.num_conflicts++; + lexer.warning_count++; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a warning message for one shift/reduce conflict. + * + * @param red_itm the item with the reduce. + * @param conflict_sym the index of the symbol conflict occurs under. + */ + protected void report_shift_reduce( + lalr_item red_itm, + int conflict_sym) + throws internal_error + { + lalr_item itm; + symbol shift_sym; + + /* emit top part of message including the reduce item */ + System.err.println("*** Shift/Reduce conflict found in state #"+index()); + System.err.print (" between "); + System.err.println(red_itm.to_simple_string()); + + /* find and report on all items that shift under our conflict symbol */ + for (Enumeration itms = items().all(); itms.hasMoreElements(); ) + { + itm = (lalr_item)itms.nextElement(); + + /* only look if its not the same item and not a reduce */ + if (itm != red_itm && !itm.dot_at_end()) + { + /* is it a shift on our conflicting terminal */ + shift_sym = itm.symbol_after_dot(); + if (!shift_sym.is_non_term() && shift_sym.index() == conflict_sym) + { + /* yes, report on it */ + System.err.println(" and " + itm.to_simple_string()); + } + } + } + System.err.println(" under symbol "+ terminal.find(conflict_sym).name()); + System.err.println(" Resolved in favor of shifting.\n"); + + /* count the conflict */ + emit.num_conflicts++; + lexer.warning_count++; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison. */ + public boolean equals(lalr_state other) + { + /* we are equal if our item sets are equal */ + return other != null && items().equals(other.items()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof lalr_state)) + return false; + else + return equals((lalr_state)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a hash code. */ + public int hashCode() + { + /* just use the item set hash code */ + return items().hashCode(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() + { + String result; + lalr_transition tr; + + /* dump the item set */ + result = "lalr_state [" + index() + "]: " + _items + "\n"; + + /* do the transitions */ + for (tr = transitions(); tr != null; tr = tr.next()) + { + result += tr; + result += "\n"; + } + + return result; + } + + /*-----------------------------------------------------------*/ +} diff --git a/Repair/RepairCompiler/java_cup/lalr_transition.class b/Repair/RepairCompiler/java_cup/lalr_transition.class new file mode 100755 index 0000000000000000000000000000000000000000..f4f7b721ec4839c6654542e9a92b4432878af2ba GIT binary patch literal 1505 zcma)6ZBNrs6n^eD)~=Kn2Mpvz3nFgaVEB%LC?F^}@dJt>#w^_^Skkpi*BSg*n!uJw zq90BCQO0xExt2o)*%*p`sOtbjQYc?l8Bi@2G<5N>gCn~OUV ziMs;sNsurr;yynYxblI7hgcM`#5Ip3EaNf1JrS`YU{$~xgH*JwV(n9BY3u`R`_o2KHG z$H~?i)PK4VkLSYoLB=pfWL(Cmj4_OJf-4Luo=vcn)%wAKPRaD14=rN@&tzP~w1DR_ zHlZ?f^F&*_ro5Apfhu52#tRfU_$32-&oI)dHq;V^en0f9(ve=Kjf|%GWQV*h2xhg& z^>M9Q)vbMo+(m%a0t9`$N@z5FogBR0@u6!K8q+|>;I9Pz9)`8AAGea(WEe|tdb@Q2 zH74n=P0@cJMT~csZZY2A)=534GY-ZZO)tS!`ufm90`qDUEc*jJXNc@2qfNxV=l*%diny9Pg`m!!Li|F$3<}8^BuI`@oN{3q<|4bJzAzmQp-C`7UhGZBj zgrTbhx`FfsP%#YMA`q=r8|qMsJjv}dNPA6mC*=lu)CPJR=%ZV*pG1Qm#kM)ittSu~ jNH#DKG9(Av;H)1rNzDP?PzAeKz*`isN0GCniy-$KhVWVa literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/lalr_transition.java b/Repair/RepairCompiler/java_cup/lalr_transition.java new file mode 100755 index 0000000..1c941bd --- /dev/null +++ b/Repair/RepairCompiler/java_cup/lalr_transition.java @@ -0,0 +1,93 @@ +package java_cup; + +/** This class represents a transition in an LALR viable prefix recognition + * machine. Transitions can be under terminals for non-terminals. They are + * internally linked together into singly linked lists containing all the + * transitions out of a single state via the _next field. + * + * @see java_cup.lalr_state + * @version last updated: 11/25/95 + * @author Scott Hudson + * + */ +public class lalr_transition { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Full constructor. + * @param on_sym symbol we are transitioning on. + * @param to_st state we transition to. + * @param nxt next transition in linked list. + */ + public lalr_transition(symbol on_sym, lalr_state to_st, lalr_transition nxt) + throws internal_error + { + /* sanity checks */ + if (on_sym == null) + throw new internal_error("Attempt to create transition on null symbol"); + if (to_st == null) + throw new internal_error("Attempt to create transition to null state"); + + /* initialize */ + _on_symbol = on_sym; + _to_state = to_st; + _next = nxt; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor with null next. + * @param on_sym symbol we are transitioning on. + * @param to_st state we transition to. + */ + public lalr_transition(symbol on_sym, lalr_state to_st) throws internal_error + { + this(on_sym, to_st, null); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The symbol we make the transition on. */ + protected symbol _on_symbol; + + /** The symbol we make the transition on. */ + public symbol on_symbol() {return _on_symbol;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The state we transition to. */ + protected lalr_state _to_state; + + /** The state we transition to. */ + public lalr_state to_state() {return _to_state;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Next transition in linked list of transitions out of a state */ + protected lalr_transition _next; + + /** Next transition in linked list of transitions out of a state */ + public lalr_transition next() {return _next;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Convert to a string. */ + public String toString() + { + String result; + + result = "transition on " + on_symbol().name() + " to state ["; + result += _to_state.index(); + result += "]"; + + return result; + } + + /*-----------------------------------------------------------*/ +} diff --git a/Repair/RepairCompiler/java_cup/lexer.class b/Repair/RepairCompiler/java_cup/lexer.class new file mode 100755 index 0000000000000000000000000000000000000000..db534c568e2f723eb437a07ddbbcbba250156a4b GIT binary patch literal 5185 zcma)933yc175?wcB=cr6B$Kcv1RO*l1VUIuBLNg5Xe0uPfI(?^nY@IN$;>!2Vbj)q z7Z+44xG=b-R&62JBnqx|t2-*TZq?Q<*01Z=&9_G#z7})B@d0x11z89z9y9T~z-~s~|8o0>7#Re`haH)Z21D6@N z+`ttEt~79!fvXK%BNDFlU>mOU;(FX5%Nu3bF2hYS+$_T_GVGAyR$>0W8#}!ihs_3d z$$Xm(w;Q;_z@75B+lv(T2>V?I?w0u;FNb?YzxzbfPFeoI!2L4+(7*!*9(3a&FJ|LM zBH+hv?De7s`()82O#5X?0~_$LXz&vQ-5w%6g7g}AMCM0jI3UA81CJSa+`tpEdeV)j zmVI%wg0X1X;-2 zl^O1^oPGQueS@`SQ#9U^P#E5Dj=9mS?ns8h)hC;Y^+~fiY}G3GUT1`2uz>3GC@upz3Ba);lo6LA56lu$@ z^XG;lq2zo8XT{`I3a+|n3q=<-@Pwru?afyF4AF%IVWWkMHV3Vk9F}n783ni5veAqL z$>6oxL&+w677eOMTNE}UZPhE1aUNJJ;ys#4RG=oImL@tSo^`FOqJHukN+g{2wZAnK zAq)40tqdeQj6hLhlNk<2H_?dpb~;3%uqDbxi$#fYn8N6a$y$Y`U`MPvPSZo}R`m+) zNjf%?7o78UZhSj`=6O**<6s3>lk;Q@#-H%RYmk9k)_JK{lWaY+2*4O^S7 z_%w;558pwP538`6*2K)<2D6O}#X7{=A@z}@)n>(o?^z$7!}ALHq4robPD5N`1=nUU z9nt)l8BbWuJR@nv+d~mE%uq!n)&(4Mm@5%93A#3glIv-ob}Y4u#jT*#V(AFE!d5F! z$cu;C)^j$v-%KQ;K_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dx) z@Tn`ALswz6x|-40hH>h8RHz$h!i_Xx8|JE8ut4o#Bz9uC+J&>#9X4}3i1(XQ&PVW}!68(D?W=hGC+_R($^RwmTcqtqY;{+CwbnU3jNz_F{b;G54=%Da?~wF=sdY8JfRXh+GIhFNLA}%#up_BcPc?!h{qSXy#IXEQJ}eDV~zr zINEQeFpkZ^A54h`A|(B*LpVxAl`LfbiWFW|c4S^`t-Zdw)V{8>PdAD4Qqm--B`a4i zP87{qlXl8tku2Db`E06bbf(oySMbGj`M_&Ya*{5$rBcaH<|iZ3i+bwR`9&@o*I_(! z=~+0{3z(u_=52n3xA_oi)Ek(m4&wy%Hm|_DI8A+kMz-Ix)kkPmzd=a-7U!zp^EQ8i zi`1WR4cqZe>K|;`|3tU?Hy%-+;h_2to?wf9TKx|%tIu)B;lLl*s{iQ7$6p*?^f?NY z(^07Wj$##X3{%S;rM7G^(9!>jU8@@nP;~&OH2V1#Te2Sx{mmC2zeli_>VC?3jFUZz mf3^-X7H%f?au(P%7)7Dwd=muNMUG;@tw4f_zmaqYHvJ#+;NXG) literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/lexer.java b/Repair/RepairCompiler/java_cup/lexer.java new file mode 100755 index 0000000..2230d12 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/lexer.java @@ -0,0 +1,543 @@ +package java_cup; + +import java_cup.runtime.Symbol; +import java.util.Hashtable; + +/** This class implements a small scanner (aka lexical analyzer or lexer) for + * the JavaCup specification. This scanner reads characters from standard + * input (System.in) and returns integers corresponding to the terminal + * number of the next Symbol. Once end of input is reached the EOF Symbol is + * returned on every subsequent call.

+ * Symbols currently returned include:

+ *    Symbol        Constant Returned     Symbol        Constant Returned
+ *    ------        -----------------     ------        -----------------
+ *    "package"     PACKAGE               "import"      IMPORT 
+ *    "code"        CODE                  "action"      ACTION 
+ *    "parser"      PARSER                "terminal"    TERMINAL
+ *    "non"         NON                   "init"        INIT 
+ *    "scan"        SCAN                  "with"        WITH
+ *    "start"       START                 "precedence"  PRECEDENCE
+ *    "left"        LEFT		  "right"       RIGHT
+ *    "nonassoc"    NONASSOC		  "%prec        PRECENT_PREC  
+ *      [           LBRACK                  ]           RBRACK
+ *      ;           SEMI 
+ *      ,           COMMA                   *           STAR 
+ *      .           DOT                     :           COLON
+ *      ::=         COLON_COLON_EQUALS      |           BAR
+ *    identifier    ID                    {:...:}       CODE_STRING
+ *    "nonterminal" NONTERMINAL
+ *  
+ * All symbol constants are defined in sym.java which is generated by + * JavaCup from parser.cup.

+ * + * In addition to the scanner proper (called first via init() then with + * next_token() to get each Symbol) this class provides simple error and + * warning routines and keeps a count of errors and warnings that is + * publicly accessible.

+ * + * This class is "static" (i.e., it has only static members and methods). + * + * @version last updated: 7/3/96 + * @author Frank Flannery + */ +public class lexer { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** The only constructor is private, so no instances can be created. */ + private lexer() { } + + /*-----------------------------------------------------------*/ + /*--- Static (Class) Variables ------------------------------*/ + /*-----------------------------------------------------------*/ + + /** First character of lookahead. */ + protected static int next_char; + + /** Second character of lookahead. */ + protected static int next_char2; + + /** Second character of lookahead. */ + protected static int next_char3; + + /** Second character of lookahead. */ + protected static int next_char4; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** EOF constant. */ + protected static final int EOF_CHAR = -1; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Table of keywords. Keywords are initially treated as identifiers. + * Just before they are returned we look them up in this table to see if + * they match one of the keywords. The string of the name is the key here, + * which indexes Integer objects holding the symbol number. + */ + protected static Hashtable keywords = new Hashtable(23); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Table of single character symbols. For ease of implementation, we + * store all unambiguous single character Symbols in this table of Integer + * objects keyed by Integer objects with the numerical value of the + * appropriate char (currently Character objects have a bug which precludes + * their use in tables). + */ + protected static Hashtable char_symbols = new Hashtable(11); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Current line number for use in error messages. */ + protected static int current_line = 1; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Character position in current line. */ + protected static int current_position = 1; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Character position in current line. */ + protected static int absolute_position = 1; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Count of total errors detected so far. */ + public static int error_count = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Count of warnings issued so far */ + public static int warning_count = 0; + + /*-----------------------------------------------------------*/ + /*--- Static Methods ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Initialize the scanner. This sets up the keywords and char_symbols + * tables and reads the first two characters of lookahead. + */ + public static void init() throws java.io.IOException + { + /* set up the keyword table */ + keywords.put("package", new Integer(sym.PACKAGE)); + keywords.put("import", new Integer(sym.IMPORT)); + keywords.put("code", new Integer(sym.CODE)); + keywords.put("action", new Integer(sym.ACTION)); + keywords.put("parser", new Integer(sym.PARSER)); + keywords.put("terminal", new Integer(sym.TERMINAL)); + keywords.put("non", new Integer(sym.NON)); + keywords.put("nonterminal",new Integer(sym.NONTERMINAL));// [CSA] + keywords.put("init", new Integer(sym.INIT)); + keywords.put("scan", new Integer(sym.SCAN)); + keywords.put("with", new Integer(sym.WITH)); + keywords.put("start", new Integer(sym.START)); + keywords.put("precedence", new Integer(sym.PRECEDENCE)); + keywords.put("left", new Integer(sym.LEFT)); + keywords.put("right", new Integer(sym.RIGHT)); + keywords.put("nonassoc", new Integer(sym.NONASSOC)); + + /* set up the table of single character symbols */ + char_symbols.put(new Integer(';'), new Integer(sym.SEMI)); + char_symbols.put(new Integer(','), new Integer(sym.COMMA)); + char_symbols.put(new Integer('*'), new Integer(sym.STAR)); + char_symbols.put(new Integer('.'), new Integer(sym.DOT)); + char_symbols.put(new Integer('|'), new Integer(sym.BAR)); + char_symbols.put(new Integer('['), new Integer(sym.LBRACK)); + char_symbols.put(new Integer(']'), new Integer(sym.RBRACK)); + + /* read two characters of lookahead */ + next_char = System.in.read(); + if (next_char == EOF_CHAR) { + next_char2 = EOF_CHAR; + next_char3 = EOF_CHAR; + next_char4 = EOF_CHAR; + } else { + next_char2 = System.in.read(); + if (next_char2 == EOF_CHAR) { + next_char3 = EOF_CHAR; + next_char4 = EOF_CHAR; + } else { + next_char3 = System.in.read(); + if (next_char3 == EOF_CHAR) { + next_char4 = EOF_CHAR; + } else { + next_char4 = System.in.read(); + } + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Advance the scanner one character in the input stream. This moves + * next_char2 to next_char and then reads a new next_char2. + */ + protected static void advance() throws java.io.IOException + { + int old_char; + + old_char = next_char; + next_char = next_char2; + if (next_char == EOF_CHAR) { + next_char2 = EOF_CHAR; + next_char3 = EOF_CHAR; + next_char4 = EOF_CHAR; + } else { + next_char2 = next_char3; + if (next_char2 == EOF_CHAR) { + next_char3 = EOF_CHAR; + next_char4 = EOF_CHAR; + } else { + next_char3 = next_char4; + if (next_char3 == EOF_CHAR) { + next_char4 = EOF_CHAR; + } else { + next_char4 = System.in.read(); + } + } + } + + /* count this */ + absolute_position++; + current_position++; + if (old_char == '\n' || (old_char == '\r' && next_char!='\n')) + { + current_line++; + current_position = 1; + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit an error message. The message will be marked with both the + * current line number and the position in the line. Error messages + * are printed on standard error (System.err). + * @param message the message to print. + */ + public static void emit_error(String message) + { + System.err.println("Error at " + current_line + "(" + current_position + + "): " + message); + error_count++; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Emit a warning message. The message will be marked with both the + * current line number and the position in the line. Messages are + * printed on standard error (System.err). + * @param message the message to print. + */ + public static void emit_warn(String message) + { + System.err.println("Warning at " + current_line + "(" + current_position + + "): " + message); + warning_count++; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Determine if a character is ok to start an id. + * @param ch the character in question. + */ + protected static boolean id_start_char(int ch) + { + /* allow for % in identifiers. a hack to allow my + %prec in. Should eventually make lex spec for this + frankf */ + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || + (ch == '_'); + + // later need to deal with non-8-bit chars here + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Determine if a character is ok for the middle of an id. + * @param ch the character in question. + */ + protected static boolean id_char(int ch) + { + return id_start_char(ch) || (ch >= '0' && ch <= '9'); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Try to look up a single character symbol, returns -1 for not found. + * @param ch the character in question. + */ + protected static int find_single_char(int ch) + { + Integer result; + + result = (Integer)char_symbols.get(new Integer((char)ch)); + if (result == null) + return -1; + else + return result.intValue(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Handle swallowing up a comment. Both old style C and new style C++ + * comments are handled. + */ + protected static void swallow_comment() throws java.io.IOException + { + /* next_char == '/' at this point */ + + /* is it a traditional comment */ + if (next_char2 == '*') + { + /* swallow the opener */ + advance(); advance(); + + /* swallow the comment until end of comment or EOF */ + for (;;) + { + /* if its EOF we have an error */ + if (next_char == EOF_CHAR) + { + emit_error("Specification file ends inside a comment"); + return; + } + + /* if we can see the closer we are done */ + if (next_char == '*' && next_char2 == '/') + { + advance(); + advance(); + return; + } + + /* otherwise swallow char and move on */ + advance(); + } + } + + /* is its a new style comment */ + if (next_char2 == '/') + { + /* swallow the opener */ + advance(); advance(); + + /* swallow to '\n', '\r', '\f', or EOF */ + while (next_char != '\n' && next_char != '\r' && + next_char != '\f' && next_char!=EOF_CHAR) + advance(); + + return; + + } + + /* shouldn't get here, but... if we get here we have an error */ + emit_error("Malformed comment in specification -- ignored"); + advance(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Swallow up a code string. Code strings begin with "{:" and include + all characters up to the first occurrence of ":}" (there is no way to + include ":}" inside a code string). The routine returns a String + object suitable for return by the scanner. + */ + protected static Symbol do_code_string() throws java.io.IOException + { + StringBuffer result = new StringBuffer(); + + /* at this point we have lookahead of "{:" -- swallow that */ + advance(); advance(); + + /* save chars until we see ":}" */ + while (!(next_char == ':' && next_char2 == '}')) + { + /* if we have run off the end issue a message and break out of loop */ + if (next_char == EOF_CHAR) + { + emit_error("Specification file ends inside a code string"); + break; + } + + /* otherwise record the char and move on */ + result.append(new Character((char)next_char)); + advance(); + } + + /* advance past the closer and build a return Symbol */ + advance(); advance(); + return new Symbol(sym.CODE_STRING, result.toString()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Process an identifier. Identifiers begin with a letter, underscore, + * or dollar sign, which is followed by zero or more letters, numbers, + * underscores or dollar signs. This routine returns a String suitable + * for return by the scanner. + */ + protected static Symbol do_id() throws java.io.IOException + { + StringBuffer result = new StringBuffer(); + String result_str; + Integer keyword_num; + char buffer[] = new char[1]; + + /* next_char holds first character of id */ + buffer[0] = (char)next_char; + result.append(buffer,0,1); + advance(); + + /* collect up characters while they fit in id */ + while(id_char(next_char)) + { + buffer[0] = (char)next_char; + result.append(buffer,0,1); + advance(); + } + + /* extract a string and try to look it up as a keyword */ + result_str = result.toString(); + keyword_num = (Integer)keywords.get(result_str); + + /* if we found something, return that keyword */ + if (keyword_num != null) + return new Symbol(keyword_num.intValue()); + + /* otherwise build and return an id Symbol with an attached string */ + return new Symbol(sym.ID, result_str); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return one Symbol. This is the main external interface to the scanner. + * It consumes sufficient characters to determine the next input Symbol + * and returns it. To help with debugging, this routine actually calls + * real_next_token() which does the work. If you need to debug the + * parser, this can be changed to call debug_next_token() which prints + * a debugging message before returning the Symbol. + */ + public static Symbol next_token() throws java.io.IOException + { + return real_next_token(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Debugging version of next_token(). This routine calls the real scanning + * routine, prints a message on System.out indicating what the Symbol is, + * then returns it. + */ + public static Symbol debug_next_token() throws java.io.IOException + { + Symbol result = real_next_token(); + System.out.println("# next_Symbol() => " + result.sym); + return result; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The actual routine to return one Symbol. This is normally called from + * next_token(), but for debugging purposes can be called indirectly from + * debug_next_token(). + */ + protected static Symbol real_next_token() throws java.io.IOException + { + int sym_num; + + for (;;) + { + /* look for white space */ + if (next_char == ' ' || next_char == '\t' || next_char == '\n' || + next_char == '\f' || next_char == '\r') + { + /* advance past it and try the next character */ + advance(); + continue; + } + + /* look for a single character symbol */ + sym_num = find_single_char(next_char); + if (sym_num != -1) + { + /* found one -- advance past it and return a Symbol for it */ + advance(); + return new Symbol(sym_num); + } + + /* look for : or ::= */ + if (next_char == ':') + { + /* if we don't have a second ':' return COLON */ + if (next_char2 != ':') + { + advance(); + return new Symbol(sym.COLON); + } + + /* move forward and look for the '=' */ + advance(); + if (next_char2 == '=') + { + advance(); advance(); + return new Symbol(sym.COLON_COLON_EQUALS); + } + else + { + /* return just the colon (already consumed) */ + return new Symbol(sym.COLON); + } + } + + /* find a "%prec" string and return it. otherwise, a '%' was found, + which has no right being in the specification otherwise */ + if (next_char == '%') { + advance(); + if ((next_char == 'p') && (next_char2 == 'r') && (next_char3 == 'e') && + (next_char4 == 'c')) { + advance(); + advance(); + advance(); + advance(); + return new Symbol(sym.PERCENT_PREC); + } else { + emit_error("Found extraneous percent sign"); + } + } + + /* look for a comment */ + if (next_char == '/' && (next_char2 == '*' || next_char2 == '/')) + { + /* swallow then continue the scan */ + swallow_comment(); + continue; + } + + /* look for start of code string */ + if (next_char == '{' && next_char2 == ':') + return do_code_string(); + + /* look for an id or keyword */ + if (id_start_char(next_char)) return do_id(); + + /* look for EOF */ + if (next_char == EOF_CHAR) return new Symbol(sym.EOF); + + /* if we get here, we have an unrecognized character */ + emit_warn("Unrecognized character '" + + new Character((char)next_char) + "'(" + next_char + + ") -- ignored"); + + /* advance past it */ + advance(); + } + } + + /*-----------------------------------------------------------*/ +} + diff --git a/Repair/RepairCompiler/java_cup/lr_item_core.class b/Repair/RepairCompiler/java_cup/lr_item_core.class new file mode 100755 index 0000000000000000000000000000000000000000..b5704fd93bc1458dc55308d28fded5546acd458f GIT binary patch literal 3152 zcma)8TWl0%6#oA1c6Ym-UMRGs*y2Ddw7XSAQKVoIDrjYGRW4e*4AbqjySUw1cBca3 zUA&=B#%O>C(U|bU14h{<5*1%cVtnvHA5DxgCTffiUSo{iQT_e2rEPC4(2VmJ0gaIYNhlf#JY_R8-5C?3Fr zVLTK?J&Y*D`{ZLrF^XguV{)(}7!PAY;3+w$<+ER&8xh&Vg3UxQ8AdjW_1NIngHYCznYiMe6)XMKNM>CW}w;f7aIq{XAEM3@w7^t5gSZjCBg3l?0 z%aH}Tdl*|(&Zc8n*)au*_A=Z{LtE^(R}QXDbVsdmNlumtX!E18cGh5OCev9n!$d?2 zsr0zxCUPDylQ+_iHR)avSnKB6IxuBs81yn<&~t#|XlNGITtcnMnAwRn!=wAHq_a@~ zb>+I1G8~Z-dRu#Rzgtnp>)1viJ(il zI6Aqf+vD>?_uKNPM8h^5)i8itWyjBRcwWN`*unaAbq(!KB)Ym3TEq{3`L<4tk6U>S zFXAPIYQ3-TW?e% zGS6nj3eM;r{-6Z;M>@MZve8}1MR#QvaczVWzM%@&^Yj_VdNtR_V$)DDbq-Z(D1H%j z=Mflb3QnW?<5>J0LhUC}-yVA(p(4WXc()Pvw*4GxVvTjByJ)I?-#OIsP~(B$MwjeF zQiRqQYzr1qcLEKuw%`TS7tz2M-{t!X>-gbv?~0 zH$5F(6;-Pxh_l?3{0zCmyZGI}moJ6ZoS6rGh#L zavVc5UZLt1Y^AzTWPmr~Z6^&aIqns|S&DxiEhFN-gc01w)K-kvGv~nT2;&Vb!ihQQ z<;W@fSmpZIN%wTI6nB%+dK^t+lc$je=GXHg#cYPYK%_8pXy(}iz z%L#CNu7#`07VhaSjfEMk^LB0wt9|cPpsIrc$uu@}}tv;JzVY=C)(sx1jpA0k^kS;G( SJ*rhBqG}PPcT!q~q5l9JG`ng5 literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/lr_item_core.java b/Repair/RepairCompiler/java_cup/lr_item_core.java new file mode 100755 index 0000000..c0fa656 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/lr_item_core.java @@ -0,0 +1,280 @@ + +package java_cup; + +/** The "core" of an LR item. This includes a production and the position + * of a marker (the "dot") within the production. Typically item cores + * are written using a production with an embedded "dot" to indicate their + * position. For example:

+ *     A ::= B * C d E
+ *  
+ * This represents a point in a parse where the parser is trying to match + * the given production, and has succeeded in matching everything before the + * "dot" (and hence is expecting to see the symbols after the dot next). See + * lalr_item, lalr_item_set, and lalr_start for full details on the meaning + * and use of items. + * + * @see java_cup.lalr_item + * @see java_cup.lalr_item_set + * @see java_cup.lalr_state + * @version last updated: 11/25/95 + * @author Scott Hudson +*/ + +public class lr_item_core { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Full constructor. + * @param prod production this item uses. + * @param pos position of the "dot" within the item. + */ + public lr_item_core(production prod, int pos) throws internal_error + { + symbol after_dot = null; + production_part part; + + if (prod == null) + throw new internal_error( + "Attempt to create an lr_item_core with a null production"); + + _the_production = prod; + + if (pos < 0 || pos > _the_production.rhs_length()) + throw new internal_error( + "Attempt to create an lr_item_core with a bad dot position"); + + _dot_pos = pos; + + /* compute and cache hash code now */ + _core_hash_cache = 13*_the_production.hashCode() + pos; + + /* cache the symbol after the dot */ + if (_dot_pos < _the_production.rhs_length()) + { + part = _the_production.rhs(_dot_pos); + if (!part.is_action()) + _symbol_after_dot = ((symbol_part)part).the_symbol(); + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor for dot at start of right hand side. + * @param prod production this item uses. + */ + public lr_item_core(production prod) throws internal_error + { + this(prod,0); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The production for the item. */ + protected production _the_production; + + /** The production for the item. */ + public production the_production() {return _the_production;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The position of the "dot" -- this indicates the part of the production + * that the marker is before, so 0 indicates a dot at the beginning of + * the RHS. + */ + protected int _dot_pos; + + /** The position of the "dot" -- this indicates the part of the production + * that the marker is before, so 0 indicates a dot at the beginning of + * the RHS. + */ + public int dot_pos() {return _dot_pos;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Cache of the hash code. */ + protected int _core_hash_cache; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Cache of symbol after the dot. */ + protected symbol _symbol_after_dot = null; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Is the dot at the end of the production? */ + public boolean dot_at_end() + { + return _dot_pos >= _the_production.rhs_length(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return the symbol after the dot. If there is no symbol after the dot + * we return null. */ + public symbol symbol_after_dot() + { + /* use the cached symbol */ + return _symbol_after_dot; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Determine if we have a dot before a non terminal, and if so which one + * (return null or the non terminal). + */ + public non_terminal dot_before_nt() + { + symbol sym; + + /* get the symbol after the dot */ + sym = symbol_after_dot(); + + /* if it exists and is a non terminal, return it */ + if (sym != null && sym.is_non_term()) + return (non_terminal)sym; + else + return null; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a new lr_item_core that results from shifting the dot one + * position to the right. + */ + public lr_item_core shift_core() throws internal_error + { + if (dot_at_end()) + throw new internal_error( + "Attempt to shift past end of an lr_item_core"); + + return new lr_item_core(_the_production, _dot_pos+1); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison for the core only. This is separate out because we + * need separate access in a super class. + */ + public boolean core_equals(lr_item_core other) + { + return other != null && + _the_production.equals(other._the_production) && + _dot_pos == other._dot_pos; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison. */ + public boolean equals(lr_item_core other) {return core_equals(other);} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof lr_item_core)) + return false; + else + return equals((lr_item_core)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Hash code for the core (separated so we keep non overridden version). */ + public int core_hashCode() + { + return _core_hash_cache; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Hash code for the item. */ + public int hashCode() + { + return _core_hash_cache; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return the hash code that object would have provided for us so we have + * a (nearly) unique id for debugging. + */ + protected int obj_hash() + { + return super.hashCode(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string (separated out from toString() so we can call it + * from subclass that overrides toString()). + */ + public String to_simple_string() throws internal_error + { + String result; + production_part part; + + if (_the_production.lhs() != null && + _the_production.lhs().the_symbol() != null && + _the_production.lhs().the_symbol().name() != null) + result = _the_production.lhs().the_symbol().name(); + else + result = "$$NULL$$"; + + result += " ::= "; + + for (int i = 0; i<_the_production.rhs_length(); i++) + { + /* do we need the dot before this one? */ + if (i == _dot_pos) + result += "(*) "; + + /* print the name of the part */ + if (_the_production.rhs(i) == null) + { + result += "$$NULL$$ "; + } + else + { + part = _the_production.rhs(i); + if (part == null) + result += "$$NULL$$ "; + else if (part.is_action()) + result += "{ACTION} "; + else if (((symbol_part)part).the_symbol() != null && + ((symbol_part)part).the_symbol().name() != null) + result += ((symbol_part)part).the_symbol().name() + " "; + else + result += "$$NULL$$ "; + } + } + + /* put the dot after if needed */ + if (_dot_pos == _the_production.rhs_length()) + result += "(*) "; + + return result; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string */ + public String toString() + { + /* can't throw here since super class doesn't, so we crash instead */ + try { + return to_simple_string(); + } catch(internal_error e) { + e.crash(); + return null; + } + } + + /*-----------------------------------------------------------*/ + +} + diff --git a/Repair/RepairCompiler/java_cup/non_terminal.class b/Repair/RepairCompiler/java_cup/non_terminal.class new file mode 100755 index 0000000000000000000000000000000000000000..3a37d33778a9c5bd50884ce3a937fde87c1496a5 GIT binary patch literal 3801 zcmaJ@TW}j!8U8kwthKzcW7%F|Z0bVHIzuJ}7vOzOC zXZM`{eERf8)ZnzdWCO?rQ4336@-m!}y+;E$8^F0B zG*~Jgllh}6J|^?|AnNhB3{Qyo$7T4044(|(Q}#;`Yj8Tq6;q%-EyHI5cv9xis`#A9 zd|r^gATmVi#200Fsvcj$)AICX8NMQNUzN451rfzl0eoHNXJq(>2z*nXo)zQ2CBp@I zoeARGcuvK4#M|>KzAJ*ytN5OZ7gT&-OrSq63iL|>ysW?%i>FcwRu7$wpNaS7EhE*p zFP@vS;^Qg3U%^V*j*Xv-8D>&Hs~~9VXD#jAFPN4Bb!2q!1EVo{Tw|lf68TJ@ znKomVo}D(#c#3!-BNx-B$Ms}VPsZX2%Sf9Flw%6CSSFiJ=Ixc7g1VTQPo=~N>Wobo z*_;*2>5HLVSlJ+S?QX*~tUU^D?_QqIgsW=dODMrV|G}LlwqB-5$ROO-7ANgVD*dA z(MTH>C#WHwOnO!nw3R%zl~>O8OVrd#F6jf4U02prWp!0b>sc*s0V!xmrPHUlP%aGB zN|(~Bpv6szH|f;8JCSm#A~=%HXA}DUhLlv3iz;QgO-f(GK@4m7AoeL}UZxjh{|6fO z;~qAP?Awld?G=gR8V+Dc!v}DWhFQGARw&CFCZ(w^rf0KhrnA-7;<0xiKQSSBZo4m^ zNf`+yIZQK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zh;f}k8+1h@4Ek0#3fu0Q z$ED@Zu-16v24+w4}eDbPvEcYwA1UkL5E@ayzx)WRTOQ=WmBhhSmtuPvp3>=|6%z + * + * This is an abstract class. + * + * @see java_cup.production + * @version last updated: 11/25/95 + * @author Scott Hudson + */ +public abstract class production_part { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Simple constructor. */ + public production_part(String lab) + { + _label = lab; + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** Optional label for referring to the part within an action (null for + * no label). + */ + protected String _label; + + /** Optional label for referring to the part within an action (null for + * no label). + */ + public String label() {return _label;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Indicate if this is an action (rather than a symbol). Here in the + * base class, we don't this know yet, so its an abstract method. + */ + public abstract boolean is_action(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison. */ + public boolean equals(production_part other) + { + if (other == null) return false; + + /* compare the labels */ + if (label() != null) + return label().equals(other.label()); + else + return other.label() == null; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof production_part)) + return false; + else + return equals((production_part)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a hash code. */ + public int hashCode() + { + return label()==null ? 0 : label().hashCode(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() + { + if (label() != null) + return label() + ":"; + else + return " "; + } + + /*-----------------------------------------------------------*/ + +} diff --git a/Repair/RepairCompiler/java_cup/reduce_action.class b/Repair/RepairCompiler/java_cup/reduce_action.class new file mode 100755 index 0000000000000000000000000000000000000000..e82285f3e73486ab6dc11ae522405b2ed3c275d7 GIT binary patch literal 1215 zcmZuwTTj$L6#ix}w3KoyEW2`%dc)lBF>7c@0QE8u{ zqlqt@FPvJBs=c)AO@?H?uuSy)RbW;LJ=8!S7c!$B3ooeq=x?cN+S{eoja^>x=R{oI zG52?(?quIt^F7PnX6TQ(qx2|BM^)CGz^m|wmS|mTBAFE8sK{WJAzK&9vVHE^X0^;c z&+!;$@A*F8bA8=+^oqw#pX;XHR7V$LQ_v2oRsBR~QTe8dKJ=>?#1O+koudh^;w(lb z+){B4BXL&aA?^oTTbvr{eX{i6+2T?@WD_*HiaE@ySip$zXq>E|;yf;pbag7%^!9l< zQZ>|{M%yH8tdtme-wCRITWDIQ>vA!?@y2=lgN5_{zg<#3O%vw_V#v$UtvDr%jx5mw z0O*DYrO1=W&tQPwLY8)Skt7eu6_3D-U+6qWVqHrfA@!|jd`9|Xh|Q55K$>iZ>SQ4! zM^%T&8^#%mrl@9uJ{kjAQFnw^Mr*qG3F!~y&|4te76!-24u>fsb&z%mnt9 zdD3SAJ-9uV+1iwfm30(RMY$pAm literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/reduce_action.java b/Repair/RepairCompiler/java_cup/reduce_action.java new file mode 100755 index 0000000..e8f4c84 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/reduce_action.java @@ -0,0 +1,84 @@ + +package java_cup; + +/** This class represents a reduce action within the parse table. + * The action simply stores the production that it reduces with and + * responds to queries about its type. + * + * @version last updated: 11/25/95 + * @author Scott Hudson + */ +public class reduce_action extends parse_action { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Simple constructor. + * @param prod the production this action reduces with. + */ + public reduce_action(production prod ) throws internal_error + { + /* sanity check */ + if (prod == null) + throw new internal_error( + "Attempt to create a reduce_action with a null production"); + + _reduce_with = prod; + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The production we reduce with. */ + protected production _reduce_with; + + /** The production we reduce with. */ + public production reduce_with() {return _reduce_with;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Quick access to type of action. */ + public int kind() {return REDUCE;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality test. */ + public boolean equals(reduce_action other) + { + return other != null && other.reduce_with() == reduce_with(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality test. */ + public boolean equals(Object other) + { + if (other instanceof reduce_action) + return equals((reduce_action)other); + else + return false; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Compute a hash code. */ + public int hashCode() + { + /* use the hash code of the production we are reducing with */ + return reduce_with().hashCode(); + } + + + /** Convert to string. */ + public String toString() + { + return "REDUCE(with prod " + reduce_with().index() + ")"; + } + + /*-----------------------------------------------------------*/ + +} diff --git a/Repair/RepairCompiler/java_cup/shift_action.class b/Repair/RepairCompiler/java_cup/shift_action.class new file mode 100755 index 0000000000000000000000000000000000000000..0580f898d8ab80dfde328a1c2aa129f13d8169a0 GIT binary patch literal 1196 zcmZuv+fEZv6kVqmW*CQCp|o<5@rJ!{6H!z^yhH*C!3T&5zBEHQz+joy>D2Hm{(!#l zpox}55-%^B_)*4nW-8Rm!|b!qp1s!IXYKv#_vbGFCa`EAfl&=NbYu)fkZp&CoI#V< zFs9CNgK3i*rVJPu)p1ju(<*pNc{4h0tMiVAS%LOKbz^whP5tWwKi)BWX+SKwqPDm>x#?Ok=%V^NMoGQEm4$*O*Ycm`LKTK+NFZ@ zys{@S^~m?-LB+THvQ_jXwXdLuJz@WrHu@W1nicHIn0|_z_9W-K9MzX1y`HvRBW#*3!##M z4(W<<0 zmQbxG^FNTt*U^^a_ZC|09b(Z|=u7~$8qnzmG?D)f?G4Oa{u{J9^rI$RCzSx^sm}ts zu}CDBrGZyGszqIutfRfP+A{xgFB;jiffm5X35?BSTu7L8bcD#xI=T|wyw=gvs>&MS K*H|Qi>wf_C^!26y literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/shift_action.java b/Repair/RepairCompiler/java_cup/shift_action.java new file mode 100755 index 0000000..33fc17a --- /dev/null +++ b/Repair/RepairCompiler/java_cup/shift_action.java @@ -0,0 +1,82 @@ + +package java_cup; + +/** This class represents a shift action within the parse table. + * The action simply stores the state that it shifts to and responds + * to queries about its type. + * + * @version last updated: 11/25/95 + * @author Scott Hudson + */ +public class shift_action extends parse_action { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Simple constructor. + * @param shft_to the state that this action shifts to. + */ + public shift_action(lalr_state shft_to) throws internal_error + { + /* sanity check */ + if (shft_to == null) + throw new internal_error( + "Attempt to create a shift_action to a null state"); + + _shift_to = shft_to; + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The state we shift to. */ + protected lalr_state _shift_to; + + /** The state we shift to. */ + public lalr_state shift_to() {return _shift_to;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Quick access to type of action. */ + public int kind() {return SHIFT;} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality test. */ + public boolean equals(shift_action other) + { + return other != null && other.shift_to() == shift_to(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality test. */ + public boolean equals(Object other) + { + if (other instanceof shift_action) + return equals((shift_action)other); + else + return false; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Compute a hash code. */ + public int hashCode() + { + /* use the hash code of the state we are shifting to */ + return shift_to().hashCode(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() {return "SHIFT(to state " + shift_to().index() + ")";} + + /*-----------------------------------------------------------*/ + +} diff --git a/Repair/RepairCompiler/java_cup/sym.class b/Repair/RepairCompiler/java_cup/sym.class new file mode 100755 index 0000000000000000000000000000000000000000..89ff5b3b564556ec79c07ec05c83b9ab44bf92c2 GIT binary patch literal 1111 zcmYk)S#J_i6bJBg*~?NWUFoKEZL5O&T3d(V0%KtYXU6(S04Ii~1w+BakL8nz4}JhY zl<|Lt#GIEq=XdWpcbz|ffBhz+GM%O=O3fr$NqVm+YCEX?>C`mGG0du+I)|hvg&7Rbb4>O+(ptLi zbG)i3*)hyhqY+j`6va)a<=8y7guG9d-{d%>C}FibjvH1*krqrQ;|UKbMa8hDJ8$)e zk4DSmkzzPoyKOKQv7wq1mKS)>rV%cZRur*noUn~v%eKOd1uWMwTu+B*OyB_W{7FUW zj;l>w)3zDzdjfDeW5!S{t9z-8eI{80E2{8;!2{8acE{9O12{8IQ8 y{95=8d?fr9J{CTK-w7LdS;hYZ+8Y00p^4&$KS}*Sha!zOfiK~q71i;LP~#u1fN>Q7 literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/sym.java b/Repair/RepairCompiler/java_cup/sym.java new file mode 100755 index 0000000..9810a3d --- /dev/null +++ b/Repair/RepairCompiler/java_cup/sym.java @@ -0,0 +1,43 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Sun Jul 25 13:35:26 EDT 1999 +//---------------------------------------------------- + +package java_cup; + +/** CUP generated class containing symbol constants. */ +public class sym { + /* terminals */ + public static final int NON = 8; + public static final int NONTERMINAL = 27; + public static final int STAR = 15; + public static final int SEMI = 13; + public static final int CODE = 4; + public static final int EOF = 0; + public static final int NONASSOC = 23; + public static final int LEFT = 21; + public static final int PACKAGE = 2; + public static final int COLON = 17; + public static final int WITH = 11; + public static final int IMPORT = 3; + public static final int error = 1; + public static final int COLON_COLON_EQUALS = 18; + public static final int COMMA = 14; + public static final int DOT = 16; + public static final int SCAN = 10; + public static final int ID = 28; + public static final int INIT = 9; + public static final int PARSER = 6; + public static final int TERMINAL = 7; + public static final int PRECEDENCE = 20; + public static final int LBRACK = 25; + public static final int RBRACK = 26; + public static final int PERCENT_PREC = 24; + public static final int START = 12; + public static final int RIGHT = 22; + public static final int BAR = 19; + public static final int ACTION = 5; + public static final int CODE_STRING = 29; +} + diff --git a/Repair/RepairCompiler/java_cup/symbol.class b/Repair/RepairCompiler/java_cup/symbol.class new file mode 100755 index 0000000000000000000000000000000000000000..a5fbeeb38dc81d4f404a9d4a6efc217bad0febf9 GIT binary patch literal 925 zcmZvZ-*3`T6vw}}lon`pi1XLnrhqyq3?6;Z=z~V1K~0=7ZZEZTb?Jn5f!4VH$p=k_ zOMLLv#6QaTy|*L~AWhCWz5Slg`QFpN|9<@j&_TBZ3wMer;cfx<3fPflLxyIF!I4!< zR&5izCOQInH}ZyoK&5x=eet>jFFNY(C8IDpdLUrA?Rskdmf%Bsd#SNy9}ew}oUYSU?nbC@$oNgcOgV3$(f zbK0=Q%)M~v8S>v*WHSwQc%SjcN~y6ZeN5>FZZgVi&QrB-3)JTnZ7PYBO2^WG~Cf>0xc_h z+FLD^&gVv4)vSPj&M*!8zCiy#jnz?%WHfVUBxzfQxicGoE>O3W-O>e`Rt!^L%kOXM z)-!E0LmGMceOk}iM%FwKXsdp;9Fr$Ep+NNH(?5%3PgUlK?COnA2DKD&Q^uOw!RQ$= zEMkepLxFHCwwg#L6Kju$k{hdw>nkxz(N#{7v$9)6nI_;=eW|xqs}QN0$E6@=Ce0O6 z?nIo4(i-@+TuwK)1O}_8c8*-LcWy1Ttry(Shx|WxT&D-qPVbC%mYYkr0Nts>^wN6h zYXM&R0o}@A5kfsf!*_T#!rmh4ek$r$_&z(qS4eiiN3xS-H-Z%0ie3VWkOYAX0%YJw z3Am47J!Fv-RTSZ`!0;Of`r)UEREN^634l38=oEDNlrQj|&_#gr`yJ&N$tacOy7th? zt{(64CBJFX(`uCbrYR|>jjE@JC~6VXA=;G!0xJCr2p&SJJ3?Iz%DjUTE1`^+P{QhO z$e-Zz9xLiE$OY6_vNt;Id;$px>e5q+q}?pVk5W9d?NW*earQGv-Xq9-Eui6J1;wp3 zN#3-!rRW!>=qYwTMelbsZWPf(Sj`2rxESFAT2C$-!fj+_b-6(<#aBe}HMKHD@Nu$v Gp!@>{>L}s> literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/symbol_part.java b/Repair/RepairCompiler/java_cup/symbol_part.java new file mode 100755 index 0000000..9142b5f --- /dev/null +++ b/Repair/RepairCompiler/java_cup/symbol_part.java @@ -0,0 +1,100 @@ +package java_cup; + +/** This class represents a part of a production which is a symbol (terminal + * or non terminal). This simply maintains a reference to the symbol in + * question. + * + * @see java_cup.production + * @version last updated: 11/25/95 + * @author Scott Hudson + */ +public class symbol_part extends production_part { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Full constructor. + * @param sym the symbol that this part is made up of. + * @param lab an optional label string for the part. + */ + public symbol_part(symbol sym, String lab) throws internal_error + { + super(lab); + + if (sym == null) + throw new internal_error( + "Attempt to construct a symbol_part with a null symbol"); + _the_symbol = sym; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor with no label. + * @param sym the symbol that this part is made up of. + */ + public symbol_part(symbol sym) throws internal_error + { + this(sym,null); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The symbol that this part is made up of. */ + protected symbol _the_symbol; + + /** The symbol that this part is made up of. */ + public symbol the_symbol() {return _the_symbol;} + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Respond that we are not an action part. */ + public boolean is_action() { return false; } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Equality comparison. */ + public boolean equals(symbol_part other) + { + return other != null && super.equals(other) && + the_symbol().equals(other.the_symbol()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Generic equality comparison. */ + public boolean equals(Object other) + { + if (!(other instanceof symbol_part)) + return false; + else + return equals((symbol_part)other); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Produce a hash code. */ + public int hashCode() + { + return super.hashCode() ^ + (the_symbol()==null ? 0 : the_symbol().hashCode()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() + { + if (the_symbol() != null) + return super.toString() + the_symbol(); + else + return super.toString() + "$$MISSING-SYMBOL$$"; + } + + /*-----------------------------------------------------------*/ + +} diff --git a/Repair/RepairCompiler/java_cup/symbol_set.class b/Repair/RepairCompiler/java_cup/symbol_set.class new file mode 100755 index 0000000000000000000000000000000000000000..9c559b89293f9c922384e714ed3743e3dddd0668 GIT binary patch literal 2621 zcmZ`)-)~c87=BLMtzCE6MqvX+8AS$kZCMpjH@1O*Lk8=RAA&=$blutLY|km}DdC6S z7(+}jUJGc9(PSoap^0=ViQolbyj7zy#*ld9jsJr9yyu+t$EX*5&-uRdzR&x<&-;8| zfBg5`?*R1UydS;Tzd6f_TK^o+SvfjiuHoZfqlX-z@N}}G%@mWx z(iH1S8Z-Z2Dm~jQ&%9Px^mV7E$x(Ab%NgfcRHFp!uvt4-N@ZCpM$IZR&ic zanvki^jSf3Sg=~McS(T%s8K4UwS5`kwY^Gazf4HQ7K9b7XfQ4Lq^a11%_^S4HWf3N zRdE*mD&lxj!77Qd29(iFt)Qo}Nv%*Y3JNw%kl~PFaT+QWwdqhs50Qe9K`N}d2zExr z9CoRA9m6WNqTh?GiX7NTdj;99R>jlUu0n^Q;u$=vB9C(_22oHkARh*?Lq)OD#}d(~ z7?PL~sad(Kpv&sDhNC^DnHh~(CQ1riv5<E_ZQI#aQCLXkyS>2Qr8*tYeuyh;dg6YT=JcrIjQh zKBY)s#6t6a!FL5xTC=s^N6V8!+rZm*bBTA18FgLVaX z(NV_o>u7S{pM#@-G zg_A!d;1uCb*M;-UJH-yOR4F!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Xf1XzC(Ii=>SFp3UI4mSd#J|GSv>qR%4j`nd+F zO}F>(zUSOUEl7R-TEA~;=dJhrCcTdOyphMt=$3(BreJS9M|drI#T|a7N0*xKnBvYU zx*ons!63)qTwC)6k7mwwZK-wrp02Z)qZG!52~RelA>Pdei(lrdRYvMk{R5ZeM?~-w zci}_Kdx1$Oj1xOXFIV~M0eq)Vt$wcVF*=jc*URWTz%}Q&-+3OWr0-y2V3n!2(1tx+ Q!q>QlZ&+Y~b|3Ek3+Z6JOaK4? literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/terminal.java b/Repair/RepairCompiler/java_cup/terminal.java new file mode 100755 index 0000000..e1a40aa --- /dev/null +++ b/Repair/RepairCompiler/java_cup/terminal.java @@ -0,0 +1,169 @@ +package java_cup; + +import java_cup.assoc; +import java.util.Hashtable; +import java.util.Enumeration; + +/** This class represents a terminal symbol in the grammar. Each terminal + * has a textual name, an index, and a string which indicates the type of + * object it will be implemented with at runtime (i.e. the class of object + * that will be returned by the scanner and pushed on the parse stack to + * represent it). + * + * @version last updated: 7/3/96 + * @author Frank Flannery + */ +public class terminal extends symbol { + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Full constructor. + * @param nm the name of the terminal. + * @param tp the type of the terminal. + */ + public terminal(String nm, String tp, int precedence_side, int precedence_num) + { + /* superclass does most of the work */ + super(nm, tp); + + /* add to set of all terminals and check for duplicates */ + Object conflict = _all.put(nm,this); + if (conflict != null) + // can't throw an execption here because this is used in static + // initializers, so we do a crash instead + // was: + // throw new internal_error("Duplicate terminal (" + nm + ") created"); + (new internal_error("Duplicate terminal (" + nm + ") created")).crash(); + + /* assign a unique index */ + _index = next_index++; + + /* set the precedence */ + _precedence_num = precedence_num; + _precedence_side = precedence_side; + + /* add to by_index set */ + _all_by_index.put(new Integer(_index), this); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor for non-precedented terminal + */ + + public terminal(String nm, String tp) + { + this(nm, tp, assoc.no_prec, -1); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Constructor with default type. + * @param nm the name of the terminal. + */ + public terminal(String nm) + { + this(nm, null); + } + + /*-----------------------------------------------------------*/ + /*------------------- Class Variables ---------------------*/ + /*-----------------------------------------------------------*/ + + private int _precedence_num; + private int _precedence_side; + + /*-----------------------------------------------------------*/ + /*--- (Access to) Static (Class) Variables ------------------*/ + /*-----------------------------------------------------------*/ + + /** Table of all terminals. Elements are stored using name strings as + * the key + */ + protected static Hashtable _all = new Hashtable(); + + /** Access to all terminals. */ + public static Enumeration all() {return _all.elements();} + + /** Lookup a terminal by name string. */ + public static terminal find(String with_name) + { + if (with_name == null) + return null; + else + return (terminal)_all.get(with_name); + } + + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Table of all terminals indexed by their index number. */ + protected static Hashtable _all_by_index = new Hashtable(); + + /** Lookup a terminal by index. */ + public static terminal find(int indx) + { + Integer the_indx = new Integer(indx); + + return (terminal)_all_by_index.get(the_indx); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Total number of terminals. */ + public static int number() {return _all.size();} + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Static counter to assign unique index. */ + protected static int next_index = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Special terminal for end of input. */ + public static final terminal EOF = new terminal("EOF"); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** special terminal used for error recovery */ + public static final terminal error = new terminal("error"); + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Report this symbol as not being a non-terminal. */ + public boolean is_non_term() + { + return false; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Convert to a string. */ + public String toString() + { + return super.toString() + "[" + index() + "]"; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** get the precedence of a terminal */ + public int precedence_num() { + return _precedence_num; + } + public int precedence_side() { + return _precedence_side; + } + + /** set the precedence of a terminal */ + public void set_precedence(int p, int new_prec) { + _precedence_side = p; + _precedence_num = new_prec; + } + + /*-----------------------------------------------------------*/ + +} diff --git a/Repair/RepairCompiler/java_cup/terminal_set.class b/Repair/RepairCompiler/java_cup/terminal_set.class new file mode 100755 index 0000000000000000000000000000000000000000..eec6bab21e8c5fc73a25066ae54698215136939b GIT binary patch literal 2472 zcmaJ?U2GIp6#i!ayB$iq{IrxJTTp4Y3oD2Uwgm+W7Fwtl(BjWJ-QL2$?#!|~OF-kB z4<;rWA0cYu6ETvgs9R#AVoWsgLF1#wcQr<1OpI^pcV?!$JN(#(b7${8=X~G!&bhZ= z|MT&u0Jfl(#769mV_ykf#CuAP9~JYM zm}xmU>L2*0#~Oae#pUrho=9LOjuT1rVy~Dd6L?D2r^WLbG5G|Zl~g2UXo!wYP92@m z&^>Y5IA`PwwQ|l;m6B;0#e7vc!y4N1s;ElJa;h3qu2-(+n8n;4)0uW1Vk4$yI=eK4 z2L_L8i0rlJl!oOKrlk(oO0%kR)R--Dr+45s7!s8nJ6}*`$FwcNBrMy>TeV_Q!zwQ* zS2V1Xxg)cuRlyk+|EMaJoeM7J2?i8w%P~xeU409b;X(RD2F7L4&1$|{n`Lczd;b4O z(YM3(Evw3sci5Pl(-5nul6{U9-5N`(F)gZCC0R0xsk1es$d6mrBJ3S|+NqeI!186 z4pUH0W4n$sD9YZbj{D@GB*>N+8`9baXloT3wCAa;%fCg0J+=9HRnbw#Sq-6VTE{Nz z)=@!KhlAaWdSR*RmQkTXH-WGrmOGa2@QizdArn<7+7>kpw!j~`8=B`g#vMe{np5YQ z>!fnXOf*~SbL%w`*D!T+ag;%?@Okl#8RfFFI8@ozL0`&$(=2#0a3Uh}#FYsg_XZ|# zbLHGJN(%kF=NtJBg|J2%#IK07o@*yGnH1U#f8EP{jq8fc0<_E`LNnJ8UO?m{MBnGO zh9TMxglSWBT}ivjO^{`3Nif1S#I?swFjPk@GxQ;%b;PeD6v!g+z#X*f(S|g-NpdrH zgg}CpL+R(t5l?b1ANmT*7Lk}qwJjj|*^PvT88kw2qb+GP+=H!5DAdwSBDEzlSJ7UF zeudv&K{0oKAMG|O;1#l&tAKW8+#*;5*JX8dG{fYj1&$z!sQ~0QY-cKg?DvzjWf;FU z5bR-|pd+sY-Nb#2t4Q1LVm5V~%u0M6%d_5IXOn}cq9TV=Y~>lY*$QxZppkr&&!yc< zo~fg&nZ_&S0@FMf2;b4r`PSYP|2cXtxhaOOqbD%`Ui|ln;|E^F9~sFv z)sKIN_;OLtq}EJ?N5i`=|6XfxN%i}uL+=sJyO>+h&hMXiDSoC@zaWWUIYhtl5&NAN`ww2% uKXHir$M6^b+x*RUCx_(~}BW!E|a-4K>jYldDLe=mEP z%Cj0lppA6_V!~oJXiKkHo`%RHp)^u%sI6%XJ^!*^>&lU=^rY!j>fUM7xrne&Sn}HU zRM12agji<&!MZUY5Xu8*J5Kf+M)p;NZ)|j_jrKnX`NN}o!a{1>?7C9ZM%`xprgFb! zv&WIRZZp?XRUM!_=_LtGl<^6l39I4VXk~-SBsmFmlg literal 0 HcmV?d00001 diff --git a/Repair/RepairCompiler/java_cup/version.java b/Repair/RepairCompiler/java_cup/version.java new file mode 100755 index 0000000..06600b5 --- /dev/null +++ b/Repair/RepairCompiler/java_cup/version.java @@ -0,0 +1,55 @@ + +package java_cup; + +/** This class contains version and authorship information. + * It contains only static data elements and basically just a central + * place to put this kind of information so it can be updated easily + * for each release. + * + * Version numbers used here are broken into 3 parts: major, minor, and + * update, and are written as v.. (e.g. v0.10a). + * Major numbers will change at the time of major reworking of some + * part of the system. Minor numbers for each public release or + * change big enough to cause incompatibilities. Finally update + * letter will be incremented for small bug fixes and changes that + * probably wouldn't be noticed by a user. + * + * @version last updated: 12/22/97 [CSA] + * @author Frank Flannery + */ + +public class version { + /** The major version number. */ + public static final int major = 0; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The minor version number. */ + public static final int minor = 10; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The update letter. */ + public static final char update = 'k'; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** String for the current version. */ + public static final String version_str = "v" + major + "." + minor + update; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Full title of the system */ + public static final String title_str = "CUP " + version_str; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Name of the author */ + public static final String author_str = + "Scott E. Hudson, Frank Flannery, and C. Scott Ananian"; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The command name normally used to invoke this program */ + public static final String program_name = "java_cup"; +} -- 2.34.1