From 978b13f8666f11f17c9c308e262b1e14113a0979 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 10 Apr 2016 05:14:27 +0200 Subject: [PATCH] lexer (HL), dictionnary for the special keywords use a simple sum --- src/ce_dlangmaps.pas | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ce_dlangmaps.pas b/src/ce_dlangmaps.pas index c0b2b129..c7ff3355 100644 --- a/src/ce_dlangmaps.pas +++ b/src/ce_dlangmaps.pas @@ -15,33 +15,33 @@ type private const fWords: array [0..15] of string = ( - '__PRETTY_FUNCTION__', '__VENDOR__', '', '__VERSION__', '__DATE__', - '__FILE__', '__LINE__', '', '__FUNCTION__', '', '__TIMESTAMP__', '__TIME__', - '__EOF__', '', '', '__MODULE__' + '__FILE__', '', '__TIME__', '', '', '__EOF__', '__VENDOR__', '__LINE__', + '', '__PRETTY_FUNCTION__', '__DATE__', '__MODULE__', '__FUNCTION__', + '__TIMESTAMP__', '__VERSION__', '' ); const fHasEntry: array [0..15] of boolean = ( - true, true, false, true, true, true, true, false, true, false, true, true, - true, false, false, true + true, false, true, false, false, true, true, true, false, true, true, true, + true, true, true, false ); const fCoeffs: array[0..255] of Byte = ( - 50, 243, 103, 74, 140, 54, 86, 48, 32, 12, 76, 146, 95, 139, 178, 149, 255, - 167, 77, 13, 101, 143, 16, 6, 221, 208, 221, 79, 217, 253, 102, 24, 243, - 208, 70, 196, 133, 33, 208, 26, 203, 72, 234, 222, 92, 240, 162, 139, 102, - 174, 240, 48, 10, 173, 208, 107, 85, 176, 211, 77, 246, 56, 253, 2, 164, - 108, 181, 37, 35, 11, 111, 224, 51, 16, 170, 123, 245, 147, 183, 250, 15, - 202, 106, 126, 199, 31, 2, 174, 221, 81, 207, 50, 170, 86, 71, 12, 51, 3, - 30, 192, 132, 159, 74, 35, 62, 90, 10, 135, 33, 23, 15, 100, 2, 69, 250, 248, - 36, 120, 134, 108, 134, 54, 89, 89, 219, 86, 165, 72, 244, 130, 60, 44, 84, - 129, 130, 253, 90, 104, 25, 52, 103, 109, 239, 100, 16, 188, 87, 132, 201, - 110, 175, 152, 181, 178, 196, 61, 52, 60, 169, 26, 52, 48, 90, 236, 244, 26, - 28, 117, 65, 155, 24, 60, 216, 220, 80, 152, 202, 173, 43, 17, 48, 83, 135, - 188, 251, 254, 232, 167, 196, 3, 222, 73, 169, 156, 222, 215, 217, 6, 105, - 171, 130, 169, 27, 9, 147, 176, 207, 45, 43, 47, 11, 163, 215, 117, 11, 100, - 253, 70, 242, 169, 92, 61, 198, 236, 243, 26, 144, 220, 76, 40, 178, 158, - 164, 80, 112, 61, 157, 26, 224, 53, 123, 105, 27, 170, 126, 101, 3, 65, 113, - 101, 157, 109, 110, 252, 207, 0 + 23, 54, 252, 239, 192, 69, 42, 70, 63, 3, 89, 171, 21, 218, 140, 187, 191, + 74, 12, 230, 108, 85, 152, 3, 56, 199, 164, 61, 172, 64, 225, 99, 179, 182, + 174, 189, 171, 243, 108, 60, 208, 146, 6, 17, 236, 103, 127, 4, 219, 83, + 85, 138, 228, 29, 243, 85, 155, 246, 32, 93, 255, 80, 135, 160, 38, 224, 3, + 134, 54, 8, 27, 129, 142, 243, 201, 39, 198, 171, 242, 78, 141, 183, 57, + 187, 168, 138, 251, 219, 96, 186, 112, 117, 220, 164, 203, 21, 127, 101, + 77, 41, 187, 233, 66, 20, 108, 205, 192, 246, 49, 38, 71, 106, 176, 176, + 253, 21, 18, 136, 165, 120, 50, 144, 62, 90, 56, 10, 0, 109, 109, 70, 108, + 191, 244, 103, 237, 145, 214, 39, 227, 200, 40, 135, 49, 12, 7, 203, 37, + 101, 142, 4, 156, 251, 234, 144, 54, 251, 17, 82, 59, 108, 178, 60, 229, + 43, 72, 97, 193, 36, 253, 36, 154, 219, 246, 59, 165, 144, 136, 136, 231, + 243, 222, 108, 73, 148, 208, 148, 147, 57, 9, 1, 193, 247, 251, 116, 48, + 72, 165, 80, 49, 86, 220, 197, 227, 71, 24, 98, 21, 132, 2, 164, 133, 186, + 43, 19, 138, 166, 119, 202, 109, 124, 91, 32, 159, 155, 145, 124, 164, 19, + 200, 143, 191, 31, 199, 229, 240, 115, 135, 52, 181, 14, 140, 174, 12, 139, + 45, 158, 171, 146, 186, 72, 34, 12, 6, 207, 151, 117 ); class function hash(const w: string): Byte; static; {$IFNDEF DEBUG}inline;{$ENDIF} public @@ -49,7 +49,7 @@ type end; (** - * Perfect static hash-map that detects the "straight" D2 keywords plus a few + * Perfect static hash-map that detects the 'straight' D2 keywords plus a few * exception for the library types related to immutable strings. *) keywordsMap = record @@ -138,8 +138,8 @@ var i: integer; begin Result := 0; - for i := 2 to length(w) do - Result += fCoeffs[(Byte(w[i]) + (Byte(i-1) xor Byte(w[i-1]))) and $FF]; + for i := 1 to length(w) do + Result += fCoeffs[Byte(w[i])]; Result := Result and $F; end; {$IFDEF DEBUG}{$POP}{$ENDIF}