Yab to C converter
#21
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
Reply
#22
cool!
Reply
#23
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.
Reply
#24
That's why I don't use c or c++, basic is fine for me.
Reply
#25
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.
Reply
#26
2

Hello
world!


3.141593        is pi


now it ONLY needs to work from a yab source file.  Wink
Reply
#27
(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
Reply
#28
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.
Reply
#29
(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++?
Reply
#30
(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.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)
Free Web Hosting