Jump to content
  • entries
    13
  • comments
    25
  • views
    634

Syntax Changes


Guest

146 views

I'm one step closer to a final syntax for the language implemented in my 2600 interpreter system, which still doesn't have a name and probably won't for a while. The jist, if you haven't heard from me on [stella], is to have a propgramming system that runs on an unexpanded 2600 that is more advanced / easier to deal with than BASIC Programming.Anyway, today I refined the syntax a little bit more, following some pretty in-depth email discussions, and following some suggestions I'm going with the BEGIN/END block construct. Another thing that was suggested was that I make the code in all lowercase instead of all uppercase, which helps with readability. I'm still undecided on that one, and thus today's new sample program will be in all uppercase, purely hypothetically.

PROGBEGIN SUB FIN   DISP 'DONE'ENDREAD KEYBEGIN IF KEY = 8   DISP KEY: ELSE CALL FINENDENDP

I've figured that this can be tokenized into 33 bytes of RAM. The only statement here that may not be needed in a tokenized format is the PROG declaration and its corresponding ENDP declaration. These are just there for the parser, so it's simplified by being told explicitly where the program starts and where the program ends. READ reads an input from the Atari Keypad, and stores it to a variable. Variables have names up to three characters long, which seems like a nightmare but hey, it saves RAM and realistically, are you going to need more than 27 variables within a program when it only has 48 to 64 bytes of memory? Subroutine names are the same way, three characters. These may later be extended to four characters, but it might not be possible.The BEGIN/END block construct also simplifies things for the parser. A block can either be an if/then statement, a FOR loop, or a subroutine. the basic format for an if/then block is this:

BEGIN IF (condition)   (code):ELSE (code)END

where condition is an equality statement between two variables, a variable and an integer, or a variable and an integer arithmetic expression (which may contain a variable). The code to be executed if the statement is true may be up to two statements long, with statements separated by a colon. The ELSE statement contains the code to be executed if the condition is not met. END should be self-explanitory.A FOR loop will look like this:

BEGIN FOR (loop variable)=(lowerbound),(upperbound)   (expression involving loop variable):NEXT (loop variable)END

Anyone who is familiar with the BASIC language should know what this code is up to.The last type of BEGIN/END code block is the subroutine.

BEGIN SUB (subroutine name)  (code)END

That should be pretty self-explanitory as well. The only thing to remember here is that a subroutine should probably be defined before it is called... although this probably wouldnt matter as the interpreter has to tokenize the code before running it anyway. Nevermind that.That's all for now... I'll update the blog as things develop.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...