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


C++ pANTLR3_BASE_TREE::getCharPositionInLine方法代码示例

本文整理汇总了C++中pANTLR3_BASE_TREE::getCharPositionInLine方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_BASE_TREE::getCharPositionInLine方法的具体用法?C++ pANTLR3_BASE_TREE::getCharPositionInLine怎么用?C++ pANTLR3_BASE_TREE::getCharPositionInLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pANTLR3_BASE_TREE的用法示例。


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

示例1: dumpTree

std::string MySQLRecognitionBase::dumpTree(pANTLR3_UINT8 *tokenNames, pANTLR3_BASE_TREE tree, const std::string &indentation)
{
  std::string result;

  ANTLR3_UINT32 char_pos = tree->getCharPositionInLine(tree);
  ANTLR3_UINT32 line = tree->getLine(tree);
  pANTLR3_STRING token_text = tree->getText(tree);

  pANTLR3_COMMON_TOKEN token = tree->getToken(tree);
  const char* utf8 = (const char*)token_text->chars;
  if (token != NULL)
  {
    ANTLR3_UINT32 token_type = token->getType(token);

    pANTLR3_UINT8 token_name;
    if (token_type == EOF)
      token_name = (pANTLR3_UINT8)"EOF";
    else
      token_name = tokenNames[token_type];

#ifdef ANTLR3_USE_64BIT
    result = base::strfmt("%s(line: %i, offset: %i, length: %" PRId64 ", index: %" PRId64 ", %s[%i])    %s\n",
                          indentation.c_str(), line, char_pos, token->stop - token->start + 1, token->index, token_name,
                          token_type, utf8);
#else
    result = base::strfmt("%s(line: %i, offset: %i, length: %i, index: %i, %s[%i])    %s\n",
                          indentation.c_str(), line, char_pos, token->stop - token->start + 1, token->index, token_name,
                          token_type, utf8);
#endif

  }
  else
  {
    result = base::strfmt("%s(line: %i, offset: %i, nil)    %s\n", indentation.c_str(), line, char_pos, utf8);
  }

  for (ANTLR3_UINT32 index = 0; index < tree->getChildCount(tree); index++)
  {
    pANTLR3_BASE_TREE child = (pANTLR3_BASE_TREE)tree->getChild(tree, index);
    std::string child_text = dumpTree(tokenNames, child, indentation + "\t");
    result += child_text;
  }
  return result;
}
开发者ID:ThiagoGarciaAlves,项目名称:mysql-workbench,代码行数:44,代码来源:mysql-parser-common.cpp

示例2:

	ASTNode::ASTNode(const pANTLR3_BASE_TREE node)
	{
		m_LineNumber = node->getLine(node);
		m_CharPosition = node->getCharPositionInLine(node);

		pANTLR3_BASE_TREE n = node;
		while ((n != NULL) && (n->u == NULL))
		{ 
			if (n->u != NULL)
			{
				m_FileName = (wchar_t*) n->u;
				node->u = n->u;
				break;
			}
			else
			{
				n = n->getParent(n);
			}
		}
	}
开发者ID:ernestobad,项目名称:ContainedObjects,代码行数:20,代码来源:ASTNode.cpp


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