Lexer is not collecting hanging new lines

This commit is contained in:
Krzosa Karol
2022-05-24 22:13:53 +02:00
parent e032fefd07
commit 52910d5606
3 changed files with 19 additions and 14 deletions

View File

@@ -114,6 +114,7 @@ struct Lex_Stream{
String file;
S32 line;
S32 inside_brace_paren;
S32 last_valid_indent;
};
struct Lexer{
@@ -481,7 +482,11 @@ lex__stream(Intern_Table *table, Array<Token> *array, Lex_Stream *s){
if(t.len==0)
lex_set_len(s,&t);
B32 skip = t.kind == TK_NewLine && s->inside_brace_paren > 0;
B32 skip = 0;
if(t.kind == TK_NewLine){
if(s->inside_brace_paren > 0) skip = 1;
if(array->len > 0 && array->last()->kind == TK_NewLine) array->pop();
}
if(!skip){
array->add(t);
}