Jump to content




Nova scripting language


  • You cannot reply to this topic
8 replies to this topic

#1 Exerro

  • Members
  • 801 posts

Posted 12 April 2014 - 11:25 PM

Hi,

I just wrote a small scripting language, and although it is still in development, I thought I would upload it. Its current features are:
  • Completely Lua free interpretter & value assignment
  • If statements
  • While loops
  • Dynamic values
  • Classes
Screenies:
code = output
code = output

To demonstrate how the language works, I will include a small example:
Spoiler

Notes:
  • Only 1 value can be assigned per statement so you can't do "var1, var2 = unpack( { 1, 2 } )" for example.
  • Function calls in variables cannot call other functions with multiple args because it will break the interpretter.
    • print( x( "something" ), "something" ) is ok
    • print( x( "something", "something" ), "something" ) is not ok
  • The error handling system is bad to say the least. It doesn't return line numbers.
  • Classes can have private methods, methods, variables, and static variables
  • Tables can have numerical indexes assigned when created, but not anything else
    • t = { 1, 2, 3 }; is ok
    • t = { [1] = 1, [2] = 2, [3] = 3 }; is not ok
More on classes:
Spoiler

The current code is just under 2000 lines, and is lacking for loops and else/elseif statements, and I honestly probably won't be adding these in any time soon.
Anyway, I hope you can use this, or maybe this will inspire you to attempt making your own version / scripting language.

The String class I made is below:
Spoiler

pastebin get eq2NP9xZ script

Edited by awsumben13, 13 April 2014 - 03:41 PM.


#2 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 14 April 2014 - 07:59 PM

Looks nice! Awesome!

#3 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 19 April 2014 - 01:21 PM

Well.. yeah. But isn't this useless? What are its advantages in comparison to standard Lua ?? I pretty much think u are reinventing the wheel...

#4 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 19 April 2014 - 06:12 PM

View Postviluon, on 19 April 2014 - 01:21 PM, said:

Well.. yeah. But isn't this useless? What are its advantages in comparison to standard Lua ?? I pretty much think u are reinventing the wheel...
If you see it like that, Java would be a "reinvention of the wheel" too, because there was C before it.
One advantage is OOP, ie classes, methods, access declarations... (it's your thing if you say OOP is an advantage or not)
Ok this is a bit raw, but I'm sure it will be very useful when it's finished. Especially for larger Applications some classes would be nice.

Edited by ardera, 19 April 2014 - 06:12 PM.


#5 Yevano

  • Members
  • 376 posts
  • LocationUSA

Posted 19 April 2014 - 06:27 PM

You could improve this greatly by converting the code to tokens before the parsing stage, so that you aren't doing string matching while generating your AST (It's probably why your code looks so big and loopy). As well, you could store line and column numbers in the tokens so that you can give useful line number info with errors.

#6 ElvishJerricco

  • Members
  • 803 posts

Posted 19 April 2014 - 07:48 PM

View Postviluon, on 19 April 2014 - 01:21 PM, said:

Well.. yeah. But isn't this useless? What are its advantages in comparison to standard Lua ?? I pretty much think u are reinventing the wheel...

Lots of things are useless before they're useful. It's a baby. It might not survive to adulthood but for now it's good to keep alive.

Anyway take a look at some of the other language projects out there to get some ideas on how to improve this and fix some of the issues. For example, you're not building your AST quite right if you can't have function calls with several arguments as arguments to function calls, and there's a lot of projects you could look at to help figure it out. LuaLua is one you might be interested in, although it compels to bytecode.

#7 Agoldfish

  • Members
  • 451 posts
  • LocationSome Fish Bowl in Ohio.

Posted 19 April 2014 - 08:52 PM

View PostElvishJerricco, on 19 April 2014 - 07:48 PM, said:

View Postviluon, on 19 April 2014 - 01:21 PM, said:


[shamelessplug]LuaLua is one you might be interested in, although it compels to bytecode.[/shamelessplug]
:P

Edited by Agoldfish, 19 April 2014 - 08:52 PM.


#8 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 20 April 2014 - 02:07 PM

View Postardera, on 19 April 2014 - 06:12 PM, said:

View Postviluon, on 19 April 2014 - 01:21 PM, said:

Well.. yeah. But isn't this useless? What are its advantages in comparison to standard Lua ?? I pretty much think u are reinventing the wheel...
If you see it like that, Java would be a "reinvention of the wheel" too, because there was C before it.
One advantage is OOP, ie classes, methods, access declarations... (it's your thing if you say OOP is an advantage or not)
Ok this is a bit raw, but I'm sure it will be very useful when it's finished. Especially for larger Applications some classes would be nice.

OOP is already possible (and easily implemented) without additional compilers.

http://www.lua.org/pil/16.html

And if I'd like an extension, I'd use http://www.computerc...on-environment/

#9 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 20 April 2014 - 03:07 PM

View Postviluon, on 20 April 2014 - 02:07 PM, said:

OOP is already possible (and easily implemented) without additional compilers.

http://www.lua.org/pil/16.html

And if I'd like an extension, I'd use http://www.computerc...on-environment/
I knew someone would say that :P

There are so many OOP extensions for lua, but I don't like any. Lua is simply not good in this. Lua is meant to be used as a scripting language, and it's far better in scripting than using it for OOP purposes.

Look at "SEE" by Yevano: It's way to import stuff is exactly what I mean, it's done trough comments. In Java, it's done trough language statements because it's optimized for using imports and packages.
Nothing against SEE, sure it's good to have and if I'd have some big projects, I'd be using it, but this is better.



Suggestion:
Static Types?
(This would help debugging a lot, it would be better for foreseeing problems and bugs, and less runtime error's would occur.)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users