1083 lines · 38.7 KB · Text
RawDownload
/* A recursive-descent parser generated by peg 0.1.15 */ #define YYRULECOUNT 32#ifndef YY_MALLOC#define YY_MALLOC(C, N)		malloc(N)#endif#ifndef YY_REALLOC#define YY_REALLOC(C, P, N)	realloc(P, N)#endif#ifndef YY_FREE#define YY_FREE(C, P)		free(P)#endif#ifndef YY_LOCAL#define YY_LOCAL(T)	static T#endif#ifndef YY_ACTION#define YY_ACTION(T)	static T#endif#ifndef YY_RULE#define YY_RULE(T)	static T#endif#ifndef YY_PARSE#define YY_PARSE(T)	T#endif#ifndef YYPARSE#define YYPARSE		yyparse#endif#ifndef YYPARSEFROM#define YYPARSEFROM	yyparsefrom#endif#ifndef YYRELEASE#define YYRELEASE	yyrelease#endif#ifndef YY_BEGIN#define YY_BEGIN	( yy->__begin= yy->__pos, 1)#endif#ifndef YY_END#define YY_END		( yy->__end= yy->__pos, 1)#endif#ifdef YY_DEBUG# define yyprintf(args)	fprintf args#else# define yyprintf(args)#endif#ifndef YYSTYPE#define YYSTYPE	int#endif#ifndef YY_STACK_SIZE#define YY_STACK_SIZE 128#endif #ifndef YY_BUFFER_SIZE#define YY_BUFFER_SIZE 1024#endif #ifndef YY_PART typedef struct _yycontext yycontext;typedef void (*yyaction)(yycontext *yy, char *yytext, int yyleng);typedef struct _yythunk { int begin, end;  yyaction  action;  struct _yythunk *next; } yythunk; struct _yycontext {  char     *__buf;  int       __buflen;  int       __pos;  int       __limit;  char     *__text;  int       __textlen;  int       __begin;  int       __end;  int       __textmax;  yythunk  *__thunks;  int       __thunkslen;  int       __thunkpos;  YYSTYPE   __;  YYSTYPE  *__val;  YYSTYPE  *__vals;  int       __valslen;#ifdef YY_CTX_MEMBERS  YY_CTX_MEMBERS#endif}; #ifdef YY_CTX_LOCAL#define YY_CTX_PARAM_	yycontext *yyctx,#define YY_CTX_PARAM	yycontext *yyctx#define YY_CTX_ARG_	yyctx,#define YY_CTX_ARG	yyctx#ifndef YY_INPUT#define YY_INPUT(yy, buf, result, max_size)		\  {							\    int yyc= getchar();					\    result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1);	\    yyprintf((stderr, "<%c>", yyc));			\  }#endif#else#define YY_CTX_PARAM_#define YY_CTX_PARAM	void#define YY_CTX_ARG_#define YY_CTX_ARGyycontext _yyctx= { 0, 0 };yycontext *yyctx= &_yyctx;#ifndef YY_INPUT#define YY_INPUT(buf, result, max_size)			\  {							\    int yyc= getchar();					\    result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1);	\    yyprintf((stderr, "<%c>", yyc));			\  }#endif#endif YY_LOCAL(int) yyrefill(yycontext *yy){  int yyn;  while (yy->__buflen - yy->__pos < 512)    {      yy->__buflen *= 2;      yy->__buf= (char *)YY_REALLOC(yy, yy->__buf, yy->__buflen);    }#ifdef YY_CTX_LOCAL  YY_INPUT(yy, (yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos));#else  YY_INPUT((yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos));#endif  if (!yyn) return 0;  yy->__limit += yyn;  return 1;} YY_LOCAL(int) yymatchDot(yycontext *yy){  if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;  ++yy->__pos;  return 1;} YY_LOCAL(int) yymatchChar(yycontext *yy, int c){  if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;  if ((unsigned char)yy->__buf[yy->__pos] == c)    {      ++yy->__pos;      yyprintf((stderr, "  ok   yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos));      return 1;    }  yyprintf((stderr, "  fail yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos));  return 0;} YY_LOCAL(int) yymatchString(yycontext *yy, const char *s){  int yysav= yy->__pos;  while (*s)    {      if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;      if (yy->__buf[yy->__pos] != *s)        {          yy->__pos= yysav;          return 0;        }      ++s;      ++yy->__pos;    }  return 1;} YY_LOCAL(int) yymatchClass(yycontext *yy, unsigned char *bits){  int c;  if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;  c= (unsigned char)yy->__buf[yy->__pos];  if (bits[c >> 3] & (1 << (c & 7)))    {      ++yy->__pos;      yyprintf((stderr, "  ok   yymatchClass @ %s\n", yy->__buf+yy->__pos));      return 1;    }  yyprintf((stderr, "  fail yymatchClass @ %s\n", yy->__buf+yy->__pos));  return 0;} YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end){  while (yy->__thunkpos >= yy->__thunkslen)    {      yy->__thunkslen *= 2;      yy->__thunks= (yythunk *)YY_REALLOC(yy, yy->__thunks, sizeof(yythunk) * yy->__thunkslen);    }  yy->__thunks[yy->__thunkpos].begin=  begin;  yy->__thunks[yy->__thunkpos].end=    end;  yy->__thunks[yy->__thunkpos].action= action;  ++yy->__thunkpos;} YY_LOCAL(int) yyText(yycontext *yy, int begin, int end){  int yyleng= end - begin;  if (yyleng <= 0)    yyleng= 0;  else    {      while (yy->__textlen < (yyleng + 1))	{	  yy->__textlen *= 2;	  yy->__text= (char *)YY_REALLOC(yy, yy->__text, yy->__textlen);	}      memcpy(yy->__text, yy->__buf + begin, yyleng);    }  yy->__text[yyleng]= '\0';  return yyleng;} YY_LOCAL(void) yyDone(yycontext *yy){  int pos;  for (pos= 0;  pos < yy->__thunkpos;  ++pos)    {      yythunk *thunk= &yy->__thunks[pos];      int yyleng= thunk->end ? yyText(yy, thunk->begin, thunk->end) : thunk->begin;      yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yy->__text));      thunk->action(yy, yy->__text, yyleng);    }  yy->__thunkpos= 0;} YY_LOCAL(void) yyCommit(yycontext *yy){  if ((yy->__limit -= yy->__pos))    {      memmove(yy->__buf, yy->__buf + yy->__pos, yy->__limit);    }  yy->__begin -= yy->__pos;  yy->__end -= yy->__pos;  yy->__pos= yy->__thunkpos= 0;} YY_LOCAL(int) yyAccept(yycontext *yy, int tp0){  if (tp0)    {      fprintf(stderr, "accept denied at %d\n", tp0);      return 0;    }  else    {      yyDone(yy);      yyCommit(yy);    }  return 1;} YY_LOCAL(void) yyPush(yycontext *yy, char *text, int count){  yy->__val += count;  while (yy->__valslen <= yy->__val - yy->__vals)    {      long offset= yy->__val - yy->__vals;      yy->__valslen *= 2;      yy->__vals= (YYSTYPE *)YY_REALLOC(yy, yy->__vals, sizeof(YYSTYPE) * yy->__valslen);      yy->__val= yy->__vals + offset;    }}YY_LOCAL(void) yyPop(yycontext *yy, char *text, int count)   { yy->__val -= count; }YY_LOCAL(void) yySet(yycontext *yy, char *text, int count)   { yy->__val[count]= yy->__; } #endif /* YY_PART */ #define	YYACCEPT	yyAccept(yy, yythunkpos0) YY_RULE(int) yy_EndOfLine(yycontext *yy); /* 32 */YY_RULE(int) yy_Comment(yycontext *yy); /* 31 */YY_RULE(int) yy_Space(yycontext *yy); /* 30 */YY_RULE(int) yy_Range(yycontext *yy); /* 29 */YY_RULE(int) yy_Char(yycontext *yy); /* 28 */YY_RULE(int) yy_IdentCont(yycontext *yy); /* 27 */YY_RULE(int) yy_IdentStart(yycontext *yy); /* 26 */YY_RULE(int) yy_END(yycontext *yy); /* 25 */YY_RULE(int) yy_BEGIN(yycontext *yy); /* 24 */YY_RULE(int) yy_DOT(yycontext *yy); /* 23 */YY_RULE(int) yy_Class(yycontext *yy); /* 22 */YY_RULE(int) yy_Literal(yycontext *yy); /* 21 */YY_RULE(int) yy_CLOSE(yycontext *yy); /* 20 */YY_RULE(int) yy_OPEN(yycontext *yy); /* 19 */YY_RULE(int) yy_PLUS(yycontext *yy); /* 18 */YY_RULE(int) yy_STAR(yycontext *yy); /* 17 */YY_RULE(int) yy_QUESTION(yycontext *yy); /* 16 */YY_RULE(int) yy_Primary(yycontext *yy); /* 15 */YY_RULE(int) yy_NOT(yycontext *yy); /* 14 */YY_RULE(int) yy_Suffix(yycontext *yy); /* 13 */YY_RULE(int) yy_Action(yycontext *yy); /* 12 */YY_RULE(int) yy_AND(yycontext *yy); /* 11 */YY_RULE(int) yy_Prefix(yycontext *yy); /* 10 */YY_RULE(int) yy_SLASH(yycontext *yy); /* 9 */YY_RULE(int) yy_Sequence(yycontext *yy); /* 8 */YY_RULE(int) yy_Expression(yycontext *yy); /* 7 */YY_RULE(int) yy_LEFTARROW(yycontext *yy); /* 6 */YY_RULE(int) yy_Identifier(yycontext *yy); /* 5 */YY_RULE(int) yy_EndOfFile(yycontext *yy); /* 4 */YY_RULE(int) yy_Definition(yycontext *yy); /* 3 */YY_RULE(int) yy_Spacing(yycontext *yy); /* 2 */YY_RULE(int) yy_Grammar(yycontext *yy); /* 1 */ YY_ACTION(void) yy_7_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_7_Primary\n"));  {   push(makePredicate("YY_END")); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_6_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_6_Primary\n"));  {   push(makePredicate("YY_BEGIN")); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_5_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_5_Primary\n"));  {   push(makeAction(yytext)); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_4_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_4_Primary\n"));  {   push(makeDot()); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_3_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_3_Primary\n"));  {   push(makeClass(yytext)); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_2_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_2_Primary\n"));  {   push(makeString(yytext)); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_1_Primary(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_1_Primary\n"));  {   push(makeName(findRule(yytext))); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_3_Suffix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_3_Suffix\n"));  {   push(makePlus (pop())); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_2_Suffix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_2_Suffix\n"));  {   push(makeStar (pop())); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_1_Suffix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_1_Suffix\n"));  {   push(makeQuery(pop())); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_3_Prefix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_3_Prefix\n"));  {   push(makePeekNot(pop())); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_2_Prefix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_2_Prefix\n"));  {   push(makePeekFor(pop())); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_1_Prefix(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_1_Prefix\n"));  {   push(makePredicate(yytext)); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}YY_ACTION(void) yy_2_Sequence(yycontext *yy, char *yytext, int yyleng){#define __ yy->__#define yypos yy->__pos#define yythunkpos yy->__thunkpos  yyprintf((stderr, "do yy_2_Sequence\n"));  {   push(makePredicate("1")); ;  }#undef __#undef yythunkpos#undef yypos#undef yy}

Lines 1–500 of 1083.