jackieju / xcompiler

Cross-compile any programming language to another

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xcompiler

Cross compile any programming language to another

*** HOW TO USE

Video: https://youtu.be/tc00vaMgB2M

  1. Prepare

This project developed on macos. But should be easy to port on windows, since it uses ruby.

You need to have ruby 2.6+.

You need to download cpp2ruby first.

cd ..
git clone https://github.com/jackieju/CPP2Ruby.git
cd xcompiler
  1. Generate Parser from EBNF
    cd cocoR\
    ./gen_parser [atg file]

In case you change the location of cpp2ruby, you can edit file gen_parser and change the line

    cpp2ruby_dir=../../CPP2Ruby

EBNF(https://tomassetti.me/ebnf/) describes the syntax of source language, written in atg file which will be used by cocoR(http://www.ssw.uni-linz.ac.at/Coco/)

You also put your code in atg to generate code of destination language.

Please see example at https://github.com/jackieju/abap2ruby.

List of atg files(EBNF) for popular langauge: https://github.com/jackieju/xcompiler/tree/master/cocoR/cocor17/samples

  1. Modify macro.rb to do preprocessing

  2. Modfiy cp.rb to do overriding

  3. run

    ruby translate.rb -d [output dir] [source code files]

For example to use xcompiler to translate code, please see https://github.com/jackieju/abap2ruby

About

Cross-compile any programming language to another

License:GNU Affero General Public License v3.0


Languages

Language:Ruby 78.4%Language:C 12.5%Language:VBA 4.5%Language:C++ 3.6%Language:Makefile 0.6%Language:Roff 0.3%Language:Shell 0.0%