Skip to content

Add an example usecase of the parser. #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2019
Merged

Add an example usecase of the parser. #1177

merged 2 commits into from
Jul 26, 2019

Conversation

windelbouwman
Copy link
Contributor

No description provided.


fn main() {
env_logger::init();
let app = App::new("RustPython")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since RustPython is the name of the whole project and, presumably, its interpreter as a stand-alone application – shouldn’t this be called something else (or at least – more specific)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, copy paste error, thanks!

res.extend(x);
}

if metadata.is_file() && path.extension().map(|s| s.to_str().unwrap()) == Some("py") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if metadata.is_file() && path.extension().map(|s| s.to_str().unwrap()) == Some("py") {
if metadata.is_file() && path.extension().and_then(|s| s.to_str()) == Some("py") {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

if folder.exists() && folder.is_dir() {
println!("Parsing folder of python code: {:?}", folder);
let res = parse_folder(&folder).unwrap();
println!("Processed {:?} files", res.len());
Copy link
Member

@coolreader18 coolreader18 Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it print the parsed files or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some ideas for metrics:

  • parsed lines per second
  • print the amount of functions / classes

For now, I just use it to try and scan my cpython lib folder

@windelbouwman windelbouwman merged commit a02e131 into master Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants