Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: rockbrentwood@gmail.com Newsgroups: comp.compilers Subject: Re: New experimental back end for C/C++ compiler targeting CLI Date: Fri, 26 Aug 2016 12:54:34 -0700 (PDT) Organization: Compilers Central Lines: 39 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <16-08-008@comp.compilers> References: <16-08-007@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="85269"; mail-complaints-to="abuse@iecc.com" Keywords: C, code Posted-Date: 28 Aug 2016 20:44:08 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1730 On Thursday, August 25, 2016 at 10:17:46 AM UTC-5, Alexandre wrote: > Btw, at now, is just a experimental project, it's not build every C > program... I've been looking seriously, as of late, at doing {machine,source} to source synthesis -- even "normalization" (source to source synthesis from/to the same language); the key trick being to combine the so-called abstract syntax tree and control flow graphs into one by making the abstract syntax tree, itself, the control flow graph ... i.e. by using an infinitary abstract syntax. That means that a loop while (E) S gets represented the very same way as the branch if (E) { S while (E) S } in the graph. This goes perfectly with continuation semantics since it requires a place-holder Q; so that a statement {if (E) S} is "completed" with Q into {if (E) S}[Q] = E? S[Q]: Q When applied to the loop, the result is a conditional expression with an infinite abstract syntax E? S[E? S[E? S[...]: Q]: Q]: Q. The abstract syntax "tree", itself, is compactly represented in its "maximally rolled up" form as a cyclic graph; and that graph is none other than the control flow graph. So the AST and CFG become one and the same. Data flow analysis is done by the framework underlying the "magic algebra" I described here: https://www.scribd.com/document/235320018/Magic-Algebra-The-Algebraic-Approac h-to-Control-Flow-Analysis The REAL trick though -- especially with source-to-source transformation is converting the white space! About 75-80% of the "indent" utility revolves around that very issue; and when I do conversions by hand a similar percentage of effort is involved in dealing with this issue -- particularly in converting or rewriting the language IN the comments. A really good source-to-source compiler should also be making proper adjustments to the comments. That may even entail a degree of natural language processing! Except for the "may" part.