potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
599 stars 79 forks source link

(Optionally) provide comments as AST nodes. #416

Closed rkaminsk closed 1 year ago

rkaminsk commented 1 year ago

There are applications where auxiliary information is extracted from comments. For example, to annotate rules. For such applications, it would be nice if the AST would also capture comments. In principle, this should be a straightforward extension to the parser.

The enums in the C-API have to be extended to account for comments. Then, I see two options: always yield nodes for comments or only if requested. In the latter case, the clingo_ast_parse_string and clingo_ast_parse_files functions could receive an additional Boolean argument. The C++ and Python APIs can be extended with overloads/arguments having default values.