Example #1
0
static HParser* h_in_or_not__m(HAllocator* mm__, const uint8_t *options, size_t count, int val) {
  HCharset cs = new_charset(mm__);
  for (size_t i = 0; i < 256; i++)
    charset_set(cs, i, 1-val);
  for (size_t i = 0; i < count; i++)
    charset_set(cs, options[i], val);

  return h_new_parser(mm__, &charset_vt, cs);
}
Example #2
0
static void desugar_whitespace(HAllocator *mm__, HCFStack *stk__, void *env) {

  HCharset ws_cs = new_charset(mm__);
  for(size_t i=0; i<sizeof(SPACE_CHRS); i++)
    charset_set(ws_cs, SPACE_CHRS[i], 1);
  
  HCFS_BEGIN_CHOICE() {
    HCFS_BEGIN_SEQ() {
      HCFS_BEGIN_CHOICE() {
	HCFS_BEGIN_SEQ() {
	  HCFS_ADD_CHARSET(ws_cs);
	  HCFS_APPEND(HCFS_THIS_CHOICE); // yay circular pointer!
	} HCFS_END_SEQ();
	HCFS_BEGIN_SEQ() {
	} HCFS_END_SEQ();
      } HCFS_END_CHOICE();
      HCFS_DESUGAR( (HParser*)env );
    } HCFS_END_SEQ();
    HCFS_THIS_CHOICE->reshape = h_act_last;
  } HCFS_END_CHOICE();
}
Example #3
0
HParser* h_ch_range__m(HAllocator* mm__, const uint8_t lower, const uint8_t upper) {
  HCharset cs = new_charset(mm__);
  for (int i = 0; i < 256; i++)
    charset_set(cs, i, (lower <= i) && (i <= upper));
  return h_new_parser(mm__, &charset_vt, cs);
}