Commit e2ae6e5a authored by petter's avatar petter

with additional annotations for upcoming Eclipse Plugin

git-svn-id: https://www2.in.tum.de/repos/cup/develop@61 f8377d4f-c7f8-0310-b030-a31f13008fac
parent f45e3117
......@@ -185,14 +185,28 @@ action code {:
}
}
}
private int cur_debug_id = 0;
public int get_new_debug_id() {
return cur_debug_id++;
}
public String attach_debug_symbol(int id, String code) {
if (!parser.debugSymbols)
return code;
return "//@@CUPDBG" + id + "\n" + code;
}
:};
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
parser code {:
/* override error routines */
protected Lexer lexer;
public boolean debugSymbols;
public void setDebugSymbols(boolean debugSymbols){
this.debugSymbols = debugSymbols;
}
public void report_fatal_error(
String message,
Object info)
......@@ -349,7 +363,7 @@ action_code_part ::=
if (emit.action_code!=null)
ErrorManager.getManager().emit_warning("Redundant action code (skipping)");
else /* save the user included code string */
emit.action_code = user_code;
emit.action_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -361,7 +375,7 @@ parser_code_part ::=
if (emit.parser_code!=null)
ErrorManager.getManager().emit_warning("Redundant parser code (skipping)");
else /* save the user included code string */
emit.parser_code = user_code;
emit.parser_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -373,7 +387,7 @@ init_code ::=
if (emit.init_code!=null)
ErrorManager.getManager().emit_warning("Redundant init code (skipping)");
else /* save the user code */
emit.init_code = user_code;
emit.init_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -385,7 +399,7 @@ scan_code ::=
if (emit.scan_code!=null)
ErrorManager.getManager().emit_warning("Redundant scan code (skipping)");
else /* save the user code */
emit.scan_code = user_code;
emit.scan_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -709,7 +723,7 @@ prod_part ::=
CODE_STRING:code_str
{:
/* add a new production part */
add_rhs_part(new action_part(code_str));
add_rhs_part(new action_part(attach_debug_symbol(get_new_debug_id(),code_str)));
:}
;
......
......@@ -91,6 +91,8 @@ public class Main {
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 eclipse debug symbols */
protected static boolean opt_do_debugsymbols = false;
/** User option -- do we compact tables by making most common reduce the
default action */
protected static boolean opt_compact_red = false;
......@@ -370,6 +372,7 @@ version.title_str + "\n" +
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;
else if (argv[i].equals("-debugsymbols")) opt_do_debugsymbols = true;
/* frankf 6/18/96 */
else if (argv[i].equals("-nopositions")) lr_values = false;
else if (argv[i].equals("-locations")) locations = true;
......@@ -485,6 +488,7 @@ version.title_str + "\n" +
/* create a parser and parse with it */
ComplexSymbolFactory csf = new ComplexSymbolFactory();
parser_obj = new parser(new Lexer(csf),csf);
parser_obj.setDebugSymbols(opt_do_debugsymbols);
try {
if (opt_do_debug)
parser_obj.debug_parse();
......
......@@ -55,6 +55,7 @@ public class CUPTask extends Task
private boolean dump=false;
private boolean time=false;
private boolean debug=false;
private boolean debugsymbols=false;
private boolean nopositions=false;
private boolean xmlactions=false;
private boolean genericlabels=false;
......@@ -91,6 +92,7 @@ public class CUPTask extends Task
if (dump) { sc.add("-dump"); }
if (time) { sc.add("-time"); }
if (debug) { sc.add("-debug"); }
if (debugsymbols) { sc.add("-debugsymbols"); }
if (nopositions) { sc.add("-nopositions"); }
if (locations) { sc.add("-locations"); }
if (genericlabels) { sc.add("-genericlabels"); }
......@@ -549,8 +551,26 @@ public class CUPTask extends Task
public void setDebug(boolean argDebug){
this.debug = argDebug;
}
/**
* Gets the value of debug
*
* @return the value of debug
*/
public boolean isDebugSymbols() {
return this.debugsymbols;
}
/**
* Sets the value of debug
*
* @param argDebug Value to assign to this.debug
*/
public void setDebugSymbols(boolean argDebug){
this.debugsymbols = argDebug;
}
/**
* Gets the value of nopositions
*
* @return the value of nopositions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment