• Scripter : My go at a language made in Lua.
    40 replies, posted
[Release] [IMG]https://lh5.googleusercontent.com/-GiZeJ7z1t4Y/TzFgjSK_dhI/AAAAAAAAAFY/13R58YiVhbo/s560/Scripter2.png[/IMG] Hello. In this post I am going to present to you my go at a language made in Lua. Before any of you go porting Advance Duplicator into my new language, Please consider 2 things : 1- You would need to port all the libraries yourself, and 2- It's not the most efficient language. I made this as a project, as to prove to myself that if I can put my mind to it, I can do moderately interesting things. Without further ado, let's get on with the presentation. [B]Scripter![/B] Scripter is a language, conceived with Lua, to aid developers in making quick scripts. It has a customizable syntax, which is perfect for people wanting to make different "dialects" of this language. It's in it's early stages, so don't expect anything big from this, but for what it's worth it's pretty good. It currently supports a a small range of features, but I'm sure you can find that out in due time. It is centralized around a stack, which has its pro's and con's. [B]How does it work?[/B] I'm pretty crap at explaining with words, so I got on paint and drew a picture instead. [IMG]https://lh3.googleusercontent.com/--uWc14BiIR4/TzEnOPhNCrI/AAAAAAAAAEg/ypVnQjnCA5U/w719-h358-k/Scripter.png[/IMG] [B]Examples of work[/B] [table="width: 500"] [tr] [td][CODE]Vector ( 1 , 2 , 3 ) Pop MyVector MyVector::Print[/CODE][/td] [td][CODE]LocalPlayer ( ) Pop Me Me :: Name Pop MyName print ( MyName )[/CODE][/td] [td][CODE]_G ( ) Pop Variables PrintTable ( Variables )[/CODE][/td] [/tr] [/table] You can also call functions from Lua [table="width: 500"] [tr] [td][Lua]Scripter:Push( "My String" ) Scripter:Push( "print" ) Scripter:Call( 0 )[/Lua][/td] [td][Lua]Scripter:AddGlobal( "Var" , "Variable" )[/Lua][/td] [td][Lua]Scripter:AddMetaFunction( "Vector" , "Foo" , function( self ) print ( "foo was called" , self ) end[/Lua][/td] [/tr] [/table] [B]Functions:[/B] [CODE]Scripter:Run( String, debug ) -- Run a string, with a debug paramater Scripter:NewDataType( Name , ID ) -- Permits new datatypes Scripter:AddGlobal( Name, Object , deletable ) -- Set Global Scripter:AddGlobalCustomType( Type, Name, Object , deletable ) -- Set global with type ( custom detatypes ) Scripter:RemoveGlobal( Name ) -- Delete Global Scripter:GetGlobal( Name ) -- Get Global ( returns table { TYPE , VAR } ) Scripter:GlobalType( Name ) -- Gets the type ( number or String ) Scripter:AddMetaFunction( DATATYPE , Name, Function ) -- Meta Functions Scripter:GetMeta( Datatype ) -- for metatables Scripter:GetMetaFunction( DataType , Name ) -- ditto Scripter:Push( Object ) -- Push onto stack Scripter:Pop( ) -- get top of stack Scripter:Ghost( Amount ) -- get top of stack without removing Scripter:WholeStack( ) -- pop the whole stack Scripter:EmptyStack( ) -- empty the stack Scripter:GhostStack( ) -- Get the stack without popping Scripter:StackSize( ) -- Amount of items on stack Scripter:Call( Amount ) -- Call a function , last string pushed is the name of the function Scripter:CheckType( Argument, Enum ) -- Check type ( outdated ) Scripter:SetPreTokenizeFunction( Function ) -- Like gm_preproc but worse Scripter:InvalidatePreTokenizeFunction( ) -- remove the protokenize function that's set Scripter:Tokenize( String ) -- Returns a preliminary interpretation Scripter:AddToken( Token , ID ) -- Custom tokens Scripter:AddInterpretation( Id , Args , Function ) -- Language modifying ( ID = Unique name , Args = table of token ids , Function ) Scripter:Interpretate( Tokens ) -- Secondary interpretation [/CODE] [B]Constants:[/B] [CODE]SCRIPTER_FUNCTION = 0; SCRIPTER_NUMBER = 1; SCRIPTER_STRING = 2; SCRIPTER_TABLE = 3; SCRIPTER_BOOLEAN = 4; SCRIPTER_ANGLE = 5; SCRIPTER_VECTOR = 6; Scripter.Tokens Scripter.DataTypes Scripter.PreTokenize [/CODE] [B]Download:[/B] It's in it's early beta, but here is the SVN: [url]http://custom-scripting-language.googlecode.com/svn/trunk/[/url] Thank you for your attention [Highlight] This is opensource, don't hesitate to ask if you want to have commit permissions [/HIGHLIGHT] [/RELEASE]
Is there any real use for this?
It depends, It's useful if you make it useful.
Cool I guess but I doubt anyone will use it.
To be honest I didn't post it here so people could use it, I posted it here so people could go through the sourcecode and learn from it.
I really like this, I hope it continues [editline]7th February 2012[/editline] Does this need a DLL, cause it would be really useful to be able to run this clientside
It doesn't use a DLL, It's all coded in Lua. I've included a C++ file though with some shortcut functions though. [url]http://code.google.com/p/custom-scripting-language/source/browse/trunk/scripter.cpp[/url] ( I'm not sure I coded it correctly though, so if anyone wants to pick up the scripter.cpp file and work their magic I would be grateful, seeing as it's not at the top of my list or things-to-do )
Cool idea. As you said, it's more for example than use, but nevertheless a good contribution
its a cool idea, must have been a fun learning experience! though i'd say it doesn't have much practical use, it's still always fun to mess about on a project like this, congrats
This literally has no use, but neither did wiremods Expression 2. Things are only useful if you find a creative way to express it. So hopefully you can expand on this and turn this into a useful and cool addon.
Expression 3.
Do we need expression 3? Only if it had function support.
At the moment I'm focusing on the class system, and then I will focus on If conditions, and then functions.
[QUOTE=KillerLUA;34600965]Do we need expression 3? Only if it had function support.[/QUOTE] E2 got function support a few months ago.
It might be more useful if you integrate this into Wiremod.
It can only be usefull if people adapt it to be usefull.... A language o its own does nothing... Its the user that decides what it can be usefull for...
Seems overly complicated for something derived from lua.
[QUOTE=101kl;34602650]Seems overly complicated for something derived from lua.[/QUOTE] It's not [I]derived[/I] from Lua, it's simply [I]created[/I] in Lua. You say derived as in I modify the string and use G.RunString on it, which isn't the case. It runs the string through a library of "tokens" , applies values to them, then interprets them using predefined syntax tables.
Ironically, this seems like it'd have a far steeper learning curve than Lua itself. :v: While it's definitely a cool proof of concept, and undoubtedly a fun, enjoyable, and educational project for you, I can't really see a feasible use for this in the context of Garry's Mod. I certainly can't see it being used by people who want to do programming but don't want to learn Lua because they find it too complicated, because this is even more complicated. Still, like I said, very neat that you were able to do it. [img]http://dl.dropbox.com/u/8416055/FacepunchEmots/Buddy.gif[/img]
It looks complicated, but that's the syntax I chose. You can change the syntax very easily, with functions that permit this easily.
imo it seems dumb to mix a high level language with stack based stuff.
You might find it dumb, but i've not seen you do better.
I gotta admit, I am very impressed and this most of taken a lot of work. I don't think most people are trying to insult you here, it is clearly impressive what you did. But, could you give us an example of how you would actually use it?
[QUOTE=James xX;34608115]You might find it dumb, but i've not seen you do better.[/QUOTE] Yeah, because creating a scripting language inside of a scripting language is a great idea.
[QUOTE=Nexus435;34610091]Yeah, because creating a scripting language inside of a scripting language is a great idea.[/QUOTE] seemed to have kicked off pretty well in the wiremod community can you post some longer multiline examples?
[QUOTE=CapsAdmin;34612140]seemed to have kicked off pretty well in the wiremod community can you post some longer multiline examples?[/QUOTE] expressions in wiremod have a completely different purpose than this
[QUOTE=Nexus435;34612485]expressions in wiremod have a completely different purpose than this[/QUOTE] No, they don't.
[QUOTE=LauScript;34613302]No, they don't.[/QUOTE] What good purpose does this have then?
[QUOTE=Nexus435;34613402]What good purpose does this have then?[/QUOTE] what good purpose does expression have that can't be done easier in Lua? think about it.
[QUOTE=Nexus435;34613402]What good purpose does this have then?[/QUOTE] Not everything has to have a purpose. He said himself that he didn't expect this to be utilised. What's cool is that he made his own scripting language. He probably spent a lot of time on this and decided to share his work with us.
Sorry, you need to Log In to post a reply to this thread.