diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-21 15:29:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-21 15:29:53 -0300 |
commit | 9f7183c280f310c0d0b49b7b9c3b8eac297fafa7 (patch) | |
tree | 503392ee1a94f6446151a0b90babe8235efdb573 /lpvm.h | |
parent | 7b42a7b13f9c6655dfa7c5951de46dcf0642b0a6 (diff) | |
download | lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.tar.gz lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.tar.bz2 lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.zip |
Field Instruction.key put inside a union
So that we can get its space for other uses, if needed.
Diffstat (limited to 'lpvm.h')
-rw-r--r-- | lpvm.h | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -8,14 +8,14 @@ | |||
8 | /* Virtual Machine's instructions */ | 8 | /* Virtual Machine's instructions */ |
9 | typedef enum Opcode { | 9 | typedef enum Opcode { |
10 | IAny, /* if no char, fail */ | 10 | IAny, /* if no char, fail */ |
11 | IChar, /* if char != aux, fail */ | 11 | IChar, /* if char != aux1, fail */ |
12 | ISet, /* if char not in buff, fail */ | 12 | ISet, /* if char not in buff, fail */ |
13 | ITestAny, /* in no char, jump to 'offset' */ | 13 | ITestAny, /* in no char, jump to 'offset' */ |
14 | ITestChar, /* if char != aux, jump to 'offset' */ | 14 | ITestChar, /* if char != aux1, jump to 'offset' */ |
15 | ITestSet, /* if char not in buff, jump to 'offset' */ | 15 | ITestSet, /* if char not in buff, jump to 'offset' */ |
16 | ISpan, /* read a span of chars in buff */ | 16 | ISpan, /* read a span of chars in buff */ |
17 | IUTFR, /* if codepoint not in range [offset, utf_to], fail */ | 17 | IUTFR, /* if codepoint not in range [offset, utf_to], fail */ |
18 | IBehind, /* walk back 'aux' characters (fail if not possible) */ | 18 | IBehind, /* walk back 'aux1' characters (fail if not possible) */ |
19 | IRet, /* return from a rule */ | 19 | IRet, /* return from a rule */ |
20 | IEnd, /* end of pattern */ | 20 | IEnd, /* end of pattern */ |
21 | IChoice, /* stack a choice; next fail will jump to 'offset' */ | 21 | IChoice, /* stack a choice; next fail will jump to 'offset' */ |
@@ -40,8 +40,10 @@ typedef enum Opcode { | |||
40 | typedef union Instruction { | 40 | typedef union Instruction { |
41 | struct Inst { | 41 | struct Inst { |
42 | byte code; | 42 | byte code; |
43 | byte aux; | 43 | byte aux1; |
44 | short key; | 44 | union { |
45 | short key; | ||
46 | } aux2; | ||
45 | } i; | 47 | } i; |
46 | int offset; | 48 | int offset; |
47 | byte buff[1]; | 49 | byte buff[1]; |
@@ -49,7 +51,7 @@ typedef union Instruction { | |||
49 | 51 | ||
50 | 52 | ||
51 | /* extract 24-bit value from an instruction */ | 53 | /* extract 24-bit value from an instruction */ |
52 | #define utf_to(inst) (((inst)->i.key << 8) | (inst)->i.aux) | 54 | #define utf_to(inst) (((inst)->i.aux2.key << 8) | (inst)->i.aux1) |
53 | 55 | ||
54 | 56 | ||
55 | void printpatt (Instruction *p, int n); | 57 | void printpatt (Instruction *p, int n); |