Persistent line number
This commit is contained in:
parent
a57b759af9
commit
84e344a970
@ -8,6 +8,6 @@ using namespace std;
|
|||||||
/*
|
/*
|
||||||
Retrieves user input
|
Retrieves user input
|
||||||
*/
|
*/
|
||||||
vector<string> get_input();
|
vector<string> get_input(vector<string> history);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -34,7 +34,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
Parses a string into a vector of tokens
|
Parses a string into a vector of tokens
|
||||||
*/
|
*/
|
||||||
vector<Token> tokenize(vector<string> str);
|
vector<Token> tokenize(vector<string> str, int initial_line=0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Format and print a Token
|
Format and print a Token
|
||||||
|
@ -8,11 +8,10 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> get_input() {
|
vector<string> get_input(vector<string> input) {
|
||||||
string buffer;
|
string buffer;
|
||||||
vector<string> input;
|
|
||||||
|
|
||||||
int line_num = 0;
|
int line_num = input.size();
|
||||||
while (1) {
|
while (1) {
|
||||||
line_num++;
|
line_num++;
|
||||||
printf(BOLD "%4d " RESET , line_num);
|
printf(BOLD "%4d " RESET , line_num);
|
||||||
|
@ -25,8 +25,9 @@ int main(int argc, char* argv[]) {
|
|||||||
vector<Token> tokens;
|
vector<Token> tokens;
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
input = get_input();
|
int initial_line = input.size();
|
||||||
tokens = tokenize(input);
|
input = get_input(input);
|
||||||
|
tokens = tokenize(input, initial_line);
|
||||||
|
|
||||||
Node ast = parse(tokens);
|
Node ast = parse(tokens);
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ void _debug_print_tokens(vector<Token> tokens) {
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Token> tokenize(vector<string> input) {
|
vector<Token> tokenize(vector<string> input, int initial_line) {
|
||||||
vector<Token> tokens;
|
vector<Token> tokens;
|
||||||
|
|
||||||
for (int i = 0; i < int(input.size()); i++) {
|
for (int i = initial_line; i < int(input.size()); i++) {
|
||||||
string line = input[i];
|
string line = input[i];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user