fusionlanguage / fut

Fusion programming language. Transpiling to C, C++, C#, D, Java, JavaScript, Python, Swift, TypeScript and OpenCL C.
https://fusion-lang.org
GNU General Public License v3.0
1.77k stars 55 forks source link

How to transpile Fut sources? #106

Closed andr1972 closed 1 year ago

andr1972 commented 1 year ago

I install gcc-13 with libstdc++

sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

and compile and install Fur by make.

I don't notice intermediate files. If I transpile:

fut -l java -o Lexer.java Lexer.fu 

is OK, but

fut -l java -o AST.java AST.fu 

I have errors:

AST.fu(582): ERROR: Type FuToken not found
AST.fu(605): ERROR: Type FuToken not found
AST.fu(485): ERROR: FuLexer not found
AST.fu(500): ERROR: FuLexer not found
AST.fu(591): ERROR: FuToken not found
AST.fu(607): ERROR: FuToken not found
AST.fu(610): ERROR: Switch on type poison - expected int, enum, string or object reference
........

How to transpile fut sources to Java or C++?

pfusik commented 1 year ago

For C++:

make libfut.cpp

For Java: Whole fut will not work yet, see #48. There is no one-to-one relationship between the Fusion and Java sources. Since AST.fu depends on Lexer.fu, you should transpile them together:

mkdir ../fut-java
fut -l java -o ../fut-java Lexer.fu AST.fu
pfusik commented 1 year ago

I've just ported fut to Java. Install JDK 21 and build with:

make java/GenBase.java
make FUT_HOST=java