You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lpvm.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. ** $Id: lpvm.h,v 1.3 2014/02/21 13:06:41 roberto Exp $
  3. */
  4. #if !defined(lpvm_h)
  5. #define lpvm_h
  6. #include "lpcap.h"
  7. /* Virtual Machine's instructions */
  8. typedef enum Opcode {
  9. IAny, /* if no char, fail */
  10. IChar, /* if char != aux, fail */
  11. ISet, /* if char not in buff, fail */
  12. ITestAny, /* in no char, jump to 'offset' */
  13. ITestChar, /* if char != aux, jump to 'offset' */
  14. ITestSet, /* if char not in buff, jump to 'offset' */
  15. ISpan, /* read a span of chars in buff */
  16. IBehind, /* walk back 'aux' characters (fail if not possible) */
  17. IRet, /* return from a rule */
  18. IEnd, /* end of pattern */
  19. IChoice, /* stack a choice; next fail will jump to 'offset' */
  20. IJmp, /* jump to 'offset' */
  21. ICall, /* call rule at 'offset' */
  22. IOpenCall, /* call rule number 'key' (must be closed to a ICall) */
  23. ICommit, /* pop choice and jump to 'offset' */
  24. IPartialCommit, /* update top choice to current position and jump */
  25. IBackCommit, /* "fails" but jump to its own 'offset' */
  26. IFailTwice, /* pop one choice and then fail */
  27. IFail, /* go back to saved state on choice and jump to saved offset */
  28. IGiveup, /* internal use */
  29. IFullCapture, /* complete capture of last 'off' chars */
  30. IOpenCapture, /* start a capture */
  31. ICloseCapture,
  32. ICloseRunTime
  33. } Opcode;
  34. typedef union Instruction {
  35. struct Inst {
  36. byte code;
  37. byte aux;
  38. short key;
  39. } i;
  40. int offset;
  41. byte buff[1];
  42. } Instruction;
  43. void printpatt (Instruction *p, int n);
  44. const char *match (lua_State *L, const char *o, const char *s, const char *e,
  45. Instruction *op, Capture *capture, int ptop);
  46. #endif