![]() |
Forum Index : Microcontroller and PC projects : CMM1/2: Programmatic manipulation of MMBasic
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi folks, As part of the task of automating the creation of a CMM1 version of my Z-machine from the CMM2 source code I will need a tool or tools to: 1. Merge in all #Included files 2. Conditionally include/exclude sections of code 3. Shorten the names of variables, functions and subroutines 4. Discard all unnecessary comments and other whitespace If necessary I can write this all myself, hopefully in MMBasic, failing that in Python. However if there is existing code I can beg or borrow for some or all of this then that would make my life easier. I've already found: http://www.fruitoftheshed.com/MMBasic.MMBasic-Source-Compression-Utility-CRUNCH-bas-v2-4-part-of-the-original-MMBasic-library.ashx?HL=crunch Is there anything else I should be aware of? Regards, Tom Edited 2020-06-13 02:11 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
This post has details of an addition I have used on MMEdit. It probably won't work with the latest version 4.0 MMedit as help files have changed, but OK with 3.8 versions. MMReplace MMedit will merge include files. The MMReplace addon gives the #REPLACE directive allowing replacement of variable names etc with shorted ones at load time. The #LIBRARYSTART #LIBRARYEND directives can be used to exclude code from loading.I think I also allowed /* */ block comments as well. MMEdit can be set to remove comments, white space. You would need to edit your code in MMEdit and upload each time. May or may not be suitable. Reguards Gerry Latest F4 Latest H7 FotS |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Thanks Gerry, Looks cool, but unfortunately as it currently is it doesn't fit into my Windows-free toolchain. Looks like you distribute the source, so I could try and port it to MMBasic, any gotchas you'd like to warn me about before I look into that further? Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
None I know of. MMBasic string length limitations would mean it needs a fair bit of rework, as PureBasic lets me put big strings/files into memory and process them there. Latest F4 Latest H7 FotS |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
If you are willing to stoop to 'wine', MMEdit and very probably MMReplace work under wine OK. Gerry, I think that MMReplace will still work with the V4x of MMEdit. If not, I should be able to tweak things for you. The changes to syntax files are not too much of a handicap to you either. Now that I am using PB to do the variable report, I will reconsider the option to reduce variable names. No promises. Jim VK7JH MMedit |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Thanks Jim, but I'm running on a Pi and AFAIK Wine does not run on ARM. No worries, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
This is probably directed at Peter or Jim, but does anyone have a list of CMM2 MMBasic keywords to hand so I don't have to construct one myself from the manual? Thanks in advance, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
LIST COMMANDS LIST FUNCTIONS |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Keywords you can get from LIST COMMANDS and LIST FUNCTIONS The lists don't include the parameters for the various commands. This list does include many of the parameters but also includes keywords for all devices, not just the CMM2 allKeywords.zip Hope that helps a bit. Jim VK7JH MMedit |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Or in other words RTFM ![]() I'm waiting a couple of months before printing a copy to obsessively read. Thanks, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
I'm waiting a couple of months before printing a copy to obsessively read. Tom I think quite a few of us are waiting for the dust to settle so to speak before we put printer ink/toner to paper. I know I am. @ Jim, what do we open the allkeywords.TKN file with? Edited 2020-06-21 18:26 by Chopperp ChopperP |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
@ Jim, what do we open the allkeywords.TKN file with? It's just a text file VK7JH MMedit |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
OK. One long continuous list to sort out. Edit. Thinking about the list. You sure have put a fair bit of time & effort into MMEdit. Much appreciated. Thanks. Edited 2020-06-21 20:30 by Chopperp ChopperP |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Much appreciated. Thanks. 9 years. Not as long as Geoff VK7JH MMedit |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
You're too modest. BTW, the CMM2 was/is a great team effort. Looking forward to more MMEdit updates. Brian ChopperP |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
allKeywords.zip Hope that helps a bit. Jim That's neat and just what I need to write a lexer/tokenizer to run on the CMM itself. Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi Jim, Hopefully you don't mind a couple of follow up questions to help me out with my tokenizer: 1. What's the distinction between the 3 lists that file contains: - List 1: looks like keywords - List 2: I'm guessing is the "constant" parameter values used for some commands/functions though I'm not sure why the VAR from PEEK/POKE is in the first list but for example BLACK is in the second ... I guess BASIC syntax can be a little heterogenous sometimes. - List 3: I haven't a clue. 2. Why the need for 3 variants in some cases, for example mid, mid$, mid$( ? Not sure if it is helpful but I notice the following appear twice in the .tkn file, and those marked * appear twice in the same list: select * case * tempr * start * gps append autorun base baudrate bitmap calibrate * copy default disable * explicit float hide * image integer interrupt * mp3 none pullup * show * write * Regards, Tom Edited 2020-06-22 06:39 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Hopefully you don't mind a couple of follow up questions to help me out with my tokenizer: 1. What's the distinction between the 3 lists that file contains: - List 1: looks like keywords - List 2: I'm guessing is the "constant" parameter values used for some commands/functions though I'm not sure why the VAR from PEEK/POKE is in the first list but for example BLACK is in the second ... I guess BASIC syntax can be a little heterogenous sometimes. - List 3: I haven't a clue. 2. Why the need for 3 variants in some cases, for example mid, mid$, mid$( ? Regards, Tom The list is a compilation of many different lists. one for each variant of 'mite. There is a lot of manual checking but it still needs more. Having duplicates doesn't worry my programs so it's not a high priority. More important to add missing words. Ideally, the 3 sections will end up as different colours in the editor. That's a future aim and for now there is no practical difference although I have been adding keywords to the first list. mid, mid$, mid$( is needed so that as the user enters a variable, he/she is warned that they have entered a keyword as soon as the first part is entered. If the list only had the full mid$(, an illegal use of MID as a variable would not be noticed. It depends on the lexicon used for the editor. When it comes to parameters, things get difficult. It is legal to use LENGTH or FLOAT as variables or user function names but I would prefer them to be flagged as keywords. In general, I have excluded any parameter that is one or two letters long but there are dozens more I could add. Thank you for the list of duplicates. I will update my file. Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |