xo-reader2: + StringTable in ParserStringTable
This commit is contained in:
parent
535f48e202
commit
9ab828059b
5 changed files with 19 additions and 7 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "ParserResult.hpp"
|
||||
#include <xo/expression2/DVariable.hpp>
|
||||
#include <xo/expression2/StringTable.hpp>
|
||||
#include <xo/tokenizer2/Token.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/arena/DArena.hpp>
|
||||
|
|
@ -30,9 +31,11 @@ namespace xo {
|
|||
using AAllocator = xo::mm::AAllocator;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using DArena = xo::mm::DArena;
|
||||
using size_type = std::size_t;
|
||||
|
||||
public:
|
||||
ParserStateMachine(const ArenaConfig & config,
|
||||
size_type max_stringtable_capacity,
|
||||
obj<AAllocator> expr_alloc);
|
||||
|
||||
/** @defgroup scm-parserstatemachine-accessors accessor methods **/
|
||||
|
|
@ -129,6 +132,10 @@ namespace xo {
|
|||
|
||||
private:
|
||||
|
||||
/** Table containing interned strings + symbols.
|
||||
**/
|
||||
StringTable stringtable_;
|
||||
|
||||
/** Arena for internal parsing stack.
|
||||
* Must be owned exclusively because destructively
|
||||
* modified as parser completes parsing of each sub-expression
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ namespace xo {
|
|||
* @p debug_flag true to enable debug logging
|
||||
**/
|
||||
SchematikaParser(const ArenaConfig & config,
|
||||
size_t max_stringtable_capacity,
|
||||
obj<AAllocator> expr_alloc,
|
||||
bool debug_flag);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@ namespace xo {
|
|||
|
||||
namespace scm {
|
||||
ParserStateMachine::ParserStateMachine(const ArenaConfig & config,
|
||||
size_type max_stringtable_capacity,
|
||||
obj<AAllocator> expr_alloc)
|
||||
: parser_alloc_{DArena::map(config)},
|
||||
: stringtable_{max_stringtable_capacity},
|
||||
parser_alloc_{DArena::map(config)},
|
||||
expr_alloc_{expr_alloc},
|
||||
debug_flag_{config.debug_flag_}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ namespace xo {
|
|||
// ----- SchematikaParser -----
|
||||
|
||||
SchematikaParser::SchematikaParser(const ArenaConfig & config,
|
||||
size_t max_stringtable_capacity,
|
||||
obj<AAllocator> expr_alloc,
|
||||
bool debug_flag)
|
||||
: psm_{config, expr_alloc},
|
||||
: psm_{config, max_stringtable_capacity, expr_alloc},
|
||||
debug_flag_{debug_flag}
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace xo {
|
|||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, expr_alloc, false /*debug_flag*/);
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
REQUIRE(parser.debug_flag() == false);
|
||||
REQUIRE(parser.is_at_toplevel() == true);
|
||||
|
|
@ -42,7 +42,7 @@ namespace xo {
|
|||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, expr_alloc, false /*debug_flag*/);
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
parser.begin_interactive_session();
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ namespace xo {
|
|||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, expr_alloc, false /*debug_flag*/);
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
parser.begin_batch_session();
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ namespace xo {
|
|||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, expr_alloc, false /*debug_flag*/);
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
parser.begin_batch_session();
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ namespace xo {
|
|||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, expr_alloc, false /*debug_flag*/);
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
parser.begin_interactive_session();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue