A Reporting library for for Ara Programming Language πŸ“ƒ

Overview

Ara Reporting

Actions Status Crates.io Docs

A Reporting library for Ara Programming Language πŸ“ƒ

Internally, Ara reporting uses the codespan-reporting library to build a report of the issues found in the code.

Note If you are planning on adding more features to Ara reporting, please consider adding them to codespan instead if possible.

Usage

Add ara_reporting to your Cargo.toml, and you're good to go!

[dependencies]
ara_reporting = "0.6.0"

Example

use ara_reporting::annotation::Annotation;
use ara_reporting::builder::CharSet;
use ara_reporting::builder::ColorChoice;
use ara_reporting::builder::ReportBuilder;
use ara_reporting::error::Error;
use ara_reporting::issue::Issue;
use ara_reporting::Report;
use ara_reporting::ReportFooter;
use ara_source::source::Source;
use ara_source::source::SourceKind;
use ara_source::SourceMap;

fn main() -> Result<(), Error> {
    let origin = "example.ara";
    let code = r#"
$b = match $a {
    1 => 2,
    2 => 3,
    default => "string",
};
"#;

    let map = SourceMap::new(vec![Source::new(SourceKind::Script, origin, code)]);

    let report = Report::new()
        .with_issue(
            Issue::error("E0417", "`match` arms have incompatible types")
                .with_source(origin, 6, 67)
                .with_annotation(
                    Annotation::new(origin, 26, 27).with_message("this is found to be of type `{int}`"),
                )
                .with_annotation(
                    Annotation::new(origin, 38, 39).with_message("this is found to be of type `{int}`"),
                )
                .with_annotation(
                    Annotation::new(origin, 56, 64).with_message("expected `{int}`, found `{string}`"),
                )
                .with_note("for more information about this error, try `ara --explain E0417`"),
        )
        .with_footer(
            ReportFooter::new("this is a report footer message")
                .with_note("this is a note message"),
        );

    let builder = ReportBuilder::new(&map)
        .with_colors(ColorChoice::Always)
        .with_charset(CharSet::Unicode);

    builder.print(&report)
}

see examples directory for more examples.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Credits

You might also like...
Yfin is the Official package manager for the Y-flat programming language
Yfin is the Official package manager for the Y-flat programming language

Yfin is the Official package manager for the Y-flat programming language. Yfin allows the user to install, upgrade, and uninstall packages. It also allows a user to initialize a package with the Y-flat package structure and files automatically generated. In future, Yfin will also allow users to publish packages.

Notes on learning the Rust programming language syntax.

notes-on-rust Notes on learning the Rust programming language syntax. Resources https://www.rust-lang.org/learn/get-started https://doc.rust-lang.org/

A clone of linux cal command, using rust programming language

CLI Calendar command What the project does This command was inspired by Linux Cal command that shows the current month calendar as output (by default)

A simple lexer which creates over 75 various tokens based on the rust programming language.

Documentation. This complete Lexer/Lexical Scanner produces tokens for a string or a file path entry. The output is a Vector for the user to handle ac

An embeddable dynamic programming language for Rust.

rune Visit the site 🌐 - Read the book πŸ“– An embeddable dynamic programming language for Rust. Contributing If you want to help out, there should be a

Idiomatic inotify wrapper for the Rust programming language

inotify-rs Idiomatic inotify wrapper for the Rust programming language. extern crate inotify; use std::env; use inotify::{ EventMask, Watch

Object Notation Programming Language?
Object Notation Programming Language?

You may have questions ONLang - Object Notation Language (jsON) VSCode extension - OnLang 1. God, what the f**** is this ONLang is an experimental, es

Programming language that compiles into Scratch blocks (SB3).

Claw Hello, and welcome to my cool project! I've spent... at least a month on this, and it's still not finished! Feel free to check it out though. :D

Stream-based visual programming language for systems observability
Stream-based visual programming language for systems observability

Stream-based visual programming language for systems observability. Metalens allows to build observability programs in a reactive and visual way. On L

Comments
  • chore: returns `Severity` from `IssueSeverity`

    chore: returns `Severity` from `IssueSeverity`

    I think this makes things easier to read. So, instead of:

    let diagnostic = Into::<Diagnostic<usize>>::into(issue.severity)
    

    We can go directly to:

    let diagnostic = Diagnostic::new(issue.severity.into())
    
    opened by KennedyTedesco 0
  • new: added severity() method to Report

    new: added severity() method to Report

    Added severity() method to Report to retrieve the highest severity from all issues in the report.

    Closes: https://github.com/ara-lang/reporting/issues/4

    opened by KennedyTedesco 0
  • remove the issue message from the primary annotation

    remove the issue message from the primary annotation

    e.g:

    error[A0019]: array access operation discarded
       β”Œβ”€ src/foo.ara:42:5
       β”‚
    42 β”‚     $x[1];
       β”‚     ^^^^^ array access operation discarded
       β”‚
       = note: array access operations are side-effect free, so you can safely remove them.
    

    the message "array access operation discarded" is displayed twice, we should remove the second, which is straight forward, by removing this line of code: https://github.com/ara-lang/reporting/blob/main/src/builder.rs#L216

    opened by azjezz 0
Releases(0.6.0)
  • 0.6.0(Jan 14, 2023)

    What's Changed

    • chore: returns Severity from IssueSeverity by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/20
    • new: add ability to print multiple reports by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/21
    • feat: add a summary to ReportFooter by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/22
    • chore: add #[must_use] by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/24
    • chore: get rid of std HashMap by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/23
    • new: add code of conduct by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/26
    • fix: Bug has a higher severity by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/27
    • chore: fix cs by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/25
    • new: add with_source() to Issue by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/28

    Full Changelog: https://github.com/ara-lang/reporting/compare/0.5.1...0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.1(Jan 8, 2023)

  • 0.5.0(Jan 7, 2023)

    What's Changed

    • chore: rename IssueKind to IssueSeverity by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/9
    • chore: change from kind to severity by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/12
    • new: added severity() method to Report by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/13
    • new: add AnnotationType to Annotation by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/15
    • chore: remove duplicated issue message by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/14
    • chore: change Charset to CharSet by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/17
    • new: add an optional message to Report by @KennedyTedesco in https://github.com/ara-lang/reporting/pull/16
    • feat: add display style by @azjezz in https://github.com/ara-lang/reporting/pull/18
    • chore: remove help messages by @azjezz in https://github.com/ara-lang/reporting/pull/19

    New Contributors

    • @KennedyTedesco made their first contribution in https://github.com/ara-lang/reporting/pull/9
    • @azjezz made their first contribution in https://github.com/ara-lang/reporting/pull/18

    Full Changelog: https://github.com/ara-lang/reporting/compare/0.4.2...0.5.0

    Source code(tar.gz)
    Source code(zip)
  • 0.4.2(Jan 1, 2023)

  • 0.4.1(Dec 31, 2022)

    What's Changed

    • fix: typo by @nhedger in https://github.com/ara-lang/reporting/pull/2

    New Contributors

    • @nhedger made their first contribution in https://github.com/ara-lang/reporting/pull/2

    Full Changelog: https://github.com/ara-lang/reporting/compare/0.4.0...0.4.1

    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Dec 30, 2022)

Owner
Ara Programming Language
Ara Programming Language
A command line progress reporting library for Rust

indicatif Documentation A Rust library for indicating progress in command line applications to users. This currently primarily provides progress bars

Armin Ronacher 3.2k Dec 30, 2022
Rust CLI utility library. Error handling, status reporting, and exit codes.

narrate This library provides CLI application error and status reporting utilities. The coloured output formatting aims to be similar to Cargo. Error

Christopher Morton 5 Nov 2, 2022
An Interpreter for Brainfuck programming language implemented in the Rust programming language with zero dependencies.

Brainfuck Hello, Visitor! Hey there, welcome to my project showcase website! It's great to have you here. I hope you're ready to check out some awesom

Syed Vilayat Ali Rizvi 7 Mar 31, 2023
A C-like programming language that is similar to Rust's syntax. Toy programming language.

CRUST This is a hobby project to learn about compilers and language design. I've designed the language to be similar to C and Rust. Heavily inspired b

Mahmoud Almontasser 50 Jul 13, 2024
Programming language made by me to learn other people how to make programming languages :3

Spectra programming language Programming language made for my tutorial videos (my youtube channel): Syntax Declaring a variable: var a = 3; Function

Adi Salimgereyev 3 Jul 25, 2023
The Amp programming language: a language designed for building high performance systems.

A language designed for building high performance systems. Platform Support x86_64-pc-windows βœ… x86_64-unknown-linux ⚠️ untested x86_64-unknown-darwin

The Amp Programming Language 5 Mar 17, 2023
Nexa programming language. A language for game developers by a game developer

NexaLang Nexa programming language. A language for game developers by a game developer. Features High-Level: Nexa is an easy high level language Two M

Sabe 3 Aug 21, 2023
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Alexandre Bury 3.3k Jan 9, 2023
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Alexandre Bury 3.3k Jan 3, 2023
πŸŽ„My Advent of Code 2021 solutions in the Rust programming language

Advent of Code 2021 in Rust My Advent of Code 2021 solutions in the Rust programming language. This repository holds a separate Rust project for each

Tim VisΓ©e 227 Dec 16, 2022