diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-23 11:02:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-23 11:02:52 -0300 |
commit | f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef (patch) | |
tree | fcd765f59c5d74574bdb21cd7a11e1f723068d87 /lpprint.c | |
parent | 9f7183c280f310c0d0b49b7b9c3b8eac297fafa7 (diff) | |
download | lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.tar.gz lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.tar.bz2 lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.zip |
Towards a smaller encoding for charsets in code
Diffstat (limited to 'lpprint.c')
-rw-r--r-- | lpprint.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -33,6 +33,18 @@ void printcharset (const byte *st) { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | static void printIcharset (const Instruction *inst, const byte *buff) { | ||
37 | byte cs[CHARSETSIZE]; | ||
38 | int i; | ||
39 | loopset(j, cs[j] = 0); | ||
40 | for (i = 0; i < CHARSETSIZE << 3; i++) { | ||
41 | if (charinset(inst, buff, i)) | ||
42 | setchar(cs, i); | ||
43 | } | ||
44 | printcharset(cs); | ||
45 | } | ||
46 | |||
47 | |||
36 | static const char *capkind (int kind) { | 48 | static const char *capkind (int kind) { |
37 | const char *const modes[] = { | 49 | const char *const modes[] = { |
38 | "close", "position", "constant", "backref", | 50 | "close", "position", "constant", "backref", |
@@ -83,15 +95,15 @@ void printinst (const Instruction *op, const Instruction *p) { | |||
83 | break; | 95 | break; |
84 | } | 96 | } |
85 | case ISet: { | 97 | case ISet: { |
86 | printcharset((p+1)->buff); | 98 | printIcharset(p, (p+1)->buff); |
87 | break; | 99 | break; |
88 | } | 100 | } |
89 | case ITestSet: { | 101 | case ITestSet: { |
90 | printcharset((p+2)->buff); printjmp(op, p); | 102 | printIcharset(p, (p+2)->buff); printjmp(op, p); |
91 | break; | 103 | break; |
92 | } | 104 | } |
93 | case ISpan: { | 105 | case ISpan: { |
94 | printcharset((p+1)->buff); | 106 | printIcharset(p, (p+1)->buff); |
95 | break; | 107 | break; |
96 | } | 108 | } |
97 | case IOpenCall: { | 109 | case IOpenCall: { |