bison and flex with GPC

Tue, 5 Aug 1997 21:26:07 +0200 (MET DST)


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  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 

   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]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es