On Thu, 2007-08-30 at 21:05 -0700, Erick Tryzelaar wrote:
> I'm enjoying playing around with felix's dssls, but there are some
> things that would make the process a little bit easier than it is
> right now.
> 
> * First off, we really need a way to print out the scheme-converted
> code pre and post evaluation. There's a lot of guesswork trying to
> debug a small piece of code. So, it'd be handy if there were two other
> flxp-like processes. One, lets call flxp-ocs converts the .flx file
> into an unevaluated scheme file. 

I'm not clear on what that means. What happens can be traced
now by stuff like:

    if !(dyp.global_data.pdebug) then
    Buffer.add_string b ("Reducing Rule for " ^ 
      name ^ ", scm="^scm^"\n");

....
        if !(dyp.global_data.pdebug) then begin
          Buffer.add_string b ("Arg " ^ string_of_int n ^ " = "); 
          buffer_add_ocs b s; Buffer.add_string b "\n";
        end;
...

    let r = 
      try scheme_eval cde 
      with Ocs_error.Error err | Ocs_error.ErrorL (_,err) -> 
        print_string (Buffer.contents b);
        print_string ("Error "^err^" evaluating " ^ scm);
        failwith "Error evaluating Scheme"
    in
    `Obj_sexpr (!age,sr,r),[]

Here, if and only if the pdebug switch is set (by flxp based on
the -v switch), then Scheme code and its arguments are dumped,
if, and only if, Scheme evaluation fails.

Fairly easy to hack that so that it prints, even when it doesn't
fail. You can also trace conversion to sex and flx AST by
editing away comments in:

let ocs2flx sr r = 
  let sex = Ocs2sex.ocs2sex r in
  (*
  print_endline "OCS scheme term converted to s-expression:";
  Sex_print.sex_print sex;
  *)
  let fresh = ref 1 in
  let env = [] in
  let flx = Flx_sex2flx.xstatement_t sr fresh env sex in
  (*
  print_endline "s-expression converted to Felix statement!";
  print_endline (string_of_statement 0 flx);
  *)
  flx

(and also add a dump of the Scheme term 'r' if you like).

Now, the thing is, there is no such thing as an 'unevaluated
scheme file'. The Scheme code is evaluated by Dypgen in each
reduction, by the user action.


The result is an Scheme value (s-expression, list of lists etc).
You can print that using

        print_endline (Ocs_print.string_of_ocs r)

as desired in ocs2flx: the intermediate values are already
printed as 'reduction rule' and 'arguments' prior to evaluation,
and the result is invariably an argument for the next reduction,
so you get a print of that too (except for the top level statement
which is handled by ocs2flx).

What you will find is that the result is more or less useless:
it is very long and has LOTS of ((((((((((((((((( in it.

IMHO: the BEST reference for what Scheme to code is in 
fact the transcoder Flx_sex2flx.ml, even though it is mapping
Sex to Flx AST, the Sex ast is encoded as Ocaml:

  | Lst [Id "ast_type_alias"; sr; Str n; vs; t] ->
    `AST_type_alias (xsr sr,n, xvs vs, ti t)

  | Lst [Id "ast_andlist"; sr; Lst es] -> 
    `AST_andlist (xsr sr, map ex es)


because the sex format is just a trivial s-expression:

type sexp_t =
  | Int of string
  | Str of string
  | Sym of string
  | Id of string
  | Lst of sexp_t list

with a more or less direct and obvious mapping from OCS Scheme
s-expressions.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to