flat assembler
Message board for the users of flat assembler.

Index > Main > asm syntax highlightning

Author
Thread Post new topic Reply to topic
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 19 Nov 2004, 18:15
hello, i am wondering if i could get the php code for your asm syntax highlighting?

it would be very nice.. Smile

_________________
BOS homepage: http://bos.asmhackers.net/
Post 19 Nov 2004, 18:15
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 19 Nov 2004, 21:18
well have you tried clicking on the PHPBB @ the bottom? Smile
it is free

maeby you could find it in it?

you're making some highlighting for your site?
Post 19 Nov 2004, 21:18
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 20 Nov 2004, 08:14
No, the assembly syntax highlighter is not a part of PHPBB; I wrote it... I've lost the source code for it, so please ask Privalov!

Regards
Post 20 Nov 2004, 08:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 20 Nov 2004, 09:59
Tommy, would it be OK with you to publish this code as a public domain?
Post 20 Nov 2004, 09:59
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 20 Nov 2004, 11:20
Privalov wrote:
Tommy, would it be OK with you to publish this code as a public domain?


IMHO, this code can be distributed only as GPL or not to be distributed at all. But GPL is good license for such addition to phpBB.

Regards.
Post 20 Nov 2004, 11:20
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 20 Nov 2004, 13:09
Why only GPL?
Post 20 Nov 2004, 13:09
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 20 Nov 2004, 13:27
crc wrote:
Why only GPL?


Well, because it is part (modification) of the product (phpBB) distributed under GPL. Under the terms of GPL, every modification of GPLed product must be distributed under GPL. IMHO, you can make modifications for your personal needs without distributing them.
Of course, the mentioned module for syntax highlighting can be released as a separate product, under any other license, if it doesn't contain any code from GPLed product. But IMHO, for such module intended to improve bug GPLed product like phpBB, it is simply meaningless to be released as separate product. In similar cases, GPL looks like very reasonable distribution license.
Of course, only Tommy, as an author have the right to decide what he wants.

Regards.
Post 20 Nov 2004, 13:27
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 20 Nov 2004, 14:25
Since this code in its current state is our common work, we have to agree both on how to release it.
Post 20 Nov 2004, 14:25
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 20 Nov 2004, 14:33
Privalov wrote:
Since this code in its current state is our common work, we have to agree both on how to release it.


Yes, you are right, of course.

Regards
Post 20 Nov 2004, 14:33
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 21 Nov 2004, 08:14
Yes, it's allright with me! Smile
Post 21 Nov 2004, 08:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 21 Nov 2004, 09:54
OK, this is the routine used by this message board:
Code:
/**
 * Syntax highlighting for fasm code by Tommy Lillehagen
 * Fixed and improved by Tomasz Grysztar
 */
function showasm($src)
{
 $code = explode("\n",$src);
 $result = "";
 $chars = ".,()[]{}=|\\#&!:+-*/<>~`\t ";
 $q = ""; $inq = false;
 $colors = array("#000000","#808080","#880000","#0000FF","#008800");
 foreach($code as $line)
  {
   $lastcolor = 3;
   $nextcolor = 0;
   $part = "";
   $inq = false;
   $column = 0;

   for ($i=0;$i<strlen($line);$i++)
    {
     if ($nextcolor == 1)
      {
       $lastcolor = 3;
       $nextcolor = 0;
      }
     if (substr($line,$i,1) == ";" & $lastcolor != 2)
      {
       $lastcolor = 1;
      }
     elseif ((strstr("0123456789",substr($line,$i,1)) | (substr($line,$i,1) == "$")) & $lastcolor == 3)
      {
       $lastcolor = 4;
       if (substr($line,$i,1) == "$" & stristr("0123456789ABCDEF",substr($line,$i+1,1)) === false)
        {
         $lastcolor = 0;
        }
      }
     elseif ((substr($line,$i,1) == "'" | substr($line,$i,1) == "\"") & ($lastcolor == 3 | $lastcolor == 2))
      {
       if ($inq === false)
        {
         $q = substr($line,$i,1);
        }
       if (substr($line,$i,1) == $q)
        {
         if ($lastcolor == 2)
          { $lastcolor = 2; $nextcolor = 1; $inq = false; }
         else
          { $lastcolor = 2; $inq = true; }
        }
      }
     elseif ((strpos($chars,substr($line,$i,1)) != false) & ($lastcolor != 1) & ($inq === false))
      {
       $lastcolor = 3;
       $nextcolor = 1;
      }
     elseif ($lastcolor == 3)
      {
       $lastcolor = 0;
      }
     $part .= $lastcolor;
    }

   $isStarted = false;

   for ($i=0;$i<strlen($line);$i++)
    {
     if ($isStarted === false)
      {
       $result .= "{A\n}span{S\n}style={Q\n}color:{S\n}".$colors[substr($part,$i,1)]."{Q\n}{B\n}";
       $isStarted = true;
      }
     $c=substr($line,$i,1);
     if ($c != "\t")
      $result .= $c;
     else
      {
       $spacecount = 8 - $column % 8;
       $result .= str_repeat(" ",$spacecount);
       $column += $spacecount-1;
      }
     if (substr($part,$i+1,1) != substr($part,$i,1))
      {
       $result .= "{A\n}/span{B\n}";
       $isStarted = false;
      }
     $column++;
    }

   if ($isStarted) $result .= "{A\n}/span{B\n}";

   $result .= "{A\n}br{B\n}";

  }

 $result = htmlspecialchars($result) ;

 $result = str_replace(" ", "&nbsp;", $result);

 $result = preg_replace("/{A\n}/i", "<", $result);
 $result = preg_replace("/{B\n}/i", ">", $result);
 $result = preg_replace("/{Q\n}/i", "\"", $result);
 $result = preg_replace("/{S\n}/i", " ", $result);

 return($result);
}    
Post 21 Nov 2004, 09:54
View user's profile Send private message Visit poster's website Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 21 Nov 2004, 18:17
Thanks! Smile
Post 21 Nov 2004, 18:17
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 21 Nov 2004, 19:01
No problem.. Smile
Post 21 Nov 2004, 19:01
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 21 Nov 2004, 20:40
Privalov wrote:
OK, this is the routine used by this message board:


Well, it looks I was wrong, about the license. Embarassed This procedure is not dependent on the phpBB in any way, so if you doesn't distribute modified version of phpBB with this procedure used, but only the source of the procedure itself, you can choose whatever license you like.

Regards.
Post 21 Nov 2004, 20:40
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
zbenjudah



Joined: 11 Aug 2004
Posts: 17
zbenjudah 28 Nov 2004, 20:07
about this piece of code I take it that it does syntax high lighting but why have you done it in C rather than assembly just curiouse is all
Post 28 Nov 2004, 20:07
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 28 Nov 2004, 20:13
I think that it's in PHP, not C Smile

The reason would be that the message board software is written in PHP, not assembly.
Post 28 Nov 2004, 20:13
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 28 Nov 2004, 20:15
Smile
It is not C - it is a PHP highlighter (for websites). If you want similar code in asm, you can try my asm2html program - it adds HTML-based syntax highlighting to your sources.
Post 28 Nov 2004, 20:15
View user's profile Send private message Visit poster's website Reply with quote
zbenjudah



Joined: 11 Aug 2004
Posts: 17
zbenjudah 29 Nov 2004, 02:04
I have not done much php! just quikly paroused the sourse it does have C style comments so I was mistaken............

that would explain why it does not compile in a c compiler what compiler does one use to compile this particular piece of code


decard u say u have an htm converter are there any C2asm coverters around
Post 29 Nov 2004, 02:04
View user's profile Send private message Reply with quote
rea



Joined: 14 Nov 2004
Posts: 92
rea 29 Nov 2004, 02:37
much compilers can output asm files, check if exist the option in the one you are using.


I think that decard is talking about a program that read a parse a input file, and format is like html style...
Post 29 Nov 2004, 02:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.