/* ************************************************************************* */ TEST( wrap, ArgumentList ) { ArgumentList args; Argument arg1; arg1.type = "double"; arg1.name = "x"; Argument arg2; arg2.type = "double"; arg2.name = "y"; Argument arg3; arg3.type = "double"; arg3.name = "z"; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); EXPECT(assert_equal("ddd", args.signature())); EXPECT(assert_equal("double,double,double", args.types())); EXPECT(assert_equal("x,y,z", args.names())); }
bool ParserThread::ParseArgumentList(ArgumentList &argumentList) { // do nothing on the argumentList, just do the loop if(PeekToken()->type_id() != TKN_LESS) return true; // shoud be a (xxxx) or <xxxxx> Token * tk = ConsumeToken(); TRACE("ParserThread::ParseArgumentList() Enter..."); int level = 1; argumentList.clear(); argumentList.push_back(*tk); // push <while(true) while(true) { tk = PeekToken();// if(tk->type_id() == TKN_LESS) { ConsumeToken(); argumentList.push_back(*tk); level++; } else if (tk->type_id() == TKN_GREATER) { level--; ConsumeToken(); argumentList.push_back(*tk); if(level <= 0) break; } else if(tk->type_id()==TKN_SEMICOLON || tk->type_id()==TKN_R_BRACE) { m_Context.EndStatement(); return false; } else { //std::cout<<*tk<<std::endl; argumentList.push_back(*tk); ConsumeToken(); } } //cout<<"currentToken"<<*(CurrentToken())<<endl; TRACE("ParserThread::ParseArgumentList() Leave..."); return true; }
Parser::ArgumentList Parser::arguments(istream* input) { ArgumentList list; get_token(input); for(;;) { if(curr_sym.curr_tok == Lexer::RP) { return list; } else if (curr_sym.curr_tok == Lexer::SEP) { get_token(input); continue; } else if (curr_sym.curr_tok == Lexer::PRINT || curr_sym.curr_tok == Lexer::END) { throw Error::SyntaxError(") expected"); } else { list.push_back(expr(input, false)); } } }
ArgumentList ArgumentParser::findUnknownArguments() const { ArgumentList args; foreach (auto& arg, m_arguments) if (!arg.isKnown()) args.push_back(arg); return args; }
ArgumentList ArgumentParser::findArguments(const Option& option) const { ArgumentList args; foreach (auto& arg, m_arguments) if (&option == arg.option) args.push_back(arg); return args; }
ArgumentList arguments(istream* input) { ArgumentList args; TokenList arg; Token tok; while((tok = get_token(input, true, false)).token != TOK_END) { if(tok.token == TOK_SEP || tok.token == TOK_RPAREN) { if(arg.size() < 1) { cerr << "Missing macro argument" << endl; } args.push_back(arg); arg.clear(); if(tok.token == TOK_RPAREN) break; } else arg.push_back(tok); } return args; }
ArgumentList Calculator::arguments(Lexer& lexer) { ArgumentList list; for(;;) { Token tok = lexer.peek(); switch(tok.Type) { case Token::RP: lexer.pop(); return list; case Token::SEP: lexer.pop(); continue; case Token::PRINT: case Token::END: throw Error::SyntaxError("')' expected"); default: list.push_back(expr(lexer)); break; } } }
ArgumentList gatherArguments(int argc, const char **argv, Settings &settings) { ArgumentList args; for (int i = 1 ; i < argc ; ++i) { std::string argument = argv[i]; if (argument == "--trace") { std::cout << "INFO: Trace mode enabled!\n"; settings.trace = true; } else if (argument == "--verbose") { std::cout << "INFO: Verbose mode enabled!\n"; settings.verbose = true; } else { args.push_back(argument); } } return args; }