aboutsummaryrefslogtreecommitdiff
path: root/lpvm.h
diff options
context:
space:
mode:
authorSergio Medeiros <sqmedeiros@gmail.com>2014-10-29 18:13:38 -0300
committerSergio Medeiros <sqmedeiros@gmail.com>2014-10-29 18:13:38 -0300
commit8d30a0ff8a8584e225c03d878a9add439ea193a3 (patch)
treecdc03907837ebec1aed26be7290a5a40d00f3e2c /lpvm.h
parent3af55803f0a261dd9b2ccf85a7532288c4a270ae (diff)
downloadlpeglabel-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.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/lpvm.h b/lpvm.h
new file mode 100644
index 0000000..8024b45
--- /dev/null
+++ b/lpvm.h
@@ -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 */
12typedef 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
43typedef 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
55int getposition (lua_State *L, int t, int i);
56void printpatt (Instruction *p, int n);
57const char *match (lua_State *L, const char *o, const char *s, const char *e,
58 Instruction *op, Capture *capture, int ptop);
59int verify (lua_State *L, Instruction *op, const Instruction *p,
60 Instruction *e, int postable, int rule);
61void checkrule (lua_State *L, Instruction *op, int from, int to,
62 int postable, int rule);
63
64
65#endif
66