本文整理汇总了C++中ParseContext类的典型用法代码示例。如果您正苦于以下问题:C++ ParseContext类的具体用法?C++ ParseContext怎么用?C++ ParseContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParseContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_block
void parse_block(ParseContext& pc, vector<BaseNode*>& nodes, size_t indent,
bool fblock) {
bool first = true;
while (!pc.isFileEnd()) {
if (pc.getTokens().empty())
continue;
size_t line_indent = pc.getLine().indent;
if ((first && line_indent != indent) || line_indent > indent) {
parse_err(pc, "Improper indent level in block");
break;
} else if (line_indent < indent) {
break;
}
BaseNode* bn;
if (fblock) {
bn = parse_func(pc);
if (!bn) {
parse_err(pc,
"Only function definitions expected in type block");
}
} else
bn = parse_line(pc);
if (bn == NULL)
return;
nodes.push_back(bn);
if (error())
break;
first = false;
}
}
示例2: createSourcesAtPath
bool CSourceEmitter::createSourcesAtPath(const ParseContext& context, const std::string& outputBasePath) {
Three::CCodeGenVisitor visitor;
context.rootNode()->accept(visitor);
std::ofstream bodyFile(outputBasePath + ".c");
assert(bodyFile);
// make sure to import the headers
visitor.addInternalHeader(true, outputBasePath + ".h");
visitor.addDeclarationsHeader(true, outputBasePath + "_internal.h");
bodyFile << "// Declarations" << std::endl;
bodyFile << visitor.declarationsString();
bodyFile << std::endl << "// Definitions" << std::endl;
bodyFile << visitor.bodyString();
std::ofstream internalHeaderFile(outputBasePath + "_internal.h");
internalHeaderFile << Three::CSource::includeGuard("");
internalHeaderFile << visitor.internalHeaderString();
std::ofstream externalHeaderFile(outputBasePath + ".h");
externalHeaderFile << Three::CSource::includeGuard("");
externalHeaderFile << visitor.externalHeaderString();
return true;
}
示例3: MaybeCheckEvalFreeVariables
static bool
MaybeCheckEvalFreeVariables(ExclusiveContext *cxArg, HandleScript evalCaller, HandleObject scopeChain,
Parser<FullParseHandler> &parser,
ParseContext<FullParseHandler> &pc)
{
if (!evalCaller || !evalCaller->functionOrCallerFunction())
return true;
// Eval scripts are only compiled on the main thread.
JSContext *cx = cxArg->asJSContext();
// Watch for uses of 'arguments' within the evaluated script, both as
// free variables and as variables redeclared with 'var'.
RootedFunction fun(cx, evalCaller->functionOrCallerFunction());
HandlePropertyName arguments = cx->names().arguments;
for (AtomDefnRange r = pc.lexdeps->all(); !r.empty(); r.popFront()) {
if (r.front().key() == arguments) {
if (!CheckArgumentsWithinEval(cx, parser, fun))
return false;
}
}
for (AtomDefnListMap::Range r = pc.decls().all(); !r.empty(); r.popFront()) {
if (r.front().key() == arguments) {
if (!CheckArgumentsWithinEval(cx, parser, fun))
return false;
}
}
// If the eval'ed script contains any debugger statement, force construction
// of arguments objects for the caller script and any other scripts it is
// transitively nested inside. The debugger can access any variable on the
// scope chain.
if (pc.sc->hasDebuggerStatement()) {
RootedObject scope(cx, scopeChain);
while (scope->is<ScopeObject>() || scope->is<DebugScopeObject>()) {
if (scope->is<CallObject>() && !scope->as<CallObject>().isForEval()) {
RootedScript script(cx, scope->as<CallObject>().callee().getOrCreateScript(cx));
if (!script)
return false;
if (script->argumentsHasVarBinding()) {
if (!JSScript::argumentsOptimizationFailed(cx, script))
return false;
}
}
scope = scope->enclosingScope();
}
}
return true;
}
示例4: parse
DeckRecord ParserRecord::parse(const ParseContext& parseContext , MessageContainer& msgContainer, RawRecord& rawRecord ) const {
std::vector< DeckItem > items;
items.reserve( this->size() + 20 );
for( const auto& parserItem : *this )
items.emplace_back( parserItem->scan( rawRecord ) );
if (rawRecord.size() > 0) {
std::string msg = "The RawRecord for keyword \"" + rawRecord.getKeywordName() + "\" in file\"" + rawRecord.getFileName() + "\" contained " +
std::to_string(rawRecord.size()) +
" too many items according to the spec. RawRecord was: " + rawRecord.getRecordString();
parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msgContainer, msg);
}
return { std::move( items ) };
}
示例5: deckRecord
DeckRecord ParserRecord::parse(const ParseContext& parseContext , MessageContainer& msgContainer, RawRecord& rawRecord ) const {
DeckRecord deckRecord( size() + 20 );
for (size_t i = 0; i < size(); i++) {
auto parserItem = get(i);
deckRecord.addItem( parserItem->scan( rawRecord ) );
}
if (rawRecord.size() > 0) {
std::string msg = "The RawRecord for keyword \"" + rawRecord.getKeywordName() + "\" in file\"" + rawRecord.getFileName() + "\" contained " +
std::to_string(rawRecord.size()) +
" too many items according to the spec. RawRecord was: " + rawRecord.getRecordString();
parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msgContainer, msg);
}
return deckRecord;
}
示例6: checkOptions
void checkOptions(const DeckKeyword& keyword, std::multimap<std::string , PartiallySupported<T> >& map, const ParseContext& parseContext, ErrorGuard& errorGuard)
{
// check for partially supported keywords.
typename std::multimap<std::string, PartiallySupported<T> >::iterator it, itlow, itup;
itlow = map.lower_bound(keyword.name());
itup = map.upper_bound(keyword.name());
for (it = itlow; it != itup; ++it) {
const auto& record = keyword.getRecord(0);
if (record.getItem(it->second.item).template get<T>(0) != it->second.item_value) {
std::string msg = "For keyword '" + it->first + "' only value " + boost::lexical_cast<std::string>(it->second.item_value)
+ " in item " + it->second.item + " is supported by flow.\n"
+ "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n";
parseContext.handleError(ParseContext::SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED, msg, errorGuard);
}
}
}
示例7: checkKeywords
void checkKeywords(const Deck& deck, const ParseContext& parseContext, ErrorGuard& errorGuard)
{
// These keywords are supported by opm-parser, but are not supported
// by flow. For some of them, only part of the options are supported.
// The list is used to output messages only.
std::unordered_set<std::string> unsupported_keywords = {
"ACTION",
"ACTIONX",
"ADSALNOD",
"API",
"APIGROUP",
"AQUCON",
"AQUCT",
"AQUTAB",
"AQUNUM",
"BRANPROP",
"CARFIN",
"COMPDATL",
"COMPLUMP",
"CONNECTION",
"CPR",
"DATE",
"ENDACTIO",
"ENDFIN"
"ENDNUM",
"ENDSKIP",
"ENKSRVD",
"ENPTVD",
"EQLNUM",
"EQUALREG",
"EXCEL",
"EXTRAPMS",
"FILLEPS",
"FIPNUM",
"FLUXTYPE",
"FULLIMP",
"GCONSALE",
"GCONSUMP",
"GDORIENT",
"GECON",
"GLIFTOPT",
"GNETINJE",
"GPMAINT",
"GRIDUNIT",
"GRUPNET",
"GSATPROD",
"GUIDERAT",
"IMKRVD",
"IMPES",
"IMPTVD",
"LGR",
"LIFTOPT",
"MAPUNITS",
"MAXVALUE",
"MESSAGES",
"MINVALUE",
"MONITOR",
"MSGFILE",
"MULT_XYZ",
"NETBALAN",
"NEXTSTEP",
"NOCASC",
"NODEPROP",
"NOGGF",
"NOINSPEC",
"NOMONITO",
"NONNC",
"NORSSPEC",
"NOWARN",
"NSTACK",
"NUMRES",
"NUPCOL",
"OILVISCT",
"OLDTRAN",
"OPERATER",
"OPTIONS",
"PARALLEL",
"PBVD",
"PCG",
"PERMR",
"PERMTHT",
"PERMXY",
"PERMYZ",
"PERMZX",
"PIMULTAB",
"PLYADSS",
"PLYDHFLF",
"PPCWMAX",
"REFINE",
"RADFIN4",
"RHO",
"RKTRMDIR",
"ROCKCOMP",
"ROCKOPTS",
"ROCKTAB",
"RPTGRID",
"RPTONLY",
"RPTONLYO",
"RPTPROS",
"PRTRST",
//.........这里部分代码省略.........