123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- /* A recursive-descent parser generated by peg 0.1.1 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define YYRULECOUNT 1
- #include <unistd.h>
- #ifndef YY_VARIABLE
- #define YY_VARIABLE(T) static T
- #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 YY_INPUT
- #define YY_INPUT(buf, result, max_size) \
- { \
- int yyc= getchar(); \
- result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
- yyprintf((stderr, "<%c>", yyc)); \
- }
- #endif
- #ifndef YY_BEGIN
- #define YY_BEGIN ( yybegin= yypos, 1)
- #endif
- #ifndef YY_END
- #define YY_END ( yyend= yypos, 1)
- #endif
- #ifdef YY_DEBUG
- # define yyprintf(args) fprintf args
- #else
- # define yyprintf(args)
- #endif
- #ifndef YYSTYPE
- #define YYSTYPE int
- #endif
- #ifndef YY_PART
- typedef void (*yyaction)(char *yytext, int yyleng);
- typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk;
- YY_VARIABLE(char * ) yybuf= 0;
- YY_VARIABLE(int ) yybuflen= 0;
- YY_VARIABLE(int ) yypos= 0;
- YY_VARIABLE(int ) yylimit= 0;
- YY_VARIABLE(char * ) yytext= 0;
- YY_VARIABLE(int ) yytextlen= 0;
- YY_VARIABLE(int ) yybegin= 0;
- YY_VARIABLE(int ) yyend= 0;
- YY_VARIABLE(int ) yytextmax= 0;
- YY_VARIABLE(yythunk *) yythunks= 0;
- YY_VARIABLE(int ) yythunkslen= 0;
- YY_VARIABLE(int ) yythunkpos= 0;
- YY_VARIABLE(YYSTYPE ) yy;
- YY_VARIABLE(YYSTYPE *) yyval= 0;
- YY_VARIABLE(YYSTYPE *) yyvals= 0;
- YY_VARIABLE(int ) yyvalslen= 0;
- YY_LOCAL(int) yyrefill(void)
- {
- int yyn;
- while (yybuflen - yypos < 512)
- {
- yybuflen *= 2;
- yybuf= realloc(yybuf, yybuflen);
- }
- YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos));
- if (!yyn) return 0;
- yylimit += yyn;
- return 1;
- }
- YY_LOCAL(int) yymatchDot(void)
- {
- if (yypos >= yylimit && !yyrefill()) return 0;
- ++yypos;
- return 1;
- }
- YY_LOCAL(int) yymatchChar(int c)
- {
- if (yypos >= yylimit && !yyrefill()) return 0;
- if (yybuf[yypos] == c)
- {
- ++yypos;
- yyprintf((stderr, " ok yymatchChar(%c) @ %s\n", c, yybuf+yypos));
- return 1;
- }
- yyprintf((stderr, " fail yymatchChar(%c) @ %s\n", c, yybuf+yypos));
- return 0;
- }
- YY_LOCAL(int) yymatchString(char *s)
- {
- int yysav= yypos;
- while (*s)
- {
- if (yypos >= yylimit && !yyrefill()) return 0;
- if (yybuf[yypos] != *s)
- {
- yypos= yysav;
- return 0;
- }
- ++s;
- ++yypos;
- }
- return 1;
- }
- YY_LOCAL(int) yymatchClass(unsigned char *bits)
- {
- int c;
- if (yypos >= yylimit && !yyrefill()) return 0;
- c= yybuf[yypos];
- if (bits[c >> 3] & (1 << (c & 7)))
- {
- ++yypos;
- yyprintf((stderr, " ok yymatchClass @ %s\n", yybuf+yypos));
- return 1;
- }
- yyprintf((stderr, " fail yymatchClass @ %s\n", yybuf+yypos));
- return 0;
- }
- YY_LOCAL(void) yyDo(yyaction action, int begin, int end)
- {
- while (yythunkpos >= yythunkslen)
- {
- yythunkslen *= 2;
- yythunks= realloc(yythunks, sizeof(yythunk) * yythunkslen);
- }
- yythunks[yythunkpos].begin= begin;
- yythunks[yythunkpos].end= end;
- yythunks[yythunkpos].action= action;
- ++yythunkpos;
- }
- YY_LOCAL(int) yyText(int begin, int end)
- {
- int yyleng= end - begin;
- if (yyleng <= 0)
- yyleng= 0;
- else
- {
- while (yytextlen < (yyleng - 1))
- {
- yytextlen *= 2;
- yytext= realloc(yytext, yytextlen);
- }
- memcpy(yytext, yybuf + begin, yyleng);
- }
- yytext[yyleng]= '\0';
- return yyleng;
- }
- YY_LOCAL(void) yyDone(void)
- {
- int pos;
- for (pos= 0; pos < yythunkpos; ++pos)
- {
- yythunk *thunk= &yythunks[pos];
- int yyleng= thunk->end ? yyText(thunk->begin, thunk->end) : thunk->begin;
- yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yytext));
- thunk->action(yytext, yyleng);
- }
- yythunkpos= 0;
- }
- YY_LOCAL(void) yyCommit()
- {
- if ((yylimit -= yypos))
- {
- memmove(yybuf, yybuf + yypos, yylimit);
- }
- yybegin -= yypos;
- yyend -= yypos;
- yypos= yythunkpos= 0;
- }
- YY_LOCAL(int) yyAccept(int tp0)
- {
- if (tp0)
- {
- fprintf(stderr, "accept denied at %d\n", tp0);
- return 0;
- }
- else
- {
- yyDone();
- yyCommit();
- }
- return 1;
- }
- YY_LOCAL(void) yyPush(char *text, int count) { if (text) { } yyval += count; }
- YY_LOCAL(void) yyPop(char *text, int count) { if (text) { } yyval -= count; }
- YY_LOCAL(void) yySet(char *text, int count) { if (text) { } yyval[count]= yy; }
- #endif /* YY_PART */
- #define YYACCEPT yyAccept(yythunkpos0)
- YY_RULE(int) yy_start(); /* 1 */
- YY_ACTION(void) yy_2_start(char *yytext, int yyleng)
- { if(yytext) { } if (yyleng) { }
- yyprintf((stderr, "do yy_2_start\n"));
- putchar(yytext[0]); ;
- }
- YY_ACTION(void) yy_1_start(char *yytext, int yyleng)
- { if(yytext) { } if (yyleng) { }
- yyprintf((stderr, "do yy_1_start\n"));
- printf("%s", getlogin()); ;
- }
- YY_RULE(int) yy_start()
- { int yypos0= yypos, yythunkpos0= yythunkpos;
- yyprintf((stderr, "%s\n", "start"));
- { int yypos2= yypos, yythunkpos2= yythunkpos; if (!yymatchString("username")) goto l3; yyDo(yy_1_start, yybegin, yyend); goto l2;
- l3:; yypos= yypos2; yythunkpos= yythunkpos2; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l1; if (!yymatchDot()) goto l1; yyText(yybegin, yyend); if (!(YY_END)) goto l1; yyDo(yy_2_start, yybegin, yyend);
- }
- l2:;
- yyprintf((stderr, " ok %s @ %s\n", "start", yybuf+yypos));
- return 1;
- l1:; yypos= yypos0; yythunkpos= yythunkpos0;
- yyprintf((stderr, " fail %s @ %s\n", "start", yybuf+yypos));
- return 0;
- }
- #ifndef YY_PART
- typedef int (*yyrule)();
- YY_PARSE(int) YYPARSEFROM(yyrule yystart)
- {
- int yyok;
- if (!yybuflen)
- {
- yybuflen= 1024;
- yybuf= malloc(yybuflen);
- yytextlen= 1024;
- yytext= malloc(yytextlen);
- yythunkslen= 32;
- yythunks= malloc(sizeof(yythunk) * yythunkslen);
- yyvalslen= 32;
- yyvals= malloc(sizeof(YYSTYPE) * yyvalslen);
- yybegin= yyend= yypos= yylimit= yythunkpos= 0;
- }
- yybegin= yyend= yypos;
- yythunkpos= 0;
- yyval= yyvals;
- yyok= yystart();
- if (yyok) yyDone();
- yyCommit();
- return yyok;
- (void)yyrefill;
- (void)yymatchDot;
- (void)yymatchChar;
- (void)yymatchString;
- (void)yymatchClass;
- (void)yyDo;
- (void)yyText;
- (void)yyDone;
- (void)yyCommit;
- (void)yyAccept;
- (void)yyPush;
- (void)yyPop;
- (void)yySet;
- (void)yytextmax;
- }
- YY_PARSE(int) YYPARSE(void)
- {
- return YYPARSEFROM(yy_start);
- }
- #endif
- int main()
- {
- while (yyparse());
- return 0;
- }
|