[Wave] Modifying the way function-like macros are interpreted
I am trying to use boost::wave as a preprocessor for LSL, a language used in the virtual world Second Life. There is a data type there for collections of data, but it can only be accessed through functions such as llList2String(list,iterator); I wanted to define macros that would allow me to do something like #define x[y] llList2String(x,y), however, wave as it stands does not seem to have any immediately obvious way to do this.
On Fri, Dec 25, 2009 at 7:10 AM, <fractured@modularsystems.sl> wrote:
I am trying to use boost::wave as a preprocessor for LSL, a language used in the virtual world Second Life.
There is a data type there for collections of data, but it can only be accessed through functions such as llList2String(list,iterator); I wanted to define macros that would allow me to do something like #define x[y] llList2String(x,y), however, wave as it stands does not seem to have any immediately obvious way to do this.
Wave is a C++ preprocessor, you are talking about mutating a language in a way not supported in a C preprocessor type way. First question must be asked, does LSL use the [ or ] tokens at all at any time in its grammar?
I am trying to use boost::wave as a preprocessor for LSL, a language used in the virtual world Second Life.
There is a data type there for collections of data, but it can only be accessed through functions such as llList2String(list,iterator); I wanted to define macros that would allow me to do something like #define x[y] llList2String(x,y), however, wave as it stands does not seem to have any immediately obvious way to do this.
As Wave is a preprocessor conforming to the C++ Standard this is not possible. But you can define your macro like #define x(y) llList2String(x,y) if that's an option. OTOH, Wave is open source, so you should be able to find the corresponding code to add your syntax. Do you want _all_ macros to be defined using the [] syntax or is this something you want to have additionally to the 'normal' function style syntax? Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com
As Wave is a preprocessor conforming to the C++ Standard this is not
possible. But you can define your macro like
#define x(y) llList2String(x,y)
if that's an option.
OTOH, Wave is open source, so you should be able to find the corresponding code to add your syntax. Do you want _all_ macros to be defined using the [] syntax or is this something you want to have additionally to the 'normal' function style syntax? As far as I can tell, x(y) treats it as a function named x with a argument, not the x as a argument itself to do (y) on; in any case I wanted it in addition to the normal behavior.
Also, LSL does not use [] except for defining lists, e.g. list ex = [entry1,entry2,entr3];, or as a argument to a function, func([1,2,3],.. , but never in this particular manner, which would involve alphanumeric characters from the var name directly preceding the [. I was just wondering if there was something I could easily change to allow for this through wave.
On Fri, Dec 25, 2009 at 10:31 AM, <fractured@modularsystems.sl> wrote:
As Wave is a preprocessor conforming to the C++ Standard this is not
possible. But you can define your macro like
#define x(y) llList2String(x,y)
if that's an option.
OTOH, Wave is open source, so you should be able to find the corresponding code to add your syntax. Do you want _all_ macros to be defined using the [] syntax or is this something you want to have additionally to the 'normal' function style syntax?
As far as I can tell, x(y) treats it as a function named x with a argument, not the x as a argument itself to do (y) on; in any case I wanted it in addition to the normal behavior.
Also, LSL does not use [] except for defining lists, e.g. list ex = [entry1,entry2,entr3];, or as a argument to a function, func([1,2,3],.. , but never in this particular manner, which would involve alphanumeric characters from the var name directly preceding the [. I was just wondering if there was something I could easily change to allow for this through wave.
In that case you could easily make a stand-alone parser out of Spirit.QI that can do what you wish. Use of the symbol table and skipping things you are not matching will work perfectly. I doubt you would want to use Boost.Wave though as it would be difficult to edit and would do a *lot* more then necessary (and be slower because of that).
On 12/25/2009 12:59 PM, OvermindDL1 wrote:
In that case you could easily make a stand-alone parser out of Spirit.QI that can do what you wish. Use of the symbol table and skipping things you are not matching will work perfectly. I doubt you would want to use Boost.Wave though as it would be difficult to edit and would do a *lot* more then necessary (and be slower because of that). ______________________________________________
I still need wave as I am using it to provide #include and #define functionality, which LSL does not support. This however I have already implemented, I'm just trying to expand the functionality as much as I can using various preprocessing. I'll look up Spirit.QI though.
fractured@modularsystems.sl wrote:
I am trying to use boost::wave as a preprocessor for LSL, a language used in the virtual world Second Life.
<OT -- sorry!> Coming up soon (don't know date) you'll be able to write Second Life scripts in C# as well as LSL. SL already uses the Mono engine internally to execute LSL scripts, so it'll be the Mono implementation of C#. In increasing order of desirability for writing new scripts: 1. Original LSL 2. Preprocessor-enhanced LSL 3. C# C# is a much richer language than LSL was ever designed to be. I hope that will address the syntax issues you wanted to ease with a preprocessor -- plus a whole lot more functionality than a preprocessor could hope to give you. </OT>
participants (4)
-
fractured@modularsystems.sl
-
Hartmut Kaiser
-
Nat Goodspeed
-
OvermindDL1