Re: Parsing partial sentences

George Neuner <gneuner2@comcast.net>
Fri, 07 Apr 2017 12:59:03 -0400

          From comp.compilers

Related articles
Parsing partial sentences DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2017-04-03)
Re: Parsing partial sentences pronesto@gmail.com (Fernando) (2017-04-04)
Re: Parsing partial sentences DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2017-04-07)
Re: Parsing partial sentences gneuner2@comcast.net (George Neuner) (2017-04-07)
Re: Parsing partial sentences mail@slkpg.com (mail) (2017-04-07)
Re: Parsing partial sentences DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2017-04-07)
Re: Parsing partial sentences gneuner2@comcast.net (George Neuner) (2017-04-10)
Re: Parsing partial sentences DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2017-04-11)
Re: Parsing partial sentences martin@gkc.org.uk (Martin Ward) (2017-04-11)
Re: Parsing partial sentences DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2017-04-11)
[8 later articles]
| List of all articles for this month |

From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Fri, 07 Apr 2017 12:59:03 -0400
Organization: A noiseless patient Spider
References: 17-04-001 17-04-002 17-04-003
Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="7742"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, C
Posted-Date: 07 Apr 2017 13:14:20 EDT

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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.