From 9487dd9aca96274e86bed04d55d55bb1acecd8f2 Mon Sep 17 00:00:00 2001 From: Takanori Ishikawa Date: Sat, 27 Jul 2024 11:53:26 +0900 Subject: [PATCH 1/2] Add support for `while` loops in the compiler --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index b4d6fab..cb09a0c 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,57 @@ In this project, we provide a simple command called `sum-diff`. This command aut ## Install +Using `pipx`. + ```bash +# download zip $ unzip sum-diff.zip $ pipx ./sum-diff + +# nightly from GitHub +pipx install git+https://github.com/ishikawa/sum-diff +``` + +## API key + +`sum-diff` uses Anthropic's Claude 3.5 Sonnet to generate output. You need to get API key from [their console](https://console.anthropic.com/) and exporting it via `ANTHROPIC_API_KEY` environment variable. + +```bash +$ export ANTHROPIC_API_KEY=sk-ant-... ``` ## How to use +After you made some changes in your project and before you're going to create a PR for these changes, run `sum-diff` command to let AI to write title and description of the PR. + ```bash $ sum-diff ``` + +It takes some seconds, then, prints title and description in standard output. For example: + +```` +Add `while` statement support to compiler + +This PR introduces support for `while` loops in the compiler, enhancing the language's control flow capabilities. + +Key changes: +- Add `While` token and parsing logic in `tokenizer.rs` +- Implement `WhileStmt` struct and parsing in `parser.rs` +- Add code generation for `while` loops in `asm.rs` +- Update `LocalVarAllocator` to handle `while` statements in `allocator.rs` +- Add test cases for `while` loops in `test.sh` + +The implementation follows the existing pattern for control flow statements, such as `if` statements. The `while` loop consists of a condition and a body, which are evaluated and executed accordingly. + +Example of the new `while` loop syntax: + +```rust +i = 0; +while (i < 20) + i = i + 1; +return i; +``` + +This PR completes the basic control flow structures for the compiler, allowing for more complex program logic to be expressed in the language. +```` From a3008d4d38d38a61e21a42aaa9e5b42ecf560cc6 Mon Sep 17 00:00:00 2001 From: Takanori Ishikawa Date: Sat, 27 Jul 2024 11:57:12 +0900 Subject: [PATCH 2/2] feat: Add support for `while` loops in the compiler --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cb09a0c..e790573 100644 --- a/README.md +++ b/README.md @@ -2,38 +2,41 @@ > Summarize your changes into a concise title and a detailed description. -In this project, we provide a simple command called `sum-diff`. This command automatically generates a concise and clear title and a detailed description from the current branch's differences in a git repository. +`sum-diff` is a simple command-line tool that automatically generates a concise title and a detailed description by analyzing the current git branch, including: -## Install +- Branch name +- Code changes (`git diff`) -Using `pipx`. +## Installation + +Install using `pipx`: ```bash -# download zip +# Download and unzip $ unzip sum-diff.zip -$ pipx ./sum-diff +$ pipx install ./sum-diff -# nightly from GitHub -pipx install git+https://github.com/ishikawa/sum-diff +# Install nightly from GitHub +$ pipx install git+https://github.com/ishikawa/sum-diff ``` -## API key +## API Key -`sum-diff` uses Anthropic's Claude 3.5 Sonnet to generate output. You need to get API key from [their console](https://console.anthropic.com/) and exporting it via `ANTHROPIC_API_KEY` environment variable. +`sum-diff` uses Anthropic's Claude 3.5 Sonnet to generate the output. Obtain an API key from [Anthropic's console](https://console.anthropic.com/) and set it as an environment variable: ```bash $ export ANTHROPIC_API_KEY=sk-ant-... ``` -## How to use +## Usage -After you made some changes in your project and before you're going to create a PR for these changes, run `sum-diff` command to let AI to write title and description of the PR. +After making changes to your project and before creating a PR, run the `sum-diff` command to have the AI generate a title and description for your PR. ```bash $ sum-diff ``` -It takes some seconds, then, prints title and description in standard output. For example: +The command will take a few seconds to process and then output the title and description. For example: ```` Add `while` statement support to compiler