slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] new slang 2 development snapshot released


Ben Duncan <ben@xxxxxxxxxxxxxxxxxx> wrote:
>I think Michael is on to what i am trying to do. Basically SLAG will store the
>  SDEF's in a 
>file. In each "field" parameter can be code snippets, and in following Appgen's
>  design,

As Mike point out, S-Lang 2 throws an exception when it encounters a
parse error.  Such exceptions can be caught:

   expression = "(":
   try
   {
      eval ("(");
   }
   catch ParseError:
   {  
      vmessage ("failed to parse expression");
   }

You can probably use this to create a validation function:

   define validate (expression)
   {
      try 
      {
         eval (expression);
	 return 0;
      }
      catch AnyError;
      return -1;
   }
   
if (-1 == validate ("("))
  message ("Failed to validate");

In the validate function, evaling the expression could fail for other
reasons that have nothing to do with parsing.  For example,
eval("1/0") will generate a DivideByZeroError exception.  This is why
AnyError was caught.  

I hope this helps a bit. 
--John

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]