yab | yet another Basic for HAIKU
Yab to C converter - Printable Version

+- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum)
+-- Forum: General discussion (https://yab.orgfree.com/forum/forumdisplay.php?fid=8)
+--- Forum: yab stuff (https://yab.orgfree.com/forum/forumdisplay.php?fid=10)
+--- Thread: Yab to C converter (/showthread.php?tid=118)

Pages: 1 2 3 4 5


RE: Yab to C converter - SamuraiCrow - 03-24-2021

UPDATE:

Wrote my first test routine. The compiler segfaults at shutdown but generates the correct code.

build instructions:
make -j
./tester
cd runtime
make
./main

It should execute the equivalent of the following BASIC:

v=2
Print v
End


RE: Yab to C converter - bbjimmy - 03-24-2021

cool!


RE: Yab to C converter - SamuraiCrow - 03-27-2021

I've just thrown out a half of a week's worth of work over wrong smart-pointers.  Now I'm starting over from my last commit.


RE: Yab to C converter - bbjimmy - 03-27-2021

That's why I don't use c or c++, basic is fine for me.


RE: Yab to C converter - SamuraiCrow - 03-29-2021

Update:

After throwing out most of the smart pointers and replacing them with conventional raw pointers and destructors, not only is the segfault gone but the code is about 40k smaller under Linux! Now testing under Haiku!

SUCCESS!

82k executable on Haiku beta2 under GCC 8.x and runs.


RE: Yab to C converter - bbjimmy - 03-29-2021

2

Hello
world!


3.141593        is pi


now it ONLY needs to work from a yab source file.  Wink


RE: Yab to C converter - SamuraiCrow - 03-30-2021

(03-29-2021, 06:12 PM)bbjimmy Wrote: now it ONLY needs to work from a yab source file.  Wink
Heh, I wish. Smile Now I'm going to test the expressions and subroutines. Once I get that done I need to test arrays and structured programming. After that I need to test labels, goto, gosub and the unstructured branching.

Currently, I've discovered another segfault in the function constructor. Sad


RE: Yab to C converter - SamuraiCrow - 04-07-2021

Update: I've run into a corner-case where if a variable is used twice in the same expression, it will get double-free conditioned. This will take some thought.


RE: Yab to C converter - bbjimmy - 04-08-2021

(04-07-2021, 12:07 PM)SamuraiCrow Wrote: Update:  I've run into a corner-case where if a variable is used twice in the same expression, it will get double-free conditioned.  This will take some thought.
Can't one use a variable twice in an expression in c/c++?


RE: Yab to C converter - SamuraiCrow - 04-08-2021

(04-08-2021, 11:05 AM)bbjimmy Wrote:
(04-07-2021, 12:07 PM)SamuraiCrow Wrote: Update:  I've run into a corner-case where if a variable is used twice in the same expression, it will get double-free conditioned.  This will take some thought.
Can't one use a variable twice in an expression in c/c++?
Yes, but I'm going to be using the expression parser from the Yab sources instead.  This will allow us to maintain more compatibility from the BASIC side of things.  As such, the orders of operations will be split into multiple simple expressions and use temporary variables to substitute for orders of operations.

FIxed:  The problem was that I added a mechanism in which temporary variables would be recycled but had to fix it so that non-temporary ones would not be deallocated until they go out of scope.

Now I'm working on producing functions.  This and structured programming involve a lot of reinvented wheels because the non-structured on..goto and on..gosub routines have no equivalents in C++ structured programming.


Free Web Hosting