You are not logged in.

#1 2006-06-16 16:58:48

cmp
Member
Registered: 2005-01-03
Posts: 350

my little pet project - a scripting language

Well I'm kind of proud of this project, because it's only 700 loc, took only 2 afternoons to implement and is yet semi usefull. While you could not write an entire application in it and it's bugy as hell, the most important parts are there:

· import and usage of python modules
· blocks (kind of lambdas)
· scopes and variables

It is actually an experiment to test how far you can push a language with only infix operators, so there is no real function invocation but only infix operators (hence the name infix), to call a function you would apply it to a tuple:

do_sth % ( a , b , c )

And the tuple creating part "( a , b , c )" is not built into the language but rather using the tuple creation operator ",".

There are only 4 preused characters (){}. () are used to create some kind of precedenc in expression evaluation (everything else goes just from left to right) and {} are used to create blocks, which are just expression lists which run in a scope and return the result of the last expression in them.
Every function / variable name is freeformed and may use any non-whitespace-characters.

As I said it's a pure experiment, but still kind of fun:

__scope__ import io
( clone % __scope__ ) => my_scope
io . print => print

{ 
    print % a
    print % b
} => my_block

{ 
    2 => a
    "hello world" => b
} % my_scope

my_block % my_scope

output:

2
hello world

btw. note that the io module is real python module.

Offline

#2 2006-06-16 17:09:03

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: my little pet project - a scripting language

That looks like fun. Links? Using only infix operators is an interesting idea... kind of lispish without the brackets.

no... lispish without the brackets would be whitespace...

Dusty

Offline

#3 2006-06-16 17:25:36

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: my little pet project - a scripting language

Hey! Thats plagiarism of Dustys "my little pet project"-post ;-)

cmp: Looks interesting, even if I don't have too much programing experience..


Haven't been here in a while. Still rocking Arch. smile

Offline

#4 2006-06-17 20:04:35

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: my little pet project - a scripting language

Hm. My implementation has a big flaw. Because every reference is directly looked up and the value is returned, you can't probaly redefine allready defined variables:

2 => a
3 => a

does not work, because in the first time a reference is returned, because a isn't defined, the second time a was defined and it's value is directly returned, so it turns into (3 => 2).
I will rewrite the core tomorrow to return allways references, if I'm not too busy learning math.

btw.: If's and Loops are implemented now.

Offline

#5 2006-06-23 18:15:56

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: my little pet project - a scripting language

Well, that was such a stressfull week, studying physics sucks, but still I managed to do some work on this project:
I rewrote part of the core and allmost the complete builtin library, which is still very unorganized. I will now clean up the core to get it workable in less than 500 lines of code (currently 538).
I fixed the refrence problem, so now stuff like this is working:

__scope__ import io
( io . print ) => print


99 => n

(current in (1 .. (n + 1))) foreach {
    n - current + 1 => current
    str % current => cur_str

    (current > 0) then {
        print % ( cur_str + " bottles of beer on the wall" )
    } else {
        print % "1 bottle of beer on the wall"
    }
}

edit:
so now it's scheme without parenthesis. the core is currently 433 lines of code and I also got a way to create lists, functions and infixes in infix itself. Next I have to think about rewriting as much as possible in infix itself, so I got only the minimal barebone coded in python.

Offline

Board footer

Powered by FluxBB