diff options
author | Sergio Medeiros <sqmedeiros@gmail.com> | 2014-10-29 18:13:38 -0300 |
---|---|---|
committer | Sergio Medeiros <sqmedeiros@gmail.com> | 2014-10-29 18:13:38 -0300 |
commit | 8d30a0ff8a8584e225c03d878a9add439ea193a3 (patch) | |
tree | cdc03907837ebec1aed26be7290a5a40d00f3e2c /lpvm.h | |
parent | 3af55803f0a261dd9b2ccf85a7532288c4a270ae (diff) | |
download | lpeglabel-8d30a0ff8a8584e225c03d878a9add439ea193a3.tar.gz lpeglabel-8d30a0ff8a8584e225c03d878a9add439ea193a3.tar.bz2 lpeglabel-8d30a0ff8a8584e225c03d878a9add439ea193a3.zip |
Creating the git repository with the current implementation.
Diffstat (limited to 'lpvm.h')
-rw-r--r-- | lpvm.h | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | ** $Id: lpvm.h,v 1.2 2013/04/03 20:37:18 roberto Exp $ | ||
3 | */ | ||
4 | |||
5 | #if !defined(lpvm_h) | ||
6 | #define lpvm_h | ||
7 | |||
8 | #include "lpcap.h" | ||
9 | |||
10 | |||
11 | /* Virtual Machine's instructions */ | ||
12 | typedef enum Opcode { | ||
13 | IAny, /* if no char, fail */ | ||
14 | IChar, /* if char != aux, fail */ | ||
15 | ISet, /* if char not in buff, fail */ | ||
16 | ITestAny, /* in no char, jump to 'offset' */ | ||
17 | ITestChar, /* if char != aux, jump to 'offset' */ | ||
18 | ITestSet, /* if char not in buff, jump to 'offset' */ | ||
19 | ISpan, /* read a span of chars in buff */ | ||
20 | IBehind, /* walk back 'aux' characters (fail if not possible) */ | ||
21 | IRet, /* return from a rule */ | ||
22 | IEnd, /* end of pattern */ | ||
23 | IChoice, /* stack a choice; next fail will jump to 'offset' */ | ||
24 | IJmp, /* jump to 'offset' */ | ||
25 | ICall, /* call rule at 'offset' */ | ||
26 | IOpenCall, /* call rule number 'key' (must be closed to a ICall) */ | ||
27 | ICommit, /* pop choice and jump to 'offset' */ | ||
28 | IPartialCommit, /* update top choice to current position and jump */ | ||
29 | IBackCommit, /* "fails" but jump to its own 'offset' */ | ||
30 | IFailTwice, /* pop one choice and then fail */ | ||
31 | IFail, /* go back to saved state on choice and jump to saved offset */ | ||
32 | IGiveup, /* internal use */ | ||
33 | IFullCapture, /* complete capture of last 'off' chars */ | ||
34 | IOpenCapture, /* start a capture */ | ||
35 | ICloseCapture, | ||
36 | ICloseRunTime, | ||
37 | IThrow, /* "fails" with a specific label labeled failure */ | ||
38 | ILabChoice /* labeled choice */ | ||
39 | } Opcode; | ||
40 | |||
41 | |||
42 | |||
43 | typedef union Instruction { | ||
44 | struct Inst { | ||
45 | byte code; | ||
46 | byte aux; | ||
47 | short key; | ||
48 | } i; | ||
49 | int offset; | ||
50 | Labelset labels; /* labeled failure */ | ||
51 | byte buff[1]; | ||
52 | } Instruction; | ||
53 | |||
54 | |||
55 | int getposition (lua_State *L, int t, int i); | ||
56 | void printpatt (Instruction *p, int n); | ||
57 | const char *match (lua_State *L, const char *o, const char *s, const char *e, | ||
58 | Instruction *op, Capture *capture, int ptop); | ||
59 | int verify (lua_State *L, Instruction *op, const Instruction *p, | ||
60 | Instruction *e, int postable, int rule); | ||
61 | void checkrule (lua_State *L, Instruction *op, int from, int to, | ||
62 | int postable, int rule); | ||
63 | |||
64 | |||
65 | #endif | ||
66 | |||