this is more like the book
This commit is contained in:
parent
912064cb22
commit
7f670a5301
1 changed files with 4 additions and 4 deletions
|
|
@ -113,14 +113,14 @@ void add_token(char* source, int line, TokenList* token_list, enum TokenType typ
|
||||||
tokenlist_add(token_list, token);
|
tokenlist_add(token_list, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
void advance(int* pos){
|
char advance(char * source, int* pos){
|
||||||
|
char c = source[*pos];
|
||||||
(*pos) +=1;
|
(*pos) +=1;
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scan_token(char* source, int line, int start, int* current_pos, TokenList* token_list){
|
void scan_token(char* source, int line, int start, int* current_pos, TokenList* token_list){
|
||||||
char c = source[*current_pos];
|
char c = advance(source, current_pos);
|
||||||
|
|
||||||
advance(current_pos);
|
|
||||||
|
|
||||||
switch (c){
|
switch (c){
|
||||||
case '(': add_token(source, line, token_list, LEFT_PAREN, start, *current_pos); break;
|
case '(': add_token(source, line, token_list, LEFT_PAREN, start, *current_pos); break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue