1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| sekka•tree-sitter/tree-sitter-hello/tree-sitter-c(master⚡)» python3 hello.py [16:30:00] Parsed AST: (translation_unit [0, 0] - [6, 0] (preproc_include [0, 0] - [1, 0] path: (system_lib_string [0, 9] - [0, 18])) (function_definition [2, 0] - [5, 1] type: (primitive_type [2, 0] - [2, 3]) declarator: (function_declarator [2, 4] - [2, 10] declarator: (identifier [2, 4] - [2, 8]) parameters: (parameter_list [2, 8] - [2, 10])) body: (compound_statement [2, 11] - [5, 1] (expression_statement [3, 2] - [3, 27] (call_expression [3, 2] - [3, 26] function: (identifier [3, 2] - [3, 8]) arguments: (argument_list [3, 8] - [3, 26] (string_literal [3, 9] - [3, 25] (string_content [3, 10] - [3, 22]) (escape_sequence [3, 22] - [3, 24]))))) (return_statement [4, 2] - [4, 11] (number_literal [4, 9] - [4, 10])))))
Generated LLVM IR: ; ModuleID = "hello_module" target triple = "unknown-unknown-unknown" target datalayout = ""
define i32 @"main"() { entry: %".2" = getelementptr inbounds [15 x i8], [15 x i8]* @"hello_str", i32 0, i32 0 %".3" = call i32 (i8*, ...) @"printf"(i8* %".2") ret i32 0 }
@"hello_str" = internal constant [15 x i8] c"Hello, World!\0a\00" declare i32 @"printf"(i8* %".1", ...)
|