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