Ian Piumarta | 1 May 16:50

Re: working on a C grammar

Hi Michael,

> I was wondering if any of you out there have a freely licensed PEG for
> C?

No guarantees that left recursion has been removed correctly.  C  
grammars also admit a lot that is syntactically correct but semantic  
nonsense and that has to be eliminated in the middle of the  
compiler.  (The standard is large in part because they have to  
explain, in English, all the exceptions to the overly-permissive  
rules in their grammar.)

In my experience, parsing C is fairly easy but pre-processing real- 
world .c and .h files into something you can then parse is a nightmare.

Cheers,
Ian

Attachment (c99.leg): application/octet-stream, 17 KiB
Hi Michael,

> I was wondering if any of you out there have a freely licensed PEG for
> C?

No guarantees that left recursion has been removed correctly.  C  
grammars also admit a lot that is syntactically correct but semantic  
nonsense and that has to be eliminated in the middle of the  
compiler.  (The standard is large in part because they have to  
explain, in English, all the exceptions to the overly-permissive  
rules in their grammar.)

In my experience, parsing C is fairly easy but pre-processing real- 
world .c and .h files into something you can then parse is a nightmare.

Cheers,
Ian


Gmane