Re: [dev] nscript - a little stack-based scripting language interpretter I wrote

From: pancake <>
Date: Thu, 26 Aug 2010 01:17:29 +0200

On Thu, 26 Aug 2010 03:02:08 +0300 (AST)
Nikhilesh S <> wrote:

> The current way of doing it makes the implementation very simple - if it

that's the point, but it makes no possible to override native functions.

> encounters a '$' it just reads the variable name and makes a new one. If
> it encounters an '&', it just sets 'callFunc' to 0 and continues like
> a normal name-read except it won't execute it now - it'll just push the
> object onto the stack. Then 'callFunc' is set back to 1 (the default).
> $bla can be used to reassign to variables too. So even after 'foo' is
> defined, running '3 $foo' will set foo to 3, whatever it was before.
> For it to work your way, I'll have to change the implementation a bit.
> It might have to search ahead for a 'def' and do things differently.
> What advantages does your idea provide?

with def you will be able to override any operator or function. nevertheless you
can also doit with '$' and the parsing will go faster

> Actually I will probably rewrite the whole parser in a more proper way
> some time - right now it just runs through the characters with a primitive
> state system and some forward-peeking, and simply executes the code as
> it goes by (the whole thing is in 'ns_interpret' in nscript.c). Should
> I use 'bison' or something instead?


the current parser is quite smart, it can be improved, but it's far better than
using bison or yacc. they generate lot of code and results in big binaries and
slow executions. in Vala they start using it and end up writing their own
parser char-by-char, because of the performance.

Received on Thu Aug 26 2010 - 01:17:29 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 26 2010 - 01:24:02 CEST