Lambdas, statements, typechecking lambdas
This commit is contained in:
24
new_lex.cpp
24
new_lex.cpp
@@ -47,8 +47,6 @@ enum Token_Kind{
|
||||
TK_Dot,
|
||||
|
||||
TK_NewLine,
|
||||
TK_NewUpScope,
|
||||
TK_NewDownScope,
|
||||
TK_Colon,
|
||||
|
||||
TK_Assign,
|
||||
@@ -86,6 +84,12 @@ enum Token_Kind{
|
||||
|
||||
TK_Pointer,
|
||||
TK_Dereference,
|
||||
|
||||
// These are not produced by lexer
|
||||
// but identified by parser
|
||||
OPEN_SCOPE,
|
||||
CLOSE_SCOPE,
|
||||
SAME_SCOPE,
|
||||
};
|
||||
|
||||
struct Token{
|
||||
@@ -525,17 +529,6 @@ lex_restream(Lexer *lexer, String istream, String file){
|
||||
lexer->tokens.clear();
|
||||
lexer->token_iter = 0;
|
||||
lex__stream(&lexer->interns, &lexer->tokens, &lexer->stream);
|
||||
|
||||
S32 indent = 0;
|
||||
For(lexer->tokens){
|
||||
if(it->kind == TK_NewLine){
|
||||
if(it->indent > indent)
|
||||
it->kind = TK_NewUpScope;
|
||||
if(it->indent < indent)
|
||||
it->kind = TK_NewDownScope;
|
||||
indent = it->indent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Lexer
|
||||
@@ -664,8 +657,9 @@ token_kind_string(Token_Kind kind){
|
||||
case TK_Float: return "Float"_s;
|
||||
case TK_Integer: return "Int"_s;
|
||||
case TK_Keyword: return "Keyword"_s;
|
||||
case TK_NewUpScope: return "New_Up_Scope"_s;
|
||||
case TK_NewDownScope: return "New_Down_Scope"_s;
|
||||
case CLOSE_SCOPE: return "Close_Scope"_s;
|
||||
case OPEN_SCOPE: return "Open_Scope"_s;
|
||||
case SAME_SCOPE: return "Same_Scope"_s;
|
||||
default: invalid_codepath; return "<Undefined>"_s;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user