Giter Site home page Giter Site logo

luka's People

Contributors

oransimhony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

luka's Issues

Rewrite if expressions

Add option to use else if like in the following example:

if n <= 0 {
    0 as u64
} else if n == 1 {
    1 as u64
} else {
    fib(n - 1) + fib(n - 2)
}

Add casts

  • Add syntax for manual cast.

  • Try to cast automatically function arguments.

Fix struct values

Struct values should work like array literals, should return a reference to a global variable.

Improve type system

  • Automatically infer types of variables and expressions.
  • Validate types of different sides of expressions.
  • Try to cast expressions if possible and fail if not.

Fix memory leaks

โฏ valgrind  --leak-check=full --show-reachable=yes --error-limit=no --suppressions=minimal.supp ./luka ../examples/struct.luka -O3
==1139112== Memcheck, a memory error detector
==1139112== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1139112== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==1139112== Command: ./luka ../examples/struct.luka -O3
==1139112==
==1139112== Invalid write of size 8
==1139112==    at 0x11C6C9: TYPE_initialize_type (type.c:33)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==    by 0x11C4ED: PARSER_parse_function (parser.c:1287)
==1139112==  Address 0xc1b3718 is 4 bytes after a block of size 4 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid write of size 8
==1139112==    at 0x11C6D5: TYPE_initialize_type (type.c:34)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==    by 0x11C4ED: PARSER_parse_function (parser.c:1287)
==1139112==  Address 0xc1b3720 is 12 bytes after a block of size 4 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid write of size 8
==1139112==    at 0x11A698: parse_ident_expr (parser.c:397)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==    by 0x11C4ED: PARSER_parse_function (parser.c:1287)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid read of size 8
==1139112==    at 0x10FAAF: AST_print_ast (ast.c:979)
==1139112==    by 0x10F260: AST_print_ast (ast.c:861)
==1139112==    by 0x10E1BF: ast_print_statements_block (ast.c:609)
==1139112==    by 0x10ECF1: AST_print_ast (ast.c:779)
==1139112==    by 0x10E278: AST_print_functions (ast.c:619)
==1139112==    by 0x119213: main (main.c:155)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid read of size 8
==1139112==    at 0x10FAFB: AST_print_ast (ast.c:982)
==1139112==    by 0x10F260: AST_print_ast (ast.c:861)
==1139112==    by 0x10E1BF: ast_print_statements_block (ast.c:609)
==1139112==    by 0x10ECF1: AST_print_ast (ast.c:779)
==1139112==    by 0x10E278: AST_print_functions (ast.c:619)
==1139112==    by 0x119213: main (main.c:155)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid read of size 8
==1139112==    at 0x1164D4: gen_codegen_struct_value (gen.c:1263)
==1139112==    by 0x117378: GEN_codegen (gen.c:1373)
==1139112==    by 0x113DFA: gen_codegen_let_stmt (gen.c:943)
==1139112==    by 0x1172D0: GEN_codegen (gen.c:1361)
==1139112==    by 0x1126E4: gen_codegen_stmts (gen.c:636)
==1139112==    by 0x112E5C: gen_codegen_function (gen.c:693)
==1139112==    by 0x117222: GEN_codegen (gen.c:1349)
==1139112==    by 0x1192EE: main (main.c:171)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid free() / delete / delete[] / realloc()
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x10DEF5: AST_free_node (ast.c:538)
==1139112==    by 0x10DC1E: AST_free_node (ast.c:450)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1adb80 is 0 bytes inside a block of size 7 free'd
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x118969: LIB_free_tokens_vector (lib.c:20)
==1139112==    by 0x119793: main (main.c:290)
==1139112==  Block was alloc'd at
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x117DAE: lexer_lex_identifier (lexer.c:87)
==1139112==    by 0x11872F: LEXER_tokenize_source (lexer.c:405)
==1139112==    by 0x119136: main (main.c:129)
==1139112==
==1139112== Invalid read of size 8
==1139112==    at 0x10DF94: AST_free_node (ast.c:555)
==1139112==    by 0x10DC1E: AST_free_node (ast.c:450)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid read of size 8
==1139112==    at 0x10DFA1: AST_free_node (ast.c:557)
==1139112==    by 0x10DC1E: AST_free_node (ast.c:450)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid write of size 8
==1139112==    at 0x10DFB8: AST_free_node (ast.c:558)
==1139112==    by 0x10DC1E: AST_free_node (ast.c:450)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1b3838 is 0 bytes after a block of size 8 alloc'd
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11A5E4: parse_ident_expr (parser.c:385)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== Invalid free() / delete / delete[] / realloc()
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x10E05B: AST_free_node (ast.c:578)
==1139112==    by 0x10DCE5: AST_free_node (ast.c:476)
==1139112==    by 0x10DD74: AST_free_node (ast.c:490)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1ae360 is 0 bytes inside a block of size 4 free'd
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x118969: LIB_free_tokens_vector (lib.c:20)
==1139112==    by 0x119793: main (main.c:290)
==1139112==  Block was alloc'd at
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x117DAE: lexer_lex_identifier (lexer.c:87)
==1139112==    by 0x11872F: LEXER_tokenize_source (lexer.c:405)
==1139112==    by 0x119136: main (main.c:129)
==1139112==
==1139112== Invalid free() / delete / delete[] / realloc()
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x10E084: AST_free_node (ast.c:584)
==1139112==    by 0x10DCE5: AST_free_node (ast.c:476)
==1139112==    by 0x10DD74: AST_free_node (ast.c:490)
==1139112==    by 0x10D81D: AST_free_node (ast.c:354)
==1139112==    by 0x118A59: LIB_free_functions_vector (lib.c:39)
==1139112==    by 0x1197B3: main (main.c:294)
==1139112==  Address 0xc1ae470 is 0 bytes inside a block of size 5 free'd
==1139112==    at 0x483B9AB: free (vg_replace_malloc.c:538)
==1139112==    by 0x118969: LIB_free_tokens_vector (lib.c:20)
==1139112==    by 0x119793: main (main.c:290)
==1139112==  Block was alloc'd at
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x117DAE: lexer_lex_identifier (lexer.c:87)
==1139112==    by 0x11872F: LEXER_tokenize_source (lexer.c:405)
==1139112==    by 0x119136: main (main.c:129)
==1139112==
==1139112==
==1139112== HEAP SUMMARY:
==1139112==     in use at exit: 277 bytes in 19 blocks
==1139112==   total heap usage: 3,584 allocs, 3,570 frees, 1,131,960 bytes allocated
==1139112==
==1139112== 4 bytes in 1 blocks are definitely lost in loss record 1 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B6FC: parse_statement (parser.c:932)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== 4 bytes in 1 blocks are definitely lost in loss record 2 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11B866: parse_statement (parser.c:959)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==
==1139112== 8 bytes in 2 blocks are definitely lost in loss record 3 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11A697: parse_ident_expr (parser.c:397)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==
==1139112== 9 bytes in 2 blocks are definitely lost in loss record 4 of 15
==1139112==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
==1139112==    by 0x9D38B4E: strdup (in /usr/lib/libc-2.32.so)
==1139112==    by 0x115942: gen_codegen_struct_definition (gen.c:1217)
==1139112==    by 0x11735E: GEN_codegen (gen.c:1371)
==1139112==    by 0x1126E4: gen_codegen_stmts (gen.c:636)
==1139112==    by 0x112E5C: gen_codegen_function (gen.c:693)
==1139112==    by 0x117222: GEN_codegen (gen.c:1349)
==1139112==    by 0x1192EE: main (main.c:171)
==1139112==
==1139112== 12 bytes in 3 blocks are definitely lost in loss record 5 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11C6A6: TYPE_initialize_type (type.c:26)
==1139112==    by 0x11B003: parser_parse_primary (parser.c:719)
==1139112==    by 0x11AFBA: parser_parse_unary (parser.c:710)
==1139112==    by 0x11ADEC: parser_parse_factor (parser.c:647)
==1139112==    by 0x11AD34: parser_parse_term (parser.c:615)
==1139112==    by 0x11AC56: parser_parse_comparison (parser.c:574)
==1139112==    by 0x11AB9E: parser_parse_equality (parser.c:543)
==1139112==    by 0x11B4A2: parser_parse_assignment (parser.c:875)
==1139112==    by 0x11B424: parser_parse_expression (parser.c:856)
==1139112==    by 0x11A828: parse_ident_expr (parser.c:436)
==1139112==    by 0x11B04D: parser_parse_primary (parser.c:729)
==1139112==
==1139112== 16 bytes in 1 blocks are indirectly lost in loss record 6 of 15
==1139112==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
==1139112==    by 0x9CA5305: vector_setup (vector.c:37)
==1139112==    by 0x119F80: PARSER_initialize (parser.c:214)
==1139112==    by 0x1191D6: main (main.c:149)
==1139112==
==1139112== 16 bytes in 1 blocks are definitely lost in loss record 7 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x1157D9: gen_codegen_struct_definition (gen.c:1187)
==1139112==    by 0x11735E: GEN_codegen (gen.c:1371)
==1139112==    by 0x1126E4: gen_codegen_stmts (gen.c:636)
==1139112==    by 0x112E5C: gen_codegen_function (gen.c:693)
==1139112==    by 0x117222: GEN_codegen (gen.c:1349)
==1139112==    by 0x1192EE: main (main.c:171)
==1139112==
==1139112== 16 bytes in 1 blocks are definitely lost in loss record 8 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x11649D: gen_codegen_struct_value (gen.c:1255)
==1139112==    by 0x117378: GEN_codegen (gen.c:1373)
==1139112==    by 0x113DFA: gen_codegen_let_stmt (gen.c:943)
==1139112==    by 0x1172D0: GEN_codegen (gen.c:1361)
==1139112==    by 0x1126E4: gen_codegen_stmts (gen.c:636)
==1139112==    by 0x112E5C: gen_codegen_function (gen.c:693)
==1139112==    by 0x117222: GEN_codegen (gen.c:1349)
==1139112==    by 0x1192EE: main (main.c:171)
==1139112==
==1139112== 24 bytes in 1 blocks are definitely lost in loss record 9 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119BA8: parse_type (parser.c:93)
==1139112==    by 0x11BCFF: parse_prototype (parser.c:1075)
==1139112==    by 0x11A084: PARSER_parse_top_level (parser.c:246)
==1139112==    by 0x1191F4: main (main.c:153)
==1139112==
==1139112== 24 bytes in 1 blocks are definitely lost in loss record 10 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119BA8: parse_type (parser.c:93)
==1139112==    by 0x11BEB5: parse_prototype (parser.c:1115)
==1139112==    by 0x11A084: PARSER_parse_top_level (parser.c:246)
==1139112==    by 0x1191F4: main (main.c:153)
==1139112==
==1139112== 24 bytes in 1 blocks are definitely lost in loss record 11 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119BA8: parse_type (parser.c:93)
==1139112==    by 0x11BFE9: parse_prototype (parser.c:1133)
==1139112==    by 0x11A084: PARSER_parse_top_level (parser.c:246)
==1139112==    by 0x1191F4: main (main.c:153)
==1139112==
==1139112== 24 bytes in 1 blocks are definitely lost in loss record 12 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119BA8: parse_type (parser.c:93)
==1139112==    by 0x11BBA6: parse_prototype (parser.c:1042)
==1139112==    by 0x11C4DD: PARSER_parse_function (parser.c:1286)
==1139112==    by 0x11A05C: PARSER_parse_top_level (parser.c:240)
==1139112==    by 0x1191F4: main (main.c:153)
==1139112==
==1139112== 24 bytes in 1 blocks are definitely lost in loss record 13 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119BA8: parse_type (parser.c:93)
==1139112==    by 0x11B6C8: parse_statement (parser.c:927)
==1139112==    by 0x11BA24: parse_statements (parser.c:1008)
==1139112==    by 0x11C4ED: PARSER_parse_function (parser.c:1287)
==1139112==    by 0x11A05C: PARSER_parse_top_level (parser.c:240)
==1139112==    by 0x1191F4: main (main.c:153)
==1139112==
==1139112== 40 bytes in 1 blocks are still reachable in loss record 14 of 15
==1139112==    at 0x483ADEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==1139112==    by 0x51E9FFE: ??? (in /usr/lib/libLLVM-10.so)
==1139112==    by 0x9F5D18E: __pthread_once_slow (in /usr/lib/libpthread-2.32.so)
==1139112==    by 0x51EA0F8: llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const (in /usr/lib/libLLVM-10.so)
==1139112==    by 0x518078A: llvm::cl::OptionCategory::registerCategory() (in /usr/lib/libLLVM-10.so)
==1139112==    by 0x5096006: ??? (in /usr/lib/libLLVM-10.so)
==1139112==    by 0x40112DD: call_init.part.0 (in /usr/lib/ld-2.32.so)
==1139112==    by 0x40113C7: _dl_init (in /usr/lib/ld-2.32.so)
==1139112==    by 0x40020C9: ??? (in /usr/lib/ld-2.32.so)
==1139112==    by 0x2: ???
==1139112==    by 0x1FFF000612: ???
==1139112==    by 0x1FFF000619: ???
==1139112==
==1139112== 48 (32 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 15 of 15
==1139112==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==1139112==    by 0x119F21: PARSER_initialize (parser.c:207)
==1139112==    by 0x1191D6: main (main.c:149)
==1139112==
==1139112== LEAK SUMMARY:
==1139112==    definitely lost: 221 bytes in 17 blocks
==1139112==    indirectly lost: 16 bytes in 1 blocks
==1139112==      possibly lost: 0 bytes in 0 blocks
==1139112==    still reachable: 40 bytes in 1 blocks
==1139112==         suppressed: 0 bytes in 0 blocks
==1139112==
==1139112== For lists of detected and suppressed errors, rerun with: -s
==1139112== ERROR SUMMARY: 46 errors from 25 contexts (suppressed: 0 from 0)

Add import guards

When importing an already imported module, pass the already created imported module struct instead of re-importing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.