示例#1
0
static int parse_and_expr (pfstate_t *pf)
{
	int result;

	result = parse_primary (pf);
	if (result < 0) return (-1);

	while (pf->token_type == TOKEN_AND) {
	  int e;

	  next_token (pf);
	  e = parse_primary (pf);
	  if (e < 0) return (-1);
	  result &= e;
	}

	return (result);
}
示例#2
0
/*
 * lease-time :== NUMBER SEMI
 */
void
parse_lease_time(FILE *cfile, time_t *timep)
{
	char *val;
	int token;

	token = next_token(&val, cfile);
	if (token != TOK_NUMBER) {
		parse_warn("Expecting numeric lease time");
		skip_to_semi(cfile);
		return;
	}
	convert_num((unsigned char *)timep, val, 10, 32);
	/* Unswap the number - convert_num returns stuff in NBO. */
	*timep = ntohl(*timep);	/* XXX */

	parse_semi(cfile);
}
示例#3
0
文件: clparse.c 项目: OPSF/uClinux
void read_client_leases ()
{
	int file;
	struct parse *cfile;
	const char *val;
	int token;

	/* Open the lease file.   If we can't open it, just return -
	   we can safely trust the server to remember our state. */
	if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
		return;
	cfile = (struct parse *)0;
	/* new_parse() may fail if the file is of zero length. */
	if (new_parse(&cfile, file, (char *)0, 0,
		      path_dhclient_db, 0) != ISC_R_SUCCESS)
		return;

	do {
		token = next_token (&val, (unsigned *)0, cfile);
		if (token == END_OF_FILE)
			break;

		switch (token) {
		      case DEFAULT_DUID:
			parse_client_default_duid(cfile);
			break;

		      case LEASE:
			parse_client_lease_statement(cfile, 0);
			break;

		      case LEASE6:
			parse_client6_lease_statement(cfile);
			break;

		      default:
			log_error ("Corrupt lease file - possible data loss!");
			skip_to_semi (cfile);
			break;
		}
	} while (1);

	end_parse (&cfile);
}
示例#4
0
/*
expr_primary -> literal
	| '(' expr ')'
	| identifier
*/
static struct finsh_node* proc_primary_expr(struct finsh_parser* self)
{
	enum finsh_token_type token;
	struct finsh_node* expr;

	next_token(token, &(self->token));
	switch ( token )
	{
	case finsh_token_type_identifier:
		{
			char id[FINSH_NAME_MAX + 1];

			finsh_token_replay(&(self->token));
			proc_identifier(self, id);
			return finsh_node_new_id(id);
		}

	case finsh_token_type_left_paren:
		expr = proc_expr(self);
		match_token(token, &(self->token), finsh_token_type_right_paren);
		return expr;

	case finsh_token_type_value_int:
		return finsh_node_new_int(self->token.value.int_value);

	case finsh_token_type_value_long:
		return finsh_node_new_long(self->token.value.long_value);

	case finsh_token_type_value_char:
		return finsh_node_new_char(self->token.value.char_value);

	case finsh_token_type_value_string:
		return finsh_node_new_string((char*)self->token.string);

	case finsh_token_type_value_null:
		return finsh_node_new_ptr(NULL);

	default:
		finsh_error_set(FINSH_ERROR_INVALID_TOKEN);
		break;
	}

	return NULL;
}
示例#5
0
	void FlexBasisPropertyParser::parse(StylePropertySetter *setter, const std::string &name, StyleParser &parser)
	{
		auto &tokens = parser.tokens;

		StyleSetValue flex_basis;

		size_t pos = 0;
		StyleToken token = next_token(pos, tokens);
		if (token.type == StyleTokenType::ident && pos == tokens.size())
		{
			if (equals(token.value, "main-size"))
				flex_basis = StyleSetValue::from_keyword("main-size");
			else if (equals(token.value, "inherit"))
				flex_basis = StyleSetValue::from_keyword("inherit");
			else
				return;
		}
		else if (is_length(token) && pos == tokens.size())
		{
			StyleSetValue length;
			if (parse_length(token, length) && length.number >= 0.0f)
			{
				flex_basis = length;
			}
			else
			{
				return;
			}
		}
		else if (token.type == StyleTokenType::percentage && pos == tokens.size())
		{
			float v = StringHelp::text_to_float(token.value);
			if (v >= 0.0f)
			{
				flex_basis = StyleSetValue::from_percentage(v);
			}
			else
			{
				return;
			}
		}

		setter->set_value("flex-basis", flex_basis);
	}
示例#6
0
/* Locate the next null ("-") or numeric token in a string.  The delim
 * characters are passed in as a param.  The token also will not go past
 * a new line char or the end of the string.  Skip any delimiters before
 * the token.
 */
u32 sdp_getnextnumtok_or_null (const char *str, const char **str_end,
                               const char *delim, tinybool *null_ind,
                               sdp_result_e *result)
{
  const char *token_list = str;
  char temp_token[SDP_MAX_STRING_LEN];
  char *strtoul_end;
  unsigned long numval;

  *null_ind = FALSE;

  if (!str || !str_end || !delim || !null_ind || !result) {
    if (result) {
      *result = SDP_FAILURE;
    }
    return 0;
  }

  *result = next_token(&token_list, temp_token, sizeof(temp_token), delim);

  if (*result != SDP_SUCCESS) {
    return 0;
  }

  /* First see if its the null char ("-") */
  if (temp_token[0] == '-') {
      *null_ind = TRUE;
      *result = SDP_SUCCESS;
      *str_end = str;
      return 0;
  }

  errno = 0;
  numval = strtoul(temp_token, &strtoul_end, 10);

  if (errno || strtoul_end == temp_token || numval > UINT_MAX) {
    *result = SDP_FAILURE;
    return 0;
  }

  *result = SDP_SUCCESS;
  *str_end = token_list;
  return (u32) numval;
}
示例#7
0
文件: parser.cpp 项目: ruslashev/revl
Node* Parser::parse_function_call()
{ // expects TOKEN_OPENING_PAREN as a current token
	Node *node = create_node(NODE_FUNCTION_CALL);

	next_token();

	node->next.push_back(parse_expression());
	node->function_call_function = node->next[0];

	if (_current->kind == TOKEN_CLOSING_PAREN)
		error("Opening parenthesis implies a function call.\n"
				"Function calls are required to take one argument.");

	node->next.push_back(parse_expression());

	node->function_call_argument = node->next[1];

	return node;
}
示例#8
0
static int init_dom_sid2s(char *sids_str, DOM_SID2 *sids, int max_sids)
{
	char *ptr;
	pstring s2;
	int count = 0;

	DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:""));

	if(sids_str) {
		for (count = 0, ptr = sids_str; 
	   	  next_token(&ptr, s2, NULL, sizeof(s2)) && count < max_sids; count++) {
			DOM_SID tmpsid;
			string_to_sid(&tmpsid, s2);
			init_dom_sid2(&sids[count], &tmpsid);
		}
	}

	return count;
}
示例#9
0
文件: config.c 项目: multiplay/qstat
STATIC int
pf_gametype_new(char *text, void *_context)
{
	GameTypeContext *context = (GameTypeContext *)_context;
	char *token;
	int key;

	token = first_token(text);
	if (token == NULL) {
		return (0);
	}

	if (strcmp(token, "end") == 0) {
		add_config_type(context->gametype);
		parse_func = pf_top_level;
		parse_context = NULL;
		return (0);
	}

	key = get_config_key(token, new_keys);

	if (key <= 0) {
		return (key);
	}

	token = next_token();
	if (strcmp(token, "=") != 0) {
		REPORT_ERROR((stderr, "Expecting \"=\", found \"%s\"", token));
		return (-1);
	}

	token = next_value();
	if ((token == NULL) && ((key != CK_MASTER_PROTOCOL) && (key != CK_MASTER_QUERY))) {
		REPORT_ERROR((stderr, "Missing value after \"=\""));
		return (-1);
	}

	if (debug) {
		printf("%d %s = <%s>\n", key, new_keys[key - 1].key_name, token ? token : "");
	}

	return (set_game_type_value(context->gametype, key, token));
}
示例#10
0
文件: lexer.c 项目: yewton/tinyca
/**
 * トークンを取得
 * @return Token トークン
 */
Token get_token(void) {
    Token token;
    if(st_look_ahead_token_exists) {
        /* 
         * 先読みトークンがあったらそれを返し、
         * 先読みトークン存在フラグを下げる
         */
        st_look_ahead_token_exists = 0;
        return st_look_ahead_token;
    } else {
        /*
         * 先読みトークンがなかったらトークンを取得して
         * 先読みトークンにセットし、返す 
         */
        token = next_token();
        st_look_ahead_token = token;
        return token;
    }
}
示例#11
0
void CDDB::cddb_read(KSocket *socket)
{
    int  n;
    char buffer[CDDB_READ_BUFFER_LEN];
    
    if(socket == 0L || socket->socket() < 0)
	return;

    memset(buffer,0,CDDB_READ_BUFFER_LEN);
    n = read(socket->socket(), buffer, CDDB_READ_BUFFER_LEN-1 );
    buffer[n] = '\0';
    tempbuffer += buffer;

//     if(debugflag) 
// 	fprintf(stderr,"BUFFER: '%s'",buffer);

    while(next_token())
        do_state_machine();
}
void command_echo( struct char_buffer* cbuff ) {
	char str_arg1[CONFIG_CLI_MAX_CHARACTERS];
	char str_arg2[CONFIG_CLI_MAX_CHARACTERS];

	if( next_token( cbuff, str_arg1 ) == 0 ) {
		CommandOutput( "[ECHO]\tInvalid Arguments" );
		return;
	}

	int i = 0;
	while( cbuff->state != CBUFF_EMPTY ) {
		str_arg2[i] = cbuffer_pop( cbuff );
		i++;
	}
	str_arg2[i] = '\0';


	CommandOutput( "%s%s", str_arg1, str_arg2 );
}
示例#13
0
static te_expr *power(state *s) {
    /* <power>     =    {("-" | "+")} <base> */
    int sign = 1;
    while (s->type == TOK_INFIX && (s->function == add || s->function == sub)) {
        if (s->function == sub) sign = -sign;
        next_token(s);
    }

    te_expr *ret;

    if (sign == 1) {
        ret = base(s);
    } else {
        ret = NEW_EXPR(TE_FUNCTION1 | TE_FLAG_PURE, base(s));
        ret->function = negate;
    }

    return ret;
}
示例#14
0
文件: syn.c 项目: zgthompson/fa14
void post(syn_state *ss) {
    switch (ss->cur_token) {
        case PLUSPLUS: case MINUSMINUS:
            next_token(ss);
            break;
        case AND: case ANDEQ: case ASSIGN: case COLON: case COMMA: case DIV: 
        case DIVEQ: case EQUALTO: case EXP: case EXPEQ: case GT: case GTE: 
        case LOGAND: case LOGOR: case LT: case LTE: case MINUS: case MINUSEQ: 
        case MOD: case MODEQ: case MULT: case MULTEQ: case NOTEQ: case OR: 
        case OREQ: case PLUS: case PLUSEQ: case QUEST: case RPAREN: case SEMI: 
        case SHIFTL: case SHIFTLEQ: case SHIFTR: case SHIFTREQ: case XOR: 
        case XOREQ:
            return;
        default:
            ss->error_count++;
            print_error(ss, "expected a postfix operator");
            break;
    }
}
示例#15
0
文件: tinyexpr.c 项目: cguebert/Panda
static te_expr *power(state *s) {
    /* <power>     =    {("-" | "+")} <base> */
    int sign = 1;
    while (s->type == TOK_FUNCTION2 && (s->f2 == add || s->f2 == sub)) {
        if (s->f2 == sub) sign = -sign;
        next_token(s);
    }

    te_expr *ret;

    if (sign == 1) {
        ret = base(s);
    } else {
        ret = new_expr(base(s), 0);
        ret->f1 = negate;
    }

    return ret;
}
示例#16
0
//done
char* check_for_label (char* token) {
  if(util_get_opcode (token) == -1){
		//if it is then is it a vaild label?		
    if(util_is_valid_label(token)){
			//if it is a vaild label add that shit
			//return the next token broski
      //fprintf(stderr, "adding symbol: %s\n",token);
      if(symbol_add(lc3_sym_tab,token,currAddr) == 0){
        asm_error(ERR_DUPLICATE_LABEL,token);
      }
      return next_token();
    }	else{
      //damn that shit anint wokring right
    asm_error(ERR_BAD_LABEL,token);
    }		
  }

  return token;
}
示例#17
0
static int
consume_polarity (parse_state *state)
{
	int result = 0;
	if (!strcasecmp (state->token, "positive"))
	{
		result = 1;
	}
	else if (!strcasecmp (state->token, "negative"))
	{
		result = -1;
	}
	else
	{
		expected_error (state, "positive' or 'negative");
	}
	next_token (state);
	return result;
}
示例#18
0
/* alter schema load
 *  'alter <schema> load STRING'
 */
static
rc_t kqsh_alter_schema_load ( KSymTable *tbl, KTokenSource *src, KToken *t, KSymbol *sym )
{
    rc_t rc;
    String path;
    struct VSchema *schema = ( void* ) sym -> u . obj;

    switch ( t -> id )
    {
    case eString:
    case eEscapedString:
        path = t -> str;
        path . addr += 1;
        path . size -= 2;
        break;

    case eUntermString:
    case eUntermEscapedString:
        CONST_STRING ( & t -> str, "<unterminated string>" );
    default:
        return expected ( t, klogErr, "path string" );
    }

    /* consume semi-colon */
    if ( next_token ( tbl, src, t ) -> id != eSemiColon )
        return expected ( t, klogErr, ";" );

    rc = _VSchemaParseFile ( schema, "%.*s", ( int ) path . size, path . addr );
    if ( rc != 0 )
    {
        PLOGERR ( klogErr,  (klogErr, rc, "cannot load file '$(path)' into schema '$(name)'",
                  "path=%.*s,name=%.*s"
                  , ( int ) path . size, path . addr
                             , ( int ) sym -> name . size, sym -> name . addr));
    }
    else if ( interactive )
    {
        kqsh_printf ( "loaded file '%S' into schema '%N' ( %p )\n",
                      & path, sym, schema );
    }

    return rc;
}
示例#19
0
/****************************************************************************
parse a lpq line

here is an example of "lpstat -o dcslw" output under sysv

dcslw-896               tridge            4712   Dec 20 10:30:30 on dcslw
dcslw-897               tridge            4712   Dec 20 10:30:30 being held

****************************************************************************/
static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
{
  fstring tok[9];
  int count=0;
  char *p;

  /* handle the dash in the job id */
  string_sub(line,"-"," ");
  
  for (count=0; count<9 && next_token(&line,tok[count],NULL); count++) ;

  /* we must get 7 tokens */
  if (count < 7)
    return(False);

  /* the 2nd and 4th, 6th columns must be integer */
  if (!isdigit(*tok[1]) || !isdigit(*tok[3])) return(False);
  if (!isdigit(*tok[5])) return(False);

  /* if the user contains a ! then trim the first part of it */  
  if ((p=strchr(tok[2],'!')))
    {
      fstring tmp;
      fstrcpy(tmp,p+1);
      fstrcpy(tok[2],tmp);
    }
    

  buf->job = atoi(tok[1]);
  buf->size = atoi(tok[3]);
  if (count > 7 && strequal(tok[7],"on"))
    buf->status = LPQ_PRINTING;
  else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held"))
    buf->status = LPQ_PAUSED;
  else
    buf->status = LPQ_QUEUED;
  buf->priority = 0;
  buf->time = EntryTime(tok, 4, count, 7);
  StrnCpy(buf->user,tok[2],sizeof(buf->user)-1);
  StrnCpy(buf->file,tok[2],sizeof(buf->file)-1);
  return(True);
}
void CL_CSSParserFontSize::parse(CL_CSSBoxProperties &properties, const CL_String &name, const std::vector<CL_CSSToken> &tokens)
{
	size_t pos = 0;
	CL_CSSToken token = next_token(pos, tokens);
	if (token.type == CL_CSSToken::type_ident && pos == tokens.size())
	{
		if (token.value == "xx-small")
			properties.font_size.type = CL_CSSBoxFontSize::type_xx_small;
		else if (token.value == "x-small")
			properties.font_size.type = CL_CSSBoxFontSize::type_x_small;
		else if (token.value == "small")
			properties.font_size.type = CL_CSSBoxFontSize::type_small;
		else if (token.value == "medium")
			properties.font_size.type = CL_CSSBoxFontSize::type_medium;
		else if (token.value == "large")
			properties.font_size.type = CL_CSSBoxFontSize::type_large;
		else if (token.value == "x-large")
			properties.font_size.type = CL_CSSBoxFontSize::type_x_large;
		else if (token.value == "xx-large")
			properties.font_size.type = CL_CSSBoxFontSize::type_xx_large;
		else if (token.value == "smaller")
			properties.font_size.type = CL_CSSBoxFontSize::type_smaller;
		else if (token.value == "larger")
			properties.font_size.type = CL_CSSBoxFontSize::type_larger;
		else if (token.value == "inherit")
			properties.font_size.type = CL_CSSBoxFontSize::type_inherit;
	}
	else if (is_length(token) && pos == tokens.size())
	{
		CL_CSSBoxLength length;
		if (parse_length(token, length))
		{
			properties.font_size.type = CL_CSSBoxFontSize::type_length;
			properties.font_size.length = length;
		}
	}
	else if (token.type == CL_CSSToken::type_percentage && pos == tokens.size())
	{
		properties.font_size.type = CL_CSSBoxFontSize::type_percentage;
		properties.font_size.percentage = CL_StringHelp::text_to_float(token.value);
	}
}
示例#21
0
void read_leases ()
{
	FILE *cfile;
	char *val;
	int token;

	new_parse (path_dhcpd_db);

	/* Open the lease file.   If we can't open it, fail.   The reason
	   for this is that although on initial startup, the absence of
	   a lease file is perfectly benign, if dhcpd has been running 
	   and this file is absent, it means that dhcpd tried and failed
	   to rewrite the lease database.   If we proceed and the
	   problem which caused the rewrite to fail has been fixed, but no
	   human has corrected the database problem, then we are left
	   thinking that no leases have been assigned to anybody, which
	   could create severe network chaos. */
	if ((cfile = fopen (path_dhcpd_db, "r")) == NULL) {
		warn ("Can't open lease database %s: %m -- %s",
		      path_dhcpd_db,
		      "check for failed database rewrite attempt!");
		warn ("Please read the dhcpd.leases manual page if you.");
		error ("don't know what to do about this.");	}

	do {
		token = next_token (&val, cfile);
		if (token == EOF)
			break;
		if (token != LEASE) {
			warn ("Corrupt lease file - possible data loss!");
			skip_to_semi (cfile);
		} else {
			struct lease *lease;
			lease = parse_lease_declaration (cfile);
			if (lease)
				enter_lease (lease);
			else
				parse_warn ("possibly corrupt lease file");
		}

	} while (1);
}
示例#22
0
//done
void check_line_syntax (char* token) {
  printf("check_line_syntax('%s')\n", token);
  //check if its a label
  token = check_for_label(token);
  printf(" my token is %s \n ", token);
  //store the op in an int
  if(token == NULL)
    return;
  int myop = util_get_opcode(token);
  printf("opcode is: %d\n", myop );
  //store it itno my data structure..
  currInfo -> opcode = myop;

  if(myop == OP_BR){
    currInfo->reg1 = util_parse_cond(token+2);
    token = next_token();
    currInfo->reference = strdup(token);
    //get_operand(op,token);
  }

  LC3_inst_t* inst = lc3_get_inst_info(myop);
  printf("inst is:  %p \n" , inst);

  int position = 0;
  if(strcasecmp(inst ->forms[0].name,token) != 0){
    position = 1;
  }
  
  /*if(inst ->forms[1].name != NULL &&strcasecmp(inst ->forms[1].name,token) == 0){
    position = 1;
    if(strcasecmp(inst ->forms[0].name,token) != 0)
    position = 1;
  }*/
 if(myop != OP_BR){
  currInfo->form=position;}

printf("%d\n whats my position", position);
  operands_t format =  inst -> forms[position].operands;
  scan_operands(format);

  
}
示例#23
0
文件: parse.c 项目: PatrickFang/slash
static sl_node_base_t*
class_expression(sl_parse_state_t* ps)
{
    sl_token_t* class_token = expect_token(ps, SL_TOK_CLASS);
    SLVAL doc = ps->vm->lib.nil;
    if(class_token->comment) {
        doc = sl_make_string(ps->vm, class_token->comment->buff, class_token->comment->len);
    }
    sl_token_t* tok = expect_token(ps, SL_TOK_CONSTANT);
    SLID name = sl_intern2(ps->vm, sl_make_string(ps->vm, tok->as.str.buff, tok->as.str.len));
    sl_node_base_t *extends, *body;
    if(peek_token(ps)->type == SL_TOK_EXTENDS) {
        next_token(ps);
        extends = expression(ps);
    } else {
        extends = NULL;
    }
    body = body_expression(ps);
    return sl_make_class_node(ps, name, doc, extends, body);
}
示例#24
0
/****************************************************************************
help
****************************************************************************/
void cmd_help(char *dum_in, char *dum_out)
{
  int i=0,j;
  fstring buf;

  if (next_token(NULL,buf,NULL))
    {
      if ((i = process_tok(buf)) >= 0)
	DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));		    
    }
  else
    while (commands[i].description)
      {
	for (j=0; commands[i].description && (j<5); j++) {
	  DEBUG(0,("%-15s",commands[i].name));
	  i++;
	}
	DEBUG(0,("\n"));
      }
}
示例#25
0
文件: parse.c 项目: charliesome/slash
static sl_node_base_t*
bitwise_expression(sl_parse_state_t* ps)
{
    sl_node_base_t* left = shift_expression(ps);
    sl_node_base_t* right;
    sl_token_t* tok;
    while(1) {
        switch(peek_token(ps)->type) {
            case SL_TOK_PIPE:
            case SL_TOK_AMP:
            case SL_TOK_CARET:
                tok = next_token(ps);
                right = shift_expression(ps);
                left = sl_make_send_node(ps, left, sl_intern2(ps->vm, tok->str), 1, &right);
                break;
            default:
                return left;
        }
    }
}
void CL_CSSParserFontStyle::parse(CL_CSSBoxProperties &properties, const CL_String &name, const std::vector<CL_CSSToken> &tokens, std::map<CL_String, CL_CSSBoxProperty *> *out_change_set)
{
	size_t pos = 0;
	CL_CSSToken token = next_token(pos, tokens);
	if (token.type == CL_CSSToken::type_ident && pos == tokens.size())
	{
		if (equals(token.value, "normal"))
			properties.font_style.type = CL_CSSBoxFontStyle::type_normal;
		else if (equals(token.value, "italic"))
			properties.font_style.type = CL_CSSBoxFontStyle::type_italic;
		else if (equals(token.value, "oblique"))
			properties.font_style.type = CL_CSSBoxFontStyle::type_oblique;
		else if (equals(token.value, "inherit"))
			properties.font_style.type = CL_CSSBoxFontStyle::type_inherit;
	}
	if (out_change_set)
	{
		(*out_change_set)["font-style"] = &properties.font_style;
	}
}
示例#27
0
文件: ipc.c 项目: semibiotic/bee
int answait(link_t * ld, int event, char * buf, int sz, char ** msg)
{  char        * ptr;
   char        * str;
   int           rc;
   int           xerrno = (-1);

   do
   {  if ((rc = link_gets(ld, buf, sz))<0) return rc;

      ptr = buf;
      str = next_token(&ptr, " \n\t");
      if (str == NULL) continue;

      xerrno = strtol(str, NULL, 10);
   } while (xerrno != 0 && xerrno < 400 && xerrno != event);

   *msg = ptr;

   return xerrno;
}
示例#28
0
/*
expr_assign -> expr_inclusive_or
	| expr_unary ASSIGN expr_assign
*/
static struct finsh_node* proc_assign_expr(struct finsh_parser* self)
{
	enum finsh_token_type token;
	struct finsh_node* or;
	struct finsh_node* assign;

	or = proc_inclusive_or_expr(self);

	next_token(token, &(self->token));

	if (token == finsh_token_type_assign)
	{
		assign = proc_assign_expr(self);

		return make_sys_node(FINSH_NODE_SYS_ASSIGN, or, assign);
	}
	else finsh_token_replay(&(self->token));

	return or;
}
示例#29
0
文件: lp.c 项目: zenkj/lp
int main(int argc, char* argv[]) {
    void *src = file_source(argv[1]);
    Token *t;
    char buf[BUFLEN+1];

    if (src == NULL) {
        printf("invalid file name\n");
        return 1;
    }
    while (1) {
        t = next_token(src);
        print_token(t, buf, BUFLEN);
        printf("%s\n", buf);
        if (t->type == TOKEN_EOS)
            return 0;
        if (t->type == TOKEN_ERROR)
            return 2;
    }
    return 0;
}
示例#30
0
文件: Parser.cpp 项目: cburschka/lyx
string Parser::verbatim_item()
{
	if (!good())
		error("stream bad");
	skip_spaces();
	if (next_token().cat() == catBegin) {
		Token t = get_token(); // skip brace
		string res;
		for (t = get_token(); t.cat() != catEnd && good(); t = get_token()) {
			if (t.cat() == catBegin) {
				putback();
				res += '{' + verbatim_item() + '}';
			}
			else
				res += t.asInput();
		}
		return res;
	}
	return get_token().asInput();
}