Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1843

Re: Parsing partial sentences

From George Neuner <gneuner2@comcast.net>
Newsgroups comp.compilers
Subject Re: Parsing partial sentences
Date 2017-04-07 12:59 -0400
Organization A noiseless patient Spider
Message-ID <17-04-004@comp.compilers> (permalink)
References <17-04-001@comp.compilers> <17-04-002@comp.compilers> <17-04-003@comp.compilers>

Show all headers | View raw


On Fri, 7 Apr 2017 11:16:18 -0400 (EDT), Hans-Peter Diettrich
<DrDiettrich1@netscape.net> wrote:

>Am 04.04.2017 um 15:05 schrieb Fernando:
>> Em segunda-feira, 3 de abril de 2017 12:16:18 UTC-3, Hans-Peter Diettrich
>> escreveu:
>>> Is there an easy way to parse e.g. C #defines into constants, functions
>>> or other non-terminals, which are not the goal of the entire grammar?
>
>>     I am not sure I understood the question, but from the title of the e-mail,
>> I am assuming that you want to parse C code partially available?
>
>The purpose is just what I wrote: parse #defines into constructs which
>can be translated into some other programming language. It shall become
>part of my C-to-Pascal converter, written in Pascal (OPL).

Unfortunately, #define is a textual substition ... the preprocessor
doesn't care whether the body is legal C, and the compiler itself
doesn't look at the raw #define bodies.

It might be easiest to just run the C preprocessor as a 1st pass and
then attempt to convert the result.


It's been a while since I used C regularly, but if my memory is
correct Lint was able to check and steer you to a faulty #define.
However, I *think* Lint used the preprocessor and required it to be
available.

There are some open-source alternatives to Lint. You might look into
what they are able to do.


Since a #define body is just text, it can be anything - people have
created whole DSLs using #define.  If you really need to figure them
out, I'm afraid you'll need (almost) the whole C language parser to do
it.

Sorry I can't help more.
George

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-03 09:57 +0200
  Re: Parsing partial sentences Fernando <pronesto@gmail.com> - 2017-04-04 06:05 -0700
    Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-07 11:16 -0400
      Re: Parsing partial sentences George Neuner <gneuner2@comcast.net> - 2017-04-07 12:59 -0400
        Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-07 22:24 +0200
          Re: Parsing partial sentences George Neuner <gneuner2@comcast.net> - 2017-04-10 20:22 -0400
            Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-11 10:31 +0200
              Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-11 19:40 +0200
              Re: Parsing partial sentences George Neuner <gneuner2@comcast.net> - 2017-04-11 23:05 -0400
                Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-12 13:45 +0200
          Re: Parsing partial sentences Martin Ward <martin@gkc.org.uk> - 2017-04-11 10:30 +0100
  Re: Parsing partial sentences Walter Banks <walter@bytecraft.com> - 2017-04-27 10:58 -0400
    Re: Parsing partial sentences Kaz Kylheku <686-678-9105@kylheku.com> - 2017-04-27 19:08 +0000
      Re: Parsing partial sentences rugxulo@gmail.com - 2017-04-28 16:32 -0700
      Re: Parsing partial sentences Marco van de Voort <marcov@toad.stack.nl> - 2017-04-29 14:57 +0000
        Re: Parsing partial sentences Kaz Kylheku <686-678-9105@kylheku.com> - 2017-04-30 16:31 +0000
    Re: Parsing partial sentences Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-04-28 02:48 +0200

csiph-web