Major updates
- Improve ruby block detection heuristics - Add block information storage and block aware movements. - Other minor fixes
This commit is contained in:
@@ -79,7 +79,7 @@ struct ParseEvent {
|
||||
uint8_t type; // type.
|
||||
|
||||
ParseEvent(T t) : ev_type(t) {}
|
||||
ParseEvent(std::string_view s, T e_t, uint8_t type) : name(s), ev_type(e_t), type(type) {}
|
||||
ParseEvent(T e_t, std::string_view s, uint8_t type) : name(s), ev_type(e_t), type(type) {}
|
||||
};
|
||||
|
||||
struct Language {
|
||||
@@ -119,12 +119,11 @@ struct ParseStateBranch : ParseState {
|
||||
|
||||
struct ParseStateLeaf : ParseState {
|
||||
void *state;
|
||||
uint64_t n;
|
||||
static constexpr uint32_t IS_OPENING = 1ull << 31;
|
||||
static constexpr uint32_t LINE_MASK = ~IS_OPENING;
|
||||
// followed by n number of relative offsets
|
||||
// stored as uint32_t with 1 bit for if it is start or end
|
||||
// and rest as number.
|
||||
uint32_t n;
|
||||
uint32_t cap;
|
||||
uint32_t *blocks;
|
||||
static constexpr uint32_t IS_CLOSING = 1ull << 31;
|
||||
static constexpr uint32_t LINE_MASK = ~IS_CLOSING;
|
||||
};
|
||||
|
||||
struct TreeCursor {
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#include "pch.h"
|
||||
|
||||
namespace bed::internal::syntax {
|
||||
void dump_events(ParseState *node);
|
||||
|
||||
struct Parser {
|
||||
static constexpr uint64_t MAX_CHUNK = 256;
|
||||
static constexpr uint64_t MAX_CHUNK = 512;
|
||||
|
||||
ParseState *root;
|
||||
Language lang;
|
||||
@@ -21,6 +23,9 @@ struct Parser {
|
||||
void insert(vase::Vase &, uint64_t, uint64_t);
|
||||
void modify(vase::Vase &, uint64_t, uint64_t);
|
||||
|
||||
uint64_t next_closing(uint64_t line);
|
||||
uint64_t prev_opening(uint64_t line);
|
||||
|
||||
std::pair<ParseState *, ParseState *> split_tree(ParseState *node, uint64_t line);
|
||||
ParseState *join_tree(ParseState *a, ParseState *b);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct alignas(2) RubyState {
|
||||
DEF_NAME = 0b10,
|
||||
MODULE_NAME = 0b11
|
||||
};
|
||||
static constexpr uint8_t NEWLINE = 1 << 5;
|
||||
static constexpr uint8_t ALLOW_INTERPOLATION = 1 << 6;
|
||||
static constexpr uint8_t EXPECTING_EXPRESSION = 1 << 7;
|
||||
uint8_t flags = 0;
|
||||
|
||||
@@ -11,6 +11,8 @@ struct RubyParser {
|
||||
uint32_t i = 0;
|
||||
bool heredoc_start_line = false;
|
||||
bool ending = true;
|
||||
bool op_last = false;
|
||||
bool set_op_last = false;
|
||||
|
||||
RubyParser(void **v_state, std::string_view line)
|
||||
: v_state(v_state), state((RubyState *)*v_state), line(line) {}
|
||||
@@ -58,7 +60,7 @@ struct RubyParser {
|
||||
.brace_level = 1,
|
||||
.lit_brace_level = 0,
|
||||
.state = RubyState::RubyInternalState::NONE,
|
||||
.flags = RubyState::RubyInternalState::EXPECTING_EXPRESSION,
|
||||
.flags = RubyState::RubyInternalState::EXPECTING_EXPRESSION | RubyState::RubyInternalState::NEWLINE,
|
||||
.delim_start = '\0',
|
||||
.delim_end = '\0'
|
||||
};
|
||||
|
||||
@@ -189,7 +189,6 @@ const static std::vector<std::string> methods = {
|
||||
"respond_to?",
|
||||
"equal?",
|
||||
"object_id",
|
||||
"class",
|
||||
"singleton_class",
|
||||
"clone",
|
||||
"freeze",
|
||||
|
||||
Reference in New Issue
Block a user