Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

[OT] A C-language parser test file?

by BrowserUk (Patriarch)
on Aug 27, 2015 at 12:54 UTC ( [id://1140195]=perlquestion: print w/replies, xml ) Need Help??

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know of a publicly available C source file specifically constructed for testing the edge cases of C-language parsers?

I'm writing a parser for the C-language (and yes; I need to write my own), and I sat down to think of a good way to test it.

My conclusion is that rather than just feeding it it reams and reams of C sources; most of which will simply be re-exercising the same paths; it would be better to try and construct a single, preferably relatively small, C-source that doesn't necessarily have to do anything useful, but simply uses all the constructs and language features that I need to support. (Which isn't the full standard; any of them.)

I started to try and write notes on everything I think need to be in this file -- and I will continue that -- but then I thought maybe such a file already exists. I've done a few half-hearted searches for something that might fit the bill; but its proven to be a difficult thing to construct a discriminative search criteria for.

So, this is just a hope that maybe someone here has knowledge of something that might lend itself to my purpose.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re: [OT] A C-language parser test file?
by GotToBTru (Prior) on Aug 27, 2015 at 13:19 UTC

    You don't say specifically what you've searched for, only that it was half-hearted. On the off chance it was also half-brained, I'll make what is probably the obvious suggestion. Search for other C-compiler projects, not test files. In other words, when looking for a pencil sharpener, find the guy who uses lots of pencils.

    Dum Spiro Spero

      You mean like this? Or this?

      None of them are what I'm hoping for. They are intimately entwined with the testing philosophies and tools of the projects they are a part of; they cover the full variety of C-like languages; are broken up into dozens of separate files.

      Maybe what I want doesn't exist; but maybe it does and someone here knows where.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

        I found https://gcc.gnu.org/onlinedocs/gccint/C-Tests.html which I then found better access to at https://github.com/gcc-mirror/gcc/tree/master/gcc/testsuite (the first link is actually talking about the gcc.dg subdirectory of the second). Lots of stuff in there so I didn't go trawling through there trying to guess if any of it might suite your needs.

        A compliance test suite would be a nice addition to something that has such a robust standard defined for it. I thought that was a fairly common thing for those old-style standards where you have to pay to get an official copy.

        - tye        

Re: [OT] A C-language parser test file?
by RonW (Parson) on Aug 27, 2015 at 19:02 UTC

    An interesting edge case that makes the coding standards purists scream in horror: Duff's Device

    (Yes, it really is valid, functioning C code.)

Re: [OT] A C-language parser test file?
by Anonymous Monk on Aug 27, 2015 at 16:01 UTC
    Google: grammar for C.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1140195]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found