Open skarl-api opened 1 year ago
@torfinnberset @storypku @sighingnow @nabhoneel
Which version are you working with? If you install the clang bindings using pip3 install libclang
(note that the package name is libclang
) you don't need the Config.set_library_file
anymore.
Which version are you working with? If you install the clang bindings using
pip3 install libclang
(note that the package name islibclang
) you don't need theConfig.set_library_file
anymore.
system:mac pythonversion 3.9.9 libclang version 14.0
Even if set is not set library File is not allowed either
Is there any code that I can refer to for the above example?
I cannot see which was going wrong as I cannot know how your dump_ast
are implemented. But I can provides you a reference implementation in another project:
https://github.com/v6d-io/v6d/blob/main/python/vineyard/core/codegen/parsing.py#L302
As well as the settings the parse the file:
https://github.com/v6d-io/v6d/blob/main/python/vineyard/core/codegen/parsing.py#L613
Hope that could be helpful.
I cannot see which was going wrong as I cannot know how your
dump_ast
are implemented. But I can provides you a reference implementation in another project:https://github.com/v6d-io/v6d/blob/main/python/vineyard/core/codegen/parsing.py#L302
As well as the settings the parse the file:
https://github.com/v6d-io/v6d/blob/main/python/vineyard/core/codegen/parsing.py#L613
Hope that could be helpful.
Following your prompts, I'll try it
https://github.com/v6d-io/v6d/blob/main/python/vineyard/core/codegen/parsing.py#L613
CALL_EXPR, t:
@sighingnow
CALL_EXPR, t: How do I continue parsing?
Could you please describe your problem in a more detail? e.g., Parsing which file, and encounter which unexpected behaviour? as well as the behavior/output that you desired?
give an example
bool file_exists(const std::string &file) { std::ifstream infile(file); if (!infile.is_open()) { return false; } infile.close(); return true; }
bool read_file_to_string(const std::string file_path, std::string &str) { if (!file_exists(file_path)) { return false; } std::ifstream file{file_path}; str = std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()}; file.close(); return true; }
config
Config.set_library_file('/usr/local/Cellar/llvm@14/14.0.6/lib/libclang.dylib')
use code
print(f"{' ' * level} {str(node.kind)}: {node.spelling}") for child in node.get_children(): self.print_ast(child, code_source, file_path, level + 1)
Unable to output read file to String called file exists
@sighingnow
Using dump Ast parsing, when parsing to CursorKind. CAL During EXPR, the output value of t is
@torfinnberset @storypku @nabhoneel
give an example
config
Config.set_library_file('/usr/local/Cellar/llvm@14/14.0.6/lib/libclang.dylib')
use code
Unable to output read file to String called file exists