Skip to content

Commit ec6d906

Browse files
committed
Adapt commands in main to use updated parser functions
1 parent b8e49e5 commit ec6d906

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/main.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,20 @@ fn main() {
160160
std::process::exit(1);
161161
}
162162
};
163-
let result = parsing::parser::parse_with_recovery(&filename, &content);
164-
if result.has_errors() {
165-
for error in &result.errors {
166-
eprintln!(
167-
"{}",
168-
problem::full_parsing_error(error, &filename, &content, &Terminal)
169-
);
163+
164+
let technique = match parsing::parse(&filename, &content) {
165+
Ok(document) => document,
166+
Err(errors) => {
167+
for error in errors {
168+
eprintln!(
169+
"{}",
170+
problem::full_parsing_error(&error, &filename, &content, &Terminal)
171+
);
172+
}
173+
std::process::exit(1);
170174
}
171-
std::process::exit(1);
172-
}
173-
let technique = result.document;
175+
};
176+
174177
// TODO continue with validation of the returned technique
175178

176179
eprintln!("{}", "ok".bright_green());
@@ -206,13 +209,16 @@ fn main() {
206209
std::process::exit(1);
207210
}
208211
};
212+
209213
let technique = match parsing::parse(&filename, &content) {
210214
Ok(document) => document,
211-
Err(error) => {
212-
eprintln!(
213-
"{}",
214-
problem::concise_parsing_error(&error, &filename, &content, &Terminal)
215-
);
215+
Err(errors) => {
216+
for error in errors {
217+
eprintln!(
218+
"{}",
219+
problem::concise_parsing_error(&error, &filename, &content, &Terminal)
220+
);
221+
}
216222
std::process::exit(1);
217223
}
218224
};
@@ -252,16 +258,20 @@ fn main() {
252258
std::process::exit(1);
253259
}
254260
};
261+
255262
let technique = match parsing::parse(&filename, &content) {
256263
Ok(document) => document,
257-
Err(error) => {
264+
Err(errors) => {
258265
// It is possible that we will want to render the error
259266
// into the PDF document rather than crashing here. We'll
260267
// see in the future.
261-
eprintln!(
262-
"{}",
263-
problem::full_parsing_error(&error, &filename, &content, &Terminal)
264-
);
268+
269+
for error in errors {
270+
eprintln!(
271+
"{}",
272+
problem::concise_parsing_error(&error, &filename, &content, &Terminal)
273+
);
274+
}
265275
std::process::exit(1);
266276
}
267277
};

0 commit comments

Comments
 (0)