Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #1848
| From | Martin Ward <martin@gkc.org.uk> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Parsing partial sentences |
| Date | 2017-04-11 10:30 +0100 |
| Organization | Compilers Central |
| Message-ID | <17-04-009@comp.compilers> (permalink) |
| References | <17-04-001@comp.compilers> <17-04-002@comp.compilers> <17-04-003@comp.compilers> <17-04-004@comp.compilers> <17-04-006@comp.compilers> |
On 07/04/17 21:24, Hans-Peter Diettrich wrote: >> It might be easiest to just run the C preprocessor as a 1st pass and >> then attempt to convert the result. > > That would obfuscate the source code widely On 07/04/17 21:24, John wrote: > Since preprocessor macros are text macros, there's no reason to > expect a macro's expansion can be parsed at all. This is true: handling the full generality of what is possible with #define macros without first expanding all the macros is (almost) impossible. However, in practice it depends on the purpose of your C to Pascal convertor. If it is to be a general purpose tool which has to be able to handle any C source code that anyone throws at it, then you are stuck. If, on the other hand, there is a certain defined body of C code which you want to translate then you only need to be able to handle the types of macro definitions which are actually used in that body of code: which is likely to be a small subset of the possibilities. Most macro definitions in most code (other than the original Bourne shell source code, and some similar examples) are written such that the code using the macro looks and parses like ordinary C code. An intermediate approach might be to keep all the macros which look straightforward and fall back on expanding macros which do weird things with the syntax. -- Martin Dr Martin Ward STRL Principal Lecturer & Reader in Software Engineering martin@gkc.org.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4 G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/ Mirrors: http://www.gkc.org.uk and http://www.gkc.org.uk/gkc
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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