mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
fix some bugs
This commit is contained in:
parent
d01da83866
commit
7acaafaa2f
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mers"
|
||||
version = "0.8.20"
|
||||
version = "0.8.25"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "dynamically typed but type-checked programming language"
|
||||
@ -15,7 +15,7 @@ default = ["colored-output"]
|
||||
colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"]
|
||||
|
||||
[dependencies]
|
||||
mers_lib = "0.8.20"
|
||||
mers_lib = "0.8.25"
|
||||
# mers_lib = { path = "../mers_lib" }
|
||||
clap = { version = "4.3.19", features = ["derive"] }
|
||||
colored = { version = "2.1.0", optional = true }
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mers_lib"
|
||||
version = "0.8.24"
|
||||
version = "0.8.25"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "library to use the mers language in other projects"
|
||||
@ -9,7 +9,7 @@ readme = "README.md"
|
||||
repository = "https://github.com/Dummi26/mers"
|
||||
|
||||
[features]
|
||||
default = ["parse", "pretty-print", "ecolor-html"]
|
||||
default = ["parse"]
|
||||
|
||||
# for parsing and running mers code (for most situations: just enable parse)
|
||||
parse = ["run"]
|
||||
|
@ -112,6 +112,7 @@ pub struct Source {
|
||||
comments: Vec<(usize, String)>,
|
||||
i: usize,
|
||||
sections: Vec<SectionMarker>,
|
||||
allow_includes: bool,
|
||||
}
|
||||
impl Clone for Source {
|
||||
fn clone(&self) -> Self {
|
||||
@ -123,6 +124,7 @@ impl Clone for Source {
|
||||
comments: self.comments.clone(),
|
||||
i: self.i,
|
||||
sections: vec![],
|
||||
allow_includes: self.allow_includes,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,12 +152,14 @@ impl Source {
|
||||
comments: vec![],
|
||||
i: 0,
|
||||
sections: vec![],
|
||||
allow_includes: false,
|
||||
}
|
||||
}
|
||||
pub fn new_from_string(source: String) -> Self {
|
||||
Self::new(SourceFrom::Unspecified, source)
|
||||
}
|
||||
pub fn new(src_from: SourceFrom, source: String) -> Self {
|
||||
let allow_includes = matches!(src_from, SourceFrom::File(_));
|
||||
let mut src = String::with_capacity(source.len());
|
||||
let mut comment = (0, String::new());
|
||||
let mut comments = Vec::new();
|
||||
@ -222,8 +226,13 @@ impl Source {
|
||||
comments,
|
||||
i: 0,
|
||||
sections: vec![],
|
||||
allow_includes,
|
||||
}
|
||||
}
|
||||
pub fn allow_includes(mut self, allow_includes: bool) -> Self {
|
||||
self.allow_includes = allow_includes;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn src(&self) -> &String {
|
||||
&self.src
|
||||
|
@ -281,6 +281,14 @@ pub fn parse_no_chain(
|
||||
}
|
||||
match src.next_word() {
|
||||
"include" => {
|
||||
if !src.allow_includes {
|
||||
return Err(CheckError::new()
|
||||
.src(vec![(
|
||||
(pos_in_src, src.get_pos(), srca).into(),
|
||||
Some(EColor::HashIncludeCantLoadFile),
|
||||
)])
|
||||
.msg_str(format!("not allowed to use #include (only allowed when source code is read from a file, or if allow_includes is explicitly set)")));
|
||||
}
|
||||
let end_in_src = src.get_pos();
|
||||
src.skip_whitespace();
|
||||
let string_in_src = src.get_pos();
|
||||
|
@ -75,6 +75,7 @@ impl ThemeGen for DefaultTheme {
|
||||
type T = std::io::Stdout;
|
||||
fn color(&self, text: &str, color: Self::C, t: &mut Self::T) {
|
||||
use colored::{Color, Colorize};
|
||||
use std::io::Write;
|
||||
if let Some(color) = map_color(color) {
|
||||
let _ = write!(
|
||||
t,
|
||||
@ -92,6 +93,7 @@ impl ThemeGen for DefaultTheme {
|
||||
}
|
||||
}
|
||||
fn nocolor(&self, text: &str, t: &mut Self::T) {
|
||||
use std::io::Write;
|
||||
let _ = write!(t, "{}", text);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user