Keywords

Feb 20, 2010 at 4:39 AM
Edited Feb 22, 2010 at 5:03 AM

Is there a way to define your own custom keywords? 

Coordinator
Feb 23, 2010 at 9:57 AM

if you change the grammar, yes.

Can you tell us what you have in mind ?

Feb 24, 2010 at 3:17 AM
Edited Feb 24, 2010 at 3:19 AM

Using statement, not something standard in js afaik and not something I'm currently aware of in Jint. Of course the functionality of the statement would be highly specific to my use of Jint. What would be ideal is a way to simply set keywords in the way you can set functions. JintEngine.SetKeyword ( string name, JsFunction function ) where instead of being invoked in a name(arg1, arg2... argn) manner it'd be executed in a name arg1 manner. In this situation JsFunction would be limited to one parameter. The most satisfactory solution would involve implementing a JsKeyword extension to JsFunction for this specific purpose.

I realize I could simply create a function named Using and register it, but that would really not be ideal and I'd be more likely to simply preprocess the script files using #include styled statements.

Oversaucy

Coordinator
Feb 24, 2010 at 3:47 AM
Hi, 

Thé issue with your logic, is that there will be grammar issues : how do you find the end of an expression ? This is typically a shift/reduce conflict that could not be solved. Imagine the following situation : you have defined the keyword1 and keyword2. Now you have the following statement : keyword1 keyword2. What happens ? Should we try to read one step further or is this because you want to give a function as an argument ? If you have the following statement : keyword1 keyword2 "toto", what would happen ? Is the result of keyword "toto" supposed to be the argument of keyword1 or is keyword1 keyword2 generating a new function that would take the string as an argument ? Since there is no way to decide, there is no way for your solution to be. You may need to think to something else...


Le 24 févr. 2010 à 05:17, oversaucy <notifications@codeplex.com> a écrit :

From: oversaucy

Using statement, not something standard in js afaik and not something I'm currently aware of in Jint. Of course the functionality of the statement would be highly specific to my use of Jint. What would be ideal is a way to simply set keywords in the way you can set functions. JintEngine.SetKeyword ( string name, JsFunction function ) where instead of being invoked in a name(arg1, arg2... argn) manner it'd be executed in a name arg1 manner. In this situation JsFunction would be limited to one parameter. The most satisfactory solution would involve implementing a JsKeyword extension to JsFunction for this specific purpose.

 

Oversaucy