Skip to content

Commit

Permalink
Added README file
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Nov 7, 2023
1 parent fd49405 commit 4722b54
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 22 deletions.
48 changes: 31 additions & 17 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cpast"
version = "0.2.0"
edition = "2021"
license = "GPL-3"
license = " GPL-3.0-or-later"
repository = "https://github.com/rootCircle/code_companion"
description = "Run custom testcase with powerful clex lang powered generated tool. Ideal for competitive coders. Can test two file and pass & match randomly generated outputs"
license-file = "LICENSE"
Expand Down
132 changes: 130 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,130 @@
# code_companion
Find edge cases when solving C.P. problems easily!
# cpast - Code Testing and Analysis Tool

`cpast` is a versatile code testing and analysis tool that allows you to test correct and incorrect code files against a custom language generator called `clex`. It supports a variety of programming languages, including Python, C++, C, Rust, Ruby, JavaScript, and Java. You can specify the number of iterations and test your code against random input values, comparing the output against expected results.

## Introduction

`cpast` - Code Testing and Analysis Tool is your solution to a crucial problem faced by competitive programmers (CP) and coding enthusiasts. It empowers you to streamline your coding journey and overcome common challenges in competitive programming and coding practice.

## Addressing a Crucial Problem in Competitive Programming (C.P.)

Competitive programming, often referred to as C.P., involves solving algorithmic and coding challenges within strict time limits. Participants in coding contests, such as ACM ICPC, Codeforces, and LeetCode, often face challenges like:

- Verifying code correctness against various test cases.
- Efficiently testing code under time constraints.
- Debugging errors quickly to improve code performance.

`cpast` has been designed to tackle these challenges head-on and make the competitive programming experience more efficient and enjoyable.

## How `cpast` Solves the Problem

### 1. Testing Correctness

`cpast` enables you to test your code with both correct and incorrect code files, ensuring that your solutions work as expected while also helping you identify and fix issues in your code.

### 2. Rapid Testing

In competitive programming, time is of the essence. `cpast` allows you to define custom test cases and automate testing, saving valuable time that would otherwise be spent manually verifying code correctness.

### 3. Debugging Support

With `cpast`, you can quickly identify and debug issues in your code by comparing actual output with expected results. This helps you fine-tune your code for optimal performance.

By addressing these crucial problems, `cpast` enhances your competitive programming experience, making it more efficient and effective, ultimately improving your coding skills and competition performance. Say goodbye to manual testing and debugging, and let `cpast` handle the heavy lifting for you.

## Table of Contents

- [Features](#features)
- [Getting Started](#getting-started)
- [Language Specification](#language-specification)
- [Example Usage](#example-usage)
- [References](#references)

## Features

- Test correct and incorrect code files.
- Utilize the custom `clex` language generator to define input patterns.
- Set the number of iterations to run your tests.
- Support for multiple programming languages.

## Getting Started

### Installation

To get started with `cpast`, you need to install it. You can do this by running the following command:

```bash
cargo install cpast
```

### Usage

Here's a simple example of how to use `cpast`:

```bash
cpast -s correct.cpp -t incorrect.cpp -g "(N) (?:N){\1}" --iterations 100
```

- `correct.cpp` should contain the correct code.
- `incorrect.cpp` should contain the incorrect code.
- `(N) (?:N){\1}` is the language generator.
- `100` is the number of test iterations.

## Language Specification

The `clex` language generator is based on a custom grammar specification. It allows you to define input patterns for testing. Here are some of the key elements of the `clex` language:

### Meta-characters

- `()?:\{}[],`

### Character Sets

- `SPACE = WHITESPACE | e`
- `N = Integer (-infinity to infinity)`
- `F = Float (-infinity.sth to infinity.sth)`
- `S = Non-whitespace String`
- `C = Non-whitespace Character`

### Special Functions

- `() => Capturing Group Indexed by 1`
- `(?:) => Non-capturing Group`
- `\1 => Back-reference`
- `(?:.....){} => Specify the number of occurrences of the group`
- `N|F[m, n] => Specifying min and max values of N or F (Skip one of the values means MIN and MAX respectively), check for the string if it is within the range or not`

### Language

- `PROGRAM := Vector<PRIMARY_DATA_TYPE | CAPTURING_GROUP | NON_CAPTURING_GROUP>`
- `PRIMARY_DATA_TYPE(REPETITION_STORE) := NUMERAL_TYPE(MIN_VALUE, MAX_VALUE) | CHARACTER | STRING`
- `NUMERAL_TYPE(MIN_VALUE, MAX_VALUE) := INTEGER | FLOAT`
- `CAPTURING_GROUP := PRIMARY_DATA_TYPE(1)::NUMERAL_TYPE(0|POSITIVE_NUMBER, MAX_VALUE)::INTEGER`
- `NON_CAPTURING_GROUP(REPETITION_STORE) := Vector<PRIMARY_DATA_TYPE | NON_CAPTURING_GROUP>`
- `REPETITION_STORE := BY_GROUP(GROUP_NO) | BY_COUNT(POSITIVE_NUMBER) | NONE`

For more information on the `clex` language and its usage, please refer to the [Grammar Rules for Clex Generator](#references).

## Example Usage

Here are some example usages of the `clex` language:

- `(N) N[,1000] (?:N F S){\1}`: Accepts input like "2 2 2 2.2 ABC2 3 4.5 ASD". It expects two integers (with a range from 0 to 1000), followed by triplets of Integer, Float, and String, occurring as many times as specified by the first capturing group.

- `(N[,1000]){\2}`: Valid usage.

- `(?:N[,1000]{\2})`: Valid usage.

- `(?:N{\2}[,1000])`: Invalid usage.

- `(N F)`: Invalid usage. Capturing group can only contain a single non-negative number.

## References

For more details on the `clex` language and advanced usage, you can refer to the following references:

- [Back-references in repetition construct regex](https://stackoverflow.com/questions/3407696/using-a-regex-back-reference-in-a-repetition-construct-n)
- [Back-references Stack Overflow](https://stackoverflow.com/questions/29728622/regex-with-backreference-as-repetition-count)
- [Possible solution using Code Call-out](https://stackoverflow.com/questions/29728622/regex-with-backreference-as-repetition-count/61898415#61898415)

Now you are ready to use `cpast` for testing your code against various programming languages and input patterns defined by the `clex` language. Happy testing!
2 changes: 1 addition & 1 deletion TESTCASE_LANGUAGE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Grammar Rules for TestCase Generator
# Grammar Rules for Clex Generator

Written similar to regex, just so that regex doesn't support Repeating Things through Back-references and Regex is unnecessary complex.

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod cli;

use code_companion::compile_and_test;
use cpast::compile_and_test;
use crate::cli::cli_parser::CliArgs;


Expand Down

0 comments on commit 4722b54

Please sign in to comment.