void gotop(int c) { char optmp[OPLENGTH]; char *op_ptr; struct op *s_op; char *a, *b; op_ptr = optmp; *op_ptr++ = c; while (isop((uchar)( *op_ptr = getch())))op_ptr++; if(!strict)unget(*op_ptr); else if (*op_ptr != ' ')unget( *op_ptr); *op_ptr = '\0'; s_op = op; b = optmp; while ((a = s_op->name) != 0){ op_ptr = b; while ((*op_ptr == *a) && (*op_ptr != '\0')){ a++; op_ptr++; } if (*a == '\0'){ keep(s_op); opflag = s_op->setop; if (*op_ptr != '\0'){ b = op_ptr; s_op = op; continue; } else break; } else s_op++; } }
char CharMapper::trigraph() { if (settings.trigraph) { char c = charmap(); if (c == '?') { c = charmap(); if (c == '?') { c = charmap(); switch (c) { case '=': return '#'; case '/': return '\\'; case '(': return '['; case ')': return ']'; case '\'': return '^'; case '!': return '|'; case '<': return '{'; case '>': return '}'; case '-': return '~'; } unget(c); unget('?'); } else { unget(c); } return '?'; } else { return c; } } else { return in.get(); } }
static int _fact(void * bp, int get(void * bp), int unget(int c, void * bp)) { signed c; int n = 1; while ((c = get(bp)) != EOF) { if (isblank(c)) continue; else if(isdigit(c)) { unget (c, bp); n *= _numb(bp, get, unget); } else if(c == '(') { n *= _numb(bp, get, unget); if ((c = get(bp)) != ')') unget(c, bp); } else { unget (c, bp); break; } } return (n); }
std::string Parser::readString() { do { char c = get(); if (isspace(c)) { continue; } else if (c == '#') { forgetLine(); continue; } else { unget(); break; } } while (mStream); if (not mStream) { throw utils::InternalError(); } else { std::string result; do { char c = get(); if (isalnum(c)) { result += c; } else { unget(); return result; } } while (mStream); return result; } }
Sym* getimpsym(void) { int c; char *cp; c = getnsc(); if(isspace(c) || c == '"') { unget(c); return S; } for(cp = symb;;) { if(cp <= symb+NSYMB-4) *cp++ = c; c = getc(); if(c > 0 && !isspace(c) && c != '"') continue; unget(c); break; } *cp = 0; if(cp > symb+NSYMB-4) yyerror("symbol too large: %s", symb); return lookup(); }
Error parseExport() { COFFShortExport E; E.Name = Tok.Value; read(); if (Tok.K == Equal) { read(); if (Tok.K != Identifier) return createError("identifier expected, but got " + Tok.Value); E.ExtName = E.Name; E.Name = Tok.Value; } else { unget(); } if (Machine == IMAGE_FILE_MACHINE_I386) { if (!isDecorated(E.Name, MingwDef)) E.Name = (std::string("_").append(E.Name)); if (!E.ExtName.empty() && !isDecorated(E.ExtName, MingwDef)) E.ExtName = (std::string("_").append(E.ExtName)); } for (;;) { read(); if (Tok.K == Identifier && Tok.Value[0] == '@') { Tok.Value.drop_front().getAsInteger(10, E.Ordinal); read(); if (Tok.K == KwNoname) { E.Noname = true; } else { unget(); } continue; } if (Tok.K == KwData) { E.Data = true; continue; } if (Tok.K == KwConstant) { E.Constant = true; continue; } if (Tok.K == KwPrivate) { E.Private = true; continue; } unget(); Info.Exports.push_back(E); return Error::success(); } }
void gottype(struct keyw *lptr) { char *pt; struct keyw *tlptr; int c; while(1){ pt = getnext(1); if((tlptr=lookup(pt,lastplace+1))!=0){ putch(' ',YES); copy(tlptr->name); *pt='\0'; lastplace = pt; if(tlptr->type == STRUCT){ putch(tlptr->punc,YES); gotstruct(); break; } lptr=tlptr; continue; } else{ putch(lptr->punc,NO); while((c=getch())== ' ' || c == '\t'); unget(c); break; } } }
void bootstrap( void ) { for( ;; ) { get(); switch( *sp ) { case '#': drop(); skip_to_nl(); break; case ':': drop(); get_name(); make_def(); compile_to_def(); bootcompile(); fixate_colon_def(); break; default: unget(); compile_to_buffer(); bootcompile(); bootinterpreter(); break; } } }
int CredReader::ReadNumber() { int num = atoi(&data[dataindex]); while(isdigit(get())) ; unget(); return num; }
// // SourceTokenizerC::doCommand // void SourceTokenizerC::doCommand() { SourceTokenC::Reference tok = getRaw(); doAssert(tok, SourceTokenC::TT_NAM); if (tok->data == "define") doCommand_define(tok); else if (tok->data == "else") doCommand_else(tok); else if (tok->data == "elif") doCommand_elif(tok); else if (tok->data == "endif") doCommand_endif(tok); else if (tok->data == "error") doCommand_error(tok); else if (tok->data == "if") doCommand_if(tok); else if (tok->data == "ifdef") doCommand_ifdef(tok); else if (tok->data == "ifndef") doCommand_ifndef(tok); else if (tok->data == "include") doCommand_include(tok); else if (tok->data == "undef") doCommand_undef(tok); else if (tok->data == "warning") doCommand_warning(tok); else if(isSkip()) { while(tok->type != SourceTokenC::TT_ENDL) tok = getRaw(); unget(tok); } else Error(tok->pos, "unknown command: %s", tok->data.c_str()); }
static int esc_char(int in_char_literal) { int c = get(); int v, i; switch (c) { case 'b': return '\b'; case 'e': return 033; case 'f': return '\f'; case 'n': return '\n'; case 't': return '\t'; default: if (c >= '0' && c <= '7') { for(v = i = 0; i < 3 && c >= '0' && c <= '7'; c = get()) v = v*8 + c-'0'; unget(); return v; } return c; } }
/* * Read the rest of a line that starts `\c'. Including nothing at * all (tok_word with empty text). */ token get_codepar_token(input * in) { int c; token ret; rdstring rs = { 0, 0, NULL }; filepos cpos; ret.type = tok_word; c = get(in, &cpos); /* expect (and discard) one space */ ret.pos = cpos; if (c == ' ') { c = get(in, &cpos); ret.pos = cpos; } while (!isnl(c) && c != EOF) { int c2 = c; c = get(in, &cpos); /* Discard \r just before \n. */ if (c2 != 13 || !isnl(c)) rdadd(&rs, (wchar_t)c2); } unget(in, c, &cpos); ret.text = ustrdup(rs.text); sfree(rs.text); return ret; }
//--------------------------------------------------------------------------- bool SPARQLLexer::hasNext(Token value) // Peek at the next token { Token peek=getNext(); unget(peek); return peek==value; }
double Parser::readReal() { do { char c = get(); if (isspace(c)) { continue; } else if (c == '#') { forgetLine(); continue; } else { unget(); break; } } while (mStream); if (not mStream) { throw utils::InternalError(); } else { std::string result; do { char c = get(); if (isspace(c)) { unget(); break; } else if (c == '#') { forgetLine(); break; } else if (isdigit(c)) { result += c; } else if (c == '.') { if (result.find(".") != std::string::npos){ throw utils::ParseError(fmt( _("Multiple '.' while parsing real `%1%.' ")) % result); } result += c; } else { unget(); break; } } while (mStream); return boost::lexical_cast < double >(result); } }
/* * Determine whether the next input character is an open brace (for * telling code paragraphs from paragraphs which merely start with * code). */ int isbrace(input * in) { int c; filepos cpos; c = get(in, &cpos); unget(in, c, &cpos); return (c == '{'); }
FILE_LOCAL void doif(int hash) /* * Process an #if, #ifdef, or #ifndef. The latter two are straightforward, * while #if needs a subroutine of its own to evaluate the expression. * * doif() is called only if compiling is TRUE. If false, compilation * is always supressed, so we don't need to evaluate anything. This * supresses unnecessary warnings. */ { register int c; register int found; if ((c = skipws()) == '\n' || c == EOF_CHAR) { unget(); goto badif; } if (hash == L_if) { unget(); found = (eval() != 0); /* Evaluate expr, != 0 is TRUE */ hash = L_ifdef; /* #if is now like #ifdef */ } else { if (type[c] != LET) /* Next non-blank isn't letter */ goto badif; /* ... is an error */ found = (lookid(c) != NULL); /* Look for it in symbol table */ } if (found == (hash == L_ifdef)) { compiling = TRUE; *ifptr |= TRUE_SEEN; } else { compiling = FALSE; } return; badif: cerror("#if, #ifdef, or #ifndef without an argument", NULLST); #if !OLD_PREPROCESSOR skipnl(); /* Prevent an extra */ unget(); /* Error message */ #endif return; }
Lizt_old_ATTLC& Lizt_old_ATTLC::unget(const Lizt_old_ATTLC& ll) { if (ll.sz) { register lnk_old_ATTLC* aLink = ll.t; do unget(aLink->copy()); while ((aLink = aLink->prv) != ll.t); } return *this; }
int skipSpaces() { int c = get(); while (c != EOF && ::isspace(c)) { c = get(); } unget(); return c; }
void nextword(std::string& rv) { int ch = next(); while (isspace(ch)) ch = next(); while (isalnum(ch) || ch == '_'|| ch == '-') { rv.push_back(ch); ch = next(); } unget(ch); }
// NAME outputPath [BASE=address] Error parseName(std::string *Out, uint64_t *Baseaddr) { read(); if (Tok.K == Identifier) { *Out = Tok.Value; } else { *Out = ""; unget(); return Error::success(); } read(); if (Tok.K == KwBase) { if (Error Err = expect(Equal, "'=' expected")) return Err; if (Error Err = readAsInt(Baseaddr)) return Err; } else { unget(); *Baseaddr = 0; } return Error::success(); }
int getnl(void){ int ch; char *savp; int gotcmt; gotcmt = 0; savp = p; while ((ch = getch()) == '\t' || ch == ' ')putch(ch,NO); if (ch == '/'){ if ((ch = getch()) == '*'){ putch('/',NO); putch('*',NO); comment(NO); ch = getch(); gotcmt=1; } else if (ch == '/') { putch('/',NO); putch('/',NO); cpp_comment(NO); ch = getch(); gotcmt = 1; } else { if(inswitch)*(++lastplace) = ch; else { inswitch = 1; *lastplace = ch; } unget('/'); return(0); } } if(ch == '\n'){ if(gotcmt == 0)p=savp; return(1); } unget(ch); return(0); }
// HEAPSIZE/STACKSIZE reserve[,commit] Error parseNumbers(uint64_t *Reserve, uint64_t *Commit) { if (Error Err = readAsInt(Reserve)) return Err; read(); if (Tok.K != Comma) { unget(); Commit = nullptr; return Error::success(); } if (Error Err = readAsInt(Commit)) return Err; return Error::success(); }
Parser::Token Parser::nextToken() { while (mStream) { char c = get(); if (not mStream) { return Parser::Error; } else if (isspace(c)) { continue; } else if (c == '#') { forgetLine(); continue; } else if (std::isdigit(c)) { unget(); return Parser::Real; } else if (c == '+') { unget(); return Parser::RelativeReal; } else if (c == '"') { unget(); return Parser::QuoteStr; } else if (c == '{') { unget(); return Parser::Begin; } else if (c == '}') { unget(); return Parser::End; } else if (c == '=') { unget(); return Parser::Equal; } else if (c == ',') { unget(); return Parser::Comma; } else if (c == ';') { unget(); return Parser::Semicolon; } else { unget(); return Parser::Str; } } return Parser::Error; }
/* * Process an #if, #ifdef, or #ifndef. The latter two are straightforward, * while #if needs a subroutine of its own to evaluate the expression. * * doif() is called only if compiling is TRUE. If false, compilation * is always suppressed, so we don't need to evaluate anything. This * suppresses unnecessary warnings. */ FILE_LOCAL void doif(int hash) { int c; int found; if ((c = skipws()) == '\n' || c == EOF_CHAR) { unget(); goto badif; } if (hash == L_if) { unget(); found = (eval() != 0); /* Evaluate expr, != 0 is TRUE */ hash = L_ifdef; /* #if is now like #ifdef */ } else { if (type[c] != LET) /* Next non-blank isn't letter */ goto badif; /* ... is an error */ found = (lookid(c) != NULL); /* Look for it in symbol table */ } if (found == (hash == L_ifdef)) { compiling = TRUE; *ifptr |= TRUE_SEEN; } else { compiling = FALSE; } return; badif: cerror("#if, #ifdef, or #ifndef without an argument", NULLST); skipnl(); /* Prevent an extra */ unget(); /* Error message */ return; }
static int _numb(void * bp, int get(void * bp), int unget(int c, void * bp)) { int c = get(bp); int n = 0; while (isdigit(c)) { n *= 10; n += (c - '0'); c = get(bp); } unget (c, bp); return (n); }
a_uint eval() { int c, v; a_uint n; c = getnb(); n = 0; while ((v = digit(c, radix)) >= 0) { n = n*radix + v; c = get(); } unget(c); return((n & s_mask) ? n | ~v_mask : n & v_mask); }
void gotstruct(void){ int c; int cc; char *pt; while((c=getch()) == ' ' || c == '\t') if(!strict)putch(c,NO); if(c == '{'){ structlev++; unget(c); return; } if(isalpha(c)){ putch(c,NO); while(isalnum(c=getch()))putch(c,NO); } unget(c); pt = getnext(1); if(*pt == '{')structlev++; if(strict){ eatallsp(); putch(' ',NO); } }
/* * Enter admode() to search a specific addressing mode table * for a match. Return the addressing value on a match or * -1 for no match. */ int admode(struct adsym *sp) { char *ptr; int i; unget(getnb()); i = 0; while ( *(ptr = &sp[i].a_str[0]) ) { if (srch(ptr)) { return(sp[i].a_val); } i++; } return(-1); }
void skip_space( void ) { for(;;){ get(); if( !flag ) { drop(); return; } if( !isspace( *sp )) { unget(); flag = 1; return; } if( *sp++ == '\n' ) { flag = 0; return; } } }
void get_token( void ) { int n; skip_space(); if( !flag ) return; for( n = 0;; n += 1) { get(); if( !flag ) break; if( isspace( *sp ) ) break; constop[ D_DATA + 1 + n ] = *sp++; } constop[ D_DATA ] = n; if( flag ) unget(); else drop(); flag = 1; }