matthew180 Posted November 21, 2010 Share Posted November 21, 2010 (edited) When the game contests started up around here again I was thinking of making an entry, but then remembered all the reasons I dislike BASIC and XB (besides how slow they are.) No indentation, no labels, comments that eat up memory, etc. I've wanted to make a new language for our beloved 99/4A for a long time, but alas that is just another project out of many on the list. However, in lieu of a new language, I figured it would be easy enough to add some of those features via a "translator". You would still code with BASIC, but without line numbers and such, then the translator would trim out spaces and remarks, add the line numbers, and spit out the code to copy and paste into Classic99. I wrote the guts of it last night with these features: * No line numbers allowed, they will be assigned * Labels can consist of A-Z, a-z, 0-9, _, and -. They can be any length, but a maximum line length is 256 characters. Label "definitions" must start a line and end with a single colon. Labels can be referenced any place a line number can be used, currently: THEN, ELSE, [ON]GOTO, [ON]GOSUB, and ON ERROR. * Comments are stripped from the code. Comments are any line that start with REM or // (C/C++ style single line comment notation). XB also has a "trailing comment" designated by a ! that causes the rest of the line to be ignored. These comments will be stripped as well. * Leading space is ignored so you can indent as much as you like. * Long lines can be split by ending a line with .. (two consecutive periods). These lines will be joined into one long line and the XB limit of 140 characters will be checked. * Starting line numbers and the increment can be set. Features I was thinking of adding: * Support multiple source files. Currently the translator is written in PHP, which makes it conducive to being set up on a webpage. However, that might make development cumbersome, so I was thinking of making it a native Windows app. I'd like to hear opinions either way. This post will always have the latest code. CHANGE LOG: V1.0 November 20, 2010 * Initial release V1.1 February 13, 2011 * Added forced line number override. * Fixed label bug. * Fixed max line number bug. * Change REM statements to be included in output code. V1.2 February 25, 2011 * Added the missing RESTORE, BREAK, and UNBREAK commands / statements to the list of tokens that support a line number or list of line numbers. V1.3 Feb 26, 2011 * Fixed REM and ! comments. V2.0 March 16, 2015 * Fixed using RETURN in an error context when used in an IF/THEN/ELSE statement, i.e. IF exp THEN RETURN <label>. * Added additional support for the other ON <statement> (BREAK, ERROR, etc.) commands that can accept a line-number list. * Added a version number to keep track of updates. * Added a readme.txt with instructions on how to use TidBit on the command line or with PHP's built-in web server. * Removed requirement to have .. after the XB :: operator * Added ENDIF pseudo statement V2.1 June 25, 2016 * Removed requirement to have .. after THEN or ELSE statements, or after the last expression before an ELSE statement. * Prevent the keyword 'PRINT' from being used as a label to avoid possible errors due to the BASIC use of the colon with a print statement: 'PRINT: :' V2.2 September 10, 2016 * Added more debug statements. * Added check to not allow the auto line number from being overwritten by a forced line number if the forced line number is less than the current auto line number. This prevents accidental loss of code. V3.0 September 13, 2016 * Simplified parser stage. Being less-smart reduces errors. * Added list of reserved words to avoid label confusion. * Fixed bugs in expression parsing with embedded strings. * Fixed string parsing bug with escaped double quotes. * Fixed XB ! comments that were along on a line. * Fixed XB :: operator when following PRINT or DISPLAY AT with colon options. V3.1 November 17, 2019 * Fixed incorrect parsing of the double-colon (::) when it was used immediately following a label. * Syntax cleanup and comment improvements. tidbit_v3.0.zip tidbit_v31.zip Edited November 18, 2019 by matthew180 New updates 1 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.