<div dir="ltr">Hi,<div>  I'm trying to understand the F18 parser and the parse tree code by creating some simple examples.   I would like to create a simple parser and also create a parse tree programmatically, but I'm running into some problems.</div><div><br></div><div>For the first step, I added a constructor to ParseState that accepts a std::string (to avoid constructing a CookedSource object).  The following code works:</div><div><br></div><div><font face="monospace">#include "token-parsers.h"</font></div><div><font face="monospace">using namespace Fortran::parser;<br>int main()<br>{<br>    std::string test("b");<br>    ParseState p(test);<br>    auto p1 =  "a"_ch;<br>    auto res = p1.Parse(p);<br>    std::cout << " res = " << res.value_or("no result") << std::endl;<br>    return 0;<br>}</font><br></div><div><br></div><div><font face="arial, sans-serif">For the second step, I would like to create a parse tree programmatically and call unparse.</font></div><div><font face="arial, sans-serif">The first problem is I am unable to build a MainProgram with a minimal set of inputs.</font></div><div><font face="arial, sans-serif">So far, the code to create some of the elements is as follows:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="monospace">    SpecificationPart spec{std::list<OpenMPDeclarativeConstruct>{},<br>                           std::list<Statement<Fortran::common::Indirection<UseStmt>>>{} ,<br>                           std::list<Statement<Fortran::common::Indirection<ImportStmt>>>{},<br>                           ImplicitPart{std::list<ImplicitPartStmt>{}},<br>                           std::list<DeclarationConstruct>{}};<br><br>    ExecutionPart exec{std::list<ExecutionPartConstruct>{}};<br><br>    Statement<EndProgramStmt> end{Statement<EndProgramStmt>{std::nullopt, EndProgramStmt{std::nullopt}}};</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">The problem is constructing the tuple for the MainProgram  - all these objects cause compile errors when placed in a tuple ("no matching constructor" errors).  If anyone has better example code, or instructions on how to do this properly, I would appreciate it.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Thanks,</font></div><div><font face="arial, sans-serif">Mark Dewing</font></div></div>