Michael FIG | 1 May 03:50
Favicon

working on a C grammar

Hi all,

I was wondering if any of you out there have a freely licensed PEG for
C?  I'm interested in combining it with a C preprocessor grammar to
start interpreting (or compiling via Slink) some C code.  With a
little work, this would be extensible to handle Id code, and then we'd
be one step closer to bootstrap.

If not, I have at least a decent BNF reference at
http://ivs.cs.uni-magdeburg.de/~puma/UsersManual/HTML/node12.html
though I would rather start from something that has all the operator
precedences completed in PEG format.

Thanks,

--

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//

Robert Feldt | 1 May 10:16
Picon
Favicon

Re: working on a C grammar

Hi Michael,

Check out Rats source distribution ( http://www.cs.nyu.edu/rgrimm/xtc/xtc-core.zip )
in xtc/src/xtc/lang/C.rats which is a complete C grammar. It might use Rats-specific constructs and the license is GPL2 so maybe not liberal enough.

Regards,

Robert Feldt

On Thu, May 1, 2008 at 3:54 AM, Michael FIG <michael-y8U0i/lyZOM@public.gmane.org> wrote:
Hi all,

I was wondering if any of you out there have a freely licensed PEG for
C?  I'm interested in combining it with a C preprocessor grammar to
start interpreting (or compiling via Slink) some C code.  With a
little work, this would be extensible to handle Id code, and then we'd
be one step closer to bootstrap.

If not, I have at least a decent BNF reference at
http://ivs.cs.uni-magdeburg.de/~puma/UsersManual/HTML/node12.html
though I would rather start from something that has all the operator
precedences completed in PEG format.

Thanks,

--
Michael FIG <michael-y8U0i/lyZOM@public.gmane.org> //\
  http://michael.fig.org/    \//

_______________________________________________
fonc mailing list
fonc-uVco7kAcSAQ@public.gmane.org
http://vpri.org/mailman/listinfo/fonc



--
Best regards,

/Robert Feldt
--
PhD, Assistant Professor in Software Engineering
Blekinge Inst. of Technology, School of Engineering (APS), SE-372 25 Ronneby, Sweden
Cell: +46 (0) 733 580 580
Personal web: http://drfeldt.googlepages.com/
Research group web: http://www.bth.se/tek/serl/
<div>
<p>Hi Michael,<br><br>Check out Rats source distribution ( <a href="http://www.cs.nyu.edu/rgrimm/xtc/xtc-core.zip">http://www.cs.nyu.edu/rgrimm/xtc/xtc-core.zip</a> )<br>in xtc/src/xtc/lang/C.rats which is a complete C grammar. It might use Rats-specific constructs and the license is GPL2 so maybe not liberal enough.<br><br>Regards,<br><br>Robert Feldt<br><br></p>
<div class="gmail_quote">On Thu, May 1, 2008 at 3:54 AM, Michael FIG &lt;<a href="mailto:michael@...">michael@...</a>&gt; wrote:<br><blockquote class="gmail_quote">
Hi all,<br><br>
I was wondering if any of you out there have a freely licensed PEG for<br>
C? &nbsp;I'm interested in combining it with a C preprocessor grammar to<br>
start interpreting (or compiling via Slink) some C code. &nbsp;With a<br>
little work, this would be extensible to handle Id code, and then we'd<br>
be one step closer to bootstrap.<br><br>
If not, I have at least a decent BNF reference at<br><a href="http://ivs.cs.uni-magdeburg.de/%7Epuma/UsersManual/HTML/node12.html" target="_blank">http://ivs.cs.uni-magdeburg.de/~puma/UsersManual/HTML/node12.html</a><br>
though I would rather start from something that has all the operator<br>
precedences completed in PEG format.<br><br>
Thanks,<br><br>
--<br>
Michael FIG &lt;<a href="mailto:michael@...">michael@...</a>&gt; //\<br>
 &nbsp; <a href="http://michael.fig.org/" target="_blank">http://michael.fig.org/</a> &nbsp; &nbsp;\//<br><br>
_______________________________________________<br>
fonc mailing list<br><a href="mailto:fonc@...">fonc@...</a><br><a href="http://vpri.org/mailman/listinfo/fonc" target="_blank">http://vpri.org/mailman/listinfo/fonc</a><br>
</blockquote>
</div>
<br><br clear="all"><br>-- <br>Best regards,<br><br>/Robert Feldt<br>--<br>PhD, Assistant Professor in Software Engineering<br>Blekinge Inst. of Technology, School of Engineering (APS), SE-372 25 Ronneby, Sweden<br>
Cell: +46 (0) 733 580 580<br>Personal web: <a href="http://drfeldt.googlepages.com/">http://drfeldt.googlepages.com/</a><br>Research group web: <a href="http://www.bth.se/tek/serl/">http://www.bth.se/tek/serl/</a>
</div>
Ian Piumarta | 1 May 16:50
Favicon

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

Aaron Gray | 1 May 18:36

Re: working on a C 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.

Its the C preprocessor macros that often make the semantics undecypherable 
to a machine process.

Aaron

Michael FIG | 1 May 22:59
Favicon

Re: working on a C grammar

Hi,

Ian Piumarta <piumarta@...> writes:

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

I guess I'll start with CPP then.  I found a BSD-licensed preprocessor
that looks really good: mcpp.sourceforge.net

Thanks for the other pointers (and also to Robert and Aaron),

--

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//


Gmane