Skip to content

Commit

Permalink
cargo documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier2p committed Oct 23, 2023
1 parent babd21d commit 02cfbf4
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 32 deletions.
17 changes: 10 additions & 7 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fortran.rs
# `fortran.rs`

![GitHub top language](https://img.shields.io/github/languages/top/xavier2p/fortran.rs?style=for-the-badge&logo=rust&color=orange)

Expand All @@ -9,21 +9,24 @@ Now, it supports only the Fortran90 version, but you can help me to add more ver
> **Warning**
> This project is work in progress, so it's not working today.
## How to use it
## How to install it

### Development
### From source

```bash
cargo run --release -- <FILE>
git clone https://github.com/xavier2p/fortran.rs.git && cd fortran.rs/
cargo install --path .
```

### Release
Other ways are possible, please check [install.md](./docs/install.md) for more information.

## How to use it

```bash
fortran-rs <FILE>
fortran-rs run <FILE>
```

## Help
All the options are available with the `--help` option.

```console
$ fortran-rs --help
Expand Down
22 changes: 22 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Alternative Installation methods

> **Warning**
> All of this options are not available yet.
## From crates.io

```bash
cargo install fortran-rs
```

## With Docker

```bash
docker run --rm -it --name fortran-rs --volume ./:/app/src xavier2p/fortran-rs:latest run <FILE>
```

## With Nix Flake

```bash
nix run github:xavier2p/fortran.rs
```
3 changes: 3 additions & 0 deletions src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Abstract Syntax Tree
//!
//! This module contains the AST and the evaluation function.
use crate::tokens::Token;

#[allow(dead_code)]
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions src/fortran/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Fortran Functions and Modules
//!
//! > This module contains the builtin functions and modules for the Fortran language.
//! > For each one, you will find the syntax in Fortran, and the process to interpret it.
pub mod print;
10 changes: 8 additions & 2 deletions src/modules/print.rs → src/fortran/print.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
//! # Print
//! PRINT function
//!
//! This module contains the `print` function.
//! > This module contains the builtin `PRINT` function for the Fortran language.
//!
//! ## Syntax
//!
//! ```fortran
//! PRINT *, <string>
//! ```
use crate::{
helpers::errors::{self, Error},
program::Program,
Expand Down
1 change: 1 addition & 0 deletions src/helpers/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! CLI interface and arguments parsing
//! This module is used to parse the arguments passed to the program.
use clap::{Parser, Subcommand};
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Errors Module
//! Errors and warnings management
//!
//! This module contains the error handling functions.
use crate::program::Program;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # File Traitement
//! File management
//!
//! This module contains the `File` struct and its methods.
use crate::helpers::cli::Cli;
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Helper functions for the interpreter
//!
//! > This module contains the helper functions for the interpreter.
pub mod cli;
pub mod errors;
pub mod file;
4 changes: 2 additions & 2 deletions src/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! # Lexer
//! Lexer Implementation
//!
//! The lexer is the first step of the compilation process. It takes the source code and converts it into tokens.
use crate::{
fortran::print::print_to_stdout,
helpers::errors::{self, Error},
modules::print::print_to_stdout,
program::Program,
tokens::Token,
};
Expand Down
45 changes: 33 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
//! # `fortran.rs`
//! > Fortran interpreter, written in Rust.
//!
//! > `fortran.rs` is an interpreter for the Fortran language.
//! Now, it supports only the Fortran90 version, but you can help me to add more versions !
//!
//! ## Usage
//! ## How to install it
//!
//! ### From source
//!
//! ```bash
//! git clone https://github.com/xavier2p/fortran.rs.git && cd fortran.rs/
//! cargo install --path .
//! ```
//!
//! Other ways are possible, please check [install.md](https://github.com/xavier2p/fortran.rs/blob/main/docs/install.md) for more information.
//!
//! ## How to use it
//!
//! ```bash
//! $ cargo run -- <file>
//! fortran-rs run <FILE>
//! ```
//!
//! ## Arguments
//! All the options are available with the `--help` option.
//!
//! * `<file>` - The path to the file to interpret.
//! ```console
//! $ fortran-rs --help
//! An open-source Fortran interpreter.
//! Written in Rust.
//!
//! ## Options
//! Usage: fortran-rs [OPTIONS] <COMMAND>
//!
//! * `-h`, `--help` - Print the help message.
//! * `-v`, `--verbose` - Print the verbose output.
//! * `-V`, `--version` - Print the version.
//! * `--werror` - Treat all warnings as errors.
//! Commands:
//! run Run the Fortran file passed as argument
//! check Check the syntax of the file passed as argument
//! help Print this message or the help of the given subcommand(s)
//!
//! Options:
//! -v, --verbose Print the comment during the execution of the program
//! -h, --help Print help
//! -V, --version Print version
//! ```
mod ast;
mod fortran;
mod helpers;
mod lexer;
mod modules;
mod parser;
mod program;
mod tokenizer;
Expand All @@ -35,6 +55,7 @@ use clap::Parser;

static VERBOSE: bool = true;

/// Program entry point
fn main() {
let args = cli::Cli::parse();

Expand Down
1 change: 0 additions & 1 deletion src/modules/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # Parser module
//! Parser for the Fortran language
//!
//! This module is in charge of parsing the file.
//! It's the first step of the interpreter.
Expand Down
2 changes: 1 addition & 1 deletion src/program.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # Program
//! Program Object definition
//!
//! This module contains the `Program` struct.
use crate::{tokens::Token, variables::Variable};
Expand Down
3 changes: 3 additions & 0 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Tokenizer of the language
//!
//! This module contains the tokenizer for the language. It takes in a string and returns a vector of tokens.
use crate::{
tokens::Token,
variables::{self, Variable},
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # Tokens
//! Tokens definition and implementation
//!
//! This module contains the Token enum, which is used to represent the tokens

Expand Down
2 changes: 1 addition & 1 deletion src/validation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Validation module.
//! Syntax validation of Fortran code
//!
//! This module contains the functions to validate the syntax of the code.
use crate::helpers::errors::Error;
Expand Down
2 changes: 1 addition & 1 deletion src/variables.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # Variables
//! Variables definition and assignment
//!
//! This module contains the functions to parse and assign variables.
use crate::tokens::Token;
Expand Down
5 changes: 4 additions & 1 deletion src/verbose.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@

//! Verbose and debug printing
//!
//! This module contains the verbose module, which is used to print out
//! the tokens, the AST, and the variables.

0 comments on commit 02cfbf4

Please sign in to comment.