Patch for pt-check.cc/.h

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch for pt-check.cc/.h

JD Cole-2
I added visit_subplot_axes and visit_do_until_command. Since
tree_checker is not instantiated anywhere in the code, the missing
function don't show up upon compilation ... I think.

Also, I was wondering curious about the current state of tree_checker,
does it probably "gripe" about script syntax? If so, would it be usefull
for anyone else to add some functionality which allows the following:

tree_checker tc(tree_checker::non_verbose);

stmt->accept(tc);

if (tc.valid_syntax ())
  go_on_my_way ();
else
  try_again_man();

If not, I will just use tree_checker under another name.

Thanks,

JD

Index: src/pt-check.cc
===================================================================
RCS file: /cvs/octave/src/pt-check.cc,v
retrieving revision 1.11
diff -c -r1.11 pt-check.cc
*** src/pt-check.cc 2002/12/06 21:29:18 1.11
--- src/pt-check.cc 2002/12/13 22:13:27
***************
*** 481,486 ****
--- 481,491 ----
  }
 
  void
+ tree_checker::visit_subplot_axes (subplot_axes& cmd)
+ {
+ }
+
+ void
  tree_checker::visit_subplot_list (subplot_list& lst)
  {
    subplot_list::iterator p = lst.begin ();
***************
*** 615,620 ****
--- 620,639 ----
 
    if (list)
      list->accept (*this);
+ }
+
+ void
+ tree_checker::visit_do_until_command (tree_do_until_command& cmd)
+ {
+   tree_statement_list *list = cmd.body ();
+
+   if (list)
+     list->accept (*this);
+
+   tree_expression *expr = cmd.condition ();
+
+   if (expr)
+     expr->accept (*this);
  }
 
  void
Index: src/pt-check.h
===================================================================
RCS file: /cvs/octave/src/pt-check.h,v
retrieving revision 1.9
diff -c -r1.9 pt-check.h
*** src/pt-check.h 2002/12/06 21:29:18 1.9
--- src/pt-check.h 2002/12/13 22:13:27
***************
*** 107,112 ****
--- 107,114 ----
 
    void visit_subplot (subplot&);
 
+   void visit_subplot_axes (subplot_axes&);
+
    void visit_subplot_list (subplot_list&);
 
    void visit_subplot_style (subplot_style&);
***************
*** 124,129 ****
--- 126,133 ----
    void visit_unwind_protect_command (tree_unwind_protect_command&);
 
    void visit_while_command (tree_while_command&);
+
+   void visit_do_until_command (tree_do_until_command&);
 
  private:
 
Reply | Threaded
Open this post in threaded view
|

Patch for pt-check.cc/.h

John W. Eaton-6
On 13-Dec-2002, JD Cole <[hidden email]> wrote:

| I added visit_subplot_axes and visit_do_until_command. Since
| tree_checker is not instantiated anywhere in the code, the missing
| function don't show up upon compilation ... I think.

I applied your patch.

| Also, I was wondering curious about the current state of tree_checker,
| does it probably "gripe" about script syntax?

I don't think it is currently used.  I think I started it as an
experiment in static analysis, but never finished whatever it was I
had in mind.

| If so, would it be usefull
| for anyone else to add some functionality which allows the following:
|
| tree_checker tc(tree_checker::non_verbose);
|
| stmt->accept(tc);
|
| if (tc.valid_syntax ())
|   go_on_my_way ();
| else
|   try_again_man();
|
| If not, I will just use tree_checker under another name.

I think that if what you want is similar to what tree_checker already
tries to do, and if you can get there by just adding some options, you
should do that rather than duplicating most of the current code.

Thanks,

jwe