changeset 402:22d65b2bef4f

Migrated the code that generates the ptable to Tango.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 22 Sep 2007 21:01:31 +0200
parents fcdf7ac5ad27
children e7228859d865
files trunk/src/dil/Lexer.d
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Lexer.d	Sat Sep 22 19:49:54 2007 +0200
+++ b/trunk/src/dil/Lexer.d	Sat Sep 22 21:01:31 2007 +0200
@@ -2160,10 +2160,11 @@
 static this()
 {
   alias ptable p;
+  assert(p.length == 256);
   // Initialize character properties table.
   for (int i; i < p.length; ++i)
   {
-    p[i] = 0;
+    p[i] = 0; // Reset
     if ('0' <= i && i <= '7')
       p[i] |= CP.Octal;
     if ('0' <= i && i <= '9')
@@ -2192,11 +2193,10 @@
   p['v'] |= 11 << 8;
   // Print a formatted array literal.
   char[] array = "[\n";
-  for (int i; i < p.length; ++i)
+  foreach (i, c; ptable)
   {
-    int c = p[i];
-    array ~= std.string.format(c>255?" 0x%x,":"%2d,", c, ((i+1) % 16) ? "":"\n");
+    array ~= Format((c>255?" 0x{0:x},":"{0,2},"), c) ~ (((i+1) % 16) ? "":"\n");
   }
   array[$-2..$] = "\n]";
-  writefln(array);
+  Stdout(array).newline;
 }