According to Tom Dye:
Please excuse a newbie request for help. I'm interested in using a lexer prepared with flex in a GPC program. I gather from the documentation that this is possible, but I'm not enough of a C programmer to figure out how it might be done.
This is a special case of the question "How to use a function written in C from a GPC program?", correct? This is answered in the GPC FAQ:
8< ---- begin (* from the GPC FAQ *) -----------------------------------------
[15]How do I use <insert_your_function_here> from the C library?
GNU Pascal can use every function of your C library, but it may be up to you to write declaration of an external function, before you can use it. Consider the function `sleep'. `man(3) sleep' reveals:
--------------------------------------------------------- NAME sleep - Sleep for the specified number of seconds
SYNOPSIS #include <unistd.h>
unsigned int sleep(unsigned int seconds); ---------------------------------------------------------
This small demo program shows how to use `sleep' in a Pascal program:
--------------------------------------------------------- program SleepDemo;
type word = __unsigned__ integer;
function sleep(seconds: word): word; C;
var result : word;
begin result := sleep(10); end. ----------------------------------------------------------
8< ---- end (* from the GPC FAQ *) -------------------------------------------
Remark: Recent beta versions of GPC (available at ftp://agnes.dida.physik.uni-essen.de/~gnu-pascal/beta/) don't need `word = __unsigned__ integer' any more; they have `word' built in.
Hope this helps,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]