[<<][meta][>>][..]
Fri Feb 27 10:20:18 CET 2009

Generating/Processing C code

Bottom line: I'm never going to be happy with a macro package that
doesn't understand C syntax.  NEXT: FrontC (godi, Ocaml).  This is
what's used in MetaOcaml for C pretty-printing.

Getting started with FrontC:

  M-x tuareg-run-caml /usr/local/godi/bin/ocaml

  #use "topfind";;
  #require "FrontC";;

  open Frontc;;

  Frontc.parse_file "/tmp/test.c" stderr ;;

I had to look up the "stderr" part here:
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html

With "int boo(int a) { return a + 1; }" this gives:

- : Frontc.parsing_result =
PARSING_OK
 [FUNDEF
   ((INT (NO_SIZE, NO_SIGN), NO_STORAGE,
     ("boo",
      PROTO
       (INT (NO_SIZE, NO_SIGN),
        [(INT (NO_SIZE, NO_SIGN), NO_STORAGE,
          ("a", INT (NO_SIZE, NO_SIGN), [], NOTHING))],
        false),
      [], NOTHING)),
   ([], RETURN (BINARY (ADD, VARIABLE "a", CONSTANT (CONST_INT "1")))))] 


Further experiments require a bit more Ocaml experience..



EDIT: there is now c.plt !



[Reply][About]
[<<][meta][>>][..]