lpvm.h (1646B)
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