This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Replace TabException with CompletionException; simplify.


The branch, master has been updated
       via  c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c (commit)
      from  c0c08f0972f8bf58b60bad249421032b17e55f63 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Nov 16 12:03:25 2007 -0500

    Replace TabException with CompletionException; simplify.
    
    frysk-core/frysk/debuginfo/ChangeLog
    2007-11-16  Andrew Cagney  <cagney@redhat.com>
    
    	* DebugInfo.java (complete(DebugInfoFrame,String,int,List)): Catch
    	CompletionException instead of TabException.  Do not attempt to
    	handle structures.
    
    frysk-core/frysk/expr/ChangeLog
    2007-11-16  Andrew Cagney  <cagney@redhat.com>
    
    	* TabException.java: Delete.
    	* CExpr.g (bTabPressed): Delete.
    	(tab_expression): Delete.
    	(primary_expression): Fold into scope_expression; when IDENT_TAB
    	throw IncompleteIdentifierException.
    	(IDENT_TAB): Rename TAB.
    	* CompletionException.java: New.
    	* IncompleteTokenException.java: New.
    	* IncompleteIdentifierException.java: New.
    	* IncompleteMemberException.java: New.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/debuginfo/ChangeLog               |    6 ++
 frysk-core/frysk/debuginfo/DebugInfo.java          |   14 +---
 frysk-core/frysk/expr/CExpr.g                      |   67 ++------------
 frysk-core/frysk/expr/ChangeLog                    |   13 +++
 .../frysk/expr/CompletionException.java            |   41 ++++++---
 .../frysk/expr/IncompleteIdentifierException.java  |   18 ++--
 .../frysk/expr/IncompleteMemberException.java      |   18 ++--
 .../frysk/expr/IncompleteTokenException.java       |   18 ++--
 frysk-core/frysk/expr/TabException.java            |   93 --------------------
 9 files changed, 81 insertions(+), 207 deletions(-)
 copy frysk-sys/frysk/expunit/TerminationException.java => frysk-core/frysk/expr/CompletionException.java (76%)
 copy frysk-sys/frysk/expunit/EofException.java => frysk-core/frysk/expr/IncompleteIdentifierException.java (90%)
 copy frysk-sys/frysk/expunit/EofException.java => frysk-core/frysk/expr/IncompleteMemberException.java (90%)
 copy frysk-sys/frysk/expunit/EofException.java => frysk-core/frysk/expr/IncompleteTokenException.java (90%)
 delete mode 100644 frysk-core/frysk/expr/TabException.java

First 500 lines of diff:
diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog
index 92762d1..ebf74ae 100644
--- a/frysk-core/frysk/debuginfo/ChangeLog
+++ b/frysk-core/frysk/debuginfo/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-16  Andrew Cagney  <cagney@redhat.com>
+
+	* DebugInfo.java (complete(DebugInfoFrame,String,int,List)): Catch
+	CompletionException instead of TabException.  Do not attempt to
+	handle structures.
+
 007-11-15  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	DwarfDie::getDataMemberLocation now throws DwAttributeNotFoundException
diff --git a/frysk-core/frysk/debuginfo/DebugInfo.java b/frysk-core/frysk/debuginfo/DebugInfo.java
index 34304af..cd17386 100644
--- a/frysk-core/frysk/debuginfo/DebugInfo.java
+++ b/frysk-core/frysk/debuginfo/DebugInfo.java
@@ -109,23 +109,17 @@ public class DebugInfo {
 	    // FIXME: Why is this ignored?
 	} catch (antlr.TokenStreamException ignore) {
 	    // FIXME: Why is this ignored?
-	} catch (frysk.expr.TabException t) {
-	    token = t.getTabExpression().trim();
+	} catch (frysk.expr.CompletionException t) {
+	    token = t.getText();
 	}
 
 	DwarfDie[] allDies = die.getScopes(pc - bias.bias);
 	List candidates_p = die.getScopeVarNames(allDies, token);
-	boolean haveStruct = false;
-	if (token.endsWith("."))
-	    haveStruct = true;
 	
 	for (Iterator i = candidates_p.iterator(); i.hasNext();) {
-            String sNext = (haveStruct ? "." : "") + (String) i.next();
+            String sNext = (String) i.next();
             candidates.add(sNext);
         }
-
-	if (haveStruct)
-	    token = ".";
 	// XXX: This is a big kludge (but less of a kludge than
 	// .indexOf.
 	return buffer.lastIndexOf(token);
@@ -222,8 +216,6 @@ public class DebugInfo {
 	    throw new RuntimeException(r);
 	} catch (antlr.TokenStreamException t) {
 	    throw new RuntimeException(t);
-	} catch (frysk.expr.TabException t) {
-	    throw new RuntimeException(t);
 	}
     
 	AST exprAST = parser.getAST();
diff --git a/frysk-core/frysk/expr/CExpr.g b/frysk-core/frysk/expr/CExpr.g
index 45f0a05..58a0dbc 100644
--- a/frysk-core/frysk/expr/CExpr.g
+++ b/frysk-core/frysk/expr/CExpr.g
@@ -90,20 +90,12 @@ options {
 }
 
 {
-/** 
-  *	A member variable to keep track of TAB completions requests.
-  *	If this is true the normal course of action is to simply
-  *	bail out by throwing an exception
-  */
-    private boolean bTabPressed;
     private int assign_stmt_RHS_found;
     //private String sInputExpression;
 
     protected CExprParser(TokenStream lexer, String sInput)
     {
         this(lexer);
-        bTabPressed = false;
-        //sInputExpression = sInput;
     }
 }
 
@@ -342,42 +334,17 @@ postfix_expression!
     { ## = #astPostExpr; }       
     ;           
     
+/**
+ * The TAB over here is not part of the C++ grammar.
+ * This enables auto-completion by allowing the user
+ * to press TAB whenever auto-completion is required
+ */
+
 scope_expression 
     :   identifier (SCOPE identifier)*
+    |   IDENT_TAB { throw new IncompleteIdentifierException(#IDENT_TAB); }
     |   SCOPE identifier
     |   LPAREN! expressionList RPAREN!
-    |   tab_expression
-    ;
-
-tab_expression 
-    { String sTabText; }
-    //  should subscript, component, call, post inc/dec be moved here?
-    :	post_expr1:primary_expression 
-        {
-          if (bTabPressed) {
-	      // ??? Use antlr expressions instead of tree surgery.
-            if (#post_expr1.getFirstChild() != null)
-              if (#post_expr1.getFirstChild().getNextSibling() != null)
-                sTabText = #post_expr1.getFirstChild().getNextSibling().getText();
-		      else
-		  		sTabText = #post_expr1.getFirstChild().getText();
-            else 
-              sTabText = #post_expr1.getText();
-              
-            throw new TabException(#post_expr1, sTabText);
-          }
-        }
-    ;
-
-/**
-  *	The TAB over here is not part of the C++ grammar.
-  *	This enables auto-completion by allowing the user
-  *	to press TAB whenever auto-completion is required
-  */
-primary_expression 
-    :   TAB
-        { bTabPressed = true; 
-        }
     |   constant
     |   "this"
     ;
@@ -409,22 +376,6 @@ constant
     |   "false"
     ;
     
-/***
-  *  TabException is raised everytime the TAB is pressed.
-  *  The parser thus bails out immediately and returns the
-  *  parse tree constructed so far.
-  */
-/* ??? add (identifier | (TAB {bTabPressed = true;})) */
-/*DOT!
-(   tb:TAB
-    {
-        bTabPressed = true;
-        astPostExpr = #(#[MEMBER, "Member"], #astPostExpr, #tb);
-    }
-    |   id_expr1:identifier
-    {   astPostExpr = #(#[MEMBER, "Member"], #astPostExpr, #id_expr1); }
-)*/
-
 /*---------------------------------------------------------------------------
  * The Lexer
  *---------------------------------------------------------------------------*/
@@ -506,9 +457,9 @@ options {testLiterals = true;}
  *  but also when a TAB is hit after an incomplete identifier.
  */
 
-TAB 
+IDENT_TAB 
     :   '\t'
-    |   IDENT {$setType(IDENT);} ('\t' {$setType(TAB);})? 
+    |   IDENT {$setType(IDENT);} ('\t' {$setType(IDENT_TAB);})? 
     ;
 
 protected
diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog
index 4a7ee21..1b9f728 100644
--- a/frysk-core/frysk/expr/ChangeLog
+++ b/frysk-core/frysk/expr/ChangeLog
@@ -1,3 +1,16 @@
+2007-11-16  Andrew Cagney  <cagney@redhat.com>
+
+	* TabException.java: Delete.
+	* CExpr.g (bTabPressed): Delete.
+	(tab_expression): Delete.
+	(primary_expression): Fold into scope_expression; when IDENT_TAB
+	throw IncompleteIdentifierException.
+	(IDENT_TAB): Rename TAB.
+	* CompletionException.java: New.
+	* IncompleteTokenException.java: New.
+	* IncompleteIdentifierException.java: New.
+	* IncompleteMemberException.java: New.
+
 2007-11-15  Andrew Cagney  <cagney@redhat.com>
 
 	* TestArithmetics.java (eval(String)): Do not set setASTNodeClass.
diff --git a/frysk-sys/frysk/expunit/TerminationException.java b/frysk-core/frysk/expr/CompletionException.java
similarity index 76%
copy from frysk-sys/frysk/expunit/TerminationException.java
copy to frysk-core/frysk/expr/CompletionException.java
index 7c69c9f..19aa7a4 100644
--- a/frysk-sys/frysk/expunit/TerminationException.java
+++ b/frysk-core/frysk/expr/CompletionException.java
@@ -37,25 +37,36 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.expunit;
+package frysk.expr;
 
-/**
- * Thrown an an end-of-file is encountered and nothing else matches.
+import antlr.collections.AST;
+
+/** 
+ * An incomplete blah.
  */
 
-public class TerminationException
-    extends RuntimeException
-{
+public class CompletionException extends RuntimeException {
     static final long serialVersionUID = 1;
-    static private String expecting (int expectedStatus)
-    {
-	if (expectedStatus >= 0)
-	    return " (expecting exit with status " + expectedStatus + ")";
-	else
-	    return " (expecting kill with signal " + expectedStatus + ")";
+    private final AST ast;
+    CompletionException(AST ast) {
+	super("completing " + ast);
+	this.ast = ast;
+    }
+    /**
+     * Return the incomplete string (minus the tab).
+     */
+    public String getText() {
+	String text = ast.getText();
+	int tab = text.indexOf("\t");
+	if (tab < 0)
+	    throw new RuntimeException("No tab found in " + ast);
+	return text.substring(0, tab);
+    }
+    // Useful?
+    public int getLine() {
+	return ast.getLine();
     }
-    TerminationException (int expectedStatus, String s)
-    {
-	super (s + expecting (expectedStatus));
+    public int getColumn() {
+	return ast.getColumn();
     }
 }
diff --git a/frysk-sys/frysk/expunit/EofException.java b/frysk-core/frysk/expr/IncompleteIdentifierException.java
similarity index 90%
copy from frysk-sys/frysk/expunit/EofException.java
copy to frysk-core/frysk/expr/IncompleteIdentifierException.java
index 19ec3fd..0d4fc82 100644
--- a/frysk-sys/frysk/expunit/EofException.java
+++ b/frysk-core/frysk/expr/IncompleteIdentifierException.java
@@ -37,18 +37,16 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.expunit;
+package frysk.expr;
 
-/**
- * Thrown an an end-of-file is encountered and nothing else matches.
- */
+import antlr.collections.AST;
 
-public class EofException
-    extends RuntimeException
-{
+/** 
+ * An incomplete identifier; e.g.: foo<tab>
+ */
+class IncompleteIdentifierException extends CompletionException {
     static final long serialVersionUID = 1;
-    EofException ()
-    {
-	super ("End-of-file encountered");
+    IncompleteIdentifierException(AST identifier) {
+	super(identifier);
     }
 }
diff --git a/frysk-sys/frysk/expunit/EofException.java b/frysk-core/frysk/expr/IncompleteMemberException.java
similarity index 90%
copy from frysk-sys/frysk/expunit/EofException.java
copy to frysk-core/frysk/expr/IncompleteMemberException.java
index 19ec3fd..fc093d5 100644
--- a/frysk-sys/frysk/expunit/EofException.java
+++ b/frysk-core/frysk/expr/IncompleteMemberException.java
@@ -37,18 +37,16 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.expunit;
+package frysk.expr;
 
-/**
- * Thrown an an end-of-file is encountered and nothing else matches.
- */
+import antlr.collections.AST;
 
-public class EofException
-    extends RuntimeException
-{
+/** 
+ * An incomplete field member; e.g.: structure.field<tab>
+ */
+class IncompleteMemberException extends CompletionException {
     static final long serialVersionUID = 1;
-    EofException ()
-    {
-	super ("End-of-file encountered");
+    IncompleteMemberException(AST member) {
+	super(member);
     }
 }
diff --git a/frysk-sys/frysk/expunit/EofException.java b/frysk-core/frysk/expr/IncompleteTokenException.java
similarity index 90%
copy from frysk-sys/frysk/expunit/EofException.java
copy to frysk-core/frysk/expr/IncompleteTokenException.java
index 19ec3fd..9c2a1cb 100644
--- a/frysk-sys/frysk/expunit/EofException.java
+++ b/frysk-core/frysk/expr/IncompleteTokenException.java
@@ -37,18 +37,16 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.expunit;
+package frysk.expr;
 
-/**
- * Thrown an an end-of-file is encountered and nothing else matches.
- */
+import antlr.collections.AST;
 
-public class EofException
-    extends RuntimeException
-{
+/** 
+ * An incomplete token; e.g.: :<tab>
+ */
+class IncompleteTokenException extends CompletionException {
     static final long serialVersionUID = 1;
-    EofException ()
-    {
-	super ("End-of-file encountered");
+    IncompleteTokenException(AST token) {
+	super(token);
     }
 }
diff --git a/frysk-core/frysk/expr/TabException.java b/frysk-core/frysk/expr/TabException.java
deleted file mode 100644
index 2552f7d..0000000
--- a/frysk-core/frysk/expr/TabException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2005, 2007, Red Hat Inc.
-// Copyright 2006 IBM Corp.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-package frysk.expr;
-
-import antlr.collections.AST;
-
-/** 
- * An that should be thrown when a <TAB> key is pressed.
- *
- * The constructor takes an AST (abstract syntax tree) as
- * argument. This is the the partial AST generated thus far by the
- * parser.
- */
-
-public class TabException extends RuntimeException
-{
-    static final long serialVersionUID = 1;
-
-    private AST astExpression;
-    private String sTabExpression;
-
-    /**
-     * The constructor takes an AST (abstract syntax tree) as
-     * argument. This is the the partial AST generated thus far by the
-     * parser. The second argument is the incomplete identifier that
-     * the user may have typed in. It may or may not be null
-     */
-    public TabException(AST astPartial, String sTabExpression) {
-	astExpression = astPartial;
-	this.sTabExpression = sTabExpression;
-    }
-
-    /**
-     * As the name suggests, this function returns the partial AST
-     * associated with this Exception
-     */
-    public AST getAst() {
-	return astExpression;
-    }
-
-    /**
-     * Return the partial identifier that the user may have keyed in
-     */
-    public String getTabExpression() {
-	return sTabExpression;
-    }
-
-
-    /**
-     * Returns a lisp style representation of the AST
-     */
-    public String toString() {
-	return astExpression.toStringList();
-    }
-}


hooks/post-receive
--
frysk system monitor/debugger


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]