Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. parse C header files and transformation (Ted Feng)
2. Re: parse C header files and transformation (Ted Feng)
----------------------------------------------------------------------
Message: 1
Date: Mon, 4 Mar 2013 20:33:08 +0800
From: Ted Feng <[email protected]>
Subject: [Haskell-beginners] parse C header files and transformation
To: [email protected]
Message-ID:
<cam7b5hw3nfp7mrcf-xumikuwth8ny696c__nmd8lc4ng8eu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello list,
How to do some C header files parsing and automatic code transformation.
like:
parse this <sys/time.h> header file, and generate code for this API:
int gettimeofday(struct timeval *tv, struct timezone *tz);
generated code(automatically call the API, and dump the structure
appropriately):
void dump_time(void)
{
struct timeval tv = {0};
struct timezone tz = {0};
gettimeofday(&tv, &tz);
printf("tv_sec: %d, tv_usec: %d\n", tv.tv_sec, tv.tv_usec);
printf("tz_minuteswest: %d, tz_dsttime: %d\n", tz.tz_minuteswest,
tz.tz_dsttime);
}
because I'm working on a SDK which has hundreds of API to set and get
headware states.
It'll will be very nice to write some haskell code to parse the header
files and generate C code
that can dump hardware state automatically.
BR
Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130304/53baaa53/attachment-0001.htm>
------------------------------
Message: 2
Date: Tue, 5 Mar 2013 10:11:15 +0800
From: Ted Feng <[email protected]>
Subject: Re: [Haskell-beginners] parse C header files and
transformation
To: [email protected]
Message-ID:
<CAM7b5hxAr_Y1qNp6E7DvgfUABa7PRxdjP=j5hce2zca_sub...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I have been looking at module Language.C(http://trac.sivity.net/language_c),
a complete C99 parser and pretty printer. It has some similar
examples in darcs
repo (darcs get http://code.haskell.org/language-c), like ComputeSize.hs,
but haven't figured out a way.
On Mon, Mar 4, 2013 at 8:33 PM, Ted Feng <[email protected]> wrote:
> Hello list,
>
> How to do some C header files parsing and automatic code transformation.
>
> like:
>
> parse this <sys/time.h> header file, and generate code for this API:
>
> int gettimeofday(struct timeval *tv, struct timezone *tz);
>
> generated code(automatically call the API, and dump the structure
> appropriately):
>
> void dump_time(void)
> {
> struct timeval tv = {0};
> struct timezone tz = {0};
>
> gettimeofday(&tv, &tz);
> printf("tv_sec: %d, tv_usec: %d\n", tv.tv_sec, tv.tv_usec);
> printf("tz_minuteswest: %d, tz_dsttime: %d\n", tz.tz_minuteswest,
> tz.tz_dsttime);
> }
>
> because I'm working on a SDK which has hundreds of API to set and get
> headware states.
> It'll will be very nice to write some haskell code to parse the header
> files and generate C code
> that can dump hardware state automatically.
>
> BR
> Ted
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130305/9b5f4f11/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 57, Issue 5
****************************************