Interpreted language design decision
Posted: Tue Nov 13, 2012 8:45 pm
I have a question for everyone here, but first, a bit of background.
I'm writing an interpreted language that I can incorporate into irrlicht (and other programs) and easily extend. I've made it such that I can control the input of tokens without modifying the main frame of the interpreter. The standard way of reading things would be simply getting token separated by spaces. I've also made the interpreter such that I can easily add new tokens (once again, without modifying the main frame of the interpreter) and give them the syntax I want. From the parser, I can grab any token I want and interpret it as an object in a couple quick steps. A couple important limitations, though: parenthesis and curly brackets create bodies of code.
My design decision comes in here:
I'm writing an extension class that interprets functions, and I'm trying to decide what would be the most convenient, logical syntax for running a function. The syntax for function creation is as follows:
Where "func" is a keyword that creates a function, "myFunction" is the name of the function, and "params" is either another variable or a list of variables formed by square brackets.
A few options to think about (other suggestions are more than welcome):
Where "run" is a keyword, "myFunction" is a function object, and "params" is either a regular object or a list containing objects. If it's a list, it could be enclosed in square brackets.
Another option:
Where "processes" is a keyword.
Or maybe
... as we're all used to. This actually requires more work on the part of the interpreter and not just because there's an extra token (the parenthesis at the end). Reason: The first part ("myFunction") returns an object. Parenthesis, however, already have the function of simply containing a body of code. In other words, there's nothing to associate the function with the parenthesis to indicate running.
Now, you may think, "Why not just use square brackets"? - The thing is, square brackets denote nameless list creation (although I may change this at you guys' suggestion to simply "list ... ;").
So that's the scenario. I'd appreciate you guys' advice, tips, and suggestions. Any questions?
I'm writing an interpreted language that I can incorporate into irrlicht (and other programs) and easily extend. I've made it such that I can control the input of tokens without modifying the main frame of the interpreter. The standard way of reading things would be simply getting token separated by spaces. I've also made the interpreter such that I can easily add new tokens (once again, without modifying the main frame of the interpreter) and give them the syntax I want. From the parser, I can grab any token I want and interpret it as an object in a couple quick steps. A couple important limitations, though: parenthesis and curly brackets create bodies of code.
My design decision comes in here:
I'm writing an extension class that interprets functions, and I'm trying to decide what would be the most convenient, logical syntax for running a function. The syntax for function creation is as follows:
Code: Select all
func myFunction params
{
}
A few options to think about (other suggestions are more than welcome):
Code: Select all
run myFunction params
Another option:
Code: Select all
myFunction processes params
Or maybe
Code: Select all
myFunction(params)
Now, you may think, "Why not just use square brackets"? - The thing is, square brackets denote nameless list creation (although I may change this at you guys' suggestion to simply "list ... ;").
So that's the scenario. I'd appreciate you guys' advice, tips, and suggestions. Any questions?