mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-24 05:20:17 +00:00
up
This commit is contained in:
parent
e69b66f0b7
commit
352688e9ae
@ -75,9 +75,10 @@ struct SourceData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Exception {
|
class Exception {
|
||||||
|
using StackTrace = stack<Str>;
|
||||||
StrName type;
|
StrName type;
|
||||||
Str msg;
|
Str msg;
|
||||||
stack<Str> stacktrace;
|
StackTrace stacktrace;
|
||||||
public:
|
public:
|
||||||
Exception(StrName type, Str msg): type(type), msg(msg) {}
|
Exception(StrName type, Str msg): type(type), msg(msg) {}
|
||||||
bool match_type(StrName type) const { return this->type == type;}
|
bool match_type(StrName type) const { return this->type == type;}
|
||||||
@ -89,7 +90,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Str summary() const {
|
Str summary() const {
|
||||||
stack<Str> st(stacktrace);
|
StackTrace st(stacktrace);
|
||||||
StrStream ss;
|
StrStream ss;
|
||||||
if(is_re) ss << "Traceback (most recent call last):\n";
|
if(is_re) ss << "Traceback (most recent call last):\n";
|
||||||
while(!st.empty()) { ss << st.top() << '\n'; st.pop(); }
|
while(!st.empty()) { ss << st.top() << '\n'; st.pop(); }
|
||||||
|
|||||||
@ -100,7 +100,7 @@ struct Lexer {
|
|||||||
const char* curr_char;
|
const char* curr_char;
|
||||||
int current_line = 1;
|
int current_line = 1;
|
||||||
std::vector<Token> nexts;
|
std::vector<Token> nexts;
|
||||||
stack<int> indents;
|
small_stack<int, 4> indents;
|
||||||
int brackets_level = 0;
|
int brackets_level = 0;
|
||||||
bool used = false;
|
bool used = false;
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,9 @@ struct small_vector{
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove copy assignment
|
||||||
|
small_vector& operator=(const small_vector& other) = delete;
|
||||||
|
|
||||||
template<typename __ValueT>
|
template<typename __ValueT>
|
||||||
void push_back(__ValueT&& t) {
|
void push_back(__ValueT&& t) {
|
||||||
if (_size == _capacity) {
|
if (_size == _capacity) {
|
||||||
@ -107,6 +110,6 @@ public:
|
|||||||
const Container& data() const { return vec; }
|
const Container& data() const { return vec; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, int N=8>
|
template <typename T, int N>
|
||||||
using small_stack = stack<T, small_vector<T, N>>;
|
using small_stack = stack<T, small_vector<T, N>>;
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
||||||
Loading…
x
Reference in New Issue
Block a user