vickenty / lang-c

Lightweight C parser for Rust
Apache License 2.0
202 stars 30 forks source link

Using the AST #4

Closed fotonick closed 5 years ago

fotonick commented 5 years ago

It's very nice to have a fully compliant C11 parser, but seems like the AST is fairly hard to search or manipulate at present. One possibility would be to match the visit, visit_*_mut, and fold functionality as exposed in the syn crate for manipulating Rust ASTs. Do you have direct plans? Or else a path that you like and would accept if submitted? Or else would you recommend providing such functionality in a separate crate?

vickenty commented 5 years ago

A visitor interface would indeed be nice to have. I wanted to add one, but I don't think I will have time in the coming weeks to do so. The design from syn with a trait and traversal functions looks good, so it might be good idea to to copy it.

L3nn0x commented 5 years ago

Hello, I found your crate and I really like it. I needed to traverse the ast so I went ahead and created a simple read-only visitor pattern. I can make a PR for it if you'd like.

sciencemanx commented 5 years ago

should this be closed?