[jboss-svn-commits] JBL Code SVN: r29324 - in labs/jbosstm/workspace/adinn/byteman/trunk: src/org/jboss/byteman/agent and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 14 05:27:50 EDT 2009
Author: adinn
Date: 2009-09-14 05:27:49 -0400 (Mon, 14 Sep 2009)
New Revision: 29324
Modified:
labs/jbosstm/workspace/adinn/byteman/trunk/dd/grammar/cup/ECAGrammar.cup
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECAGrammarParser.java
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECATokenLexer.java
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/sym.java
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/test/TestScript.java
Log:
more improvements to error reporting -- fixes for BYTEMAN-3
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/dd/grammar/cup/ECAGrammar.cup
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/dd/grammar/cup/ECAGrammar.cup 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/dd/grammar/cup/ECAGrammar.cup 2009-09-14 09:27:49 UTC (rev 29324)
@@ -87,36 +87,38 @@
this.file = file;
}
- public void error(String message, int line, int col)
- {
- errorCount++;
- errorBuffer.append('\n');
- errorBuffer.append(file);
- errorBuffer.append(" line ");
- errorBuffer.append(line);
- errorBuffer.append(" : ");
- errorBuffer.append(message);
- }
-
- /** Report a non fatal error (or warning). This method takes a message
- * string and an additional object (to be used by specializations
- * implemented in subclasses). Here in the base class a very simple
- * implementation is provided which simply prints the message to
- * System.err.
+ /**
+ * Called by the parser when it detects a syntax error. This is overridden so
+ * that it does nothing. Instead the parser relies upon explicit calls to routine
+ * error(String) or error(String, int line, int column) which store details of
+ * synatx errors into an error buffer for retrieval after the parse call completes.
*
* @param message an error message.
* @param info an extra object reserved for use by specialized subclasses.
*/
+
public void report_error(String message, Object info)
{
- /*
- if (info instanceof Symbol) {
- Symbol sym = (Symbol)info;
- System.err.println(message + " at line " + sym.left + " character " + sym.right);
- } else {
- System.err.println(message);
+ }
+
+ /**
+ * Called by the parser when it is unable to recover from one or more syntax errors
+ *
+ * @param cur_token the token current at the point in the token stream where the recovery
+ * process fails
+ */
+
+ public void unrecovered_syntax_error(Symbol cur_token)
+ {
+ int line = cur_token.left;
+ errorCount++;
+ errorBuffer.append('\n');
+ errorBuffer.append(file);
+ if (line >= 0) {
+ errorBuffer.append(" line ");
+ errorBuffer.append(cur_token.left);
}
- */
+ errorBuffer.append(" : unable to recover from previous errors");
}
public void error(String message)
@@ -128,6 +130,17 @@
errorBuffer.append(message);
}
+ public void error(String message, int line, int col)
+ {
+ errorCount++;
+ errorBuffer.append('\n');
+ errorBuffer.append(file);
+ errorBuffer.append(" line ");
+ errorBuffer.append(line);
+ errorBuffer.append(" : ");
+ errorBuffer.append(message);
+ }
+
public String getFile()
{
return file;
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java 2009-09-14 09:27:49 UTC (rev 29324)
@@ -520,15 +520,15 @@
try {
rule = Rule.create(ruleScript, helperClass, loader);
} catch (ParseException pe) {
- System.out.println("org.jboss.byteman.agent.Transformer : error parsing rule " + ruleName + " : " + pe);
+ System.out.println("org.jboss.byteman.agent.Transformer : error parsing rule " + ruleName + "\n" + pe);
ruleScript.recordTransform(loader, className, null, pe);
return targetClassBytes;
} catch (TypeException te) {
- System.out.println("org.jboss.byteman.agent.Transformer : error checking rule " + ruleName + " : " + te);
+ System.out.println("org.jboss.byteman.agent.Transformer : error checking rule " + ruleName + "\n" + te);
ruleScript.recordTransform(loader, className, null, te);
return targetClassBytes;
} catch (Throwable th) {
- System.out.println("org.jboss.byteman.agent.Transformer : error processing rule " + ruleName + " : " + th);
+ System.out.println("org.jboss.byteman.agent.Transformer : error processing rule " + ruleName + "\n" + th);
ruleScript.recordTransform(loader, className, null, th);
return targetClassBytes;
}
@@ -550,7 +550,7 @@
try {
cr.accept(checkAdapter, ClassReader.EXPAND_FRAMES);
} catch (Throwable th) {
- System.out.println("org.jboss.byteman.agent.Transformer : error applying rule " + rule.getName() + " to class " + className + " " + th);
+ System.out.println("org.jboss.byteman.agent.Transformer : error applying rule " + rule.getName() + " to class " + className + "\n" + th);
th.printStackTrace(System.out);
ruleScript.recordTransform(loader, className, rule, th);
return targetClassBytes;
@@ -566,7 +566,7 @@
try {
cr.accept(adapter, ClassReader.EXPAND_FRAMES);
} catch (Throwable th) {
- System.out.println("org.jboss.byteman.agent.Transformer : error injecting trigger for rule " + rule.getName() + " into class " + className + " " + th);
+ System.out.println("org.jboss.byteman.agent.Transformer : error injecting trigger for rule " + rule.getName() + " into class " + className + "\n" + th);
th.printStackTrace(System.out);
ruleScript.recordTransform(loader, className, rule, th);
return targetClassBytes;
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECAGrammarParser.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECAGrammarParser.java 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECAGrammarParser.java 2009-09-14 09:27:49 UTC (rev 29324)
@@ -1,7 +1,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.10k
-// Fri Sep 11 14:07:24 BST 2009
+// Mon Sep 14 10:26:17 BST 2009
//----------------------------------------------------
package org.jboss.byteman.rule.grammar;
@@ -10,7 +10,7 @@
import org.jboss.byteman.rule.grammar.ParseNode;
/** CUP v0.10k generated parser.
- * @version Fri Sep 11 14:07:24 BST 2009
+ * @version Mon Sep 14 10:26:17 BST 2009
*/
public class ECAGrammarParser extends java_cup.runtime.lr_parser {
@@ -713,36 +713,38 @@
this.file = file;
}
- public void error(String message, int line, int col)
- {
- errorCount++;
- errorBuffer.append('\n');
- errorBuffer.append(file);
- errorBuffer.append(" line ");
- errorBuffer.append(line);
- errorBuffer.append(" : ");
- errorBuffer.append(message);
- }
-
- /** Report a non fatal error (or warning). This method takes a message
- * string and an additional object (to be used by specializations
- * implemented in subclasses). Here in the base class a very simple
- * implementation is provided which simply prints the message to
- * System.err.
+ /**
+ * Called by the parser when it detects a syntax error. This is overridden so
+ * that it does nothing. Instead the parser relies upon explicit calls to routine
+ * error(String) or error(String, int line, int column) which store details of
+ * synatx errors into an error buffer for retrieval after the parse call completes.
*
* @param message an error message.
* @param info an extra object reserved for use by specialized subclasses.
*/
+
public void report_error(String message, Object info)
{
- /*
- if (info instanceof Symbol) {
- Symbol sym = (Symbol)info;
- System.err.println(message + " at line " + sym.left + " character " + sym.right);
- } else {
- System.err.println(message);
+ }
+
+ /**
+ * Called by the parser when it is unable to recover from one or more syntax errors
+ *
+ * @param cur_token the token current at the point in the token stream where the recovery
+ * process fails
+ */
+
+ public void unrecovered_syntax_error(Symbol cur_token)
+ {
+ int line = cur_token.left;
+ errorCount++;
+ errorBuffer.append('\n');
+ errorBuffer.append(file);
+ if (line >= 0) {
+ errorBuffer.append(" line ");
+ errorBuffer.append(cur_token.left);
}
- */
+ errorBuffer.append(" : unable to recover from previous errors");
}
public void error(String message)
@@ -754,6 +756,17 @@
errorBuffer.append(message);
}
+ public void error(String message, int line, int col)
+ {
+ errorCount++;
+ errorBuffer.append('\n');
+ errorBuffer.append(file);
+ errorBuffer.append(" line ");
+ errorBuffer.append(line);
+ errorBuffer.append(" : ");
+ errorBuffer.append(message);
+ }
+
public String getFile()
{
return file;
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECATokenLexer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECATokenLexer.java 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/ECATokenLexer.java 2009-09-14 09:27:49 UTC (rev 29324)
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.2 on 9/11/09 2:07 PM */
+/* The following code was generated by JFlex 1.4.2 on 9/14/09 10:26 AM */
/*
* JBoss, Home of Professional Open Source
@@ -33,7 +33,7 @@
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.2
- * on 9/11/09 2:07 PM from the specification file
+ * on 9/14/09 10:26 AM from the specification file
* <tt>dd/grammar/flex/ECAToken.flex</tt>
*/
public class ECATokenLexer implements java_cup.runtime.Scanner {
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/sym.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/sym.java 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/grammar/sym.java 2009-09-14 09:27:49 UTC (rev 29324)
@@ -1,7 +1,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.10k
-// Fri Sep 11 14:07:24 BST 2009
+// Mon Sep 14 10:26:17 BST 2009
//----------------------------------------------------
package org.jboss.byteman.rule.grammar;
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/test/TestScript.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/test/TestScript.java 2009-09-14 08:59:45 UTC (rev 29323)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/test/TestScript.java 2009-09-14 09:27:49 UTC (rev 29324)
@@ -220,7 +220,7 @@
try {
targetHelperClass = loader.loadClass(targetHelperName);
} catch (ClassNotFoundException e) {
- System.out.println("org.jboss.byteman.agent.Transformer : unknown helper class " + targetHelperName + " for rule " + ruleName);
+ System.out.println("TestScript : unknown helper class " + targetHelperName + " for rule " + ruleName);
}
}
RuleScript ruleScript = new RuleScript(ruleName, targetClassName, targetMethodName, targetHelperName, targetLocation, text, baseline + lineNumber, file);
More information about the jboss-svn-commits
mailing list