1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#[macro_use]
extern crate nom;
#[macro_use]
mod utils;
#[macro_use]
mod whitespace;
mod numbers;
mod idents;
mod expressions;
mod commands;
mod statements;
mod memory;
mod sections;
mod script;
pub use expressions::UnaryOperator;
pub use expressions::BinaryOperator;
pub use expressions::Expression;
pub use commands::Command;
pub use statements::AssignOperator;
pub use statements::Statement;
pub use memory::Region;
pub use sections::DataType;
pub use sections::SectionPattern;
pub use sections::OutputSectionType;
pub use sections::OutputSectionConstraint;
pub use sections::OutputSectionCommand;
pub use sections::SectionCommand;
pub use script::RootItem;
pub fn parse(ldscript: &str) -> Result<Vec<RootItem>, String> {
match script::parse(ldscript) {
nom::IResult::Done("", result) => Ok(result),
err => Err(format!("Parsing failed, error: {:?}", err)),
}
}