BASIC compiler
David Feugey (2125) 2687 posts |
Rhhhooooooo! http://www.martinkd.freeuk.com/ (Edit: Oups, did not see Rick’s message) |
Jeffrey Lee (213) 6046 posts |
but no BASIC to C converters that I’m aware of. I didn’t even try searching :-) BBC_C32’s feature list looks impressive, but it falls down in a couple of important ways (even for perfectly sane BASIC programs it can fail to generate valid C code, and it’s a commercial product that is no longer being maintained) |
Steve Pampling (1551) 7932 posts |
Commercial? From the BBC_C32 web page: Maybe, talked to nicely, Martin would release the source. |
Jeffrey Lee (213) 6046 posts |
…and it’s a commercial product that is no longer being maintained. I guess shareware would have been more accurate; if you give it a BASIC file longer than 200 lines it pops up a message saying that it’s a demo version and asks for a £12 cheque. It still processes the file, but it will nag you each time. |
Steffen Huber (91) 1945 posts |
There is BaCon and BCX but of course they don’t really care about BBC BASIC so may be of limited use. BaCon is basically a shell script – frightening. |
Chris Evans (457) 1614 posts |
My mistake, I now realise that when I saw in the posting about a BASIC to Lua converter “I think it should be able to modify it to produce C instead of lua output” my poor wishful thinking memory ‘slightly’ exaggerated this into a finished converter! |
David Feugey (2125) 2687 posts |
A cool solution would be to have a Basic to DDE jopcodes converter, so the Basic compiler would benefit from any further work make on DDE (VFP support for example). Problem: the need to sign an NDA (with?) to get access to jopcodes documentation (should be public IMHO). I could do that. Not yet for a BBC Basic implementation (I don’t have enough time this year), but perhaps for something simpler, as a Forth compiler or an Integer Basic compiler. Let me know :) |
Ronald May (387) 407 posts |
Jeffrey said However the RISC OS ports of flex/bison/m4 (as currently available from riscos.info) seem a bit dangerous – they managed to crash my Iyonix twice, one time resulting in a broken directoryI went to reasonable lengths to get lex/bison/m4 working identically to the linux versions also with Iyonix. I have downloaded the current ones and will take them home and see what they are doing. One thing, Using norcroft style directories (standard !GCC fare) you will have to specify the output names to less than 3 stage names. default lexx.yy.c style wont work. A (simple) change to the Native build recipe can fix this and I didn’t find any bad side effects within the tests that I tried. Altering riscosifying/unixifying could comeback somewhere though It worried me what might happen if someone was using gcc from norcroft makefile if that is possible or even done. Personally, I never looked back once I converted !GCC to use straight filename conventions, (test/c not c.test). But thats another story. But importantly, unless there is a need to use m4, There are very straight forward ports of bsd yacc and classic flex, I have one called reflex, These dont need forks and file redirections like I used to run m4 with flex and bison. |
Jeffrey Lee (213) 6046 posts |
Be careful! For me the broken directory was the scrap folder; I’d recommend setting up a script which sets up a scrap folder and the test files on a ram disc. Maybe the build tools as well if you’re having trouble reproducing the issue (I’d guess the repro rate was around 10%)
Yeah, I just made the makefile manually specify the output filenames for both flex and bison. |
Rick Murray (539) 13406 posts |
What would be the point of that? The jopcodes are for one end of the C compiler to talk to the other – so unless there is some hidden method of passing data to the back end, there’d be nothing you could do if you did know them… |
David Feugey (2125) 2687 posts |
For companies who would like to provide other front-ends to the DDE suite? (free or commercial). Of course, a public jopcodes specification means also a standalone jopcodes compiler. This would be a great add-on for high-level asm (independent of hardware architecture). |
Steffen Huber (91) 1945 posts |
I’m not an expert wrt lexer/scanner/parser generators (I was stuck using ayacc and aflex in the 90s), but I don’t think yacc/bison and flex are a good choice unless you are very familiar with them. I heard good things about Lemon and I think ANTLR, which is the standard parser generator in the Java world, is also capable of emitting C, although it is generally considered to emit hacky C. |
Rick Murray (539) 13406 posts |
That’s what C is! ;-) |
Jeffrey Lee (213) 6046 posts |
It wouldn’t surprise me if there are better choices available. I hadn’t really used either of them before; I just naturally gravitated towards “some kind of flex” and “some kind of yacc” since they are/were the de-facto tools of the trade and I knew there’d be a good chance of RISC OS ports being readily available. I also have the red dragon book, which goes into reasonable detail on the usage of flex & yacc, amongst all the other bits that go into (80’s/90’s) compilers. |
Ronald May (387) 407 posts |
For me the broken directory was the scrap folder; I’d recommend setting up a script which sets up a scrap folder and the test files on a ram disc. Maybe the build tools as well if you’re having trouble reproducing the issue (I’d guess the repro rate was around 10%) That is one difference, I have all Scrap activity already in RAM, but it shouldn’t really behave diferently.Unixlib converts /tmp to scrap. The fault maybe something deeper like the unique temp name creation. |
Ronald May (387) 407 posts |
I compiled the flex example.manual directory with the included makefile and found out (once again) that it is only the gcc binary that is aflicted. An easy fix is to use a question mark to wildcard the first dot.One thing, Using norcroft style directories (standard !GCC fare) you will have to specify the output names to less than 3 stage names. default lexx.yy.c style wont work. *make
Then gcc finds the files and there is no need to specify the outputs for flex or bison. I think the file I modified to fix gcc is
and it could work for the standard build of !GCC also, I haven’t tried it, I am still waiting to see if it breaks anything. Nothing so far. |
Ronald May (387) 407 posts |
Steffen said I heard good things about LemonThe debian package seems to be inside sqlite3, so I found an alternative clone, Lemon++ It is only dependant on some Boost headers. I can report that I built the binary and the examples without a single error in !GCC. Must have some c++ magic, it didn’t need to link to the Boost library. |
David Boddie (1934) 222 posts |
I just thought I’d dump this link to Writing a BBC BASIC compiler for the CLR in case someone gets something useful from the discussion there, or perhaps wants to chase up the author for hints and tips. :-) |