Successful compile with new parser!
This commit is contained in:
66
new_lex.cpp
66
new_lex.cpp
@@ -326,6 +326,31 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
|
||||
switch(lexc(s)){
|
||||
case '\t': case ' ': lex_advance(s); t.indent++; break;
|
||||
case '\r': lex_advance(s); break;
|
||||
case '/': {
|
||||
if(lexci(s,1) == '/'){
|
||||
lex_advance(s); lex_advance(s);
|
||||
t.kind = TK_Comment;
|
||||
for(;;){
|
||||
if(lexc(s) == '\n' || lexc(s) == 0) break;
|
||||
lex_advance(s);
|
||||
}
|
||||
}
|
||||
else if(lexci(s,1) == '*'){
|
||||
lex_advance(s); lex_advance(s);
|
||||
t.kind = TK_Comment;
|
||||
for(;;){
|
||||
if(lexc(s) == '*' && lexci(s,1) == '/'){
|
||||
lex_advance(s); lex_advance(s);
|
||||
break;
|
||||
}
|
||||
else if(lexc(s) == 0){
|
||||
token_error(&t, "Unterminated block comment"_s);
|
||||
break;
|
||||
}
|
||||
lex_advance(s);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case '\n':{
|
||||
lex_advance(s);
|
||||
should_emit = true;
|
||||
@@ -341,14 +366,15 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
|
||||
s->indent_stack.add(array->last());
|
||||
}
|
||||
else if(t.indent < last->indent){
|
||||
For_Reverse(s->indent_stack){
|
||||
assert(token_is_scope(*it));
|
||||
if(it[0]->indent == t.indent){
|
||||
for(S64 i = s->indent_stack.len-1; i >= 0; i-=1){
|
||||
auto it = s->indent_stack.data[i];
|
||||
assert(token_is_scope(it));
|
||||
if(it->indent == t.indent){
|
||||
t.kind = SAME_SCOPE;
|
||||
array->add(t);
|
||||
break;
|
||||
}
|
||||
else if(it[0]->indent < t.indent){
|
||||
else if(it->indent < t.indent){
|
||||
token_error(&t, "Bad indentation"_s);
|
||||
array->add(t);
|
||||
break;
|
||||
@@ -362,7 +388,7 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
|
||||
}
|
||||
else {
|
||||
t.kind = SAME_SCOPE;
|
||||
array->add(t); // else SAME_SCOPE
|
||||
array->add(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,10 +398,9 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
|
||||
} indent_loop_break:
|
||||
beginning = false;
|
||||
|
||||
// @note: handle the indented token
|
||||
t = token_make(lexcp(s), s->file, s->line, s->line_begin);
|
||||
lex_advance(s);
|
||||
|
||||
// @note: handle the indented token
|
||||
switch(*t.str){
|
||||
case 0 : break;
|
||||
case '@': t.kind = TK_At; break;
|
||||
@@ -497,33 +522,6 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
|
||||
t.kind = TK_DivAssign;
|
||||
lex_advance(s);
|
||||
}
|
||||
else if(lexc(s) == '/'){
|
||||
lex_advance(s);
|
||||
t.kind = TK_Comment;
|
||||
for(;;){
|
||||
if(lexc(s) == '\n' || lexc(s) == 0) break;
|
||||
lex_advance(s);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if(lexc(s) == '*'){
|
||||
lex_advance(s);
|
||||
t.kind = TK_Comment;
|
||||
for(;;){
|
||||
if(lexc(s) == '*' && lexci(s,1) == '/'){
|
||||
lex_advance(s);
|
||||
lex_advance(s);
|
||||
break;
|
||||
}
|
||||
else if(lexc(s) == 0){
|
||||
token_error(&t, "Unterminated block comment"_s);
|
||||
goto skip_continue;
|
||||
}
|
||||
lex_advance(s);
|
||||
}
|
||||
continue;
|
||||
skip_continue:;
|
||||
}
|
||||
else {
|
||||
t.kind = TK_Div;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user