Register to post in forums, or Log in to your existing account
 

Post new topic  Reply to topic     Home » Forums » Website or Forum problems Goto page 1, 2  Next
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Wed Sep 08, 2004 7:22 pm   

Where is the [zscript] tag? =)
 
Hello,

I just realized that the [zscript] tag is missing from the forum. Some forums use these kind of tags to syntax colour the code to increase readability.

Take a look at this example trigger that is not using syntax colour:
#CLASS {identify}
#TRIGGER {You see &{item.name}. Its hitroll appears to be &{item.hit}, the damroll &{item.dam}, and the ac &{item.ac}.} {}
#TRIGGER {$} {
#if (%find( @item.name) = "") {#new "" @item}
#t- identify
}
#CLASS 0

#ALIAS identify {#t+ identify;cast identify %1}

Now we add colours to it:
#CLASS {identify} 
#TRIGGER
 {You see &{item.name}. Its hitroll appears to be &{item.hit}, the damroll &{item.dam}, and the ac &{item.ac}.} {} 
#TRIGGER
 {$} {  
 #if
 (%find( @item.name) = "") {#new "" @item} 
 #t
- identify
 
}
#CLASS
 0

In my opinion the example with syntax colour is easier to read. A [zscript] tag that automatically does syntax colouring could be useful to the forum, and make reading scripts directly on the forum more enjoyable and fun.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Sep 08, 2004 10:58 pm   
 
And how do you expect that kind of tag to get written? Honestly, that would require putting a whole zMUD syntax parser into the PHP code for the forums somehow. Considering it took me months to write the parser within zMUD and that's coded in Delphi, that's asking a lot. I'm afraid you are stuck coloring by hand just like you always have.
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Thu Sep 09, 2004 2:29 am   
 
I don't know if these hacks/mods are open source and modifiable -I don't run a bbs- but here is what I found:

I'd like to see this implemented! Spaces!

http://www.phpbb.com/phpBB/viewtopic.php?t=190144&sid=bdc07fb8ba178f97c8c04332da8a6ab5

Could one of these possibly be modified for zscript?

http://www.phpbbhacks.com/download/3536
http://www.phpbbhacks.com/download/181
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Sep 09, 2004 4:42 am   
 
Zugg wrote:
And how do you expect that kind of tag to get written? Honestly, that would require putting a whole zMUD syntax parser into the PHP code for the forums somehow. Considering it took me months to write the parser within zMUD and that's coded in Delphi, that's asking a lot. I'm afraid you are stuck coloring by hand just like you always have.

You can use a lexer to do a rough syntax colouring. That is how I coloured the text above (with a really, really bad lexer). You don't really have to do a pretty-print with automatic identitation just colour the keywords and convert spaces to   so that the users themselves can properly indent the code.
Reply with quote
IceChild
Magician


Joined: 11 Oct 2000
Posts: 419
Location: Post Falls, ID, USA

PostPosted: Thu Sep 09, 2004 5:08 am   
 
Speaking solely on the highlighting of PHP, there's actually a function (for those that aren't aware) that will syntax highlight PHP for you, so adding that to a PHP based forum is exceedingly easy. Adding other languages though? That can become a royal pain in the rear. We spent about 4 months working on a proper highlighter for C, C++ and Ada on a webforum I helped design, and we still wound up with issues. I dunno, it'd prolly be easier to write a plugin within zmud that would give you what you need to put into the forum. Infact, didn't someone already do that?
_________________
Icechild
Coder of Arthanox

WinXP-SP2 | zMUD 7.05 | zMapper 1.22 | zApp 1.04
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Sep 09, 2004 12:26 pm   Proof of concept
 
I decided to attempt to see if it is possible to make a syntax colourer.

Syntax colouring:
http://www.silverbridge.org/~varmel/zmud/syntax/

The original file:
http://www.silverbridge.org/~varmel/zmud/syntax/script.zsc
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Sep 09, 2004 5:07 pm   
 
Rorso (or anyone else), you are free to play with this to see what you can come up with. But consider this:

You can't just use lexer. The zMUD syntax checker started with lex and yacc. A static lexer cannot handle zMUD syntax. The yacc definitions that handle the zMUD syntax in the syntax checker are extremely complicated. zMUD scripting does not follow strict BNF like more formal languages. So while it's easy to come up with something that handles basic stuff, you will find a LOT of scripts that won't work. That's the same reason there are still problems in the zMUD syntax checker. And when you start mixing in stuff like COM calls, it gets to be a complete mess.

Like I said, feel free to work on this, but I certainly don't have time to do anything like this. It's a lot more complicated that I think you realize.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Sep 09, 2004 6:07 pm   
 
I have made a test page that shows a few scripts syntax coloured:
http://www.silverbridge.org/~varmel/zmud/syntax/perform_test.php
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Sep 09, 2004 6:36 pm   
 
Nice! Actually, now that I think about it, just doing syntax "coloring" is an easier problem that actual syntax "checking" and error reporting. So maybe this isn't so bad. Looks like you have tested the basics. Try some of the scripts in the Finished Scripts area and see how it goes. And you might try some of the posts in the forum where people have stuff that are not "clean" but still work. Most of the script examples you show are pretty nice and clean and don't use a lot of "old" syntax.

You might also play with the <> and [] operators for evaluation and expansion, although I'm not sure that matters much for coloring. Also play with trigger patterns since their syntax is different than the rest of zMUD.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Sep 09, 2004 7:47 pm   
 
Zugg wrote:
Nice! Actually, now that I think about it, just doing syntax "coloring" is an easier problem that actual syntax "checking" and error reporting. So maybe this isn't so bad. Looks like you have tested the basics. Try some of the scripts in the Finished Scripts area and see how it goes. And you might try some of the posts in the forum where people have stuff that are not "clean" but still work. Most of the script examples you show are pretty nice and clean and don't use a lot of "old" syntax.

You might also play with the <> and [] operators for evaluation and expansion, although I'm not sure that matters much for coloring. Also play with trigger patterns since their syntax is different than the rest of zMUD.

Auch you were correct. A parser is needed to do proper syntax colouring - especially for the trigger patterns. There might be workarounds but the code has now become so ugly that control of it is almost lost Sad.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Sep 11, 2004 4:30 pm   
 
Don't worry too much about this. I know *exactly* how you feel though. This is the same thing that happened to me when I first thought of adding the color-coded syntax editor in zMUD. Getting it to the 80% point was pretty easy, but then when I saw all of the wierd exceptions and problems it was very discouraging. I got excited when I did the yacc parser, thinking that it might improve script execution, only to find that the yacc parser was much slower than my kludged parser. So, after months of work I ended up with a syntax checker that only worked 95% of the time, and a second complete parser that wasn't any good for anything except syntax checking adding space to the code. I was never very happy about the outcome, and even today people can still find wierd stuff that causes a syntax error.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Sep 11, 2004 8:54 pm   
 
Zugg wrote:
Don't worry too much about this. I know *exactly* how you feel though. This is the same thing that happened to me when I first thought of adding the color-coded syntax editor in zMUD. Getting it to the 80% point was pretty easy, but then when I saw all of the wierd exceptions and problems it was very discouraging. I got excited when I did the yacc parser, thinking that it might improve script execution, only to find that the yacc parser was much slower than my kludged parser. So, after months of work I ended up with a syntax checker that only worked 95% of the time, and a second complete parser that wasn't any good for anything except syntax checking adding space to the code. I was never very happy about the outcome, and even today people can still find wierd stuff that causes a syntax error.

There seems to be a lot of exceptions in zScript. You can assume that you can make "and" bold in all cases and it will work most of the time pretty well. You really don't care if the user used the correct syntax or not.

Then you get the cases like with the trigger patterns. They are only valid in the contest of a #trigger or #temp so it becomes a mess if you try to do it with some lexer.

So I wrote a parser instead. New proof that it is possible to syntax colour zScript: http://www.silverbridge.org/~varmel/zmud/syntax/perform_test.php

Some things can't be syntax coloured if you don't use a symbol table. Like alias calls which in zMUD is coloured blue.

Edit: There's probably still a lot of stuff that isn't colourized properly.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Tue Sep 14, 2004 7:59 pm   
 
I have now added support to quite a few commands to my syntax colourizer. At first I only wanted to colourize the text but suddenly it became obvious that I have a lot of hard to read zScript code. Especially stuff separated by ; is difficult to read so I had to attempt to add some kind of pretty printer as well.

What was pretty fun is that the more the parser actually parsed the more syntax errors it would detect and get confused about.

I think my experiment to write a syntax colourizer became a bit better than I first hoped, but at the same time it has a lot of issues. One of them is that it's slow. Another is that it sometimes parses stuff that zMUD doesn't parse. Like "#if {} {}{}" is the same as "#if {} {} {}" to it while in zMUD you get an error if you don't have a space before the else branch.

Yet an issue is that the pretty printer is sometimes pretty bad Very Happy. Like "#trigger {} {}" is put on two lines because it can't be sure if there is any code in the code block.

I was considering to put the .php file avaible for download on my webpage but I think I rather not. The goal was to show that it's "not too difficult" to syntax colour zScript but I am not sure if that goal was reached.

Edit: There is a test page if you want to try the syntax colourizer located at http://www.silverbridge.org/~varmel/zmud/syntax/index2.php
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Sep 24, 2004 6:19 am   
 
That is nice Now only if you can make it output with bbcode tags in place :P

Also I noticed one problem with %x1 %t1 type statements it only colors the %x or %t part blue and not the number :P

And on an offtopic note the BBCODE Extension for firefox Rules :P
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Fri Sep 24, 2004 9:35 am   
 
Quote:

Also I noticed one problem with %x1 %t1 type statements it only colors the %x or %t part blue and not the number :P

That has been fixed now. Thanks for reporting Smile.

Quote:

And on an offtopic note the BBCODE Extension for firefox Rules :P

BBCODE Extensions? You mean you have a WYSIWYG editor for BBCODE? :)

If that is the case and the input field supports html clipboard data you might want to try to select the output from the syntax colourizer and paste it. When I copy text from IE I can paste it in for example Wordpad and the colours are retained.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Fri Sep 24, 2004 5:37 pm   
 
Testing bbcode

#CLASS {identify}
#TRIGGER {You see &{item.name}. Its hitroll appears to be &{item.hit}, the damroll &{item.dam}, and the ac &{item.ac}.} {
}
#TRIGGER {$} {
 #if (%find( @item.name) = "") {
   #new "" @item
 }
 #t- identify
}
#CLASS 0

Used Pretty Print
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Sep 25, 2004 12:34 pm   
 
I think Im in love with It :P

Another Problem with Fixed-width patterns Basicly same problem that plagued %t1 but I guess this one isn't that much of a deal if it would be too hard to fix
#TR {&2 and (&2)} {test}

And on this part when using bbcode it should make it a URL to the colourizer :P
Used Pretty Print
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Sep 25, 2004 6:14 pm   
 
nexela wrote:
I think Im in love with It :P

Another Problem with Fixed-width patterns Basicly same problem that plagued %t1 but I guess this one isn't that much of a deal if it would be too hard to fix
#TR {&2 and (&2)} {test}

That should work now. Thanks for reporting it Smile.

Quote:

And on this part when using bbcode it should make it a URL to the colourizer :P
Used Pretty Print

That would make the code a bit tougher to work with :-) as I am doing a pretty odd translation. First it translates the zScript to html and then it translates the html code to bulletin board code. If you enter a script that has syntax errors like "#tri" even the error messages gets formatted as forum code.

I added a link at the bottom of the output though. Thanks for the suggestion.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Sep 25, 2004 6:25 pm   
 
Now that I've looked at how the bbcode support is implemented in the forum, it's probably easier for me to just call a routine that takes a zscript string and returns raw HTML.

When you edit your post you'd still see just the zscript tag and not any of the formatting.

Converting zscript to bbcode actually makes the implementation harder, not easier. There is a routine already that handles stuff like clickable email and http links where it might be easy to insert a zscript kind of function if it returns raw html.

Rorso, is the stuff you did all implemented in just PHP, or is there some other component that is needed?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Sep 25, 2004 6:29 pm   
 
Also, the way I'd probably implement this on the forums is to have a box somewhat like the "code" box. Where it currently says "Code:" I would replace that with "zMUD Script (from link)" where "link" is the name you want for this. I'm not sure "Pretty Printer" is quite good enough. Maybe it's "Rorso's zScript highlighter" or something like that? Anyway, that would integrate the zscript stuff into the site more like people are used to with the [code] tag.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Sep 25, 2004 7:23 pm   
 
Zugg wrote:
Now that I've looked at how the bbcode support is implemented in the forum, it's probably easier for me to just call a routine that takes a zscript string and returns raw HTML.

When you edit your post you'd still see just the zscript tag and not any of the formatting.

Converting zscript to bbcode actually makes the implementation harder, not easier. There is a routine already that handles stuff like clickable email and http links where it might be easy to insert a zscript kind of function if it returns raw html.

Rorso, is the stuff you did all implemented in just PHP, or is there some other component that is needed?

The entire syntax colourizer is implemented in PHP. It was actually quite easy to add html->bbcode support compared to the zscript->html code.

As I wrote earlier it is very unlikely I am going to release the source code for this. This is because I have issues with the GPL. It scares me, a lot. Actually most licenses scare me. While I know this is silly and sounds stupid in most cases, it has become a kind of phobia. Like some people almost faint of the thought to even enter an elevator. I am sorry for this Crying or Very sad.

My main goal was to show that it's possible to write a somewhat good zscript syntax colourizer without requiring too much work. I am not sure if I reached that goal though. The script became pretty large =).
Reply with quote
Rainchild
Wizard


Joined: 10 Oct 2000
Posts: 1551
Location: Australia

PostPosted: Sun Sep 26, 2004 10:48 pm   
 
Don't GPL the code, just give it to Zugg to do with as he pleases :P
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Sep 27, 2004 4:46 pm   
 
Yeah, why is there a GPL issue? I guess I don't understand. If you just used PHP then you can do whatever you want with the code. It's fine if you don't want to give it to me to install on the site since that is your choice. But I don't know what there is to be "scared" of about GPL. People use PHP code on commercial sites everywhere. You can be sure that I'll give you credit for your work. With all the other work I have on my plate, this is certainly not anything that I'm going to do myself for quite a while. Or did you use someone else's parser code or something?
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Mon Sep 27, 2004 6:37 pm   
 
I guess I better explain my "issue". Some years ago I barely cared about EULAs. Like most people, until the EULA gets sharp teeth and bites you back. To make a long story short I got into an ethical debate about what is my own code for some years. I managed to get pretty locked at the idea that the code I wrote might not be mine. After all I based new code on what I had seen or worked on before(aka learning).

To relate it to the GPL the question then became that if you once had worked/seen GPL code perhaps all code you write would then be GPL? An example of this is that Nexela and I managed to write almost exactly the same script on the general forum today. This shows the issue: People code similarly which also is the goal of a good programming language. Actually usually code to do the same task looks pretty much the same whoever makes it. What made this matter worse for me is that people seem to enjoy to accuse others for "stealing" code. What now "stealing" code is.

This kind of thinking got me into a state where I worried more about licenses than coding, and coding was what I usually did during my spare time. Coding is actually one of those things I really enjoy to do.

While I have managed to force myself to get into a much better mood nowadays some of the old thinking is still stuck. Releasing code most likely means you'll get contributions or suggestions. Adding those contributions/suggestions to the code would set the code into an uncertain "license state". Using those ideas/patterns into a new project could be a disaster as well. Even if it might be allowed legally/ethically there might still be a mob waiting somewhere to chase you because of it. (Imagine someone uses eMobius alot and codes for it and later wants to make his/her own email client. The person would of course use the knowledge he learnt during working on eMobius wether he wants to or not. Actually one could ponder on why he should not use what he had learnt.)

Some people say you can copyright an implementation... However I have found that very often code that does the same, looks the same.

Quote:

Or did you use someone else's parser code or something?

I am not sure Mr. Green. I coded it from my experience, and memory. I have seen other parsers and use some of their ways to do things. Here some people would probably call it stealing code while I call it learning and applying that knowledge. The question of what is someone's else code is neither black nor white in my opinion.

I hope I have managed to explain somewhat why I seem a bit "crazy" when it comes to releasing source code. I am scared to get into yet an ethical situation or perhaps even a legal mess. Sometimes your best intentions seem to wrap around and bite you.

Do I want to release the source code to the zScript colourizer? I think I want to but there is also that "feeling" warning me not to do so.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Sep 27, 2004 8:47 pm   
 
*Senseless Ramble*
And for anyone that has read the MOD KB articles at phpbb.com According to the GPL or whatever of phpbb any mods used on ANY phpbb install have to released under the gpl as they will use parts of the phpbb code...... Stupid ..... yes. So as long as your not charging anyone to use it there shouldn't be a problem with installing it to these forums.

Quote:
An example of this is that Nexela and I managed to write almost exactly the same script on the general forum today. This shows the issue: People code similarly which also is the goal of a good programming language..................... I coded it from my experience, and memory. I have seen other parsers and use some of their ways to do things. Here some people would probably call it stealing code while I call it learning and applying that knowledge. The question of what is someone's else code is neither black nor white in my opinion.

Consider that there is a limited number of ways anything can be written under any language. So who stole the script that me and rorso posted is it Rorso? Me? or did we both steal it from Zuggsoft because it is zscript.

This has been a sensless rambling by me ignore it if you can't stop laughing :P
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Website or Forum problems All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2009 Zugg Software. Hosted on Wolfpaw.net