mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 07:58:24 +00:00
beter2
This commit is contained in:
parent
2debb696ba
commit
0ea6ac3085
|
@ -106,7 +106,7 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
std::fs::write(config_path, toml::to_string_pretty(&config)?)
|
std::fs::write(config_path, toml::to_string_pretty(&config)?)
|
||||||
.context("failed to write Ed.toml")?;
|
.context("failed to write Ed.toml")?;
|
||||||
std::fs::write(path.join(".gitignore"), "/target-ed\n")
|
std::fs::write(path.join(".gitignore"), "/build\n")
|
||||||
.context("failed to write .gitignore")?;
|
.context("failed to write .gitignore")?;
|
||||||
std::fs::write(path.join(".gitattributes"), "*.ed linguist-language=Rust\n")
|
std::fs::write(path.join(".gitattributes"), "*.ed linguist-language=Rust\n")
|
||||||
.context("failed to write .gitattributes")?;
|
.context("failed to write .gitattributes")?;
|
||||||
|
@ -207,7 +207,7 @@ mod {} {{
|
||||||
);
|
);
|
||||||
|
|
||||||
let src_dir = base_dir.join("src");
|
let src_dir = base_dir.join("src");
|
||||||
let target_dir = base_dir.join("target-ed");
|
let target_dir = base_dir.join("build");
|
||||||
|
|
||||||
if !target_dir.exists() {
|
if !target_dir.exists() {
|
||||||
std::fs::create_dir_all(&target_dir)?;
|
std::fs::create_dir_all(&target_dir)?;
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub fn main() -> Result<()> {
|
||||||
|
|
||||||
pub fn compile(args: &CompilerArgs) -> Result<PathBuf> {
|
pub fn compile(args: &CompilerArgs) -> Result<PathBuf> {
|
||||||
let mut files = Vec::new();
|
let mut files = Vec::new();
|
||||||
for entry in WalkDir::new(&args.input) {
|
for entry in WalkDir::new(&args.input).sort_by_file_name() {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
if let Some(ext) = entry.path().extension() {
|
if let Some(ext) = entry.path().extension() {
|
||||||
if ext.eq_ignore_ascii_case("ed") {
|
if ext.eq_ignore_ascii_case("ed") {
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn error_to_report<'a>(
|
||||||
ParseError::InvalidToken { location } => {
|
ParseError::InvalidToken { location } => {
|
||||||
let loc = *location;
|
let loc = *location;
|
||||||
Report::build(ReportKind::Error, path, loc)
|
Report::build(ReportKind::Error, path, loc)
|
||||||
.with_code("P1")
|
.with_code("InvalidToken")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, loc..(loc + 1)))
|
Label::new((path, loc..(loc + 1)))
|
||||||
.with_color(colors.next())
|
.with_color(colors.next())
|
||||||
|
@ -57,7 +57,7 @@ pub fn error_to_report<'a>(
|
||||||
ParseError::UnrecognizedEof { location, expected } => {
|
ParseError::UnrecognizedEof { location, expected } => {
|
||||||
let loc = *location;
|
let loc = *location;
|
||||||
Report::build(ReportKind::Error, path, loc)
|
Report::build(ReportKind::Error, path, loc)
|
||||||
.with_code("P2")
|
.with_code("UnrecognizedEof")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, loc..(loc + 1)))
|
Label::new((path, loc..(loc + 1)))
|
||||||
.with_message(format!(
|
.with_message(format!(
|
||||||
|
@ -70,7 +70,7 @@ pub fn error_to_report<'a>(
|
||||||
}
|
}
|
||||||
ParseError::UnrecognizedToken { token, expected } => {
|
ParseError::UnrecognizedToken { token, expected } => {
|
||||||
Report::build(ReportKind::Error, path, token.0)
|
Report::build(ReportKind::Error, path, token.0)
|
||||||
.with_code(3)
|
.with_code("UnrecognizedToken")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, token.0..token.2))
|
Label::new((path, token.0..token.2))
|
||||||
.with_message(format!(
|
.with_message(format!(
|
||||||
|
@ -83,7 +83,7 @@ pub fn error_to_report<'a>(
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
ParseError::ExtraToken { token } => Report::build(ReportKind::Error, path, token.0)
|
ParseError::ExtraToken { token } => Report::build(ReportKind::Error, path, token.0)
|
||||||
.with_code("P3")
|
.with_code("ExtraToken")
|
||||||
.with_message("Extra token")
|
.with_message("Extra token")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, token.0..token.2))
|
Label::new((path, token.0..token.2))
|
||||||
|
@ -94,7 +94,7 @@ pub fn error_to_report<'a>(
|
||||||
LexicalError::InvalidToken(err, range) => match err {
|
LexicalError::InvalidToken(err, range) => match err {
|
||||||
tokens::LexingError::NumberParseError => {
|
tokens::LexingError::NumberParseError => {
|
||||||
Report::build(ReportKind::Error, path, range.start)
|
Report::build(ReportKind::Error, path, range.start)
|
||||||
.with_code(4)
|
.with_code("InvalidToken")
|
||||||
.with_message("Error parsing literal number")
|
.with_message("Error parsing literal number")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, range.start..range.end))
|
Label::new((path, range.start..range.end))
|
||||||
|
@ -104,7 +104,7 @@ pub fn error_to_report<'a>(
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
tokens::LexingError::Other => Report::build(ReportKind::Error, path, range.start)
|
tokens::LexingError::Other => Report::build(ReportKind::Error, path, range.start)
|
||||||
.with_code(4)
|
.with_code("Other")
|
||||||
.with_message("Other error")
|
.with_message("Other error")
|
||||||
.with_label(
|
.with_label(
|
||||||
Label::new((path, range.start..range.end))
|
Label::new((path, range.start..range.end))
|
||||||
|
|
Loading…
Reference in a new issue