Location: JBPLAY \ JBPlay.com General \ General \ Strolang Back to Threads |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
24 September 2015 20:58 (UK time)
Strolang After getting intrigued by and reading lot about theory of computation/automaton theory/compiler design for months, I felt a nagging itch to get active and start coding something up in practice. I made it my goal to create my own script/programming language, and implement an interpreter, and eventually perhaps even a compiler for it. That's when I came up with this project: Strolang. And so, the last few months I've been spending lots 'n' lots of spare time coding on up a strolang engine (masuda and spy can confirm this ![]() Strolang, at the moment (I'm kinda deciding the syntax bit by bit as I go), is a very c-like language, because I wanted to create a basic, non-specific, turing complete groundwork that I can safely extend upon later. There are not that many features as of yet however. In fact, it's still missing a ton of essential language construct and interpreter features - such as arrays, for loops, arithmetical brackets, and perhaps most importantly, a semantic analyzer (which in human language basically means: it won't check if the grammatically correct stuff you wrote actually makes sense too) is completely non-existent, and thus it'll happily crash to any nonsense. But this is all planned! My own view on the quality of this first public version is that it's the first version that is not a complete and total abomination. ![]() So without further ado, here's strolang /path/to/program.strol (the extension doesn't really matter, but .strol is the officialish file extension for strolang source files ![]() // single line A program is simply a set of function definitions. That means that at the absolute top level, nothing except for function definitions is allowed. So no includes, or global vars etc (yet). The entry point that the engine will look for is the function ) There are 2 types of functions: internal and external. Usually you'll be writing internal functions, they have a header and a body block. void function(int argument) { An external function - though not really applicable yet as of now, since you there's no way to bind libraries yet - only has a header and a reference to an api id, and is written like so (and notice the semicolon here): void function(int argument) -> some_api; A block (such as the internal function bodies) is a list of statements surrounded by curly brackets. Any statement that is not a nested block must end with a semicolon. { statement; statement{} statement; } A statement can be either of the following: - A function call : awesome(); As of now, the if and while MUST have a block. There's no single statement version yet. An expression can be a variable reference, a literal, a function call, an assignment, or an operation. The following types are supported and work pretty much as you'd expect: bool val = false; ... and a function can also have the special type "void". The following operators are supported so far (some of them have extra secondary functions, such as + for concatenating strings, but that's a topic on it's own that I'll write about in the more elaborate docs ![]() Arithmetic : + - * / % And finally: right now, there is one hardcoded simple barebones api for io. And keep in mind that these functions ONLY work for strings thus far, I'm fully aware that that's a major hindrance, but hey... it's v0.1. ![]() string in() Okay, I might've forgot to mention a few things, but that's basically it so far. Happy coding!! (well, mainly bug reporting) ![]() ![]()
Edited: 24 September 2015 21:21 You need to login to create posts in this thread. |
Spy
![]() Joined: 05 October 2007 Posts: 1031 |
24 September 2015 21:20 (UK time)
STROL! ![]() For the record, the term "strol" was coined by me somewhere around 2009. I, for some reason (probably boredom), started repeating the phrase "trol, roll and strol" in school and it sort of got stuck in my head, so then when I logged in on IRC and on #jbgames (or #jbplay, can't remember what the heck it was lol), I typed it in there too. Eventually it just became an inside joke that has lasted up to this day, and it eventually (sort of) developed a meaning as well, although it's somewhat difficult to describe. Something like silly, erratic and/or parodic behavior would come pretty close, I guess. ![]()
You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
24 September 2015 21:22 (UK time)
![]() Well, here's my first program in Strolang then! ![]() ![]() ![]() //hotarun.strol
Edited: 08 February 2022 06:26 You need to login to create posts in this thread. |
me_mantis
![]() Joined: 26 September 2003 Posts: 1152 |
14 October 2015 22:06 (UK time)
This seems cool even though I have no idea what I'd do with it! Cheers! You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
17 October 2015 08:16 (UK time)
Another epic masterpiece for use with strolang 0.2 ![]() //sosuns.strol And an updated ver of hotarunify enhanced with strolang 0.2 features //hotarun.strol And finally testing arrays and elif //array.strol
Edited: 17 October 2015 13:03 You need to login to create posts in this thread. |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
18 October 2015 00:14 (UK time)
^ awesome, these all work great in the latest alpha I just built. ![]() It's-a comin' soon...! ![]()
You need to login to create posts in this thread. |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
19 October 2015 23:20 (UK time)
Strolang 0.2 Konochan aka: the array version Well, here it is! This version is a lot cooler than the previous one. You can actually, like do things with it. Grab it here. Now, what's new? Arrays Aha! Konochan's creme de la creme new feature. Here's a little demo of how arrays work in Strolang. It's a bit non-standard, but not that much. int[] arr = int{2, 4, 6, 8, 10}; is not supported, yet. string[] fruits = string{"apples", "oranges", "grapes", "prickly pears", "durians"}; if(1 + 1 == 2) out("Good thing math still works!"); else out("WE'RE ALL GONNA DIE!!"); if(a) unless(1 + 1 != 2) out("1 + 1 is still none other than 2!"); while(1 == 1) { 1 + 2 * 3 == 7 2 ** 3 == 8 a += b a !& b // nand "123"->int == 123 There's a lot more where that came from, but I'm not gonna be listing all of them. You get the idea. ![]() main arguments While in Hotarun there was the function int main() as the entry point, Konochan looks for int main(string[]). The string array contains the arguments passed from the command line. I couldn't add this previously, because there was no such thing as an array yet. ![]() int main(string[] args) { Meanwhile on the command line... strolang argsdemo.strol one two three And that is all for now. Once again, have fun coding some strol programs. ![]()
Edited: 19 October 2015 23:41 You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
21 October 2015 12:54 (UK time)
First actually useful program written in strolang 0.2.1! A BrainFuck interpreter. ![]() //bf.strol Alternatively you can also pipe a brainfuck source like this: strolang bf.strol < brainfuck.src
Edited: 21 October 2015 15:03 You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
03 November 2015 12:42 (UK time)
And now something that even non-programmers can use! A game of 21 ![]() //21.strol
Edited: 03 November 2015 13:13 You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
15 December 2015 18:02 (UK time)
This time I made a simple mandelbrot set. ![]() . . And here's the code for it: //fractal.strol There's also a much better looking fractal I made in Javascript attached to this post. Feel free to check it out. ![]()
You need to login to create posts in this thread. |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
15 December 2015 19:56 (UK time)
Very cool one - and thanks for the two bug reports you dug up while making this one ![]() After a short hiatus I've picked up the work on strolang again a couple weeks ago. It's coming along fine, and seeing as how it's going to contain a few more advanced features as well as how the code health has been vastly improved compared to 0.2 I have a feeling it's gonna be an awesome version... stay tuned! ![]() ![]() ![]() EDIT: oh yea, I forgot to publicly release that 0.2.1 version from way back. Not gonna bother making a big announcement over it, it was made solely for supporting masuda's brainfuck interpreter, so you'll need it if you wanna run that one. From the yet unreleased changelog: v0.2.1 Konochan+ Get it in the attachment below.
Edited: 07 February 2016 17:15 You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
07 February 2016 17:39 (UK time)
A strol little program to 'welshify' a given text (according to Para's specifications ![]() Y sstrol llitttle prryggrram tto 'wellshiffyy' y ggivyn ttexxtt (yccccyrddynng tto PPyrry'ss speccyffycytionss ![]() //welshifier.strol
Edited: 07 February 2016 17:40 You need to login to create posts in this thread. |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
07 February 2016 19:01 (UK time)
Strolang 0.3 Honokachin aka: the expressive version It's been a while, but here it finally is. This version has had a huge focus on internal refactoring (especially on the implementation of arrays and operators), but there are quite a few new features and fixes as well, some of them being extremely useful. Snatch it here. Okay, here's what's new. )... 42 // decimal ) 123_456_789 \n = newline int first, second, third; 0b101100 << 2 == 0b10110000 // left bitshift int[][] twodim = int[]{ ) has two new useful functions: explode and join. This replaces the string to char[] and char[] to string conversions from 0.2.1. explode("strol") == char{'s', 't', 'r', 'o', 'l'} outln(true); // true 42 == 42.0 0 || "" == false -> Alrighty, well I'm fully aware that my "documentation" on all this is kinda wonky so far, I'll try to do something about that in the next version maybe. For now, if you got questions, don't be afraid to ask. Happy coding boys! ![]()
Edited: 07 February 2016 23:35 You need to login to create posts in this thread. |
nyasudah![]()
Joined: 06 February 2005 Posts: 832 |
07 February 2016 19:52 (UK time)
All the strols so far updated to strolang 0.3
You need to login to create posts in this thread. |
ParaSait
![]() Joined: 26 June 2007 Posts: 1478 |
08 February 2016 00:03 (UK time)
Here's a new one written by me. It's a little hangman game. It took 20 minutes to code, and 30 to find one little bug. ![]() EDIT: It's still a bit bugged on the whole game over thing but whatever. Feel free to fix and mod edit the code P. ![]() MOD: it should work now //masuda // hangman.strol
Edited: 08 February 2016 01:23 You need to login to create posts in this thread. |
|
Forums system (C) 1999-2023 by James Bunting.
Terms of Use