diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-02-20 10:13:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-02-20 10:13:46 -0300 |
commit | e08e5df853560de6482d84066a7accc6a18de545 (patch) | |
tree | ee19686bb35da90709a32ed24bf7855de1a3946a /lpvm.h | |
download | lpeg-e08e5df853560de6482d84066a7accc6a18de545.tar.gz lpeg-e08e5df853560de6482d84066a7accc6a18de545.tar.bz2 lpeg-e08e5df853560de6482d84066a7accc6a18de545.zip |
Fist version of LPeg on GIT
LPeg repository is being moved to git. Past versions won't be moved;
they are still available in RCS.
Diffstat (limited to 'lpvm.h')
-rw-r--r-- | lpvm.h | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | ** $Id: lpvm.h,v 1.3 2014/02/21 13:06:41 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 | } Opcode; | ||
38 | |||
39 | |||
40 | |||
41 | typedef union Instruction { | ||
42 | struct Inst { | ||
43 | byte code; | ||
44 | byte aux; | ||
45 | short key; | ||
46 | } i; | ||
47 | int offset; | ||
48 | byte buff[1]; | ||
49 | } Instruction; | ||
50 | |||
51 | |||
52 | void printpatt (Instruction *p, int n); | ||
53 | const char *match (lua_State *L, const char *o, const char *s, const char *e, | ||
54 | Instruction *op, Capture *capture, int ptop); | ||
55 | |||
56 | |||
57 | #endif | ||
58 | |||