当前位置: 首页>>代码示例>>C++>>正文


C++ read_char函数代码示例

本文整理汇总了C++中read_char函数的典型用法代码示例。如果您正苦于以下问题:C++ read_char函数的具体用法?C++ read_char怎么用?C++ read_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了read_char函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fftw_import_wisdom

fftw_status fftw_import_wisdom(int (*g)(void *), void *data)
{
     int n;
     int flags;
     fftw_direction dir;
     enum fftw_node_type type;
     int signature;

     get_input = g;
     input_error = FFTW_SUCCESS;

     read_char(data);

     eat_blanks(data);
     EXPECT('(');
     eat_blanks(data);
     EXPECT_STRING(WISDOM_FORMAT_VERSION);
     eat_blanks(data);

     while (next_char != ')') {
	  EXPECT('(');
	  EXPECT_INT(n);
	  EXPECT_INT(flags);
	  EXPECT_INT(dir);
	  EXPECT_INT(type);
	  EXPECT_INT(signature);
	  eat_blanks(data);
	  EXPECT(')');

	  /* the wisdom has been read properly. Add it */
	  fftw_wisdom_add(n, flags, dir, type, signature);

	  /* prepare for next morsel of wisdom */
	  eat_blanks(data);
     }

     return FFTW_SUCCESS;
}
开发者ID:fido2478,项目名称:epspectra,代码行数:38,代码来源:wisdom.c

示例2: refresh

token analyzer::get_token()
{
    refresh();
    drop_garbage();

    if( peek_char() == EOF )
        return token("END_OF_FILE","") ;

    int first_pos = comp_f_stream.tellg();
    string value = "" ;

    while( true ){
        int c = read_char();
        value.push_back(c);

        if( current_state->is_valid_transition(c) ){
            current_state = current_state->next_state(c);
            if( current_state->is_acceptance_state() ){
                last_acceptance = current_state ;
                acceptace_pos = comp_f_stream.tellg();
            }
        }
        else{//dead end
            if( last_acceptance != NULL ){
                int len = comp_f_stream.tellg()-acceptace_pos ;
                for(int i = 0 ; i < len ; ++i){
                    value.pop_back();
                }
                restore_pos();
                return token(last_acceptance->name,value);
            }
            else{//error checking
                //return fix_error(token("BAD_TOKEN",value));
                return token("BAD_TOKEN",value);
            }
        }
    }
}
开发者ID:Moh-Nabil,项目名称:Compilers-Project,代码行数:38,代码来源:analyzer.cpp

示例3: read_command

/**
 * @brief  Read command from stdin
 *
 * @param buffer buffer to read command to
 *
 * @return   false on exit
 */
static
bool read_command() {
	ssize_t num_read = BUF_SIZE;
	int c;

	while (num_read == BUF_SIZE) {

		do {
			print_prompt();
			num_read = read(0, buffer, BUF_SIZE);
		} while (num_read == EINTR); // skip interrupt

		if (num_read == BUF_SIZE) {
			while (buffer[BUF_SIZE - 1] != '\n'
					&& (c = read_char()) != '\n'
					&& c != CHAR_EOF)
				;
			print_error(ERR_LONG_INPUT);
			if (c == CHAR_EOF) {
				write(1, CMD_EXIT, strlen(CMD_EXIT));
				write(1, "\n", 1);
				return false;
			}
		}
		if (num_read == 0) {
			write(1, CMD_EXIT, strlen(CMD_EXIT));
			write(1, "\n", 1);
			return false;
		}

		if (strlen(buffer) == 1 && buffer[0] == '\n')
			num_read = BUF_SIZE; // empty line, read next
	}

	buffer[num_read - 1] = '\0';

	return true;
}
开发者ID:fridex,项目名称:shell-example,代码行数:45,代码来源:proj3.c

示例4: read_identifier

static char *
read_identifier (struct parsebuf *p)
{
  /* Index of the first character of the identifier in p->buf.  */
  int start;
  /* Next index after the last character of the identifer in p->buf.  */
  int end;

  skip_whitespace (p);

  /* Capture the start of the identifier.  */
  start = p->pos;

  /* Scan for the end.  */
  while (is_identifier_char (peek_char (p)))
    read_char (p);
  end = p->pos;

  if (end - start < 1)
    return 0;

  return grub_new_substring (p->buf, start, end);
}
开发者ID:flihp,项目名称:grub2,代码行数:23,代码来源:theme_loader.c

示例5: sourceAddr

Token* Scanner::read_general_string(char delimiter, Token::TokenType tokenType) {
  fint l = line;
  fint col = column - 1;
  const char* ss = sourceAddr() - 1;
  char* b = buffer;
  fint c;
  bool cannot_be_a_delimeter;
  do {
    Token* t = read_char(b, cannot_be_a_delimeter);
    if (t) return t;     // Error return.
    c = *b++;
    if (b >= &buffer[ScannerBufferSize]) {
      return TokenizingError("string literal or comment too long");
    }
  } while (cannot_be_a_delimeter  ||  (c != delimiter && c != EOF));
  if (c == EOF) {
    return TokenizingError("missing trailing ' of string literal or comment");
  }
  b[-1] = '\0';
  return new Token(tokenType, 
                   new String(copy_string(buffer, b-buffer), b-buffer-1), 
                   l, col, ss);
}
开发者ID:russellallen,项目名称:self,代码行数:23,代码来源:scanner.cpp

示例6: xml_decl_encoding_value_state

FAXPP_Error
xml_decl_encoding_value_state(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  case '"':
    env->state = xml_decl_encoding_value_quot_state1;
    next_char(env);
    token_start_position(env);
    break;
  case '\'':
    env->state = xml_decl_encoding_value_apos_state1;
    next_char(env);
    token_start_position(env);
    break;
  LINE_ENDINGS
  default:
    next_char(env);
    return INVALID_CHAR_IN_XML_DECL;
  }
  return NO_ERROR;  
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:23,代码来源:xmldecl.c

示例7: while

scanner::token scanner::read_symbol(char ch) {
    bool escape = false;
    if (m_smt2)
        m_string.pop_back(); // remove leading '|'
    while (ch != '|' || escape) {
        if (ch == EOF) {
            // TODO: use error reporting
            m_err << "ERROR: unexpected end of file.\n";
            return EOF_TOKEN;
        }
        if (ch == '\n') {
            ++m_line;
        }
        escape = (ch == '\\');
        m_string.push_back(ch);
        ch = read_char();                
    }
    if (!m_smt2)
        m_string.push_back(ch); // don't add trailing '|'
    m_string.push_back(0);
    m_id = m_string.begin();
    return ID_TOKEN;
}
开发者ID:AleksandarZeljic,项目名称:z3,代码行数:23,代码来源:scanner.cpp

示例8: dec_char_reference_state

FAXPP_Error
dec_char_reference_state(FAXPP_TokenizerEnv *env)
{
  while(1) {
    read_char(env);

    switch(env->current_char) {
    case ';':
      retrieve_state(env);
      token_end_position(env);
      report_token(DEC_CHAR_REFERENCE_TOKEN, env);
      next_char(env);
      token_start_position(env);
      return NO_ERROR;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      next_char(env);
      break;
    LINE_ENDINGS
    default:
      next_char(env);
      return INVALID_CHAR_IN_CHAR_REFERENCE;
    }
  }

  // Never happens
  return NO_ERROR;
}
开发者ID:Neopallium,项目名称:faxpp,代码行数:36,代码来源:reference.c

示例9: read_char

char *read_line(FILE *fin, char *line, size_t maxlen)
{
	char c, *ptr;
	size_t n;
	int eof = 0;
	
	if (line == NULL && maxlen == 0)
		return NULL;
	ptr = line;
	for (n = 1; n < maxlen; n++) {  /* start from 1 to ensure there always one character space for '\0' */
		c = read_char(fin);
		if (c == '\n')
			break;
		if (c == EOF) {
			eof = 1;
			break;
		}
		*ptr++ = c;
	}
	*ptr = '\0';
	if (eof)
		return NULL;
	return line;
}
开发者ID:dingzhihao,项目名称:pkeeper,代码行数:24,代码来源:util.c

示例10: xml_decl_standalone_state1

FAXPP_Error
xml_decl_standalone_state1(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  WHITESPACE:
    next_char(env);
    break;
  case '?':
    env->state = xml_decl_seen_question_state;
    token_start_position(env);
    next_char(env);
    break;
  case 's':
    env->state = xml_decl_standalone_state2;
    next_char(env);
    break;
  default:
    next_char(env);
    return INVALID_CHAR_IN_XML_DECL;
  }
  return NO_ERROR;
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:24,代码来源:xmldecl.c

示例11: xml_decl_encoding_value_apos_state1

FAXPP_Error
xml_decl_encoding_value_apos_state1(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  case '\'':
    env->state = xml_decl_standalone_ws_state;
    next_char(env);
    return INVALID_ENCODING_VALUE;
  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': 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':
    env->state = xml_decl_encoding_value_apos_state2;
    break;
  LINE_ENDINGS
  default:
    next_char(env);
    return INVALID_ENCODING_VALUE;
  }
  next_char(env);
  return NO_ERROR;
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:24,代码来源:xmldecl.c

示例12: play

void play()
{
	gc_init();
	Hash *h = get_basic_hash();
	t_point parsed;
	char c;

	while ((c = read_char()) != EOF) {
		if (c == OPEN_TAG) {
			parsed = parse_pipe(h, 0);
			if (parsed != NIL && quiet) {
				resolve_Thunk(parsed);
			} else if (parsed != NIL && !quiet) {
				print_Symbol(parsed);
			} else if (prompt && !quiet)
				printf("OK\n");
			gc();
		}
	}

#ifdef DEBUG
	printf("\n\n"); gc_score();
#endif
}
开发者ID:JackeLee,项目名称:pseudolisp,代码行数:24,代码来源:parser.c

示例13: read_string

Cell* read_string(char* in) {
  ReaderState rs;
  Cell stack_root[100];

  rs.state = PST_ATOM;
  rs.cell = 0;
  rs.level = 0;
  rs.stack = (void*)&stack_root;

  int i=0;
  int len = strlen(in);
  for (i=0; i<len; i++) {
    read_char(in[i], &rs);
    if (rs.state>=10) {
      //print("<read error %d at %d.>\n",rs.state,i);
      break;
    }
    //printf("rs %c: %d\n", in[i], rs.state);
  }
  if (rs.level!=0) {
    //print("<missing %d closing parens.>\n",rs.level);
  }
  if (rs.state!=PST_ATOM) {
    //printf("<read error: unexpected end of input.>\n");
  }

  Cell* root = *rs.stack;
  
  if (root) {
    Cell* ret = car(root);
    //if (root->next) free(root->next);
    //free(root);
    return ret;
  }
  return alloc_error(ERR_SYNTAX);
}
开发者ID:8l,项目名称:bomberjacket,代码行数:36,代码来源:reader.c

示例14: read

	static inline uint8_t read(char* string, uint16_t timeout = 0) {
		static unsigned char buffer;
		uint8_t i = 0;

		do {
			if (read_char(buffer, timeout) == READ_TIMEOUT)
				return READ_TIMEOUT;

			if (i == 0 && buffer == '\r') {
				return READ_SUCCESS;
			}

			if (i == 0 && buffer == '\n') {
				continue;
			}

			string[i] = static_cast<char>(buffer);
			i++;
		} while (string[i - 1] != '\r');

		string[i - 1] = '\0';

		return READ_SUCCESS;
	}
开发者ID:PaulBernier,项目名称:UART_STM32F4,代码行数:24,代码来源:Uart.hpp

示例15: read_next_value

void read_next_value(parser_t *p, char *s, size_t n)
{
  int i = 0;
  char c;

  while (isblank(c = read_char(p)))
    p->column++;

  if (c != '"') {
    printf("[read_next_value] Error: \" expected in line %i.\n", p->row);
    exit(1);
  }

  c = fgetc(p->f);
  p->column++;
  while (c != '"' && c != '\n' && c != '\r') {
    s[i] = c;
    i++;

    if (i >= n) {
      s[i] = 0;
      printf("[read_next_value] Error: Token too long in line %i. Token = '%s'\n", p->row, s);
      exit(1);
    }

    c = fgetc(p->f);
    p->column++;
  }
  s[i] = 0;
  p->column++;

  if (c != '"') {
    printf("[read_next_value] Error: End-of-line encountered before '\"' in line %i.\n", p->row);
    exit(1);
  }
}
开发者ID:jvlautz,项目名称:mdcore,代码行数:36,代码来源:c_ptrdict.c


注:本文中的read_char函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。