本文整理汇总了C++中SymbolList类的典型用法代码示例。如果您正苦于以下问题:C++ SymbolList类的具体用法?C++ SymbolList怎么用?C++ SymbolList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCurrentScope
void BaseSemanticWalker::setCurrentScope(RefPortugolAST id,
const SymbolList& params) {
_currentScopeSymbol =
_symtable->getSymbol(id->getText(), params.typeList());
_symtable->setScope(_currentScopeSymbol);
}
示例2: ParamsFindP
//==================================================================
bool ParamsFindP( ParamList ¶ms,
const SymbolList &globalSymbols,
DVec<Float3> &out_vectorP,
int fromIdx )
{
bool gotP = false;
for (size_t i=fromIdx; i < params.size(); i += 2)
{
DASSERT( params[i].type == Param::STR );
const Symbol* pSymbol = globalSymbols.FindSymbol( params[i] );
if ( pSymbol && pSymbol->IsName( "P" ) )
{
DASSTHROW( (i+1) < params.size(), "Invalid number of arguments" );
const FltVec &fltVec = params[ i+1 ].NumVec();
DASSTHROW( (fltVec.size() % 3) == 0, "Invalid number of arguments" );
out_vectorP.resize( fltVec.size() / 3 );
for (size_t iv=0, id=0; iv < fltVec.size(); iv += 3)
out_vectorP[id++] = Float3( &fltVec[ iv ] );
return true;
}
}
return false;
}
示例3: declareProc
void BaseSemanticWalker::declareProc(const Symbol& s,
SymbolList& params) {
//checar ambiguidades:
// f(a : inteiro)
// f(b : inteiro, ... resto)
// -> declaracao ambigua
try {
_symtable->insertSymbol(s);
} catch (RedeclarationException e) {
report(e.symbol().line(), e.symbol().column(),
std::string("redeclaração: ") + e.symbol().lexeme());
_symtable->setIgnoreScope();
return;
} catch (AmbiguousDeclarationException e) {
report(e.symbol().line(), e.symbol().column(),
"declaração ambígua com: " + e.otherSymbol().name());
_symtable->setIgnoreScope();
return;
}
_symtable->setScope(s);
params.setScope(s.identifier());
try {
_symtable->insertSymbols(params);
} catch (RedeclarationException e) {
report(e.symbol().line(), e.symbol().column(),
std::string("redeclaração: ") + e.symbol().lexeme());
}
}
示例4: parseParameterList
SymbolArray parseParameterList(CharacterSource* source)
{
SymbolList list;
Symbol parameter = parseParameter(source);
if (!parameter.valid())
return list;
list.add(parameter);
Span span;
while (Space::parseCharacter(source, ',', &span)) {
Symbol parameter = parseParameter(source);
if (!parameter.valid())
source->location().throwError("Expected parameter");
list.add(parameter);
}
return list;
}
示例5: get_reachables
SymbolList Grammar::get_reachables() {
SymbolList reachables;
reachables.push_back(starting_symbol);
SymbolList prev_reachables;
do {
prev_reachables = reachables;
for( auto &ch : prev_reachables ) {
for( auto rule : production_rules[get_nt_index(ch)] ) {
for( auto &symbol : rule ) {
if( contains_char(reachables, symbol) || contains_char(terminals, symbol) ) { continue; }
reachables.push_back(symbol);
}
}
}
} while( prev_reachables != reachables );
return reachables;
}
示例6: those_that_product
SymbolList Grammar::those_that_product(SymbolList& sl) {
SymbolList ret;
for( auto CV : sl ) {
for( auto nT : non_terminals ) {
for( auto rule : production_rules[get_nt_index(nT)] ) {
if( sl.size() != rule.size() ) { continue; }
for( unsigned int i = 0; i < rule.size(); ++i ) {
if( !(sl[i] == rule[i]) ) { break; }
if( i == rule.size() - 1 ) {
ret.push_back(nT);
}
}
}
}
}
return ret;
}
示例7: insertType
void SymbolTable::insertType(const std::string& name,
const SymbolList& fields,
int line) {
//checando por campos duplicados na estrutura
SymbolList::const_iterator dup = fields.duplicated();
if (dup != fields.end()) {
throw RedeclarationException(*dup);
}
//checando por redefinicao da estrutura
if (_typeBuilder->typeList().find(name) != _typeBuilder->typeList().end()) {
throw RedefinedTypeException(name);
}
_typeBuilder->typeList().push_back(
new Type(_typeBuilder, name, fields, _unit, line));
}
示例8: replace_first_of
void replace_first_of(SymbolList& sl, const Symbol& of, const Symbol& with) {
//std::cout << "replace_first_with\n";
for( unsigned int i = 0; i < sl.size(); ++i ) {
if( sl[i] == of ) {
sl[i] = with;
return;
}
}
}
示例9: MamdaOrderBook
void BookPublisher::createBook (const char* symbol, const char* partId)
{
mBook = new MamdaOrderBook();
// This turns on the generation of deltas at the order book
mBook->generateDeltaMsgs (true);
if (symbol) mBook->setSymbol (symbol);
if (partId) mBook->setPartId (partId);
mBookTime.setToNow();
mBook->setBookTime (mBookTime);
mSymbolList.push_back (symbol);
}
示例10: widgetAt
std::string widgetAt(const SymbolGroupValueContext &ctx, int x, int y, std::string *errorMessage)
{
typedef SymbolGroupValue::SymbolList SymbolList;
// First, resolve symbol since there are ambiguities. Take the first one which is the
// overload for (int,int) and call by address instead off name to overcome that.
const QtInfo &qtInfo = QtInfo::get(ctx);
const std::string func =
qtInfo.prependQtModule("QApplication::widgetAt",
qtInfo.version >= 5 ? QtInfo::Widgets : QtInfo::Gui);
const SymbolList symbols = SymbolGroupValue::resolveSymbol(func.c_str(), ctx, errorMessage);
if (symbols.empty())
return std::string(); // Not a gui application, likely
std::ostringstream callStr;
callStr << std::showbase << std::hex << symbols.front().second
<< std::noshowbase << std::dec << '(' << x << ',' << y << ')';
std::wstring wOutput;
if (!ExtensionContext::instance().call(callStr.str(), &wOutput, errorMessage))
return std::string();
// Returns: ".call returns\nclass QWidget * 0x00000000`022bf100\nbla...".
// Chop lines in front and after 'class ...' and convert first line.
const std::wstring::size_type classPos = wOutput.find(L"class ");
if (classPos == std::wstring::npos) {
*errorMessage = msgWidgetParseError(wOutput);
return std::string();
}
wOutput.erase(0, classPos + 6);
const std::wstring::size_type nlPos = wOutput.find(L'\n');
if (nlPos != std::wstring::npos)
wOutput.erase(nlPos, wOutput.size() - nlPos);
const std::string::size_type addressPos = wOutput.find(L" * 0x");
if (addressPos == std::string::npos) {
*errorMessage = msgWidgetParseError(wOutput);
return std::string();
}
// "QWidget * 0x00000000`022bf100" -> "QWidget:0x00000000022bf100"
wOutput.replace(addressPos, 3, L":");
const std::string::size_type sepPos = wOutput.find(L'`');
if (sepPos != std::string::npos)
wOutput.erase(sepPos, 1);
return wStringToString(wOutput);
}
示例11:
void AllContainersInFileIterator::Init
(
CompilerFile *pFile,
bool fIncludePartialContainers,
bool fIncludeTransientSymbols
)
{
if (pFile != NULL)
{
SymbolList *pList = pFile->GetNamespaceLevelSymbolList();
m_pNext = pList->GetFirst();
}
else
{
m_pNext = NULL;
}
m_fIncludePartialContainers = fIncludePartialContainers;
m_fIncludeTransientSymbols = fIncludeTransientSymbols;
}
示例12: perror
void MamaEntitle::readSymbolsFromFile (void)
{
/* get subjects from file or interactively */
FILE* fp = NULL;
char charbuf[1024];
if (mFilename && mFilename[0] )
{
if ((fp = fopen (mFilename, "r")) == (FILE *)NULL)
{
perror (mFilename);
exit (1);
}
}
else
{
fp = stdin;
}
if (isatty(fileno (fp)))
{
printf ("Enter one symbol per line and terminate with a .\n");
printf ("Symbol> ");
}
while (fgets (charbuf, 1023, fp))
{
/* replace newlines with NULLs */
char *c = charbuf;
/* Input terminate case */
if (*c == '.')
break;
while ((*c != '\0') && (*c != '\n'))
{
c++;
}
*c = '\0';
/* copy the string and subscribe */
mSymbolList.push_back (strdup (charbuf));
if (isatty(fileno (fp)))
{
printf ("Symbol> ");
}
}
}
示例13: setSymbols
void Preprocessor::setSymbols(const SymbolList& symbols)
{
uint nb_symbols = symbols.size();
this->symbols.resize(nb_symbols);
#ifdef PREPROC_KEEP_ORIGINAL_SYMBOLS
this->original_symbols.resize(nb_symbols);
#endif
for(uint i=0 ; i < nb_symbols ; i++)
{
this->symbols[i] = symbols[i];
#ifdef PREPROC_KEEP_ORIGINAL_SYMBOLS
this->original_symbols[i] = symbols[i];
#endif
}
}
示例14: permutations
std::vector<SymbolList> permutations(const SymbolList& str, const SymbolList& of) {
std::vector<SymbolList> ret;
unsigned int size = of.size();
unsigned int n = factorial(size);
SymbolList temp = str;
//std::cout << temp << '\n';
while( !empty_intersection(temp, of) && temp.size() > 1 ) {
SymbolList copy = temp;
for( unsigned int i = 0; i < copy.size(); ++i ) {
if( contains_char(of, copy[i]) ) {
copy.erase(copy.begin() + i);
ret.push_back(copy);
//std::cout << copy << std::endl;
break;
}
}
temp = ret.back();
}
return ret;
}
示例15: UndeclaredSymbolException
const Symbol&
SymbolTable::getSymbol(const std::string& lexeme, const TypeList& params) {
//deve considerar promocao de tipos
// função f(a:real) ...
// f(1); //resolve para a função "f_real"
//checar:
// f(a : inteiro)
// f(b : real)
// f(2); //primeira versão, sempre!
SymbolList list = _table[globalScope()].findAllByLexeme(lexeme);
if (list.size() == 0) {
throw UndeclaredSymbolException(lexeme);
}
//try exact version
for (SymbolList::iterator it = list.begin(); it != list.end(); ++it) {
if ((*it).type()->isSubprogram() &&
(*it).type()->paramTypes().equals(params)) {
return (*it);
}
}
//tentando promocoes...
for (SymbolList::iterator it = list.begin(); it != list.end(); ++it) {
if ((*it).type()->isSubprogram() &&
(*it).type()->paramTypes().isLValueFor(params)) {
return (*it);
}
}
throw UnmatchedException(lexeme);
// std::string id = Symbol::buildIdentifier(lexeme, params);
// SymbolList::const_iterator it = _table[globalScope()].findByIdentifier(id);
// if (it == _table[globalScope()].end()) {
// throw UndeclaredSymbolException(id);
// }
// return (*it);
}