这篇教程C++ unput函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中unput函数的典型用法代码示例。如果您正苦于以下问题:C++ unput函数的具体用法?C++ unput怎么用?C++ unput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了unput函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: eat_stringstatic char *eat_string(int starting_line){ int c; char buffer[500]; char *ptr = buffer; for (;;) { /* * Get the next input character, handling EOF: */ c = input(); if (!c) { unput(c); report_parse_error("unterminated string found beginning", starting_line); return(0); } /* * Deal with special characters ('//', '"', and '/n'): */ if (c=='//') { c = eat_escape_code(); if (!c) continue; } else if (c == '"') { *ptr = 0; return(string_Copy(buffer)); } else if (c == '/n') { unput(c); /* fix line # reference to right line # */ report_parse_error("carriage return found in string", yylineno); return(0); } /* * Add the character c to the current string: */ *ptr = c; ptr++; /* * If out of buffer space, do a recursive call then * concatanate the result to the string read in so far to get the * entire string and return that: */ if (ptr>buffer+sizeof(buffer)-20) { string rest_of_string, result; rest_of_string = eat_string(starting_line); if (!rest_of_string) return(0); *ptr = 0; result = string_Concat(buffer, rest_of_string); free(rest_of_string); return(result); } }}
开发者ID:andersk,项目名称:zephyr,代码行数:60,
示例2: regexprint regexpr(void){ int c; static char *buf = 0; static int bufsz = 500; char *bp; if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL) FATAL("out of space for rex expr"); bp = buf; for ( ; (c = input()) != '/' && c != 0; ) { if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, 0)) FATAL("out of space for reg expr %.10s...", buf); if (c == '/n') { SYNTAX( "newline in regular expression %.10s...", buf ); unput('/n'); break; } else if (c == '//') { *bp++ = '//'; *bp++ = input(); } else { *bp++ = c; } } *bp = 0; if (c == 0) SYNTAX("non-terminated regular expression %.10s...", buf); yylval.s = tostring(buf); unput('/'); RET(REGEXPR);}
开发者ID:djbclark,项目名称:bb10qnx,代码行数:31,
示例3: gettokint gettok(char **pbuf, int *psz) /* get next input token */{ int c; char *buf = *pbuf; int sz = *psz; char *bp = buf; c = input(); if (c == 0) return 0; buf[0] = c; buf[1] = 0; if (!isalnum(c) && c != '.' && c != '_') return c; *bp++ = c; if (isalpha(c) || c == '_') { /* it's a varname */ for ( ; (c = input()) != 0; ) { if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0)) FATAL( "out of space for name %.10s...", buf ); if (isalnum(c) || c == '_') *bp++ = c; else { *bp = 0; unput(c); break; } } *bp = 0; } else { /* it's a number */ char *rem; /* read input until can't be a number */ for ( ; (c = input()) != 0; ) { if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0)) FATAL( "out of space for number %.10s...", buf ); if (isdigit(c) || c == 'e' || c == 'E' || c == '.' || c == '+' || c == '-') *bp++ = c; else { unput(c); break; } } *bp = 0; strtod(buf, &rem); /* parse the number */ unputstr(rem); /* put rest back for later */ rem[0] = 0; } *pbuf = buf; *psz = sz; return buf[0];}
开发者ID:JamesLinus,项目名称:inferno,代码行数:54,
示例4: eat_show_linestatic char *eat_show_line(int test_for_endshow){ int c; int saw_escape_code = 0; int starting_line = yylineno; char buffer[200]; /* This must be large enough to hold "endshow" */ char *ptr = buffer; while (yylineno == starting_line) { c = input(); if (!c) { unput(c); *ptr = '/0'; return(string_Copy(buffer)); } else if (c == '//') { saw_escape_code = 1; c = eat_escape_code(); if (!c) continue; } *ptr = c; ptr++; if ((ptr==buffer+strlen("endshow")) && test_for_endshow) if (!strncmp(buffer, "endshow", strlen("endshow")) && !saw_escape_code) { c = input(); unput(c); if (!is_identifier_char(c)) return(0); } if (ptr>buffer+sizeof(buffer)-2) { string the_line; string rest_of_line = eat_show_line(0); *ptr = '/0'; the_line = string_Concat(buffer, rest_of_line); free(rest_of_line); return(the_line); } } *ptr = '/0'; return(string_Copy(buffer));}
开发者ID:andersk,项目名称:zephyr,代码行数:48,
示例5: getarggetarg(char *p) /* pick up single argument, store in p, return length */{ int n, c, npar; n = npar = 0; for ( ;; ) { c = input9(); if (c == EOF) ERROR "end of file in getarg!" FATAL; if (npar == 0 && (c == ',' || c == ')')) break; if (c == '"') /* copy quoted stuff intact */ do { *p++ = c; n++; } while ((c = input9()) != '"' && c != EOF); else if (c == '(') npar++; else if (c == ')') npar--; n++; *p++ = c; } *p = 0; unput(c); return(n + 1);}
开发者ID:n-t-roff,项目名称:9front_troff,代码行数:27,
示例6: getstrvoid getstr(char *s, int n){ register int c; register char *p; p = s; while ((c = input()) == ' ' || c == '/n') ; if (c == EOF) { *s = 0; return; } while (c != ' ' && c != '/t' && c != '/n' && c != '{' && c != '}' && c != '"' && c != '~' && c != '^') { if (!display && c == righteq) break; if (c == '(' && p > s) { /* might be defined(...) */ *p = '/0'; if (lookup(deftbl, s) != NULL) break; } if (c == '//') if ((c = input()) != '"') *p++ = '//'; *p++ = c; if (--n <= 0) ERROR "token %.20s... too long", s FATAL; c = input(); } unput(c); *p = '/0'; yylval = (int) s;}
开发者ID:99years,项目名称:plan9,代码行数:33,
示例7: unputstrvoid unputstr(const char *s) /* put a string back on input */{ int i; for (i = strlen(s)-1; i >= 0; i--) unput(s[i]);}
开发者ID:djbclark,项目名称:bb10qnx,代码行数:7,
示例8: mainint main(){ Pvoid_t PJArray = (Pvoid_t) NULL; PPosition_type pos = new_position(); PState_DFS state = new_state(); load_pjarray (&PJArray); for (int f = 0; f < LEN * LEN; ++f) { if (pos->taken[f] == N) { put (pos, state, f); if (_winning (pos, state, &PJArray)) { show (pos); } unput (pos, f); } } save_pjarray (PJArray); Word_t Rc_word; JLFA (Rc_word, PJArray); printf ( "put %lu ins %lu hit %lu Judy-bytes %lu/n" , _cnt_put, _cnt_ins, _cnt_hit, Rc_word ); release_position (pos); release_state (state);}
开发者ID:mrahn,项目名称:hex,代码行数:34,
示例9: unputString void unputString(const char* textp, size_t length) { // Add characters to input stream in back-to-front order const char* cp = textp; for (cp += length - 1; length--; cp--) { unput(*cp); } }
开发者ID:mballance,项目名称:verilator-svtnt,代码行数:7,
示例10: ifstatchar *ifstat(double expr, char *thenpart, char *elsepart) { if (expr) { unput('/n'); pushsrc(Free, thenpart); pushsrc(pString, thenpart); unput('/n'); if (elsepart) free(elsepart); return thenpart; /* to be freed later */ } else { free(thenpart); if (elsepart) { unput('/n'); pushsrc(Free, elsepart); pushsrc(pString, elsepart); unput('/n'); } return elsepart; }}
开发者ID:n-t-roff,项目名称:DWB3.3,代码行数:21,
示例11: dprintfchar *ifstat(double expr, char *thenpart, char *elsepart){ dprintf("if %g then <%s> else <%s>/n", expr, thenpart, elsepart? elsepart : ""); if (expr) { unput('/n'); pushsrc(Free, thenpart); pushsrc(String, thenpart); unput('/n'); if (elsepart) free(elsepart); return thenpart; /* to be freed later */ } else { free(thenpart); if (elsepart) { unput('/n'); pushsrc(Free, elsepart); pushsrc(String, elsepart); unput('/n'); } return elsepart; }}
开发者ID:99years,项目名称:plan9,代码行数:22,
示例12: eat_escape_codestatic chareat_escape_code(void){ int c, coded_char; c = input(); switch (c) { case 0: /* i.e., EOF */ unput(c); return(c); case '/n': return(0); case 'n': return('/n'); case 't': return('/t'); case 'b': return('/b'); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': coded_char = c - '0'; c = input(); if (!is_octal_digit(c)) { unput(c); return(coded_char); } coded_char = coded_char*8 + c-'0'; c = input(); if (!is_octal_digit(c)) { unput(c); return(coded_char); } return(coded_char*8 + c-'0'); default: return(c); }}
开发者ID:andersk,项目名称:zephyr,代码行数:38,
示例13: forloopvoid forloop(char *var, double from, double to, int op, double by, char *str) /* set up a for loop */{ dprintf("# for %s from %g to %g by %c %g /n", var, from, to, op, by); if (++forp >= forstk+10) ERROR "for loop nested too deep" FATAL; forp->var = var; forp->to = to; forp->op = op; forp->by = by; forp->str = str; setfval(var, from); nextfor(); unput('/n');}
开发者ID:99years,项目名称:plan9,代码行数:16,
示例14: get_commentget_comment(){ char c; int n; char txt[80]; n = 0; while( (c = input()) != '/n' ) { txt[n] = c; n++; } txt[n] = 0; if (displ_sw) printf("#%s/n",txt); unput('/n'); return(NUL_TKN);}
开发者ID:ivan-gimenez,项目名称:timewarp,代码行数:17,
示例15: forloopvoidforloop(char *var, double from, double to, int op, double by, char *str){ if (++forp >= forstk+10) fatal("for loop nested too deep");/* note: actually we here want to take a vector variable and construct its *//* values directly, then access them one at a time below; the current *//* version is a temporary concession to old pic's version of the 'for' */ forp->sym = findvar(var, VARNAME); if (forp->sym->s_dim && forp->sym->s_val.a) free(forp->sym->s_val.a); forp->sym->s_dim = 0; forp->sym->s_val.f = from; forp->to = to; if (by == 0.) fatal("step size of 0 not allowed"); /* For additive or subtractive step, make sure step is positive. Otherwise, make sure step is greater than 1 in absolute value. */ if ((op == ' ' || op == '+') && by < 0.) { op = '-'; by = -by; } else if (op == '-' && by < 0.) { op = '+'; by = -by; } else if (op == '*' && fabs(by) < 1.) { op = '/'; by = 1 / by; } else if (op == '/' && fabs(by) < 1.) { op = '*'; by = 1 / by; } forp->op = op; forp->by = by; forp->str = str; nextfor(); unput('/n');}
开发者ID:n-t-roff,项目名称:DWB3.3,代码行数:43,
示例16: _winningstatic uint8_t _winning (PPosition_type pos, PState_DFS state, Pvoid_t* PJArray){ if (pos->winner != N) { return 1; } Word_t const Index = encode (pos); { PWord_t PValue; JLG (PValue, *PJArray, Index); if (PValue) { ++_cnt_hit; return *PValue != pos->player; } } for (int f = 0; f < LEN * LEN; ++f) { if (pos->taken[f] == N) { put (pos, state, f); const uint8_t w = _winning (pos, state, PJArray); unput (pos, f); if (w) { insert (PJArray, Index, pos->player); return 0; } } } insert (PJArray, Index, 1 - pos->player); return 1;}
开发者ID:mrahn,项目名称:hex,代码行数:43,
示例17: handle_showstatic inthandle_show(void){ int c; int start_line_no = yylineno; /* * Eat up ' ' and '/t's after show. If the next character is a newline, * eat it. This is so we don't get an extra newline when we call * eat_til_endshow: */ while (c=input(), c==' ' || c=='/t') ; if (c!='/n') unput(c); yylval.text = eat_til_endshow(start_line_no); if (yylval.text) return(SHOW); else return(ERROR);}
开发者ID:andersk,项目名称:zephyr,代码行数:21,
示例18: includevoid include(void){ char name[100]; FILE *fin; int c; extern int errno; while ((c = input()) == ' ') ; unput(c); cstr(name, c == '"', sizeof(name)); /* gets it quoted or not */ if ((fin = fopen(name, "r")) == NULL) ERROR "can't open file %s", name FATAL; errno = 0; curfile++; curfile->fin = fin; curfile->fname = strsave(name); curfile->lineno = 0; printf(".lf 1 %s/n", curfile->fname); pushsrc(File, curfile->fname);}
开发者ID:99years,项目名称:plan9,代码行数:21,
示例19: commentcomment(){ char c, c1;#ifdef AST printf("<COMMENT>");#endifloop: while ((c = input()) != '*' && c != 0)#ifdef AST putchar(c)#endif ; if ((c1 = input()) != '/' && c != 0) { unput(c1); goto loop; }#ifdef AST printf("</COMMENT>/n");#endif}
开发者ID:bloudraak,项目名称:yaxx,代码行数:21,
示例20: commentvoid comment(){ char c, c1; output('/'); output('*');loop: while ((c = input()) != '*' && c != 0) output(c); if ((c1 = input()) != '/' && c != 0) { unput(c1); goto loop; } if (c != 0) { output('*'); output(c1); }}
开发者ID:chuxpy,项目名称:crobots-1,代码行数:22,
示例21: eat_til_endshowstatic char *eat_til_endshow(int start_line_no){ register int c; string text_so_far = string_Copy(""); string next_line; for (;;) { /* * Skip the spaces & tabs at the start of the current line: */ while ((c=input()), c==' ' || c=='/t') ; unput(c); /* * Handle unterminated shows: */ if (!c) { report_parse_error("unterminated show beginning", start_line_no); free(text_so_far); return(0); } /* * Read in rest of the line (including the <cr> at end), allowing * for escape codes and checking for "endshow{nonalpha}" at the * start of the line. (Note: /<newline> is considered the * end of a line here!) */ next_line = eat_show_line(1); if (!next_line) /* i.e., is this the endshow line? */ return(text_so_far); text_so_far = string_Concat2(text_so_far, next_line); free(next_line); }}
开发者ID:andersk,项目名称:zephyr,代码行数:38,
示例22: stringint string(void){ int c, n; char *s, *bp; static char *buf = 0; static int bufsz = 500; if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL) FATAL("out of space for strings"); for (bp = buf; (c = input()) != '"'; ) { if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, 0)) FATAL("out of space for string %.10s...", buf); switch (c) { case '/n': case '/r': case 0: SYNTAX( "non-terminated string %.10s...", buf ); lineno++; if (c == 0) /* hopeless */ FATAL( "giving up" ); break; case '//': c = input(); switch (c) { case '"': *bp++ = '"'; break; case 'n': *bp++ = '/n'; break; case 't': *bp++ = '/t'; break; case 'f': *bp++ = '/f'; break; case 'r': *bp++ = '/r'; break; case 'b': *bp++ = '/b'; break; case 'v': *bp++ = '/v'; break; case 'a': *bp++ = '/007'; break; case '//': *bp++ = '//'; break; case '0': case '1': case '2': /* octal: /d /dd /ddd */ case '3': case '4': case '5': case '6': case '7': n = c - '0'; if ((c = peek()) >= '0' && c < '8') { n = 8 * n + input() - '0'; if ((c = peek()) >= '0' && c < '8') n = 8 * n + input() - '0'; } *bp++ = n; break; case 'x': /* hex /x0-9a-fA-F + */ { char xbuf[100], *px; for (px = xbuf; (c = input()) != 0 && px-xbuf < 100-2; ) { if (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) *px++ = c; else break; } *px = 0; unput(c); sscanf(xbuf, "%x", &n); *bp++ = n; break; } default: *bp++ = c; break; } break; default: *bp++ = c; break; } } *bp = 0; s = tostring(buf); *bp++ = ' '; *bp++ = 0; yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab); RET(STRING);}
开发者ID:djbclark,项目名称:bb10qnx,代码行数:78,
示例23: yylexint yylex(void){ int c; static char *buf = 0; static int bufsize = 500; if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL) FATAL( "out of space in yylex" ); if (sc) { sc = 0; RET('}'); } if (reg) { reg = 0; return regexpr(); }/* printf("top/n"); */ for (;;) { c = gettok(&buf, &bufsize);/* printf("gettok [%s]/n", buf); */ if (c == 0) return 0; if (isalpha(c) || c == '_') return word(buf); if (isdigit(c)) { yylval.cp = setsymtab(buf, tostring(buf), atof(buf), CON|NUM, symtab); /* should this also have STR set? */ RET(NUMBER); } yylval.i = c; switch (c) { case '/n': /* {EOL} */ RET(NL); case '/r': /* assume /n is coming */ case ' ': /* {WS}+ */ case '/t': break; case '#': /* #.* strip comments */ while ((c = input()) != '/n' && c != 0) ; unput(c); break; case ';': RET(';'); case '//': if (peek() == '/n') { input(); } else if (peek() == '/r') { input(); input(); /* /n */ lineno++; } else { RET(c); } break; case '&': if (peek() == '&') { input(); RET(AND); } else RET('&'); case '|': if (peek() == '|') { input(); RET(BOR); } else RET('|'); case '!': if (peek() == '=') { input(); yylval.i = NE; RET(NE); } else if (peek() == '~') { input(); yylval.i = NOTMATCH; RET(MATCHOP); } else RET(NOT); case '~': yylval.i = MATCH; RET(MATCHOP); case '<': if (peek() == '=') { input(); yylval.i = LE; RET(LE); } else { yylval.i = LT; RET(LT); } case '=': if (peek() == '=') { input(); yylval.i = EQ; RET(EQ); } else { yylval.i = ASSIGN; RET(ASGNOP); } case '>': if (peek() == '=') { input(); yylval.i = GE; RET(GE); } else if (peek() == '>') { input(); yylval.i = APPEND; RET(APPEND); } else { yylval.i = GT; RET(GT); } case '+': if (peek() == '+') { input(); yylval.i = INCR; RET(INCR); } else if (peek() == '=') { input(); yylval.i = ADDEQ; RET(ASGNOP);//.........这里部分代码省略.........
开发者ID:djbclark,项目名称:bb10qnx,代码行数:101,
示例24: gettokint gettok(char **pbuf, int *psz) /* get next input token */{ int c, retc; char *buf = *pbuf; int sz = *psz; char *bp = buf; c = input(); if (c == 0) return 0; buf[0] = c; buf[1] = 0; if (!isalnum(c) && c != '.' && c != '_') return c; *bp++ = c; if (isalpha(c) || c == '_') { /* it's a varname */ for ( ; (c = input()) != 0; ) { if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0)) FATAL( "out of space for name %.10s...", buf ); if (isalnum(c) || c == '_') *bp++ = c; else { *bp = 0; unput(c); break; } } *bp = 0; retc = 'a'; /* alphanumeric */ } else { /* maybe it's a number, but could be . */ char *rem; /* read input until can't be a number */ for ( ; (c = input()) != 0; ) { if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0)) FATAL( "out of space for number %.10s...", buf ); if (isdigit(c) || c == 'e' || c == 'E' || c == '.' || c == '+' || c == '-') *bp++ = c; else { unput(c); break; } } *bp = 0; strtod(buf, &rem); /* parse the number */ if (rem == buf) { /* it wasn't a valid number at all */ buf[1] = 0; /* return one character as token */ retc = buf[0]; /* character is its own type */ unputstr(rem+1); /* put rest back for later */ } else { /* some prefix was a number */ unputstr(rem); /* put rest back for later */ rem[0] = 0; /* truncate buf after number part */ retc = '0'; /* type is number */ } } *pbuf = buf; *psz = sz; return retc;}
开发者ID:djbclark,项目名称:bb10qnx,代码行数:62,
示例25: peekint peek(void){ int c = input(); unput(c); return c;}
开发者ID:djbclark,项目名称:bb10qnx,代码行数:6,
示例26: yylook//.........这里部分代码省略......... if(yyt == yycrank) { /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } *yylastch++ = yych = input();# ifdef LEXDEBUG fprintf(yyout,"yylook: input "); printchar("yych",yych);# endif tryagain:# ifdef LEXDEBUG/* fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x/n",yych,yymatch[yych]); */ fprintf(yyout,"yylook: tryagain/n");# endif yyr = yyt;/* fprintf(yyout,"yylook: yyr offs: %02x/n",yyr-yycrank); */ if ( yyt > yycrank) { yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate) { if(yyt->advance+yysvec == YYLERR) /* error transitions */ {# ifdef LEXDEBUG fprintf(yyout,"yylook: unput (1) "); printchar("*yylastch",*yylastch);# endif unput(*--yylastch); break; } *lsp++ = yystate = yyt->advance+yysvec;# ifdef LEXDEBUG fprintf(yyout,"yylook: continue (1)/n");# endif goto contin; }# ifdef LEXDEBUG fprintf(yyout,"yylook: ( yyt > yycrank)/n");# endif }# ifdef YYOPTIM else if(yyt < yycrank) /* r < yycrank */ { yyt = yyr = yycrank+(yycrank-yyt);# ifdef LEXDEBUG fprintf(yyout,"yylook: compressed state/n");# endif yyt = yyt + yych; if(yyt <= yytop && yyt->verify+yysvec == yystate) {# ifdef LEXDEBUG fprintf(yyout,"yylook: (1)/n");# endif if(yyt->advance+yysvec == YYLERR) /* error transitions */ {# ifdef LEXDEBUG fprintf(yyout,"yylook: unput (2) ");
开发者ID:Aliandrana,项目名称:cc65,代码行数:67,
示例27: yylexint yylex(void){ register int c, last_char; register char *ptr; int start_line_no; int_dictionary_binding *binding; char varname[MAX_IDENTIFIER_LENGTH+1]; for (;;) { switch (c = input()) { /* * Skip whitespace: */ case ' ': case '/t': case '/n': continue; /* * '#' comments out everything up to the and including * the next <cr>: */ case '#': while ( (c=input()) && (c!='/n') ) ; if (!c) unput(c); continue; /* * Handle c-style comments. Note that "/[^*]" is not the start * of any valid token. */ case '/': start_line_no = yylineno; /* verify that next character is a '*': */ if ((c=input()) != '*') return(ERROR); /* Scan until "*//" or <EOF>: */ for (last_char=0; ; last_char=c) { c = input(); if (c == '/' && (last_char=='*')) break; if (!c) { unput(c); report_parse_error("unterminated c style comment found beginning", start_line_no); return(ERROR); } } continue; /* * The following characters lex as themselves: * '+', '|', '&', '(', ')', '.', ',' and <EOF>: */ case 0: case '+': case '|': case '&': case '(': case ')': case '.': case ',': return(c); /* * Handle "=[^~=]", "=~", and "==": */ case '=': switch (c = input()) { case '~': return(REGEQ); case '=': return(EQ); default: unput(c); return('='); } /* * Handle "![^~=]", "!~", and "!=": */ case '!': switch (c = input()) { case '~': return(REGNEQ); case '=': return(NEQ); default: unput(c); return('!'); } /* * Handle identifiers and keywords: * * Note that the below set of characters is hard coded from * is_identifier_char from parser.h. */ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E'://.........这里部分代码省略.........
开发者ID:andersk,项目名称:zephyr,代码行数:101,
示例28: yylookyylook()#endif{ register struct yysvf *yystate, **lsp; register struct yywork *yyt; struct yysvf *yyz; int yych, yyfirst; struct yywork *yyr;# ifdef LEXDEBUG int debug;# endif char *yylastch; /* start off machines */# ifdef LEXDEBUG debug = 0;# endif yyfirst=1; if (!yymorfg) yylastch = yytext; else { yymorfg=0; yylastch = yytext+yyleng; } for(;;){ lsp = yylstate; yyestate = yystate = yybgin; if (yyprevious==YYNEWLINE) yystate++; for (;;){# ifdef LEXDEBUG if(debug)fprintf(yyout,"state %d/n",yystate-yysvec-1);# endif yyt = yystate->yystoff; if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; }#ifndef __cplusplus *yylastch++ = yych = input();#else *yylastch++ = yych = lex_input();#endif if(yylastch > &yytext[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d/n",YYLMAX); exit(1); } yyfirst=0; tryagain:# ifdef LEXDEBUG if(debug){ fprintf(yyout,"char "); allprint(yych); putchar('/n'); }# endif yyr = yyt; if ( (int)yyt > (int)yycrank){ yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d/n",YYLMAX); exit(1); } goto contin; } }# ifdef YYOPTIM else if((int)yyt < (int)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt);# ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state/n");# endif yyt = yyt + yych; if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d/n",YYLMAX); exit(1); } goto contin; } yyt = yyr + YYU(yymatch[yych]);# ifdef LEXDEBUG if(debug){ fprintf(yyout,"try fall back character "); allprint(YYU(yymatch[yych])); putchar('/n'); }# endif if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transition */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d/n",YYLMAX);//.........这里部分代码省略.........
开发者ID:ombt,项目名称:ombt,代码行数:101,
示例29: lexicon/* LEXICON -- Simple "conversational mode" lexical analyser. Lexical analysis * in the CL is carried out by a dual mode lexical analyser. In conversational * mode there are few tokens and few special characters; arguments are * delimited by whitespace and may contain nonalphanumeric characters. Few * strings have to be quoted. In computational mode the arithmetic operators * are recognized and arguments must be delimited by commas. Computational * mode is in effect whenever the parenlevel is nonzero. * * The two modes are implemented with two separate lexical analyzers. Gettok * implements conversational mode, while computational mode is implemented with * a LEX finite state automaton. Gettok recognizes the following special chars: * * [ /t] argument delimiter * ["'] string * /n newline * / single character escape * ! os escape * # comment * & spawn background job * ( lparen * + plus (switch) * - minus (switch) * ; eost * = equals * += add and set * -= subtract and set * *= multiply and set * /= divide and set * < redirin * > redir * >& allredir * >> append * >>& allappend * >(G|I|P|)+ graphics stream redirection * { lbrace * | pipe * |& allpipe * } rbrace * [ beginning of index list * ] end of index list * * The history metacharacter ^ is processed before input is passed to the * lexical analyser. Any sequence of nonwhite characters that does not form * one of the recognized tokens is returned as a string. */int lexicon (void){ char *bkgerr = "ERROR: cannot submit background job inside {}/n"; register int ch, cch; register int token; int stringtok, identifier, setlevel; int clswitch; char *op, *index(); /* Return pushed back token if any. */ if (pbtoken) { token = pbtoken; pbtoken = 0; return (token); } /* Skip leading whitespace. If whitespace is seen and we are in an * argument list (according to the parser) set flag to output the * comma argument delimiter if the next token begins an argument. * If whitespace or = is seen (except whitespace at the beginning of * a command) then set LHS to false, turning [] off as conversational * mode metacharacters (they will be automatically turned on when * compute mode is entered in an expression). */ while (ch = input()) if (ch == ' ' || ch == '/t') {space: if (lexcol > 0) lhs = 0; if (inarglist) newarg++; } else if (ch == '//') { if ((ch = input()) != '/n') { unput (ch); break; } else goto space; } else break; /* Start new token. */ if (ch) { unput (ch); yyleng = 0; if (!inarglist) newarg = 0; } else return (0); /* Identify and accumulate next token. Simple tokens are returned as * integer constants, more complex tokens as operand structures in//.........这里部分代码省略.........
开发者ID:geechee,项目名称:iraf,代码行数:101,
注:本文中的unput函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ unquote函数代码示例 C++ unpinPage函数代码示例 |