本文整理汇总了C++中parser类的典型用法代码示例。如果您正苦于以下问题:C++ parser类的具体用法?C++ parser怎么用?C++ parser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
示例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";
}
}
示例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>();
}
}
示例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;
}
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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());
}
}
示例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)
示例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
}
示例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));
}