vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   custom vb BB codes (https://vborg.vbsupport.ru/showthread.php?t=68232)

trican 08-11-2004 04:26 PM

custom vb BB codes
 
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.
PHP Code:

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

Quote:

Originally Posted by trican
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

Quote:

Originally Posted by CarCdr
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?

Quote:

]
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.


All times are GMT. The time now is 06:22 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01085 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete