xo-reader2 stack: streamline + mem sizing + bugfixes
This commit is contained in:
parent
c0e61744bb
commit
9ce05973f4
8 changed files with 210 additions and 136 deletions
49
include/xo/reader2/ParserConfig.hpp
Normal file
49
include/xo/reader2/ParserConfig.hpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/** @file SchematikaParserConfig.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/arena/ArenaHashMapConfig.hpp>
|
||||
#include <xo/arena/ArenaConfig.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** @brief Configuration for SchematikaParser **/
|
||||
struct ParserConfig {
|
||||
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
|
||||
/** arena configuration for parser stack **/
|
||||
ArenaConfig parser_arena_config_ { .name_ = "parser-arena",
|
||||
.size_ = 2*1024*1024,
|
||||
.hugepage_z_ = 2*1024*1024,
|
||||
.store_header_flag_ = false,
|
||||
.header_{},
|
||||
.debug_flag_ = false };
|
||||
|
||||
/** configuration for hash map for global symbol table
|
||||
*
|
||||
* reminder: ownership chain
|
||||
* SchematikaReader
|
||||
* ->SchematikaParser
|
||||
* ->ParserStateMachine
|
||||
* ->DGlobalSymtab
|
||||
**/
|
||||
ArenaHashMapConfig symtab_config_ { .name_ = "global-symtab",
|
||||
.hint_max_capacity_ = 64*1024,
|
||||
.debug_flag_ = false };
|
||||
|
||||
/** max capacity for unique string table **/
|
||||
size_t max_stringtable_capacity_ = 4096;
|
||||
|
||||
/** control SchematikaParser debug logging **/
|
||||
bool debug_flag_ = false;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* end SchematikaParserConfig.hpp */
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include <xo/tokenizer2/Token.hpp>
|
||||
#include <xo/object2/DArray.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/arena/ArenaHashMapConfig.hpp>
|
||||
#include <xo/arena/DArena.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -38,11 +39,14 @@ namespace xo {
|
|||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using DArena = xo::mm::DArena;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
|
||||
using size_type = std::size_t;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @p config arena configuration for parser state
|
||||
* @p symtab_config configuration for global symtab
|
||||
* (maps separate dedicated memory)
|
||||
* @p max_stringtable_capacity
|
||||
* hard max size for unique stringtable
|
||||
* @p expr_alloc allocator for schematika expressions.
|
||||
|
|
@ -53,6 +57,7 @@ namespace xo {
|
|||
* same as @p expr_alloc.
|
||||
**/
|
||||
ParserStateMachine(const ArenaConfig & config,
|
||||
const ArenaHashMapConfig & symtab_config,
|
||||
size_type max_stringtable_capacity,
|
||||
obj<AAllocator> expr_alloc,
|
||||
obj<AAllocator> aux_alloc);
|
||||
|
|
@ -320,6 +325,8 @@ namespace xo {
|
|||
* Toplevel definitions go here.
|
||||
*
|
||||
* Uses mmap -> non-trivial destructor.
|
||||
*
|
||||
* TODO: may want to move ownership upstairs
|
||||
**/
|
||||
dp<DGlobalSymtab> global_symtab_;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <xo/arena/CircularBufferConfig.hpp>
|
||||
#include <xo/arena/ArenaHashMapConfig.hpp>
|
||||
#include <xo/arena/ArenaConfig.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -14,6 +15,7 @@ namespace xo {
|
|||
/** @brief Configuration for SchematikaReader
|
||||
**/
|
||||
struct ReaderConfig {
|
||||
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
|
||||
using CircularBufferConfig = xo::mm::CircularBufferConfig;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using size_t = std::size_t;
|
||||
|
|
@ -34,6 +36,19 @@ namespace xo {
|
|||
.store_header_flag_ = false,
|
||||
.header_{},
|
||||
.debug_flag_ = false };
|
||||
|
||||
/** configuration for hash map for global symbol table
|
||||
*
|
||||
* reminder: ownership chain
|
||||
* SchematikaReader
|
||||
* ->SchematikaParser
|
||||
* ->ParserStateMachine
|
||||
* ->DGlobalSymtab
|
||||
**/
|
||||
ArenaHashMapConfig symtab_config_ { .name_ = "global-symtab",
|
||||
.hint_max_capacity_ = 64*1024,
|
||||
.debug_flag_ = false };
|
||||
|
||||
/** debug flag for schematika parser **/
|
||||
bool parser_debug_flag_ = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ParserConfig.hpp"
|
||||
#include "ParserStateMachine.hpp"
|
||||
#include "ParserResult.hpp"
|
||||
#include <xo/tokenizer2/Token.hpp>
|
||||
|
|
@ -154,6 +155,7 @@ namespace xo {
|
|||
class SchematikaParser {
|
||||
public:
|
||||
using token_type = Token;
|
||||
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
|
|
@ -164,19 +166,16 @@ namespace xo {
|
|||
/** create parser in initial state;
|
||||
* parser is ready to receive tokens via @ref include_token
|
||||
*
|
||||
* @p config arena configuration for parser stack
|
||||
* @p config parser configuration
|
||||
* @p expr_alloc allocator for schematika expressions.
|
||||
* Probably shared with execution.
|
||||
* @p aux_alloc aux allocator for non-copyable memory
|
||||
* with lifetime bounded by this
|
||||
* SchematikeParser itself
|
||||
* @p debug_flag true to enable debug logging
|
||||
**/
|
||||
SchematikaParser(const ArenaConfig & config,
|
||||
size_t max_stringtable_capacity,
|
||||
SchematikaParser(const ParserConfig & config,
|
||||
obj<AAllocator> expr_alloc,
|
||||
obj<AAllocator> aux_alloc,
|
||||
bool debug_flag);
|
||||
obj<AAllocator> aux_alloc);
|
||||
|
||||
/** non-trivial dtor because of @ref psm_ **/
|
||||
~SchematikaParser() = default;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue