The C precompiler and LSL
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
07-30-2004 19:45
Just had a wicked idea this morning: use the C precompiler with LSL. It rocks... To try it out: - download Visual C++ Toolkit 2003 from http://www.microsoft.com/downloads/details.aspx?FamilyID=272be09d-40bb-49fd-9cb0-4bfa122fa91b&DisplayLang=en
- Install it to the default location at c:\program files\Microsoft Visual C++ Toolkit 2003
- download SciTe and Ezhar's plugins from here:
/54/c4/18335/1.html
- download the SciTe ESL pack from: http://www.geocities.com/hughperkins/SciTEESL.zip and unzip the contents into c:\program files\SciTe
- launch SciTe, open a .esl file and press ctrl-F7 to precompile and see notepad open with the precompilation results ready to copy and paste
Sample ESL file (ESL = "Extended SecondLife Language"  (save this as "test.esl"  // Comment out DEBUG for release #define DEBUG
// Sample comment that will be stripped
#include "header.esl"
Init() { Debug("test"); SetText("Test SetText" ); }
default { state_entry() { Init(); } }
Headerfile that this goes with (save as "header.esl"  : #ifdef DEBUG #define Debug(f) DebugPrint(f)
DebugPrint( string Message ) { llWhisper( 0, llGetScriptName() + ": " + Message ); }
#else #define Debug(f) #endif
SetText( string Message ) { llSetText( Message, <1,1,1>, 1.0 ); }
When you precompile test.esl from SciTe, by pressing ctrl-f7, you will see: DebugPrint( string Message ) { llWhisper( 0, llGetScriptName() + ": " + Message ); }
SetText( string Message ) { llSetText( Message, <1,1,1>, 1.0 ); }
Init() { DebugPrint("test"); SetText("Test SetText" ); }
default { state_entry() { Init(); } }
Now comment out #define DEBUG in the source test.esl, reprecompile (ctrl-F7), and you will see this version: SetText( string Message ) { llSetText( Message, <1,1,1>, 1.0 ); }
Init() { ; SetText("Test SetText" ); }
default { state_entry() { Init(); } }
All the debug commands have been completely stripped from the code! Leaving your code crisp and fast and ready for release. Just for info, here is the batch file that does the precompilation. This is the file "precompilelsl.bat" in the SciTeESL.zip bundle that you downloaded earlier. set PATH=%PATH%;c:\program files\Microsoft visual C++ toolkit 2003\bin
cl /Tc"%1.esl" /EP >"%1.lsl" notepad "%1.lsl"
Azelda
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
07-31-2004 06:41
That's brilliant, Az. Thanks.
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
07-31-2004 20:31
in esl.properties file.patterns.lsl=*.esl
needs to be changed to file.patterns.esl=*.esl
without this change you won't have highlighting in *.lsl files. in precompilelsl.bat you will also want to change so you can compile files with spaces in the names. (may not be supported by win 9x/me set PATH=%PATH%;c:\program files\Microsoft visual C++ toolkit 2003\bin
cl /Tc"%*.esl" /EP >"%*.lsl" start notepad "%*.lsl"
Since this uses the c precompiler it gives you access to all syntax toys. Features: Comment stripping (// and /* */ types) #define #include finaly global variables without global variables
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
08-02-2004 15:34
I've writen a simple text stripper to clean up after the precompiler. It just removes most vertical whitespace.
Source included. See attachment for download
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Nyef Nyak
Junior Member
Join date: 23 Jul 2004
Posts: 17
|
08-03-2004 16:43
I try to download the SciTEESL.zip file and they say the page isn't there, tried a file searching site to find it elsewhere with no luck, is there anywhere else to get this thing? Thanks in advance.
|
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
|
08-03-2004 22:09
Nice thinking Azelda. It looks like a lot of work for a small script, but I have worked on some monster scripts in the past that could have benefited from this.
_____________________
-- 010000010110110101100001001000000100111101101101011001010110011101100001 --
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
08-03-2004 23:32
Ok, bug in esl.properties corrected, whitespace stripper added. New installer here: http://www.geocities.com/hughperkins/SciteESLSetup.zipAzelda
|
Nyef Nyak
Junior Member
Join date: 23 Jul 2004
Posts: 17
|
08-04-2004 02:18
Ahhh, its down again, you gotta love geocities.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
08-08-2004 16:50
in the precompiler.bat i made a change that let it pass comments, which i didn't relize at the time that would be a problem with /* */ style comments. You will if it's enabled remove the /C flag from the precompiler line. haven't checked the new install. This was my fault; i have updated my download attachment above.
It would be really nice if someone would make a nice precompiler & syntax checker specificly for LSL & ESL
You can't directly link downloads from geocities. Link them a geocities page that automaticly dowloads the file.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
08-09-2004 09:56
Thanks Strife! I wasnt aware of the downloading problem because the firewall actually completely blocks geocities.com for me; cant test it. Here's a new link that could work better: http://geocities.com/hughperkins/downloadSciteESLSetup.htmlAzelda
|
Jay Fairplay
Junior Member
Join date: 10 Jul 2004
Posts: 9
|
09-05-2004 11:32
From: someone Originally posted by Strife Onizuka You can't directly link downloads from geocities. Works for me. Thanks!
|
John Sojourner
Junior Member
Join date: 25 Sep 2004
Posts: 2
|
Try my cbop.exe instead of "copy from Notepad."
10-02-2004 19:59
Hi, I've written a program to copy text from a file to the clipboard. This can replace the "start Notepad and copy all the text" stage. The program lives here: http://johnp.net/cbop/Cheers, John
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-03-2004 13:03
does it handle NT & 9X clipboards? they use different commands to operate. and you should use Ezhar's version found here because it incorporates the precompiler, newer lex file, (my file stripper in the next release) and a program to auto copy the code for you when you compile (sorry already thought of). I looked at your program, it's a good peice of code
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Kermitt Quirk
Registered User
Join date: 4 Sep 2004
Posts: 267
|
Why strip comments?
10-03-2004 19:56
Maybe I'm missing something here, but why would you want to strip comments out of your code? The only reason I could see is that you're trying to save memory in the script. However, from my own testing I have confirmed that the space taken by code in the heap is the space required to hold the compiled version, not the script itself (which makes perfect sense). Since comments get ignored during compilation then they have no affect on the memory used while the script is running.
This would be fine if it's one of your own scripts (since you'd be working on the original in your external editor when making changes), but if the script is passed on to anyone else they could end up with a 500 line script with absolutely no comments in it. Now that's not a good thing, surely.
Don't get me wrong though. It's not that I'm saying that this whole idea is a bad one, cause I'm sure we'd all agree that LSL could do with @define's and #include's. It's just that I can't see any good reason for stripping the comments.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-03-2004 20:06
There is only one good reason (besides writing obfuscated code) and that is so you can use /* */ style comments (as the precompile will then strip them). But that is an option you can enable or disable. Comment stripping is not enabled by default in Ezhar's release. Bahhh i'll just bump that thread... Basically Ezhar Fairlight absorbed this great idea into his release. I consider this thread only important for historical purposes at this point (and think it should be locked and people pointed to the other).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|