[pedevel] Hex numbers patches and ASM lang

  • From: "BiPolar" <BiPolar@xxxxxxxxxxxx>
  • To: pedevel@xxxxxxxxxxxxx
  • Date: Fri, 12 Dec 2003 17:14:17 -0300 ART

Hello there.
I did a couple of mods to the C++ and Pascal highlighters, regarding hex 
numbers.
Now something like 0x0112Fa looks right on C++, and something like $0112Fa 
looks ok with Pascal.

Also, I did a highlighter for assembler files (x86, looks ok for gas and nasm 
files), it may need a little look at the keywords file, but it works pretty 
nicely already.

I'm attaching the two diff files and the files for the ASM-x86 highlighter 
without zipping (hopping that Ecartis won't reject them).


Oscar Lesta.



-- Attached file included as plaintext by Ecartis --
-- File: CLang_cpp.diff

--- /Sources/beunited.org/pe/pe/Languages/Sources/CLang_cpp.cpp Sun Apr 13 
12:04:16 2003
+++ CLang_cpp.cpp       Fri Dec 12 16:58:11 2003
@@ -82,6 +82,14 @@
        return false;
 }
 
+bool isHexNum(char c)
+{
+       if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c 
<= 'F'))
+               return true;
+
+       return false;
+}
+
 _EXPORT void ColorLine(CLanguageProxy& proxy, int& state)
 {
        const char *text = proxy.Text();
@@ -353,7 +361,7 @@
                        case NUMERIC:
                        {
                                proxy.SetColor(s, kLNumberColor);
-                               if (isNumeric(text[i-1]))
+                               if (isNumeric(text[i-1]) || (hex_num && 
isHexNum(text[i - 1])))
                                        ;
                                else
                                        if (text[i-1]=='.' && 
floating_point==false && hex_num==false)
@@ -364,6 +372,7 @@
                                        {
                                                s=i-1;
                                                i--;
+                                               hex_num = false;
                                                state = START;
                                        }
                        }

-- Attached file included as plaintext by Ecartis --
-- File: CLang_pas.diff

--- /Sources/beunited.org/pe/pe/Languages/Sources/CLang_pas.cpp Sun Apr 13 
12:04:16 2003
+++ CLang_pas.cpp       Fri Dec 12 15:03:16 2003
@@ -88,15 +88,24 @@
        return false;
 }
 
+bool isHexNum(char c)
+{
+       if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c 
<= 'F'))
+               return true;
+
+       return false;
+}
+
 _EXPORT void ColorLine(CLanguageProxy& proxy, int& state)
 {
        const char *text = proxy.Text();
        int size = proxy.Size();
-       int i = 0, s = 0, kws, cc_cnt, esc = 0;
+       int i = 0, s = 0, kws = 0, esc = 0;
        char c;
        bool leave = false;
        bool floating_point = false;
-       
+       bool hex_num = false;
+
        if (state == COMMENT1 || state == COMMENT2 || state == LCOMMENT)
                proxy.SetColor(0, kLCommentColor);
        else
@@ -142,7 +151,7 @@
                                else if (c == '\'')
                                        state = STRING;
 
-                               else if (isNumeric(c) && !(isalpha(text[i])))
+                               else if (isNumeric(c) || (c == '$' && 
isHexNum(text[i])))
                                {
                                        state = NUMERIC;        
                                }
@@ -278,11 +287,13 @@
                        
                        case NUMERIC:
                                proxy.SetColor(s, kLNumberColor);
-                               if (isNumeric(text[i - 1]))
+                               if (isNumeric(text[i - 1]) || (hex_num && 
isHexNum(text[i - 1])))
                                        ;
                                else
                                        if (text[i - 1] == '.' && 
floating_point == false)
                                                floating_point = true;
+                                       else if (isHexNum(text[i - 1]) && 
hex_num == false)
+                                               hex_num = true;
                                        else
                                        {
                                                s = i - 1;

-- Binary/unsupported file stripped by Ecartis --
-- Type: text/x-source-code
-- File: CLang_asm.cpp


-- Binary/unsupported file stripped by Ecartis --
-- Type: text/x-assembler
-- File: keywords.asm



Other related posts: