您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ yylex函数代码示例

51自学网 2021-06-03 11:55:09
  C++
这篇教程C++ yylex函数代码示例写得很实用,希望能帮到您。

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

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

示例1: load_vars

voidload_vars(const char *file){  const Unit_t *curr_unit = NULL;  int ret = 0;   /* to silence gcc 2.7.2.1 */  char *varname;  InitPvc_t *pvc;  LaneDestList_t *ltmp;  int read_flag = 1;  assert(file != NULL);  Debug_unit(&load_unit, "Loading variables from file %s", file);  yyin = fopen(file, "r");  if (!yyin) {    Debug_unit(&load_unit, "Cannot open file %s: %s", file, strerror(errno));    return;  }  g_buf_index = 0;  do {    if (read_flag)      ret = yylex();    else      read_flag =1;    switch(ret) {    case END:      Debug_unit(&load_unit, "EOF");      break;    case UNIT:      Debug_unit(&load_unit, "Got unit %s", g_return.stringgi);      curr_unit = find_unit(g_return.stringgi);      if (curr_unit == NULL) {	Debug_unit(&load_unit, "Unknown unit %s", g_return.stringgi);      }      Debug_unit(&load_unit, "Got unit %s", g_return.stringgi);      mem_free(&load_unit,g_return.stringgi);      break;    case VARNAME:      varname = g_return.stringgi;      Debug_unit(&load_unit, "Got variable name %s", varname);      ret = yylex();      switch(ret) {      case STRING:	Debug_unit(&load_unit, "Variable is string: %s", g_return.stringgi);	set_var_str(curr_unit, varname, g_return.stringgi);	break;      case BOOLEAN:	Debug_unit(&load_unit, "Variable is boolean: %s", 		   g_return.bool==BL_TRUE?"True":"False");	set_var_bool(curr_unit, varname, g_return.bool);	break;      case INTEGER:	Debug_unit(&load_unit, "Variable is integer: %d", g_return.intti);	set_var_int(curr_unit, varname, g_return.intti);	break;      case ATMADDRESS:	Debug_unit(&load_unit, "Variable is atmaddress ");	dump_atmaddr(g_return.atmaddress);	set_var_addr(curr_unit, varname, g_return.atmaddress);	break;      case LANEDEST:	Debug_unit(&load_unit, "Invalid variable value for %s", varname);	mem_free(&load_unit, g_return.destaddr);	break;      case UNIT:	Debug_unit(&load_unit, "Invalid variable value for %s", varname);	mem_free(&load_unit, g_return.stringgi);	break;      case VCC:	Debug_unit(&load_unit, "Variable is vcc");	pvc = (InitPvc_t *)mem_alloc(curr_unit, sizeof(InitPvc_t));	pvc->pvc = (LaneVcc_t *)mem_alloc(curr_unit, sizeof(LaneVcc_t));	pvc->pvc->port = g_return.vcc.port;	pvc->pvc->vpi = g_return.vcc.vpi;	pvc->pvc->vci = g_return.vcc.vci;	pvc->address = NULL;	pvc->lecid = 0;	pvc->destinations = NULL;	ret = yylex();	if (ret != ATMADDRESS) {	  Debug_unit(&load_unit, "Invalid atm_address for pvc %d,%d,%d",		     pvc->pvc->port, pvc->pvc->vpi, pvc->pvc->vci);	  switch(ret) {	  case UNIT:	  case STRING:	  case VARNAME:	    mem_free(&load_unit, g_return.stringgi);	    break;	  case LANEDEST:	    mem_free(&load_unit, g_return.destaddr);	    break;	  }	} else {	  pvc->address = g_return.atmaddress;	}	ret = yylex();	if (ret != INTEGER) {	  Debug_unit(&load_unit, "Invalid lecid for pvc %d,%d,%d/n",		     pvc->pvc->port,pvc->pvc->vpi,pvc->pvc->vci);	  switch(ret) {//.........这里部分代码省略.........
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:101,


示例2: main

main(){	while (yylex() != 0);}
开发者ID:ombt,项目名称:ombt,代码行数:4,


示例3: mget_css_parse_buffer

void mget_css_parse_buffer(	const char *buf,	void(*callback_uri)(void *user_ctx, const char *url, size_t len, size_t pos),	void(*callback_encoding)(void *user_ctx, const char *url, size_t len),	void *user_ctx){	int token;	size_t length, pos = 0;	char *text;	yyscan_t scanner;	// let flex operate on buf as a 0 terminated string	// we could give buflen to this function and use yy_scan_bytes or yy_scan_buffer	yylex_init(&scanner);	yy_scan_string(buf, scanner);	while ((token = yylex(scanner)) != CSSEOF) {		if (token == IMPORT_SYM) {			// e.g. @import "http:example.com/index.html"			pos += yyget_leng(scanner);			// skip whitespace before URI/STRING			while ((token = yylex(scanner)) == S)				pos += yyget_leng(scanner);			// now token should be STRING or URI			if (token == STRING)				token = URI;		}		if (token == URI && callback_uri) {			// e.g. url(http:example.com/index.html)			text = yyget_text(scanner);			length = yyget_leng(scanner);			if (*text == '/'' || *text == '/"') {				// a string - remove the quotes				callback_uri(user_ctx, text + 1, length - 2, pos + 1);			} else {				// extract URI from url(...)				if (!strncasecmp(text, "url(", 4)) {					char *otext = text;					// remove trailing ) and any spaces before					for (length--; isspace(text[length - 1]); length--);					// remove leading url( and any spaces after					for (length -= 4, text += 4; isspace(*text); text++, length--);					// remove quotes					if (*text == '/'' || *text == '/"') {						text++;						length -= 2;					}					callback_uri(user_ctx, text, length, pos + (text - otext));				}			}		} else if (token == CHARSET_SYM && callback_encoding) {			// e.g. @charset "UTF-8"			pos += yyget_leng(scanner);			// skip whitespace before charset name			while ((token = yylex(scanner)) == S)				pos += yyget_leng(scanner);			// now token should be STRING			if (token == STRING) {				text = yyget_text(scanner);				length = yyget_leng(scanner);				if (*text == '/'' || *text == '/"') {					// a string - remove the quotes					callback_encoding(user_ctx, text + 1, length - 2);				} else {					// a string without quotes					callback_encoding(user_ctx, text, length);				}			} else {				error_printf(_("Unknown token after @charset: %d/n"), token);			}		}		pos += yyget_leng(scanner);	}	yylex_destroy(scanner);}
开发者ID:rockdaboot,项目名称:mget,代码行数:87,


示例4: yyparse

/* * This routine parses the input stream, and * returns if it accepts, or if an unrecoverable syntax * error is encountered. */yyparse(){	register int *ps, n, *p;	int paniced, *panicps, idfail;	yystate = 0;	yychar = yylex();	OY.Yychar = -1;	yyshifts = 3;	paniced = 0;	ps = &yys[0]-1;	yypv = &yyv[0]-1;#ifdef PXP	yypw = &yyw[0]-1;#endifstack:	/*	 * Push new state and value.	 */	if (yypv >= &yyv[MAXDEPTH-1]) {		yerror("Parse stack overflow");		pexit(DIED);	}	*++ps = yystate;	*++yypv = yyval;#ifdef PXP	yypw++;#endifnewstate:	/*	 * Locate parsing actions for the	 * new parser state.	 */	p = &yyact[ yypact[yystate+1] ]; actn:	/*	 * Search the parse actions table	 * for something useful to do.	 * While n is non-positive, it is the negation	 * of the token we are testing for.	 */#ifdef PI	if ((n = *p++) <= 0) {		if (yychar < 0)			yychar = yylex();		do			if ((n =+ yychar) != 0)				p++;		while ((n = *p++) <= 0);	}#else	while ((n = *p++) <= 0)		if ((n =+ yychar) != 0)			p++;#endif	switch (n >> 12) {		/*		 * Shift.		 */		case 2:#ifdef PXP			yypw[1].Wseqid = yyseqid;			yypw[1].Wcol = yycol;#endif			OYcopy();			yystate = n & 07777;			yyval = yylval;#ifdef PI			yychar = -1;#else			yychar = yylex();#endif			yyshifts++;			yytshifts++;			goto stack;		/*		 * Reduce.		 */		case 3:			n =& 07777;			N = yyr2[n];			if (N == 1 && OY.Yychar == YID && !yyEactr(n, yypv[0])) {				idfail = 1;				goto errin;			}			OY.Yychar = -1;			ps =- N;			yypv =- N;#ifdef PXP			yypw =- N;#endif			yyval = yypv[1];//.........这里部分代码省略.........
开发者ID:dank101,项目名称:2BSD,代码行数:101,


示例5: parse_q

//{{{ int parse_q(char *q_text, struct gqt_query *q_props)int parse_q(char *q_text, struct gqt_query *q_props){    int ntoken, vtoken;    int state = START_OF_EXP;    q_props->variant_op = -1;    q_props->op_condition = -1;    q_props->condition_value = -1;    memset(q_props->genotype_condition,0,4*sizeof(int));    char *in = (char *) malloc(100*sizeof(char));    if (!in)        err(EX_OSERR, "malloc error");    strcpy(in, q_text);    YY_BUFFER_STATE buffer = yy_scan_string(in);    ntoken = yylex();    while (ntoken) {        switch (ntoken) {            case p_maf:            case p_count:            case p_pct:                if (set_op(ntoken, q_props, &state))                    return 1;                int last_ntoken = ntoken;                ntoken = yylex();                if (ntoken != p_r_paren) {                    fprintf(stderr, "SYNTAX ERROR: '(' expected after '%s' ",                            names[last_ntoken]);                    return 1;                }                state |= OP_SET_START;                break;            case p_het:            case p_homo_ref:            case p_homo_alt:            case p_unknown:                if (set_gt(ntoken, q_props, &state))                    return 1;                state |= GT_SET_START;                break;            case p_r_paren:                fprintf(stderr, "SYNTAX ERROR: "                            "Opperation (count,pct,maf) expected "                            "prior to '%s' ",                            names[ntoken]);                    return 1;            case p_l_paren:                if ( ((q_props->variant_op == p_count) ||                      (q_props->variant_op == p_pct))  &&                     (state != (OP_SET_START | GT_SET_START) ) ) {                    fprintf(stderr, "SYNTAX ERROR: "                            "Opperation (count,pct) and "                            "genotype (HOM_REF,HET,HOM_ALT,UNKNONW) expected "                            "prior to '%s' ",                            names[ntoken]);                    return 1;                } else if ( (q_props->variant_op == p_maf) &&                            (state != OP_SET_START ) ) {                    fprintf(stderr, "SYNTAX ERROR: "                            "Opperation (maf) does not expect "                            "genotype (HOM_REF,HET,HOM_ALT,UNKNONW) "                            "prior to '%s' ",                            names[ntoken]);                    return 1;                }                state |= OP_SET_END;                state |= GT_SET_END;                break;            case p_equal:            case p_not_equal:            case p_less_than:            case p_greater_than:            case p_less_than_equal:            case p_greater_than_equal:                if (set_op_cond(ntoken, q_props, &state))                    return 1;                break;            case p_number:                if (set_cond_value(yytext, q_props, &state))                    return 1;                break;            default:                printf("Syntax error in line/n");        }        ntoken = yylex();    }    yy_delete_buffer(buffer);    if (((state & OP_SET_START) == OP_SET_START) &&        ((state & OP_SET_END) != OP_SET_END)) {//.........这里部分代码省略.........
开发者ID:jeromekelleher,项目名称:gqt,代码行数:101,


示例6: parse

/* * parse() * * get and execute a command */static void parse(void){	int i, j, k, flag;    while   (1)        {        k = yylex();        switch(k)   /*  get the token from the input and switch on it   */            {            case 'h':   moveplayer(4);  return;     /*  west        */            case 'H':   run(4);         return;     /*  west        */            case 'l':   moveplayer(2);  return;     /*  east        */            case 'L':   run(2);         return;     /*  east        */            case 'j':   moveplayer(1);  return;     /*  south       */            case 'J':   run(1);         return;     /*  south       */            case 'k':   moveplayer(3);  return;     /*  north       */            case 'K':   run(3);         return;     /*  north       */            case 'u':   moveplayer(5);  return;     /*  northeast   */            case 'U':   run(5);         return;     /*  northeast   */            case 'y':   moveplayer(6);  return;     /*  northwest   */            case 'Y':   run(6);         return;     /*  northwest   */            case 'n':   moveplayer(7);  return;     /*  southeast   */            case 'N':   run(7);         return;     /*  southeast   */            case 'b':   moveplayer(8);  return;     /*  southwest   */            case 'B':   run(8);         return;     /*  southwest   */            case '.':                               /*  stay here       */                if (yrepcount)                     viewflag=1;                return;            case 'c':                yrepcount=0;                cast();                return;     /*  cast a spell    */            case 'd':                yrepcount=0;                if (c[TIMESTOP]==0)                    dropobj();                return; /*  to drop an object   */            case 'e':                yrepcount=0;                if (c[TIMESTOP]==0)                    if (!floor_consume( OCOOKIE, "eat" ))                        consume( OCOOKIE, "eat", showeat );                return; /*  to eat a fortune cookie */            case 'g':                   yrepcount = 0 ;                cursors();                lprintf("/nThe stuff you are carrying presently weighs %d pounds",(long)packweight());                break ;            case 'i':       /* inventory */                yrepcount=0;                nomove=1;                showstr(FALSE);                return;            case 'p':           /* pray at an altar */                yrepcount = 0;                    pray_at_altar();                return;            case 'q':           /* quaff a potion */                yrepcount=0;                if (c[TIMESTOP]==0)                    if (!floor_consume( OPOTION, "quaff"))                        consume( OPOTION, "quaff", showquaff );                return;            case 'r':                yrepcount=0;                if (c[BLINDCOUNT])                    {                    cursors();                    lprcat("/nYou can't read anything when you're blind!");                    }                else if (c[TIMESTOP]==0)                    if (!floor_consume( OSCROLL, "read" ))                        if (!floor_consume( OBOOK, "read" ))                            consume( OSCROLL, "read", showread );                return;     /*  to read a scroll    */            case 's':                yrepcount = 0 ;                    sit_on_throne();                return ;            case 't':                       /* Tidy up at fountain */                yrepcount = 0 ;                    wash_fountain() ;                return ;//.........这里部分代码省略.........
开发者ID:HunterZ,项目名称:larn,代码行数:101,


示例7: main

int main(int argc, char** argv){   if(argc!=2)	yyerror("Uso correto: ./pseudosintatico nome_arq_entrada");   yyin=fopen(argv[1], "r");   if(!yyin){	yyerror("arquivo n
C++ yylex_destroy函数代码示例
C++ yyget_extra函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。