Skip to content
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

Renamed cli.h into cli.hpp, used structured bindings, made cli and compiler more consistent #24

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Fiwo735
Copy link
Collaborator

@Fiwo735 Fiwo735 commented Mar 16, 2024

Just a small PR to clear some inconsistencies:

  • cli.h remaned to cli.hpp to match other header files.
  • Used structured binding to unpack command_line_arguments, leading to clearer intent and removed the need to pass the whole struct into functions.
  • Some more comment documentation and tidying up in compiler.cpp, as that's where most students would look first.

Note the branch name changes, so that we now have:

  • main
  • dev: all ongoing development, especially useful when the coursework is in progress
  • <feature>: fresh branch created off dev branch each time, leading to a new PR

Copy link
Collaborator

@Jpnock Jpnock left a comment

Choose a reason for hiding this comment

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

LGTM. I've approved but left some comments about structured binding being used in this case.

Originally my reasoning for passing the struct around was so it was obvious where these values were coming from. That being said, this file is small enough to skim through in a few seconds so I agree with the changes here.

src/compiler.cpp Outdated Show resolved Hide resolved
src/compiler.cpp Show resolved Hide resolved
@Jpnock
Copy link
Collaborator

Jpnock commented Mar 18, 2024

Also I like the main / dev / <other> branch naming idea; it works well for this repo I think.

#include "ast.hpp"

using ast::NodePtr;

NodePtr Parse(const CommandLineArguments& args);
// Wrapper for ParseAST defined in YACC
NodePtr Parse(const std::string& compile_source_path);
Copy link
Collaborator

@simon-staal simon-staal Mar 22, 2024

Choose a reason for hiding this comment

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

This might be a bit too extra, but it might be worth considering using std::filesystem::path rather than strings? This has the benefit of making it clear that this variable represents a file path from its type rather than its name, which is usually an improvement imo - but if you think it's not worth the complexity / overhead for students happy for you to keep it as is. I think that this coursework is a good opportunity for us to teach students about the features of modern C++, but defs think we need to pick our battles with what we want to include (and smart pointers might be enough of a step for them 😅)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another interesting choice between teaching modern C++ vs not scaring students too much. I can see both points being made here and I'm slightly in favor of including this change as it doesn't look too complex and should be understandable from the type name itself. Any strong opinions @Jpnock?

Copy link
Collaborator

@Jpnock Jpnock Mar 25, 2024

Choose a reason for hiding this comment

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

but it might be worth considering using std::filesystem::path

Sounds good to me

src/compiler.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@simon-staal simon-staal left a comment

Choose a reason for hiding this comment

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

Changes themselves are fine, although left a couple comments for some more potential improvements to be bundled in with the change.

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