Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.glorb.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: mail Newsgroups: comp.compilers Subject: Re: Parsing partial sentences Date: Fri, 07 Apr 2017 14:37:58 -0800 Organization: Compilers Central Lines: 11 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <17-04-005@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: 8bit Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="30654"; mail-complaints-to="abuse@iecc.com" Keywords: C, parse Posted-Date: 10 Apr 2017 10:25:56 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Received-Bytes: 1499 X-Received-Body-CRC: 3684695566 Xref: csiph.com comp.compilers:1844 I think the short answer is "no there is not an easy way to handle C #defines," it is fairly hard. Easiest is to get an open source preprocessor and use it to convert the C file to preprocessed C. Then use your converter on that. I have one that kind of almost works posted on my site that you can look at to see one stab at the problem from a formal parsing approach. I think most real preprocessors are less parsers and more just a program. They do need to be able to parse the C constant expression grammar though. The SLK Parser Generator: http://www.slkpg.com