本文整理汇总了C++中lem::iridium::Macro_Parser::probe方法的典型用法代码示例。如果您正苦于以下问题:C++ Macro_Parser::probe方法的具体用法?C++ Macro_Parser::probe怎么用?C++ Macro_Parser::probe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lem::iridium::Macro_Parser
的用法示例。
在下文中一共展示了Macro_Parser::probe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompileDeclaration
// if(x) then ... else ...
void TrFun_If::CompileDeclaration(
PM_Automat &pm,
lem::Iridium::Macro_Parser &txtfile,
TrFunctions &functions,
TrKnownVars &known_vars,
const TrBuiltInFunSignature *signature
)
{
src_location = pm.GetDict().GetDebugSymbols().RegisterLocation( txtfile, txtfile.tellp() );
// ”словие опционально может быть заключено в круглые скобочки.
const bool req_paren = txtfile.probe( B_OROUNDPAREN );
cond = functions.CompileCall( pm, txtfile, known_vars );
if( req_paren )
txtfile.read_it( B_CROUNDPAREN );
txtfile.read_it( B_THEN );
f_then = functions.CompileCall( pm, txtfile, known_vars );
txtfile.probe( B_SEMICOLON );
if( txtfile.pick().GetToken()==B_ELSE )
{
txtfile.read_it(B_ELSE);
f_else = functions.CompileCall( pm, txtfile, known_vars );
txtfile.probe( B_SEMICOLON );
}
return;
}
示例2: LoadTxt
void TreeScorerResult::LoadTxt( Dictionary & dict, lem::Iridium::Macro_Parser & txtfile, const TreeScorerMarkers & markers )
{
// ќценка может быть отрицательной.
if( txtfile.probe( B_SUB ) )
{
type=0;
score = -txtfile.read_int();
}
else
{
if( lem::is_int( txtfile.pick().string() ) )
{
type=0;
score = txtfile.read_int();
}
else
{
const lem::Iridium::BethToken & t = txtfile.read();
id_fact = dict.GetLexAuto().GetKnowledgeBase().FindFacts( t.string() );
if( id_fact==UNKNOWN )
{
// todo - тут могут быть другие варианты вызываемых вычислений.
lem::Iridium::Print_Error(t,txtfile);
dict.GetIO().merr().printf( "Unknown scoring expression starts with %us\n", t.string().c_str() );
throw lem::E_BaseException();
}
txtfile.read_it( B_OROUNDPAREN );
while( !txtfile.eof() )
{
if( txtfile.probe( B_CROUNDPAREN ) )
break;
if( !args.empty() )
txtfile.read_it( B_COMMA );
const lem::Iridium::BethToken & var = txtfile.read();
lem::UCString upper_var = lem::to_upper(var.string());
if( !markers.IsAlreadyBound(upper_var) )
{
lem::Iridium::Print_Error(var,txtfile);
dict.GetIO().merr().printf( "variable %us not bound\n", var.string().c_str() );
throw lem::E_BaseException();
}
args.push_back( upper_var );
}
type=1;
}
}
return;
}
示例3: LoadGroup
void TreeScorers::LoadGroup( Dictionary & dict, lem::Iridium::Macro_Parser &txtfile )
{
lem::Iridium::BethToken t_name = txtfile.read();
lem::UCString gname = t_name.string();
gname.to_upper();
if( name2id.find(gname)!=name2id.end() )
{
lem::Iridium::Print_Error( t_name, txtfile );
dict.GetIO().merr().printf( "Tree scorer group [%us] is already declared\n", t_name.string().c_str() );
throw lem::E_ParserError();
}
TreeScorerGroupParams params;
if( txtfile.probe( B_OFIGPAREN ) )
{
while( !txtfile.eof() )
{
if( txtfile.probe( B_CFIGPAREN ) )
break;
lem::Iridium::BethToken tparam = txtfile.read();
if( tparam.string().eqi(L"allow_unmatched_children") )
{
txtfile.read_it( B_EQUAL );
lem::Iridium::BethToken tbool = txtfile.read();
if( tbool.string().eqi(L"true") )
params.allow_unmatched_children = true;
else if( tbool.string().eqi(L"false") )
params.allow_unmatched_children = false;
else
{
lem::Iridium::Print_Error( tbool, txtfile );
dict.GetIO().merr().printf( "[%us] is not boolean value\n", tbool.string().c_str() );
throw lem::E_ParserError();
}
}
else
{
lem::Iridium::Print_Error( tparam, txtfile );
dict.GetIO().merr().printf( "Unknown tree scorer group parameter [%us]\n", tparam.string().c_str() );
throw lem::E_ParserError();
}
}
}
const int id = storage->StoreTreeScorerGroup( gname, params );
name2id.insert( std::make_pair(gname,id) );
return;
}
示例4: LoadTxt
void ViolationHandler::LoadTxt( lem::Iridium::Macro_Parser & txtfile )
{
if( txtfile.probe( B_OSPAREN ) )
{
txtfile.read_it( B_SUB );
violation_score = -txtfile.read_int();
txtfile.probe( B_CSPAREN );
}
else
{
violation_score=0;
}
return;
}
示例5: LoadTxt
void TreeScorerQuantification::LoadTxt(lem::Iridium::Macro_Parser & txtfile)
{
if (txtfile.probe(B_OSPAREN))
{
lem::Iridium::BethToken t1 = txtfile.read();
int n1 = 0;
int n2 = MAX_COUNT;
if (t1.GetToken() == B_NOT)
{
// Ветка [not] представляет собой требования отсутствия и хранится через
// пару -1,-1
min_count = max_count = -1;
}
else
{
if (lem::is_int(t1.string()))
{
n1 = lem::to_int(t1.string());
}
else
{
txtfile.seekp(t1); // [,1] эквивалентно [0,1]
}
if (txtfile.probe(B_COMMA))
{
lem::Iridium::BethToken t2 = txtfile.read();
if (lem::is_int(t2.string()))
n2 = lem::to_int(t2.string());
else
txtfile.seekp(t2);
}
else
{
n2 = n1; // [1] эквивалентно [1,1]
}
min_count = n1;
max_count = n2;
}
txtfile.read_it(B_CSPAREN);
}
return;
}
示例6: LoadTxt
void PatternConstraints::LoadTxt(
Dictionary &dict,
lem::Iridium::Macro_Parser & txtfile,
SynPatternCompilation & compilation_context
)
{
txtfile.read_it(B_OFIGPAREN);
lem::Iridium::BSourceState beg = txtfile.tellp();
while (!txtfile.eof())
{
if (txtfile.probe(B_CFIGPAREN))
break;
PatternConstraint * c = new PatternConstraint();
c->LoadTxt(dict, txtfile, compilation_context);
constraints.push_back(c);
}
return;
}
示例7: LoadTxt
void TrType::LoadTxt(
PM_Automat &pm,
lem::Iridium::Macro_Parser &txtfile,
const TrFunctions &funs
)
{
is_const = txtfile.probe( L"const" );
const lem::Iridium::BethToken& t = txtfile.read();
if( t.string().eqi( L"bool" ) )
type = Bool;
else if( t.string().eqi( L"int" ) )
type = Int;
else if( t.string().eqi( L"string" ) )
type = String;
else if( t.string().eqi( L"tree" ) )
type = Tree;
else if( t.string().eqi( L"trees" ) )
type = Trees;
else if( t.string().eqi( L"fun" ) )
type = Fun;
else if( t.string().eqi( L"void" ) )
type = Void;
else if( t.string().eqi( L"variant" ) )
type = Variant;
else if( t.string().eqi( L"tuple" ) )
type = Tuple;
else
{
lem::Iridium::Print_Error( t, txtfile );
pm.GetIO().merr().printf( "Unknown type [%us]\n", t.string().c_str() );
throw E_ParserError();
}
return;
}
示例8: LoadTxt
void SynPattern::LoadTxt(
Dictionary &dict,
lem::Iridium::Macro_Parser & txtfile,
const SynPatterns &patterns,
WordEntrySet &wordentry_set,
const TrProcedureDeclaration &procs,
TrFunctions &functions
)
{
lem::Iridium::BSourceState pattern_beginning = txtfile.tellp();
id_src = dict.GetDebugSymbols().RegisterLocation( txtfile, txtfile.tellp() );
if( dict.GetDebugLevel_ir()>=3 )
{
dict.GetIO().mecho().printf( "pattern " );
}
// ќпционально могут быть заданы целевой ¤зык и опции.
while( !txtfile.eof() )
{
if( txtfile.probe( B_OFIGPAREN ) )
break;
if( txtfile.probe( B_LANGUAGE ) )
{
txtfile.read_it( B_EQUAL );
lem::Iridium::BethToken lang = txtfile.read();
id_language = dict.GetSynGram().Find_Language(lang.string());
if( id_language==UNKNOWN )
{
lem::Iridium::Print_Error(lang,txtfile);
dict.GetIO().merr().printf( "Unknown language name %us\n", lang.c_str() );
throw lem::E_BaseException();
}
}
else if( txtfile.probe( L"incomplete" ) )
{
incomplete=true;
}
else
{
lem::Iridium::BethToken tname = txtfile.read();
name = tname.string();
if( dict.GetDebugLevel_ir()>=3 )
{
dict.GetIO().mecho().printf( "%vfE%us%vn ", name.c_str() );
}
if( !patterns.IsPatternName(name) )
{
dict.GetIO().merr().printf( "Patterns group [%us] is not declared\n", name.c_str() );
lem::Iridium::Print_Error(tname,txtfile);
throw lem::E_BaseException();
}
const SynPatternOptions & group_options = patterns.GetOptions(name);
id_language = group_options.GetLanguageId();
// —екци¤ export { ... } содержит объ¤влени¤ координат, которые паттерн выдает наружу
// —начала попробуем вз¤ть содержимое экспорта по умолчанию, зарегистрированное в объ¤влении
// группы паттернов.
if( txtfile.probe(L"export") )
{
export_info.LoadTxt( dict, txtfile );
}
else
{
const SynPatternOptions & p_options = patterns.GetOptions(name);
export_info = p_options.GetExport();
}
export_info.RegisterExport( *compilation_context );
if( txtfile.probe( B_LANGUAGE ) )
{
txtfile.read_it( B_EQUAL );
lem::Iridium::BethToken lang = txtfile.read();
id_language = dict.GetSynGram().Find_Language(lang.string());
if( id_language==UNKNOWN )
{
lem::Iridium::Print_Error(lang,txtfile);
dict.GetIO().merr().printf( "Unknown language name %us\n", lang.c_str() );
throw lem::E_BaseException();
}
}
txtfile.read_it( B_OFIGPAREN );
break;
}
}
// —писок опорных точек в фигурных скобочках
lem::Iridium::BSourceState beg = txtfile.tellp();
//.........这里部分代码省略.........
示例9: LoadTxt
void SynPatternExport::LoadTxt(
Dictionary &dict,
lem::Iridium::Macro_Parser & txtfile
)
{
txtfile.read_it( B_OFIGPAREN );
while( !txtfile.eof() )
{
bool null_export = txtfile.probe( B_OROUNDPAREN );
lem::Iridium::BethToken coord_name = txtfile.read();
if( coord_name.GetToken()==B_CFIGPAREN )
break;
if( coord_name.string().eqi( L"node" ) )
{
txtfile.read_it( B_COLON );
lem::Iridium::BethToken t_node_name = txtfile.read();
lem::UCString node_name = t_node_name.string();
node_name.to_upper();
if( export_nodes.find(node_name)!=UNKNOWN )
{
dict.GetIO().merr().printf( "Wordform %us is already mentioned in export section\n", t_node_name.string().c_str() );
lem::Iridium::Print_Error(t_node_name,txtfile);
throw lem::E_BaseException();
}
export_nodes.push_back( node_name );
null_export_nodes.push_back( null_export ? 1 : 0 );
if( null_export )
txtfile.read_it( B_CROUNDPAREN );
continue;
}
const GramCoordAdr iglob_coord = dict.GetSynGram().FindCoord(coord_name.string());
if( !iglob_coord.IsDefined() )
{
dict.GetIO().merr().printf( "Unknown coordinate %us\n", coord_name.c_str() );
lem::Iridium::Print_Error(coord_name,txtfile);
throw lem::E_BaseException();
}
if( export_coords.find( iglob_coord.GetIndex() )!=UNKNOWN )
{
dict.GetIO().merr().printf( "Coordinate %us is already mentioned in export section\n", coord_name.c_str() );
lem::Iridium::Print_Error(coord_name,txtfile);
throw lem::E_BaseException();
}
export_coords.push_back(iglob_coord.GetIndex());
null_export_coords.push_back( null_export ? 1 : 0 );
if( null_export )
txtfile.read_it( B_CROUNDPAREN );
}
return;
}
示例10: LoadTxt
void KB_Facts::LoadTxt(Solarix::Dictionary &dict, lem::Iridium::Macro_Parser &txtfile)
{
name = txtfile.read().string();
txtfile.read_it(B_LANGUAGE);
txtfile.read_it(B_EQUAL);
lem::Iridium::BethToken lang = txtfile.read();
id_language = dict.GetSynGram().Find_Language(lang.string());
if (id_language == UNKNOWN)
{
lem::Iridium::Print_Error(lang, txtfile);
dict.GetIO().merr().printf("Unknown language name %us\n", lang.c_str());
throw lem::E_BaseException();
}
txtfile.read_it(B_OFIGPAREN);
n_ret = 0;
while (!txtfile.eof())
{
if (txtfile.probe(B_CFIGPAREN))
break;
lem::Iridium::BethToken t = txtfile.read();
if (t.string().eqi(L"arity"))
{
txtfile.read_it(B_EQUAL);
n_arg = txtfile.read_int();
}
else if (t.string().eqi(L"return"))
{
txtfile.read_it(B_EQUAL);
lem::Iridium::BethToken t_ret = txtfile.read();
if (t_ret.eqi(L"boolean"))
{
n_ret = 1;
ret_type = 0;
}
else if (t_ret.eqi(L"integer"))
{
n_ret = 1;
ret_type = 1;
}
else
{
lem::Iridium::Print_Error(t_ret, txtfile);
dict.GetIO().merr().printf("Unknown return type %us\n", t_ret.c_str());
throw lem::E_BaseException();
}
}
else if (t.string().eqi(L"violation_score"))
{
txtfile.read_it(B_EQUAL);
if (txtfile.probe(B_SUB))
violation_score = -txtfile.read_int();
else
violation_score = txtfile.read_int();
}
else if (t.string().eqi(L"violation_handler"))
{
txtfile.read_it(B_EQUAL);
violation_handler = new PredicateTemplate();
PredicateTemplateParams_KB params(n_arg);
violation_handler->LoadTxt(dict, txtfile, params);
}
else if (t.string().eqi(L"generic"))
{
allow_generic = true;
}
else
{
lem::Iridium::Print_Error(t, txtfile);
dict.GetIO().merr().printf("Unknown property %us\n", t.c_str());
throw lem::E_BaseException();
}
}
return;
}