xo-reader: + docs scaffold

This commit is contained in:
Roland Conybeare 2025-07-04 10:09:04 -05:00
commit a0b6a85297
8 changed files with 151 additions and 3 deletions

45
docs/example.rst Normal file
View file

@ -0,0 +1,45 @@
.. _examples:
.. toctree::
:maxdepth: 2
Examples
========
See ``xo-reader/examples`` for built examples
.. code-block:: cpp
:linenos:
#include "xo/reader/reader.h"
int
main() {
using namespace xo::scm;
using namespace std;
reader rdr;
rdr.begin_translation_unit();
bool eof = false;
while (!eof) {
auto input = ins.read_some();
eof = ins.eof();
for (auto rem = input; !rem.empty();) {
// res: (parsed-expr, used)
auto [expr, rem2] = rdr.read_expr(rem, eof);
if (expr) {
cout << expr << endl;
}
rem = rem.suffix_after(rem2);
}
}
if (rdr.has_prefix()) {
cout << "error: unparsed input after expression" << endl;
}
}