[−][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 Item
s, Statement
s,
and CrateType
s.
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::default(); 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. |
StaticFile | A static file pointer. |
StmtGrp | Group of statements that result in an expression to evaulate. |
Enums
AddingStaticFileError | Errors around adding a static file. |
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. |
parse_crates_in_file | Parse a code string for any crate references. |
static_file_mod_name | Obtains the effective root module name of a path. |
validate_static_file_path | Validate a path such that it can be written to a file adjacent to |
Type Definitions
Item | A single item. |
ModsMap | Mapping of modules to source code. |
StaticFiles | Set of statics files. |