My dream of writing a programming language that uses virtually no whitespace and as little symbols as possible is coming true.
I have been playing around with the syntax a bit and found something to my liking. I will post a snippet of what I already have implemented and working in code, as well as a snippet of how I envision the larger syntax to look. It will look very similar to TGRK. TGRK was made the way it was for a very specific application. I think PGRK will be more universal.
Once I have it fully written in Python, I plan on writing it again in C.
On my Github, the original GORK programming language I started, I had the same concepts in mind that I wanted to accomplish, and was making some good progress on it, but, at the time, my knowledge of C was very limited. This was the second small project I was attempting after starting to learn C. So I ended up setting it aside, and started with MGRK, then that was too much, so moved on to SMGRK, which eventually turned into TGRK.
Enough history, I will get those code snippets.
The following piece of code will interpret and execute with the code I have running now, in any of the following whitespace configurations. Programming on a tiny device with a tiny screen, having the shortest possible keyword names as well as the ability to reduce whitespace to a minimum is a plus. Have you ever tried to read a large code page on a small screen? It is very frustrating.
On the Pico Picow, the line widths will be fixed to a maximum of 16 characters wide. There are several reasons for this. At this point I don't think I want to enable any wrapping, or having any text reach off the screen. The point is to have it all visible, and miniaturized enough that a lot can fit on that 16x8 character page.
0K20248K30O$Its December$, 8K,$th$, 0KI1KO1K 0K 2024 8K 30 O $Its December$, 8K,$th$, 0K I 1K O 1K
What we have here is basic KEYWORD (variable) storage and retrieval, as well as some input and output.
Executed in the Python REPL, it outputs the following message, offers the user input which stores in the 1K KEYWORD, then outputs the message the user entered.
Creating and assigning a KEYWORD is done with "<n>K<value>" n can be any number from 0-99, and the value formats are as following:
An integer or float immediately following the K, or with any amount of whitespace between:
3K2045 3K 0 3K 72 3K 2.4928 3K 42
The above are all valid. A string is created by using the $ symbol instead of quotes. It just made sense to do this.
12K $This is a string.$ 12K $ This is another string. We can format however we want. $
Input will be like Python's input() function, which is completely blocking and can be typed into until the enter button is pressed. In PGRK, the input keyword is a single "I", immediately followed by the keyword we are storing the entered string into. I plan on adding keywords for getting individual keys and button presses for the Pico Picow, but as I am wanting to make a command line interface first, this will be helpful.
I 1K
The above takes input and stores it in the 1K keyword. It's that simple.
Output is even funnier! Output is done with a single "O" followed by the data we want to send out. On the Pico Picow, this means it will be getting sent to a function that displays it on the OLED display. But for testing, it gets printed to the python command line.
Output one value:
O123
Output two values, if there are more than one value to be sent out, they are separated by a comma. I was thinking about how I may or may not want to have spaces between these values. EASY. If you want a space, just add it after the comma. Adding more than one space will not add extra spaces. But if you don't want a space, don't add one and the data is contiguous.
O $Hell$,0
Output with spaces, also visualized how It would look trying to enter something that long on a small screen.
OK3 1K2 O $Only$, OK, $d ays$, $until$, $ January,$, 1K O $Only$, OK, $days$, $until$, $January,$, 1K
There is no need to tell the interpreter to stop outputting the data. Once it reaches the last comma, it puts out the last value and passes the program pointer back to the main interpreter.
The above is what I have gotten working so far. Below are some concepts of how the rest of the syntax and functionality will look.
KEYWORDS:
- <n>K<value> = general purpose reusable keywords. As explained above can handle various data types. Assigning any value to them is done by calling the KEYWORD, followed by the data we want to assign. Whether it be another keyword, or other data. Copy value of 2K into 0K: [ 0K2K ]They will also be available to be used as arrays. Just make a regular keyword with a first value, then follow it with commas like with the Output: [ 1K 20,40,60,80,100 ]. I have not implemented this, and am not sure how calling it would look. Maybe if we want to get the 3rd element we would do something like: [ 1K3? ], then to assign to that index: [ 1K3?<value> ]... We'll see.
- G<n> = Groups (functions). Are initialized with the "G", then their number, then the @ symbol followed by its code block, ending with another @ symbol. This is basically identical to TGRK. An example, [ G0 @ <group code> @ ] then called with its name [ G0 ]. There is no passing of parameters, as all KEYWORDS are global. A keyword that is specific to a group is the "LG" keyword...
- LG = Loop Group. When this Keyword is called, it scrolls the program pointer back to the start of the groups code block.
- L = Loop. This is a regular loop. Just like in TGRK. When it is called, it will move the program counter backwards until it hits a SEPERATOR symbol, or a group block symbol "@". I may rename it to R for REWIND... That brings us to our conditional operators, because without a condition, a loop will most likely be infinite.
- > Greater Than, the following example checks if the following comparison is true, and if not skips forward until it hits a separator or group block symbol [0K1000 : > 0K100 0K-1 O0K L: ] Using the ":" symbol as a separator, this will check if the 0K Keyword is greater than 100, if so, subtract one, output the new number, then repeat. Once it is down to 99, it skips past the separator and the program counter goes on it's merry way. All other comparison operators work in the same format as above.
- < Less Than
- >= Greater or equal than
- <= Less than or equal to
- = Equal to......................................Assignments never use the equals signs in the GORK family, so we can use it for comparisons.
- ! Not equal to
- & AND(for combining comparisons, not bit manipulation)
- ? OR (for combining comparisons, not bit manipulation)
- : SEPERATOR. I was thinking of using the period symbol, but then realized if we were placing a floating point number in there somewhere, the interpreter could get confused along the way. So for now the ":" it is.
- MATH OPERATORS
- + Adding in PGRK is like in TGRK. We just bring up the KEYWORD we want to add to and then ad to it [ 0K+1 ]. This format is used for all the operators.
- - Subtract
- * Multiply
- / Divide
- % Modulus
- ^ Exponent
- ~ Random
There will be a lot of built in functions specific to the Pico Picow device, such as wifi handling, etc. various command line builtins that will be specific to controlling the hardware.
That's about all I have right now, have a happy new year and until next time!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.