[−][src]Function axon_parser::parse_func_to_formatted_lines
pub fn parse_func_to_formatted_lines(
axon: &str,
indent: &Indent
) -> Result<Vec<String>, Error>
If the axon input represents a function, parse it and return a Vec<String>
,
each string being a formatted line of code.
The axon
argument to this function should be a string containing the
output of running toAxonCode(parseAst( ... ))
in SkySpark.
Example
use axon_parser::parse_func_to_formatted_lines; use axon_parser::Indent; let indent = Indent::new(" ".to_string(), 0); // 2-space indentation let axon = r###"{type:"func", params:[], body:{type:"block", exprs:[{type:"literal", val:"hello world"}]}}"###; let lines = parse_func_to_formatted_lines(axon, &indent).unwrap(); assert_eq!(lines.len(), 3); assert_eq!(lines[0], "() => do"); assert_eq!(lines[1], " \"hello world\""); assert_eq!(lines[2], "end");