diff options
Diffstat (limited to 'lpvm.h')
-rw-r--r-- | lpvm.h | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -17,17 +17,18 @@ typedef enum Opcode { | |||
17 | ITestChar, /* if char != aux, jump to 'offset' */ | 17 | ITestChar, /* if char != aux, jump to 'offset' */ |
18 | ITestSet, /* if char not in buff, jump to 'offset' */ | 18 | ITestSet, /* if char not in buff, jump to 'offset' */ |
19 | ISpan, /* read a span of chars in buff */ | 19 | ISpan, /* read a span of chars in buff */ |
20 | IUTFR, /* if codepoint not in range [offset, utf_to], fail */ | ||
20 | IBehind, /* walk back 'aux' characters (fail if not possible) */ | 21 | IBehind, /* walk back 'aux' characters (fail if not possible) */ |
21 | IRet, /* return from a rule */ | 22 | IRet, /* return from a rule */ |
22 | IEnd, /* end of pattern */ | 23 | IEnd, /* end of pattern */ |
23 | IChoice, /* stack a choice; next fail will jump to 'offset' */ | 24 | IChoice, /* stack a choice; next fail will jump to 'offset' */ |
24 | IPredChoice, /* labeld failure: stack a choice; changes label env next fail will jump to 'offset' */ | 25 | IPredChoice, /* labeld failure: stack a choice; changes label env next fail will jump to 'offset' */ /*labeled failure */ |
25 | IJmp, /* jump to 'offset' */ | 26 | IJmp, /* jump to 'offset' */ |
26 | ICall, /* call rule at 'offset' */ | 27 | ICall, /* call rule at 'offset' */ |
27 | IOpenCall, /* call rule number 'key' (must be closed to a ICall) */ | 28 | IOpenCall, /* call rule number 'key' (must be closed to a ICall) */ |
28 | ICommit, /* pop choice and jump to 'offset' */ | 29 | ICommit, /* pop choice and jump to 'offset' */ |
29 | IPartialCommit, /* update top choice to current position and jump */ | 30 | IPartialCommit, /* update top choice to current position and jump */ |
30 | IBackCommit, /* "fails" but jump to its own 'offset' */ | 31 | IBackCommit, /* backtrack like "fail" but jump to its own 'offset' */ |
31 | IFailTwice, /* pop one choice and then fail */ | 32 | IFailTwice, /* pop one choice and then fail */ |
32 | IFail, /* go back to saved state on choice and jump to saved offset */ | 33 | IFail, /* go back to saved state on choice and jump to saved offset */ |
33 | IGiveup, /* internal use */ | 34 | IGiveup, /* internal use */ |
@@ -35,8 +36,9 @@ typedef enum Opcode { | |||
35 | IOpenCapture, /* start a capture */ | 36 | IOpenCapture, /* start a capture */ |
36 | ICloseCapture, | 37 | ICloseCapture, |
37 | ICloseRunTime, | 38 | ICloseRunTime, |
38 | IThrow, /* fails with a given label */ | 39 | IThrow, /* fails with a given label */ /*labeled failure */ |
39 | IThrowRec, /* fails with a given label and call rule at 'offset' */ | 40 | IThrowRec, /* fails with a given label and call rule at 'offset' */ /*labeled failure */ |
41 | IEmpty /* to fill empty slots left by optimizations */ | ||
40 | } Opcode; | 42 | } Opcode; |
41 | 43 | ||
42 | 44 | ||
@@ -52,10 +54,13 @@ typedef union Instruction { | |||
52 | } Instruction; | 54 | } Instruction; |
53 | 55 | ||
54 | 56 | ||
57 | /* extract 24-bit value from an instruction */ | ||
58 | #define utf_to(inst) (((inst)->i.key << 8) | (inst)->i.aux) | ||
59 | |||
60 | |||
55 | void printpatt (Instruction *p, int n); | 61 | void printpatt (Instruction *p, int n); |
56 | const char *match (lua_State *L, const char *o, const char *s, const char *e, | 62 | const char *match (lua_State *L, const char *o, const char *s, const char *e, |
57 | Instruction *op, Capture *capture, int ptop, short *labelf, const char **sfail); /* labeled failure */ | 63 | Instruction *op, Capture *capture, int ptop, short *labelf, const char **sfail); /* labeled failure */ |
58 | 64 | ||
59 | |||
60 | #endif | 65 | #endif |
61 | 66 | ||