Remove unused sexp parser entry point.

This commit is contained in:
Tom Alexander 2023-09-11 15:05:18 -04:00
parent cf383fa394
commit 98de5e4ec5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 10 additions and 16 deletions

View File

@ -74,7 +74,7 @@ fn write_header(test_file: &mut File) {
use organic::compare_document;
use organic::parser::parse;
use organic::emacs_parse_anonymous_org_document;
use organic::parser::sexp::sexp_with_padding;
use organic::parser::sexp::sexp;
"#
)

View File

@ -10,7 +10,7 @@ use organic::emacs_parse_file_org_document;
use organic::get_emacs_version;
use organic::get_org_mode_version;
use organic::parser::parse_with_settings;
use organic::parser::sexp::sexp_with_padding;
use organic::parser::sexp::sexp;
use organic::GlobalSettings;
use organic::LocalFileAccessInterface;
@ -67,7 +67,7 @@ fn run_anonymous_parse<P: AsRef<str>>(org_contents: P) -> Result<(), Box<dyn std
let rust_parsed = parse(org_contents)?;
let org_sexp = emacs_parse_anonymous_org_document(org_contents)?;
let (_remaining, parsed_sexp) =
sexp_with_padding(org_sexp.as_str()).map_err(|e| e.to_string())?;
sexp(org_sexp.as_str()).map_err(|e| e.to_string())?;
println!("{}\n\n\n", org_contents);
println!("{}", org_sexp);
@ -104,7 +104,7 @@ fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::err
let rust_parsed = parse_with_settings(org_contents, &global_settings)?;
let org_sexp = emacs_parse_file_org_document(org_path)?;
let (_remaining, parsed_sexp) =
sexp_with_padding(org_sexp.as_str()).map_err(|e| e.to_string())?;
sexp(org_sexp.as_str()).map_err(|e| e.to_string())?;
println!("{}\n\n\n", org_contents);
println!("{}", org_sexp);

View File

@ -136,7 +136,7 @@ pub(crate) fn unquote(text: &str) -> Result<String, Box<dyn std::error::Error>>
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
let (remaining, _) = multispace0(input)?;
let remaining = OrgSource::new(remaining);
let (remaining, tkn) = token(remaining)
@ -146,12 +146,6 @@ pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
Ok((remaining, tkn))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn sexp<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Token<'s>> {
let (remaining, tkn) = token(input)?;
Ok((remaining, tkn))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn token<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Token<'s>> {
alt((list, vector, atom))(input)
@ -259,7 +253,7 @@ mod tests {
#[test]
fn simple() {
let input = " (foo bar baz ) ";
let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input");
let (remaining, parsed) = sexp(input).expect("Parse the input");
assert_eq!(remaining, "");
assert!(match parsed {
Token::Atom(_) => false,
@ -272,7 +266,7 @@ mod tests {
#[test]
fn quoted() {
let input = r#" ("foo" bar baz ) "#;
let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input");
let (remaining, parsed) = sexp(input).expect("Parse the input");
assert_eq!(remaining, "");
assert!(match parsed {
Token::Atom(_) => false,
@ -296,7 +290,7 @@ mod tests {
#[test]
fn quoted_containing_paren() {
let input = r#" (foo "b(a)r" baz ) "#;
let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input");
let (remaining, parsed) = sexp(input).expect("Parse the input");
assert_eq!(remaining, "");
assert!(match parsed {
Token::List(_) => true,
@ -332,7 +326,7 @@ mod tests {
#[test]
fn string_containing_escaped_characters() {
let input = r#" (foo "\\( x=2 \\)" bar) "#;
let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input");
let (remaining, parsed) = sexp(input).expect("Parse the input");
assert_eq!(remaining, "");
assert!(match parsed {
Token::Atom(_) => false,

View File

@ -5,7 +5,7 @@ fn {name}() {{
println!("{{}}", org_contents);
let org_sexp = emacs_parse_anonymous_org_document(org_contents.as_str()).expect("Use emacs to parse org file.");
println!("{{}}", org_sexp);
let (_remaining, parsed_sexp) = sexp_with_padding(org_sexp.as_str()).expect("Sexp Parse failure");
let (_remaining, parsed_sexp) = sexp(org_sexp.as_str()).expect("Sexp Parse failure");
let rust_parsed = parse(org_contents.as_str()).expect("Org Parse failure");
println!("{{:#?}}", rust_parsed);
let diff_result =