
Copyright (C) 2015-2018 Matthew R. Wette

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  This file is offered as-is,
without any warranty.

=== To play with example code and try modifications ...

  $ cd examples
  $ source env.sh

=== Hacking on the C99 parser ====
To play with the C99 code, in place, I recommend the following:
After sourcing env.sh as above, execute

  $ cd nyacc/lang/c99
  $ guile tryit.scm

If you modify module/nyacc/lang/c99/mach.scm you will need to rebuild the
files in the subdirectory mach.d.  To do this run, in guile, the following:
  (use-modules (nyacc lang c99 mach))
  (use-modules (nyacc lang c99 cppmach))

  (gen-c99-files ".")
  (compile-file "parser.scm")
  (gen-cpp-files ".")
  (compile-file "cpp.scm")

=== Nyacc eXtension languages (or not-exactly languages)

  $ guile
  ...
  scheme@(guile-user)> ,L nx-javascript
  Happy hacking with nx-javascript!  To switch back, type `,L scheme'.
  nx-javascript@(guile-user)> var a = 1;
  nx-javascript@(guile-user)> ,L nx-octave
  Happy hacking with nx-octave!  To switch back, type `,L nx-javascript'.
  nx-octave@(guile-user)> b = 2;
  nx-octave@(guile-user)> ,L nx-tcl
  Happy hacking with nx-tcl!  To switch back, type `,L nx-octave'.
  nx-tcl@(guile-user)> set c 3
  nx-tcl@(guile-user)> ,L scheme
  Happy hacking with Scheme!  To switch back, type `,L nx-tcl'.
  scheme@(guile-user)> (+ a b)
  $1 = 3
  scheme@(guile-user)> c
  $2 = "3"

=== Hacking on the FFI Helper ====
  $ cd examples
  $ source env.sh 			# if you haven't done so previously
  $ guild compile-ffi ffi/cairo.ffi
  $ cd nyacc/lang/c99/ffi-exam
  $ guile demo-cairo.scm		# should generate demo-cairo.png

  $ guile
  guile> (use-modules (nyacc lang c99 ffi-help))
  guile> (use-modules (bytestructures guile))
  guile> (use-modules (system ffi-help-rt))
  guile> (use-modules ((system foreign) #:prefix ffi:))
  guile> (define fh-llibs '())
  guile> (define fexp (fh-cnvt-cdecl "fmod" "double fmod(double x,double y);")
  guile> ,pp exp
  $1 = (begin
    (define ~fmod
      (delay (fh-link-proc
               ffi:double
               "fmod"
               (list ffi:double ffi:double)
               fh-llibs)))
    (define (fmod x y)
      (let ((~x (unwrap~float x)) (~y (unwrap~float y)))
        ((force ~fmod) ~x ~y)))
    (export fmod))
  guile> (eval exp (current-module))
  guile> (fmod 2.3 0.5)
  $2 = 0.2999999999999998
