Issue 1: Lemon doesn't produce a header with function prototypes
Status:  New
Owner: ----
Reported by archeng...@gmail.com, Dec 22, 2008
When using lemon, programs complain about not having the function prototypes.
It would be nice if lemon could output function prototypes in the header file.
Mar 24, 2010
#1 Eric.L.H...@gmail.com
Yes, this would be a great addition.  I found myself wanting this feature as well.  I 
ended up adding the prototypes to the header file manually with my Makefile.

I also manually add the %token_type definition to the header file, it would be nice if 
there were a place to put the token definition in the header file as well.
Mar 29, 2010
#2 andrew.p...@gmail.com
On line 4019, I inserted the attached code. It worked for me.

A few issues that make this harder than you'd think:

1. I had to scan for structs and forward-declare them as well, or else the 
declarations wouldn't compile. I don't forward-declare classes (can lemon be compiled 
as C++?), nor do I add typedefs. So there still could be problems.

2. I had to include <stdio.h> and <stddef.h> to get FILE, size_t, ptrdiff_t, etc. But 
I would have to add <time.h> to get time_t. I'm not sure what others I would need.

3. By adding this stuff, I've created a dependency on lempar.c in lemon.c, which 
sorta defeats the purpose of having a template file in the first place.

Despite all that I've attached my "fix" since it's a fairly common problem.
lemon_headers.c
1.5 KB   View   Download
Mar 29, 2010
#3 andrew.p...@gmail.com
I just realized the correct line number was 4016 (I think) because I had added a 
warning comment at the top of my source file saying that I had tainted it.

My code goes right after the line:
  out = file_open(lemp,".h","wb");
  if( out ){

I have attached a proper patch file for lemon.c this time. Sorry about that, guys.
lemon_headers.patch
1.7 KB   View   Download