[−][src]Module papyrus::code
Source file and crate contents.
Input is parsed as Rust code using the syn crate. papyrus does not differentiate the
myriad of classications for the input, rather it categorises them into Items, Statements,
and CrateTypes.
papyrus will parse a string input into a Input, and these aggregate into a SourceCode
structure, which flattens each input.
Examples
Building some source code.
use papyrus::code::*; let mut src = SourceCode::new(); src.stmts.push(StmtGrp(vec![Statement { expr: String::from("let a = 1"), semi: true }, Statement { expr: String::from("a"), semi: false } ]));
Crates have some more structure around them.
use papyrus::code::*; let input = "extern crate a_crate as acrate;"; let cr = CrateType::parse_str(input).unwrap(); assert_eq!(&cr.src_line, input); assert_eq!(&cr.cargo_name, "a-crate");
Structs
| CrateType | Some definition around crate names. |
| Input | An input collection |
| SourceCode | The flattened representation of source code. Statements are grouped based on the the 'out' number. |
| Statement | Represents an inner statement. |
| StmtGrp | Group of statements that result in an expression to evaulate. |
Functions
| construct_source_code | Construct a single string containing all the source code in |
| eval_fn_name | Constructs the evaluation function name given the mod sequence path. Appends to the buffer. |
| into_mod_path_vec | Transforms a path into a vector of components. |
Type Definitions
| Item | A single item. |
| ModsMap | Mapping of modules to source code. |