37#include <wx/cmdline.h>
50 bool Parse( std::istream& aStream )
55 const std::string sexpr_str( std::istreambuf_iterator<char>( aStream ), {} );
59 std::unique_ptr<SEXPR::SEXPR> sexpr(
m_parser.
Parse( sexpr_str ) );
62 std::cout <<
"S-Expression Parsing took " << timer.msecs() <<
"ms" << std::endl;
64 return sexpr !=
nullptr;
77 _(
"displays help on the command line parameters" ).mb_str(),
79 wxCMD_LINE_OPTION_HELP,
85 _(
"print parsing information" ).mb_str(),
91 _(
"input file" ).mb_str(),
92 wxCMD_LINE_VAL_STRING,
93 wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE,
107 wxCmdLineParser cl_parser( argc, argv );
109 cl_parser.AddUsageText(
_(
"Tests parsing of S-Expression files" ) );
111 int cmd_parsed_ok = cl_parser.Parse();
112 if( cmd_parsed_ok != 0 )
118 const auto file_count = cl_parser.GetParamCount();
119 const bool verbose = cl_parser.Found(
"verbose" );
125 if( file_count == 0 )
129 qa_parser.
Parse( std::cin );
136 for(
unsigned i = 0; i < file_count; i++ )
138 const auto filename = cl_parser.GetParam( i ).ToStdString();
141 std::cout <<
"Parsing: " << filename << std::endl;
144 fin.open( filename );
146 ok = ok && qa_parser.
Parse( fin );
151 return PARSER_RET_CODES::PARSE_FAILED;
159 "Benchmark s-expression parsing",
A small class to help profiling.
bool Parse(std::istream &aStream)
QA_SEXPR_PARSER(bool aVerbose)
std::unique_ptr< SEXPR > Parse(const std::string &aString)
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.
static const wxCmdLineEntryDesc g_cmdLineDesc[]
int sexpr_parser_func(int argc, char *argv[])