Log in

View Full Version : custom vb BB codes


trican
08-11-2004, 04:26 PM
Hi,

I'd like to setup BB code for a programming language in a similar fashion to the way its done for php (e.g. code. Could anyone point me in the right direction!

Also I've seen some sites which do syntax highlighting of code is this hard?

thanks

trican
09-02-2004, 06:41 PM
no -one?

CarCdr
09-03-2004, 10:08 AM
You would have to find a PHP script that does the syntax highlighting for the language in question. That's the hard part. Once you have that, hanging it off of a bbcode is the simple part.

trican
09-03-2004, 10:25 AM
would that not be fairly straight forward, just send the post to function, which parses it looking for keywords, and then replacing the keyword with A BBCODE for different colours?

You think it would be easy to "hang it off" vb?

CarCdr
09-03-2004, 11:30 AM
would that not be fairly straight forward, just send the post to function, which parses it looking for keywords, and then replacing the keyword with A BBCODE for different colours?

You think it would be easy to "hang it off" vb?
Writing a language parser is non-trivial. I have written a couple from scratch and, more frequently, used lexical/parser tools to define a language parser to do the job.

It is not as simple as looking for keywords. If you did that, you would incorrectly highlight keywords within strings, as in:

$variable = "foreach $string } ?> ";

You must be able to break the input into a syntactically correct stream of tokens, then parse the tokens into a semantically correct series of language constructs, such as statements and expressions.

trican
09-03-2004, 11:41 AM
Writing a language parser is non-trivial. I have written a couple from scratch and, more frequently, used lexical/parser tools to define a language parser to do the job.

It is not as simple as looking for keywords. If you did that, you would incorrectly highlight keywords within strings, as in:


And checking if there was a space bewfre and after wont be enough?

]
You must be able to break the input into a syntactically correct stream of tokens, then parse the tokens into a semantically correct series of language constructs, such as statements and expressions.

I'm not really too sure I understand what you mean by stream of token, etc



Ultimately i dont see why it wouldn't be as easy as copying the current VB php pharser and modifying the keyword, so as to suit the chosen language?

If i were to pay for a hack like this, how much would it cost do you think?

CarCdr
09-03-2004, 01:18 PM
There is nothing you can copy and modify. There is no "VB php parser". It uses the highlight_string function that comes as part of PHP.

This is not as easy as you think. Any simple methods are doomed to produce silly results.