diff --git a/ccodegen.cpp b/ccodegen.cpp index 93814d6..1f51727 100644 --- a/ccodegen.cpp +++ b/ccodegen.cpp @@ -229,6 +229,11 @@ gen_expr(Ast_Expr *ast){ } } +function void +gen_line(Ast *node){ + genln("#line %d", node->pos->line+1); +} + function void gen_ast(Ast *ast); function void @@ -236,6 +241,7 @@ gen_block(Ast_Block *block){ gen("{"); global_indent++; For(block->stmts) { + gen_line(it); genln(""); gen_ast(it); } @@ -248,7 +254,9 @@ gen_ast(Ast *ast){ switch(ast->kind){ CASE(PACKAGE, Package){ + genln("#line 0 \"%s\"", node->name.str); For(node->ordered) { + gen_line(it); genln(""); gen_ast(it); } diff --git a/main.cpp b/main.cpp index 4bcf491..63e1f16 100644 --- a/main.cpp +++ b/main.cpp @@ -80,6 +80,7 @@ Expr: [ ] - Arrays with size passed [ ] - Switch [ ] - Values inited to 0 by default +[ ] - Emitting #line [ ] - Comma notation when declaring variables thing1, thing2: S32 [ ] - Array of inferred size diff --git a/program.c b/program.c index 22620ab..3c89d2d 100644 --- a/program.c +++ b/program.c @@ -35,7 +35,10 @@ int main(){ entry(); } +#line 0 "program.kl" +#line 1 +#line 3 typedef struct Token{ U8 kind; U8 *str; @@ -44,37 +47,61 @@ typedef struct Token{ Number = 0, };*/ }Token; +#line 12 String kind_name(U8 kind){ + #line 15 if((kind==0)){ + #line 14 return LIT(""); } else{ + #line 16 return LIT(""); } } +#line 18 Bool is_numeric(U8 c){ + #line 19 Bool result = ((c>=48)&&(c<=57)); + #line 20 return result; } +#line 22 void entry(){ + #line 23 String string_to_lex = LIT("Identifier 2425525 Not_Number"); + #line 24 Slice token_array = (Slice){32, (Token [32]){}}; + #line 25 S64 token_count = 0; + #line 27 Token t; + #line 28 for(S64 i = 0;(ilen), tk->str); } } \ No newline at end of file