Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiling/failing/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Logger {
}
}

// Returns chopped string where fisrt and third part are supposed
// Returns chopped string where first and third part are supposed
// to be left as is but the second one is supposed to be highlighted
fn get_highlighted_part(&self, line: &str) -> Option<[String;3]> {
let (_row, col, len) = self.get_row_col_len()?;
Expand Down Expand Up @@ -157,7 +157,7 @@ impl Logger {
let end = col.checked_add(len).unwrap_or(len);
// If we are at the end of the code snippet and there is still some
if end - 1 > code.chars().count() {
// We substract here 2 because 1 is the offset of col (starts at 1)
// We subtract here 2 because 1 is the offset of col (starts at 1)
// and other 1 is the new line character that we do not display
*overflow = (end - 2).checked_sub(code.chars().count()).unwrap_or(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiling/failing/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Message {
Self::new(meta.get_code(), &Self::get_full_trace(meta, pos), MessageType::Info)
}

/* Attach additional infromation */
/* Attach additional information */

/// Add message to an existing log
pub fn message<T: AsRef<str>>(mut self, text: T) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/compiling/failing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Module designed to help you send Errors
//!
//! It's recommmended to use macros for this case, but you can use this module directly.
//! It's recommended to use macros for this case, but you can use this module directly.

pub mod failure;
pub mod message;
Expand Down
6 changes: 3 additions & 3 deletions src/compiling/failing/position_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct PositionInfo {
}

impl PositionInfo {
/// Create a new erorr from scratch
/// Create a new error from scratch
pub fn new(meta: &impl Metadata, position: Position, len: usize) -> Self {
let info = PositionInfo {
position,
Expand All @@ -46,7 +46,7 @@ impl PositionInfo {
info.updated_pos(meta)
}

/// Create a new erorr at the end of file
/// Create a new error at the end of file
pub fn at_eof(meta: &impl Metadata) -> Self {
let info = PositionInfo {
path: meta.get_path(),
Expand All @@ -57,7 +57,7 @@ impl PositionInfo {
info.updated_pos(meta)
}

/// Create a new erorr at given position
/// Create a new error at given position
pub fn at_pos(path: Option<String>, (row, col): (usize, usize), len: usize) -> Self {
PositionInfo {
path,
Expand Down
4 changes: 2 additions & 2 deletions src/compiling/lexing/compound_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub struct CompoundHandler {
impl CompoundHandler {
pub fn new(rules: &Rules) -> Self {
CompoundHandler {
compound_tree: Self::generate_compunds(rules.compounds.clone()),
compound_tree: Self::generate_compounds(rules.compounds.clone()),
is_triggered: false
}
}

// Generates a tree where the key is the left item of
// the pair and values are all the right items of the pair
fn generate_compunds(word_pairs: Vec<(char, char)>) -> HashMap<char, Vec<char>> {
fn generate_compounds(word_pairs: Vec<(char, char)>) -> HashMap<char, Vec<char>> {
let mut compound_tree = HashMap::new();
for (left, right) in word_pairs {
compound_tree
Expand Down
2 changes: 1 addition & 1 deletion src/compiling/lexing/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Lexer {
}

// Getting position by word here would attempt to
// substract with overflow since the new line character
// subtract with overflow since the new line character
// technically belongs to the previous line
let (row, _col) = lex_state.reader.get_position();
lex_state.lexem.push(Token {
Expand Down
2 changes: 1 addition & 1 deletion src/compiling/parser/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::compiling::failing::position_info::PositionInfo;
use serde::{Serialize, Deserialize};

/// Default implementation of metadata.
/// This is useful for debuging or languages that are not too demanding.
/// This is useful for debugging or languages that are not too demanding.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct DefaultMetadata {
/// Current index in the token stream
Expand Down
10 changes: 5 additions & 5 deletions src/compiling/parser/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{ Metadata, SyntaxModule };

/// Matches one token with given word
///
/// If token was matched succesfully - the word it contained is returned.
/// If token was matched successfully - the word it contained is returned.
/// Otherwise detailed information is returned about where this happened.
/// # Example
/// ```
Expand All @@ -27,7 +27,7 @@ pub fn token<T: AsRef<str>>(meta: &mut impl Metadata, text: T) -> Result<String,

/// Matches one token by defined function
///
/// If token was matched succesfully - the word it contained is returned.
/// If token was matched successfully - the word it contained is returned.
/// Otherwise detailed information is returned about where this happened.
/// # Example
/// ```
Expand All @@ -50,7 +50,7 @@ pub fn token_by(meta: &mut impl Metadata, cb: impl Fn(&String) -> bool) -> Resul

/// Parses syntax module
///
/// If syntax module was parsed succesfully - nothing is returned.
/// If syntax module was parsed successfully - nothing is returned.
/// Otherwise detailed information is returned about where this happened.
/// # Example
/// ```
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn syntax<M: Metadata>(meta: &mut M, module: &mut impl SyntaxModule<M>) -> R

/// Matches indentation
///
/// If indentation was matched succesfully - the amount of spaces is returned.
/// If indentation was matched successfully - the amount of spaces is returned.
/// Otherwise detailed information is returned about where this happened.
/// # Example
/// ```
Expand All @@ -104,7 +104,7 @@ pub fn indent(meta: &mut impl Metadata) -> Result<usize, Failure> {

/// Matches indentation with provided size
///
/// If indentation was identified succesfully return the std::cmp::Ordering
/// If indentation was identified successfully return the std::cmp::Ordering
/// depending on whether the amount of spaces detected was smaller, equal or greater.
/// Otherwise detailed information is returned about where this happened.
/// # Example
Expand Down
2 changes: 1 addition & 1 deletion src/compiling/parser/preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn numeric(meta: &mut impl Metadata, extend: Vec<char>) -> Result<String, Fa

/// Match an integer
///
/// Matches a positive or negetive integer.
/// Matches a positive or negative integer.
/// If desired - one can extend this implementation with other chars.
pub fn integer(meta: &mut impl Metadata, extend: Vec<char>) -> Result<String, Failure> {
match meta.get_current_token() {
Expand Down