Mail Archives: djgpp/2001/01/11/20:02:27
Hello. I've got an interesting problem. I am writing a program using Bison,
Flex, and C++. The problem is this, I have done the parser and lexer using
Bison and Flex respectively. The guts of the program I intend to write
using C++. The lexer part is okay, because Flex can generate a C++ scanner
(albeit an experimental one). The problem is with the Bison generated
parser. I intended to call C++ functions from within the parser
rule-actions until I realized that this would be a problem because the
parser is in C.
Now, I've tried doing it using pointers to functions. It works, but
(heheheh) is there a better way to do this?
[ file test.cc ]
#include <iostream>
void test()
{
cout << "Haha it works!!!" << endl;
}
void (*test_addr)() = test;
[ --end--]
[ file main.c ]
#include <stdlib.h>
extern void (*test_addr)();
int main(void)
{
(*test_addr)();
exit(0);
}
[ --end-- ]
Help please...
nimrod_a_abing
--------------
+========================================+
| Home page: www.geocities.com/n_abing |
+========================================+
ICQ: 54665893
- Raw text -