本文整理汇总了C++中parser类的典型用法代码示例。如果您正苦于以下问题:C++ parser类的具体用法?C++ parser怎么用?C++ parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: readfile
queue<string> readfile(fstream &fin,parser &SLRparser)
{
char line[SIZE];
queue<string> testCases;
while(fin.getline(line,sizeof(line),'\n')){
string transfer(line);
if(!strncmp(line, "#", 1)){
}
else if(!strncmp(line, "non-term:", 9)){
SLRparser.storeNonTerminals(transfer.substr(9));
}
else if(!strncmp(line, "term:", 5)){
SLRparser.storeTerminals(transfer.substr(5));
}
else if(!strncmp(line, "prod:", 5)){
SLRparser.storeProductions(transfer.substr(5));
}
else if(!strncmp(line, "start:", 6)){
SLRparser.storeStartSymbol(transfer.substr(6));
}
else{
testCases.push(transfer);
}
}
return testCases;
}
开发者ID:TimeMachine,项目名称:NTOU_Homework,代码行数:26,代码来源:Source.cpp
示例2: parse_notation_expr
static expr parse_notation_expr(parser & p, buffer<expr> const & locals) {
auto pos = p.pos();
expr r = p.parse_expr();
r = abstract(r, locals.size(), locals.data());
check_notation_expr(r, pos);
return r;
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:7,代码来源:notation_cmd.cpp
示例3: namespace_cmd
environment namespace_cmd(parser & p) {
auto pos = p.pos();
name n = p.check_atomic_id_next("invalid namespace declaration, atomic identifier expected");
if (is_root_namespace(n))
throw parser_error(sstream() << "invalid namespace name, '" << n << "' is reserved", pos);
return push_scope(p.env(), p.ios(), n);
}
开发者ID:silky,项目名称:lean,代码行数:7,代码来源:builtin_cmds.cpp
示例4: _parse_quadhex
inline int _parse_quadhex(parser<Iter> &in_)
{
int uni_ch = 0,
hex;
for (int i = 0; i < 4; i++)
{
if ((hex = in_.getc()) == -1)
{
return -1;
}
if ('0' <= hex && hex <= '9')
{
hex -= '0';
}
else if ('A' <= hex && hex <= 'F')
{
hex -= 'A' - 0xa;
}
else if ('a' <= hex && hex <= 'f')
{
hex -= 'a' - 0xa;
}
else
{
in_.ungetc();
return -1;
}
uni_ch = uni_ch * 16 + hex;
}
return uni_ch;
}
开发者ID:Bulliby,项目名称:Reactive,代码行数:35,代码来源:parser.hpp
示例5: parse_quoted_symbol_or_token
static name parse_quoted_symbol_or_token(parser & p, buffer<token_entry> & new_tokens, bool & used_default, notation_entry_group grp) {
used_default = false;
if (p.curr_is_quoted_symbol()) {
environment const & env = p.env();
auto pp_tk = p.get_name_val();
auto tks = utf8_trim(pp_tk.to_string());
auto tkcs = tks.c_str();
check_not_forbidden(tkcs);
p.next();
if (p.curr_is_token(get_colon_tk())) {
p.next();
unsigned prec = parse_precedence(p);
new_tokens.push_back(mk_token_entry(tkcs, prec, grp));
} else if (!get_precedence(env, tkcs, grp)) {
new_tokens.push_back(mk_token_entry(tkcs, LEAN_DEFAULT_PRECEDENCE, grp));
used_default = true;
}
return pp_tk;
} else if (p.curr_is_keyword()) {
auto tk = p.get_token_info().token();
check_not_forbidden(tk.to_string().c_str());
p.next();
return tk;
} else {
throw parser_error("invalid notation declaration, symbol expected", p.pos());
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:27,代码来源:notation_cmd.cpp
示例6: show_usage
void show_usage(parser& p)
{
cout <<desc<<"\n"<<"FORMAT KEYWORDS:\n";
for (parser::parse_elements::iterator it = p.keywords_begin(); it != p.keywords_end() ; it++)
{
cout <<"\t"<<parser::_key_word_id<<(*it).first <<"\n";
}
}
开发者ID:onotelli,项目名称:justniffer,代码行数:8,代码来源:main.cpp
示例7: parse_optional_precedence
static optional<unsigned> parse_optional_precedence(parser & p) {
if (p.curr_is_token(get_colon_tk())) {
p.next();
return some(parse_precedence_core(p));
} else {
return optional<unsigned>();
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:8,代码来源:notation_cmd.cpp
示例8: parse_binders_rbp
static unsigned parse_binders_rbp(parser & p) {
if (p.curr_is_token(get_colon_tk())) {
p.next();
return parse_precedence(p);
} else {
return 0;
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:8,代码来源:notation_cmd.cpp
示例9: load_command_variables
static void load_command_variables(variables_map& variables, parser& metadata,
int argc, const char* argv[])
{
const auto options = metadata.load_options();
const auto arguments = metadata.load_arguments();
auto command_parser = command_line_parser(argc, argv).options(options)
.positional(arguments);
store(command_parser.run(), variables);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:9,代码来源:parser.cpp
示例10: parse
void type_modifiers::parse(parser & p) {
while (true) {
if (p.curr_is_token(get_class_tk())) {
m_is_class = true;
p.next();
} else {
break;
}
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:10,代码来源:type_util.cpp
示例11: parse
void parse(parser & p) {
while (true) {
if (p.curr_is_token(get_parsing_only_tk())) {
p.next();
m_parse_only = true;
} else if (auto prio = parse_priority(p)) {
m_priority = *prio;
} else {
return;
}
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:12,代码来源:notation_cmd.cpp
示例12: parse_notation_local
static void parse_notation_local(parser & p, buffer<expr> & locals) {
if (p.curr_is_identifier()) {
name n = p.get_name_val();
p.next();
expr local_type = mk_Prop(); // type used in notation local declarations, it is irrelevant
expr l = mk_local(n, local_type); // remark: the type doesn't matter
p.add_local(l);
locals.push_back(l);
} else {
throw parser_error("invalid notation declaration, identifier expected", p.pos());
}
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:12,代码来源:notation_cmd.cpp
示例13: _parse_codepoint
inline bool _parse_codepoint(String& out, parser<Iter>& in)
{
int uni_ch;
if ((uni_ch = _parse_quadhex(in)) == -1)
{
return false;
}
if (0xd800 <= uni_ch && uni_ch <= 0xdfff)
{
if (0xdc00 <= uni_ch)
{
// a second 16-bit of a surrogate pair appeared
return false;
}
// first 16-bit of surrogate pair, get the next one
if (in.getc() != '\\' || in.getc() != 'u')
{
in.ungetc();
return false;
}
int second = _parse_quadhex(in);
if (!(0xdc00 <= second && second <= 0xdfff))
{
return false;
}
uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff);
uni_ch += 0x10000;
}
if (uni_ch < 0x80)
{
out.push_back(uni_ch);
}
else
{
if (uni_ch < 0x800)
{
out.push_back(0xc0 | (uni_ch >> 6));
}
else
{
if (uni_ch < 0x10000)
开发者ID:Bulliby,项目名称:Reactive,代码行数:48,代码来源:parser.hpp
示例14: void
compiler::compiler(parser& p, void (*fp)(const char*)) :
m(fp), forwards(), callback(fp)
{
// Perform complete compilation
while ( compile_token(p.next_token(), p) )
; // loop
}
开发者ID:cslarsen,项目名称:stack-machine,代码行数:7,代码来源:compiler.cpp
示例15: parse
void parse(parser& parser)
{
//clear
clear();
//empty
if(parser.is_empty())
return;
//composite
if(try_composite(parser))
return;
//assign
if(try_assign(parser))
return;
//dereference
if(try_dereference(parser))
return;
//annotation
if(try_annotation(parser))
return;
//unit
check(try_unit(parser));
}
开发者ID:vmorgulys,项目名称:sandbox,代码行数:35,代码来源:class.atom.h.parse.cpp
示例16: load_configuration_variables
static bool load_configuration_variables(variables_map& variables,
parser& metadata)
{
const auto config_settings = metadata.load_settings();
const auto config_path = get_config_option(variables);
// If the existence test errors out we pretend there's no file :/.
error_code code;
if (!config_path.empty() && exists(config_path, code))
{
bc::ifstream file(config_path.string());
if (!file.good())
{
BOOST_THROW_EXCEPTION(reading_file(config_path.string().c_str()));
}
const auto config = parse_config_file(file, config_settings);
store(config, variables);
return true;
}
// Loading from an empty stream causes the defaults to populate.
std::stringstream stream;
const auto config = parse_config_file(stream, config_settings);
store(config, variables);
return false;
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:27,代码来源:parser.cpp
示例17: coercion_cmd
environment coercion_cmd(parser & p) {
auto pos = p.pos();
expr f = p.parse_expr();
if (!is_constant(f))
throw parser_error("invalid 'coercion' command, constant expected", pos);
if (p.curr_is_token(g_colon)) {
p.next();
pos = p.pos();
expr C = p.parse_expr();
if (!is_constant(C))
throw parser_error("invalid 'coercion' command, constant expected", pos);
return add_coercion(p.env(), const_name(f), const_name(C), p.ios());
} else {
return add_coercion(p.env(), const_name(f), p.ios());
}
}
开发者ID:silky,项目名称:lean,代码行数:16,代码来源:builtin_cmds.cpp
示例18: printOptionName
void parser<mcld::MCLDDirectory>::printOptionDiff(const llvm::cl::Option &O,
const mcld::MCLDDirectory &V,
parser<mcld::MCLDDirectory>::OptVal Default,
size_t GlobalWidth) const
{
printOptionName(O, GlobalWidth);
outs() << "= " << V.name();
size_t VSize = V.name().size();
size_t NumSpaces = MaxOptWidth > VSize ? MaxOptWidth - VSize : 0;
outs().indent(NumSpaces) << " (default: ";
if (Default.hasValue())
outs() << Default.getValue().name();
else
outs() << "*no default*";
outs() << ")\n";
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:16,代码来源:CommandLine.cpp
示例19: load_environment_variables
static void load_environment_variables(variables_map& variables,
parser& metadata)
{
const auto& environment_variables = metadata.load_environment();
const auto environment = parse_environment(environment_variables,
BS_ENVIRONMENT_VARIABLE_PREFIX);
store(environment, variables);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:8,代码来源:parser.cpp
示例20: parse_struct_expr_core
static expr parse_struct_expr_core(parser & p, pos_info const & pos, bool curly_bar) {
expr t = p.parse_expr();
buffer<name> field_names;
buffer<expr> field_values;
buffer<expr> using_exprs;
while (p.curr_is_token(get_comma_tk())) {
p.next();
pair<optional<name>, expr> id_e = p.parse_optional_assignment();
if (id_e.first) {
field_names.push_back(*id_e.first);
field_values.push_back(id_e.second);
} else {
using_exprs.push_back(id_e.second);
}
}
if (curly_bar)
p.check_token_next(get_rcurlybar_tk(), "invalid structure expression, '|}' expected");
else
p.check_token_next(get_rdcurly_tk(), "invalid structure expression, '⦄' expected");
buffer<expr> args;
args.push_back(t);
args.append(field_values);
args.append(using_exprs);
return p.save_pos(mk_structure_instance(to_list(field_names), args.size(), args.data()), pos);
}
开发者ID:soonhokong,项目名称:lean-osx,代码行数:25,代码来源:structure_instance.cpp
注:本文中的parser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论