parser

Undocumented in source. Be warned that the author may not have intended to support it.
  1. FeatureGroup parser(string filename, string[] errors)
  2. FeatureGroup parser(R range, string[] errors, string localfile)
    parser
    (
    R
    )
    (,
    out string[] errors
    ,
    string localfile = null
    )
    if (
    isInputRange!R &&
    isSomeString!(ElementType!R)
    )

Examples

Examples: How to parse a markdown file

/// Convert ProtoDBBTestComments to Feature
   import std.traits : FunctionTypeOf;
   import tagion.basic.basic : fileId;

   enum bddfile_proto = "ProtoBDDTestComments".unitfile;
   enum bdd_filename = bddfile_proto.setExtension(FileExtension.markdown);

   auto feature_byline = File(bdd_filename).byLine;

   string[] errors;
   auto feature = parser(feature_byline, errors);
   assert(errors is null);

   const fileid = fileId!(FunctionTypeOf!parser)(FileExtension.markdown);
   immutable markdown_filename = fileid.fullpath;

   import tagion.behaviour.BehaviourIssue;

   /// Write the markdown file
   auto fout = File(markdown_filename, "w");
   auto markdown = Markdown(fout);
   markdown.issue(feature);
   fout.close;

   immutable hibon_filename = markdown_filename
       .setExtension(FileExtension.hibon);

   import tagion.hibon.HiBONFile : fread, fwrite;

   hibon_filename.fwrite(feature);

   // Check that the feature can be reloaded
   const expected_feature = hibon_filename.fread!FeatureGroup;
   assert(feature.toDoc == expected_feature.toDoc);
   // Reparse the produced markdown and check if it is the same
   errors = null;
   auto produced_feature = parser(markdown_filename, errors);
   "/tmp/produced_feature.hibon".fwrite(produced_feature);
   assert(errors is null);
   assert(produced_feature.toDoc == expected_feature.toDoc);

Meta