xo-reader2: + example app 'readerreplxx'
This commit is contained in:
parent
dc9f29275a
commit
258d0823f5
16 changed files with 258 additions and 131 deletions
|
|
@ -157,6 +157,7 @@ namespace xo {
|
|||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
using size_type = std::size_t;
|
||||
|
||||
public:
|
||||
/** create parser in initial state;
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ namespace xo {
|
|||
|
||||
/** schematika expression parsed from input **/
|
||||
obj<AExpression> expr_;
|
||||
/** input span up to end of expression.
|
||||
/** unconsumed portion of input span
|
||||
* only relevant when result type is expression.
|
||||
* (otherwise treat entire input as consumed)
|
||||
* (otherwise input consumed)
|
||||
**/
|
||||
span_type consumed_;
|
||||
span_type remaining_input_;
|
||||
|
||||
/** {src_function, error_description, input_state, error_pos} **/
|
||||
TokenizerError tk_error_;
|
||||
|
|
@ -36,18 +36,32 @@ namespace xo {
|
|||
class SchematikaReader {
|
||||
public:
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using span_type = xo::mm::span<const char>;
|
||||
using size_type = std::size_t;
|
||||
|
||||
public:
|
||||
SchematikaReader(const ReaderConfig & config,
|
||||
obj<AAllocator> expr_alloc);
|
||||
|
||||
/** true iff parser is at top-level.
|
||||
* false iff parser is working on incomplete expression
|
||||
**/
|
||||
bool is_at_toplevel() const noexcept;
|
||||
|
||||
/** prepare interactive session
|
||||
* (allows rvalue expressions at toplevel)
|
||||
**/
|
||||
void begin_interactive_session();
|
||||
|
||||
/** consume input @p input_cstr **/
|
||||
const ReaderResult & read_expr(const char * input_cstr, bool eof);
|
||||
const ReaderResult & read_expr(span_type input_span, bool eof);
|
||||
|
||||
/** reset to known starting point after encountering an error.
|
||||
* - remainder of stashed current line.
|
||||
* Necesary for well-formatted error reporting.
|
||||
* - current parsing state
|
||||
**/
|
||||
void reset_to_idle_toplevel();
|
||||
|
||||
private:
|
||||
/** tokenizer converts a stream of chars
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue