|simple code translator - suggestions? email@example.com (makc.the.great) (2005-06-02)|
|Re: simple code translator - suggestions? firstname.lastname@example.org (2005-06-02)|
|Re: simple code translator - suggestions? email@example.com (2005-06-04)|
|Re: simple code translator - suggestions? cfc@shell01.TheWorld.com (Chris F Clark) (2005-06-06)|
|Re: simple code translator - suggestions? firstname.lastname@example.org (2005-06-08)|
|Re: simple code translator - suggestions? email@example.com (Lorenzo Bettini) (2005-06-08)|
|Re: simple code translator - suggestions? firstname.lastname@example.org (=?iso-8859-1?q?C=E9dric_LEMAIRE?=) (2005-06-08)|
|Re: simple code translator - suggestions? email@example.com (Ira Baxter) (2005-06-23)|
|From:||"Ira Baxter" <firstname.lastname@example.org>|
|Date:||23 Jun 2005 22:07:16 -0400|
|Posted-Date:||23 Jun 2005 22:07:16 EDT|
"makc.the.great" <email@example.com> wrote in message
>Why can't I have my C++ code in the form:
> /* c++ code here */
> /* code written in simple dot-syntax script */
> /* c++ code here, if really necessary */
> /* more code written in simple dot-syntax script */
> And then this file gets translated in pure c++ with translator in
The DMS Software Reengineering Toolkit can do this pretty directly.
It can accept arbitrary language definitions using an analog to LEX
and YACC, so you can easily define your own domain-specific language
or "script". It already has a full, robust, C++ language definition,
including name/type resolution.
One can then write translation rules of the form of:
"syntax-fragment1" -> "syntax-fragment2" IF <condition>,
where syntax-fragment1 is surface syntax with optional
pattern variables in any of DMS's language notations
(including C++), and likewise for syntax-fragment-2.
What these represent are tree-to-tree rewrites.
This enables one to code
translation rules from your scripting language to C++,
including conditional checks (e.g., name/type lookup).
One can group rules together to get rulesets to apply; often
cooperating rules can achieve what a single rule cannot easily do.
(Think of "simplify expression" as a set of rules). One can build
arbitrary metaprograms, triggered by arbitrary patterns, which apply
rulesets where the patterns match. This is our usual practice in
building interesting translators.
One can also write patterns which mix surface syntax fragments
arbitrarily (think of this as red trees mixed into blue trees), which
provides the "some-token-switch" idea above.
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com
Return to the
Search the comp.compilers archives again.