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


C++ LA函数代码示例

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


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

示例1: access_group_by_name

void IOSCfgParser::interface_known_ip_commands() {
	
	try {      // for error handling
		{
		if ((LA(1) == ACCESS_GROUP) && (LA(2) == WORD)) {
			access_group_by_name();
		}
		else if ((LA(1) == ACCESS_GROUP) && (LA(2) == INT_CONST)) {
			access_group_by_number();
		}
		else if ((LA(1) == ADDRESS)) {
			intf_address();
		}
		else {
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		
		}
		match(NEWLINE);
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		} else {
			throw;
		}
	}
}
开发者ID:BrendanThompson,项目名称:fwbuilder,代码行数:29,代码来源:IOSCfgParser.cpp

示例2: match

void IOSCfgParser::remark() {
	
	try {      // for error handling
		match(REMARK);
		if ( inputState->guessing==0 ) {
#line 566 "iosacl.g"
			
			importer->setCurrentLineNumber(LT(0)->getLine());
			*dbg << LT(1)->getLine() << ":";
			std::string rem;
			while (LA(1) != ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE && LA(1) != NEWLINE)
			{
			rem += LT(1)->getText() + " ";
			consume();
			}
			importer->addRuleComment( rem );
			*dbg << " REMARK " << rem << std::endl;
			//consumeUntil(NEWLINE);
			
#line 909 "IOSCfgParser.cpp"
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			recover(ex,_tokenSet_1);
		} else {
			throw;
		}
	}
}
开发者ID:BrendanThompson,项目名称:fwbuilder,代码行数:31,代码来源:IOSCfgParser.cpp

示例3: match

void FMTLexer::mCSTRING(bool _createToken) {
	int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
	_ttype = CSTRING;
	std::string::size_type _saveIndex;
	
	if ((LA(1) == 0x25 /* '%' */ ) && (LA(2) == 0x22 /* '\"' */ )) {
		_saveIndex = text.length();
		match('%' /* charlit */ );
		text.erase(_saveIndex);
		_saveIndex = text.length();
		match('\"' /* charlit */ );
		text.erase(_saveIndex);
		cLexer->DoubleQuotes( true); selector->push( cLexer); selector->retry();
	}
	else if ((LA(1) == 0x25 /* '%' */ ) && (LA(2) == 0x27 /* '\'' */ )) {
		_saveIndex = text.length();
		match('%' /* charlit */ );
		text.erase(_saveIndex);
		_saveIndex = text.length();
		match('\'' /* charlit */ );
		text.erase(_saveIndex);
		cLexer->DoubleQuotes( false); selector->push( cLexer); selector->retry();
	}
	else {
		throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
	}
	
	if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
	   _token = makeToken(_ttype);
	   _token->setText(text.substr(_begin, text.length()-_begin));
	}
	_returnToken = _token;
	_saveIndex=0;
}
开发者ID:ezhangle,项目名称:GNU-Data-Language-0.9.6,代码行数:34,代码来源:FMTLexer.cpp

示例4: switch

void FMTLexer::mX(bool _createToken) {
	int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
	_ttype = X;
	std::string::size_type _saveIndex;
	
	{
	switch ( LA(1)) {
	case 0x78 /* 'x' */ :
	{
		match('x' /* charlit */ );
		break;
	}
	case 0x58 /* 'X' */ :
	{
		match('X' /* charlit */ );
		break;
	}
	default:
	{
		throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
	}
	}
	}
	if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
	   _token = makeToken(_ttype);
	   _token->setText(text.substr(_begin, text.length()-_begin));
	}
	_returnToken = _token;
	_saveIndex=0;
}
开发者ID:ezhangle,项目名称:GNU-Data-Language-0.9.6,代码行数:30,代码来源:FMTLexer.cpp

示例5: mW

void FMTLexer::mWHITESPACE(bool _createToken) {
	int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
	_ttype = WHITESPACE;
	std::string::size_type _saveIndex;
	
	{ // ( ... )+
	int _cnt135=0;
	for (;;) {
		if ((LA(1) == 0x9 /* '\t' */  || LA(1) == 0x20 /* ' ' */ )) {
			mW(false);
		}
		else {
			if ( _cnt135>=1 ) { goto _loop135; } else {throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
		}
		
		_cnt135++;
	}
	_loop135:;
	}  // ( ... )+
	_ttype=antlr::Token::SKIP;
	if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
	   _token = makeToken(_ttype);
	   _token->setText(text.substr(_begin, text.length()-_begin));
	}
	_returnToken = _token;
	_saveIndex=0;
}
开发者ID:ezhangle,项目名称:GNU-Data-Language-0.9.6,代码行数:27,代码来源:FMTLexer.cpp

示例6: matchRange

void FMTLexer::mDIGITS(bool _createToken) {
	int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
	_ttype = DIGITS;
	std::string::size_type _saveIndex;
	
	{ // ( ... )+
	int _cnt138=0;
	for (;;) {
		if (((LA(1) >= 0x30 /* '0' */  && LA(1) <= 0x39 /* '9' */ ))) {
			matchRange('0','9');
		}
		else {
			if ( _cnt138>=1 ) { goto _loop138; } else {throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
		}
		
		_cnt138++;
	}
	_loop138:;
	}  // ( ... )+
	if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
	   _token = makeToken(_ttype);
	   _token->setText(text.substr(_begin, text.length()-_begin));
	}
	_returnToken = _token;
	_saveIndex=0;
}
开发者ID:ezhangle,项目名称:GNU-Data-Language-0.9.6,代码行数:26,代码来源:FMTLexer.cpp

示例7: rule

rule()
#endif
{
	zzRULE;
	zzBLOCK(zztasp1);
	zzMake0;
	{
	if ( (setwd1[LA(1)]&0x80) ) {
		reg_expr();
		zzmatch(ACTION);
		zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r; (zzaArg(zztasp1,1 ).r)->accept=action_no;  
 zzCONSUME;

	}
	else {
		if ( (LA(1)==ACTION) ) {
			zzmatch(ACTION);
			zzaRet.l = NULL; zzaRet.r = NULL;
			error("no expression for action  ", zzline);
 zzCONSUME;

		}
		else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
	}
	zzEXIT(zztasp1);
	return;
fail:
	zzEXIT(zztasp1);
	zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
	zzresynch(setwd2, 0x1);
	}
}
开发者ID:Hensinzzx,项目名称:DDD,代码行数:32,代码来源:dlg_p.c

示例8: parse_string

/**
 * Parse string literal (ECMA-262 v5, 7.8.4)
 */
static token
parse_string (void)
{
  ecma_char_t c = (ecma_char_t) LA (0);
  JERRY_ASSERT (c == '\'' || c == '"');

  consume_char ();
  new_token ();

  const bool is_double_quoted = (c == '"');
  const char end_char = (is_double_quoted ? '"' : '\'');

  do
  {
    c = (ecma_char_t) LA (0);
    consume_char ();

    if (c == '\0')
    {
      PARSE_ERROR ("Unclosed string", token_start - buffer_start);
    }
    else if (ecma_char_is_line_terminator (c))
    {
      PARSE_ERROR ("String literal shall not contain newline character", token_start - buffer_start);
    }
    else if (c == '\\')
    {
      ecma_char_t nc = (ecma_char_t) LA (0);

      if (convert_single_escape_character (nc, NULL))
      {
        consume_char ();
      }
      else if (ecma_char_is_line_terminator (nc))
      {
        consume_char ();

        if (ecma_char_is_carriage_return (nc))
        {
          nc = (ecma_char_t) LA (0);

          if (ecma_char_is_new_line (nc))
          {
            consume_char ();
          }
        }
      }
    }
  }
  while (c != end_char);

  token ret = convert_string_to_token_transform_escape_seq (TOK_STRING,
                                                            token_start,
                                                            (size_t) (buffer - token_start) - 1u);

  token_start = NULL;

  return ret;
} /* parse_string */
开发者ID:szledan,项目名称:jerryscript-old,代码行数:62,代码来源:lexer.cpp

示例9: ANTLR_USE_NAMESPACE

void MDParser::inversionblock() {
	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
	ANTLR_USE_NAMESPACE(antlr)RefAST inversionblock_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
	
	try {      // for error handling
		ANTLR_USE_NAMESPACE(antlr)RefAST tmp55_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
		tmp55_AST = astFactory->create(LT(1));
		astFactory->makeASTRoot(currentAST, tmp55_AST);
		match(INVERSION);
		{
		switch ( LA(1)) {
		case LBRACKET:
		{
			match(LBRACKET);
			intConst();
			match(RBRACKET);
			break;
		}
		case LCURLY:
		{
			break;
		}
		default:
		{
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(LCURLY);
		{ // ( ... )*
		for (;;) {
			if ((_tokenSet_10.member(LA(1)))) {
				inversionstatement();
				astFactory->addASTChild( currentAST, returnAST );
			}
			else {
				goto _loop51;
			}
			
		}
		_loop51:;
		} // ( ... )*
		ANTLR_USE_NAMESPACE(antlr)RefAST tmp59_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
		tmp59_AST = astFactory->create(LT(1));
		astFactory->addASTChild(currentAST, tmp59_AST);
		match(RCURLY);
#line 137 "MDParser.g"
		tmp59_AST->setType(ENDBLOCK);
#line 971 "MDParser.cpp"
		inversionblock_AST = currentAST.root;
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		reportError(ex);
		recover(ex,_tokenSet_8);
	}
	returnAST = inversionblock_AST;
}
开发者ID:Patrick-Louden,项目名称:2.2,代码行数:58,代码来源:MDParser.cpp

示例10: grobble_whitespaces

static void
grobble_whitespaces (void)
{
  ecma_char_t c = LA (0);

  while ((isspace (c) && c != '\n'))
  {
    consume_char ();
    c = LA (0);
  }
}
开发者ID:szledan,项目名称:jerryscript-old,代码行数:11,代码来源:lexer.cpp

示例11: RefBasicAST

void P::factor() {
	returnAST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
	RefBasicAST factor_AST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	
	try {      // for error handling
		factor2();
		astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
		{ // ( ... )*
		for (;;) {
			if ((LA(1) == MOD || LA(1) == EXP)) {
				{
				switch ( LA(1)) {
				case EXP:
				{
					RefBinaryCompArithOpAST tmp11_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp11_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp11_AST));
					match(EXP);
					break;
				}
				case MOD:
				{
					RefBinaryCompArithOpAST tmp12_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp12_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp12_AST));
					match(MOD);
					break;
				}
				default:
				{
					throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
				}
				}
				}
				factor2();
				astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
			}
			else {
				goto _loop14;
			}
			
		}
		_loop14:;
		} // ( ... )*
		factor_AST = RefBasicAST(currentAST.root);
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		reportError(ex);
		recover(ex,_tokenSet_3);
	}
	returnAST = factor_AST;
}
开发者ID:lwhay,项目名称:ICDMS,代码行数:53,代码来源:P.cpp

示例12: lexer_skip_whitespace_and_comments

/**
 * Skip any whitespace and comment tokens
 *
 * @return true - if a newline token was skipped,
 *         false - otherwise
 */
static bool
lexer_skip_whitespace_and_comments (void)
{
  bool new_lines_occurred = false;

  while (true)
  {
    ecma_char_t c = LA (0);

    if (lit_char_is_white_space (c))
    {
      do
      {
        consume_char ();

        c = LA (0);
      }
      while (lit_char_is_white_space (c));
    }
    else if (lit_char_is_line_terminator (c))
    {
      dump_current_line ();

      new_lines_occurred = true;

      do
      {
        consume_char ();

        c = LA (0);
      }
      while (lit_char_is_line_terminator (c));
    }
    else if (c == LIT_CHAR_SLASH
             && (LA (1) == LIT_CHAR_SLASH
                 || LA (1) == LIT_CHAR_ASTERISK))
    {
      /* ECMA-262 v5, 7.4, SingleLineComment or MultiLineComment */

      if (lexer_parse_comment ())
      {
        new_lines_occurred = true;
      }
    }
    else
    {
      break;
    }
  }

  return new_lines_occurred;
} /* lexer_skip_whitespace_and_comments */
开发者ID:jiangrunwu,项目名称:iotjs-openwrt,代码行数:58,代码来源:lexer.cpp

示例13: match

/**Make sure current lookahead symbol matches token type <tt>t</tt>.
 * Throw an exception upon mismatch, which is catch by either the
 * error handler or by the syntactic predicate.
 */
void Parser::match(int t)
{
    if ( DEBUG_PARSER )
        std::cout << "enter match(" << t << ") with LA(1)=" << LA(1) << std::endl;
    if ( LA(1)!=t ) {
        if ( DEBUG_PARSER )
            std::cout << "token mismatch: " << LA(1) << "!=" << t << std::endl;
        throw MismatchedTokenException(tokenNames, LT(1), t, false);
    } else {
        // mark token as consumed -- fetch next token deferred until LA/LT
        consume();
    }
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:Parser.cpp

示例14: consumeFirst

/** Return the next monitored token.
*  Test the token following the monitored token.
*  If following is another monitored token, save it
*  for the next invocation of nextToken (like a single
*  lookahead token) and return it then.
*  If following is unmonitored, nondiscarded (hidden)
*  channel token, add it to the monitored token.
*
*  Note: EOF must be a monitored Token.
*/
RefToken TokenStreamHiddenTokenFilter::nextToken()
{
	// handle an initial condition; don't want to get lookahead
	// token of this splitter until first call to nextToken
	if ( !LA(1) ) {
		consumeFirst();
	}

	// we always consume hidden tokens after monitored, thus,
	// upon entry LA(1) is a monitored token.
	RefToken monitored = LA(1);
	// point to hidden tokens found during last invocation
	static_cast<CommonHiddenStreamToken*>(monitored.get())->setHiddenBefore(lastHiddenToken);
	lastHiddenToken = nullToken;

	// Look for hidden tokens, hook them into list emanating
	// from the monitored tokens.
	consume();
	RefToken p = monitored;
	// while hidden or discarded scarf tokens
	while ( hideMask.member(LA(1)->getType()) || discardMask.member(LA(1)->getType()) ) {
		if ( hideMask.member(LA(1)->getType()) ) {
			// attach the hidden token to the monitored in a chain
			// link forwards
			static_cast<CommonHiddenStreamToken*>(p.get())->setHiddenAfter(LA(1));
			// link backwards
			if (p != monitored) { //hidden cannot point to monitored tokens
				static_cast<CommonHiddenStreamToken*>(LA(1).get())->setHiddenBefore(p);
			}
			p = lastHiddenToken = LA(1);
		}
		consume();
	}
	return monitored;
}
开发者ID:0077cc,项目名称:sqlitebrowser,代码行数:45,代码来源:TokenStreamHiddenTokenFilter.cpp

示例15: r

math::Vector<2> CDispRigidBody::bCoef(real_t e, const NewtonCollisionBase & bData) const
{
	const real_t & dt = bData.dData.dt;

	math::Vector<2> r(bData.points.eff - rotationPoint());
	rotateToGlobal(r);

	real_t ax = 1.0 / m() + (r(1) * r(1) / Idisp());
	real_t ay = 1.0 / m() + (r(0) * r(0) / Idisp());

	//compensate permanent forces
	//reaction to permanent force
	real_t bx = resultantForce(0) * dt * ax;
	real_t by = resultantForce(1) * dt * ay;
	//reaction to permanent moment
	real_t resultantMomentx_add = 0.0;
	real_t resultantMomenty_add = 0.0;
	if (r(1) != 0.0)
		resultantMomentx_add = resultantMoment() * dt * ax / r(1);
	if (r(0) != 0.0)
		resultantMomenty_add = resultantMoment() * dt * ay / r(0);
	bx += resultantMomentx_add;
	by -= resultantMomenty_add;

	//momentum addition
	bx += e * pA(0) / m();
	by += e * pA(1) / m();

	//angular momentum addition
	bx += e * LA() * -r(1) / Idisp();
	by += e * LA() * r(0) / Idisp();

	//L translates into force proportional to (rx, ry)
	real_t Lx_coef = std::abs(r(1)) / (std::abs(r(1)) + std::abs(r(0)));
	real_t Ly_coef = std::abs(r(0)) / (std::abs(r(1)) + std::abs(r(0)));
	real_t Lx_add = std::abs(LA() * r(1) / Idisp() + resultantMomentx_add);
	real_t Ly_add = std::abs(LA() * r(0) / Idisp() - resultantMomenty_add);
	real_t px_add = std::abs(pA(0) / m() + resultantForce(0) * dt * ax);
	real_t py_add = std::abs(pA(1) / m() + resultantForce(1) * dt * ay);

	//multiply bx by bx_coef
	if ((Lx_add + px_add) != 0.0)	//do not divide by 0.0 (note: px_add and Lx_add are absolute values)
		bx *= (Lx_coef * Lx_add + px_add) / (Lx_add + px_add);
	//multiply by by by_coef
	if ((Ly_add + py_add) != 0.0)	//do not divide by 0.0 (note: py_add and Ly_add are absolute values)
		by *= (Ly_coef * Ly_add + py_add) / (Ly_add + py_add);

	return math::Vector<2>(bx, by);
}
开发者ID:michpolicht,项目名称:gpx,代码行数:49,代码来源:CDispRigidBody.cpp


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