|
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 ). And now, I am about to proudly release a first version of it to the (small) public.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 0.1.4 Hotarun, download it from the attachment! No formal documentation is included yet, so I'll just give you a quick explanation in this thread. Happy coding, and please post any cool (and also buggy!) programs. Any feedback is naturally appreciated. Oh, and also, if someone feels like creating a Strolang syntax highlight configuration for any text editor, like Notepad++ or something, please please do! I'll gladly send you the list of tokens in that case! ![]() How to use First off, here's how to install and run the engine. It's really simple. 1) Make sure Java 8 is installed. 2) Unzip the release somewhere. (and make sure you don't merge a new version with an old one, it will give problems...) 3) Add the directory to your PATH. 4) On unix, make sure strolang/strolang.sh are marked as executable. 5) Open your console and enter the command "strolang". It should work for both unix and windows. As soon as you run it, you'll be given some useful further information, but basically, to run a program just pass the path to your program as the parameter. strolang /path/to/program.strol (the extension doesn't really matter, but .strol is the officialish file extension for strolang source files )Syntax (as of v0.1 Hotarun) Keep in mind, this is all more or less c-like. It'll probably not all that unfamiliar if you ever coded in c. Comments take the form of // 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 int main(), with NO arguments (it's gonna be a string array in later versions for params, but right now it's nothing because there are no arrays yet in the language! )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 ). They also work pretty much as you'd expect.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! It's pretty much just a random mess, but it works! So here, take a look. ![]() //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? Features 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};for loops An essential language feature that goes hand in hand with arrays. It's the classic for loop that takes an initializer, a loop condition and an iterator, separated by a semicolon. Enhanced for (aka "foreach" is not supported, yet.string[] fruits = string{"apples", "oranges", "grapes", "prickly pears", "durians"};Single statement structures In Hotarun, if and while structures only took blocks as their body, even if you want it to do only one thing. In Konochan you can attach either a block or a single statement to structures. if(1 + 1 == 2) out("Good thing math still works!"); else out("WE'RE ALL GONNA DIE!!");elif/else clauses In Hotarun there was only an if statement. An if statement can now also take elif and else clauses. You can tack on as many elifs as you want, as long as they're between if and else, and else is optional. Elif is a shorthand for "else if", which is also fine to use. if(a) unless/until structures These are the dark twin brothers of if and while. They work in the same way, but the value of their condition is negated. One other notable difference, though, is that unless does not take elif clauses (but does optionally take an else clause). unless(1 + 1 != 2) out("1 + 1 is still none other than 2!");break/continue statements Control statements for loops (works for while, until and for). break will end the execution of the loop and get out before the loop condition is satisfied. continue will end the execution of the loop's current iteration and go on to the next one. while(1 == 1) {Brackets The brackets that your know from math class, to be explicit about your precedence. 1 + 2 * 3 == 7 New arithmetic operators Strolang now features the power operator, as well it's counterpart, the (unique!) root operator. Do you know any other programming language with a root operator? Yeah, didn't think so. 2 ** 3 == 8 Arithmetic assignments These are just the little shorthands of the general form (a = a <op> b) <=> (a <op>= b). There's one for each kind of arithmetic operation. Pretty straightforward and nothing unique ('cept for the root variation). a += b New logical operators While Hotarun already featured the basic and/or/not operators, Konochan also features the pretty unique nand/nor/xor/xnor. Xor and xnor are almost the same thing as != and ==; the only difference is slightly higher operator precedence (same level as the other logical operators), as well as being a more clear expression of your intent in some situations. a !& b // nand Conversion operator Unique to Strolang, it's comparable to typecasting in other languages, but it's a bit smarter. It converts values to another type. How this conversion goes varies on a case by case basis. Note that Konochan can NOT convert to and/or from arrays yet. This will be added in the future, though. "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. ![]() Extended standard library It contains some more essential functions. Refer to the apidoc.txt file for more information. 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 ) for strolang 0.3Y sstrol llitttle prryggrram tto 'wellshiffyy' y ggivyn ttexxtt (yccccyrddynng tto PPyrry'ss speccyffycytionss D) ffyrr ssttrryllyng 0.3//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. Alternate number systems for int literals Prior to this version, integer values could only be expressed in the decimal number system. Now, they can also be written in binary, octal and hexadecimal. The notations for these conform to the c convention (I experimented with some rebellious new notations at first, but trust me, it sucked )...42 // decimal Underscores in int and dec literals This is a bit of syntactic sugar. In int and dec literals you can now write _'s anywhere. This doesn't mean anything to the interpreter, it's just there to improve the readability of long numbers for your own convenience. (note: just don't put an underscore as the first character, since that will make it a variable name by definition )123_456_789 Escape sequences in char/string literals You can now use escape sequences in chars and strings. This allows you to express characters that wouldn't otherwise be easily expressable: \n = newline Declaring multiple variables in a single statement You can declare multiple variables of the same type in a single statement by separating the list of names (and their optional initializer) by commas. int first, second, third; Bitwise operators Aside from the logical operators, you can now use bitwise operators. For now, these only work on integers though. Most of these operators once again are from c, but there are a couple unique Strolang ones as well. They have assignment versions too! Note: it's relevant to say at this point that integers are 32bit in Strolang. 0b101100 << 2 == 0b10110000 // left bitshift Multidimensional arrays Prior to this version, array could have only 1 dimension. Now they can have pretty much as many as you fancy. int[][] twodim = int[]{explode and join functions The basic api (I guess we can start calling it a bit of a standard library at this point ) 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'}Alternate argument types for out/outln/err/errln These functions now also take arguments that aren't strings, or in the case of the -ln functions, no argument at all. outln(true); // true Comparing ints to decs This wasn't possible in previous versions. 42 == 42.0 Truthy and falsey Logical operators and conditional statements can now handle non-boolean expressions. It checks if the value is "truthy" or "falsey". For example, 0 is falsey, and another integer is truthy, an empty string is falsey, a non-empty string is truthy, ... 0 || "" == false c/java style operator precedence Operator precedence was a little messed up in previous versions. I've made it more c/java-like now, so you don't need to write so many brackets anymore. -> 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. (I definitely need to make debugging Strolang programs easier in the next version lol)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-2026 by James Bunting.
Terms of Use