Fix ending atoms at end of list.
This commit is contained in:
parent
8df02fa8b9
commit
5305ae7627
@ -3,18 +3,16 @@ use std::process::Command;
|
|||||||
|
|
||||||
use crate::compare::sexp::sexp;
|
use crate::compare::sexp::sexp;
|
||||||
|
|
||||||
pub fn emacs_parse_org_document<'a, C>(file_path: C) -> Result<String, Box<dyn std::error::Error>>
|
pub fn compare_parse_org_document<'a, C>(file_path: C) -> Result<String, Box<dyn std::error::Error>>
|
||||||
where
|
where
|
||||||
C: AsRef<Path>,
|
C: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let org_sexp = emacs_parse_org_document_to_sexp(file_path)?;
|
let org_sexp = emacs_parse_org_document(file_path)?;
|
||||||
let parsed_sexp = sexp(org_sexp.as_str()).expect("Parse failure");
|
let parsed_sexp = sexp(org_sexp.as_str()).expect("Parse failure");
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emacs_parse_org_document_to_sexp<'a, C>(
|
pub fn emacs_parse_org_document<'a, C>(file_path: C) -> Result<String, Box<dyn std::error::Error>>
|
||||||
file_path: C,
|
|
||||||
) -> Result<String, Box<dyn std::error::Error>>
|
|
||||||
where
|
where
|
||||||
C: AsRef<Path>,
|
C: AsRef<Path>,
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ fn atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
|||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
fn unquoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn unquoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, body) = take_till1(|c| match c {
|
let (remaining, body) = take_till1(|c| match c {
|
||||||
' ' | '\t' | '\r' | '\n' => true,
|
' ' | '\t' | '\r' | '\n' | ')' => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})(input)?;
|
})(input)?;
|
||||||
Ok((remaining, Token::Atom(body)))
|
Ok((remaining, Token::Atom(body)))
|
||||||
@ -75,11 +75,11 @@ fn quoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
|||||||
let (remaining, _) = tag(r#"""#)(input)?;
|
let (remaining, _) = tag(r#"""#)(input)?;
|
||||||
let (remaining, _) = escaped(
|
let (remaining, _) = escaped(
|
||||||
take_till1(|c| match c {
|
take_till1(|c| match c {
|
||||||
'\\' | '"' => true,
|
'\\' | '"' | ')' => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}),
|
}),
|
||||||
'\\',
|
'\\',
|
||||||
one_of(r#"""#),
|
one_of(r#""n"#),
|
||||||
)(remaining)?;
|
)(remaining)?;
|
||||||
let (remaining, _) = tag(r#"""#)(remaining)?;
|
let (remaining, _) = tag(r#"""#)(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
@ -9,8 +9,10 @@ mod init_tracing;
|
|||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
init_telemetry()?;
|
init_telemetry()?;
|
||||||
// emacs_parse_org_document("./org_mode_samples/footnote_definition/simple.org")?;
|
let org_sexp = emacs_parse_org_document("./org_mode_samples/footnote_definition/simple.org")?;
|
||||||
sexp(r#" ("foo" bar baz ) "#)?;
|
println!("{}", org_sexp);
|
||||||
|
let parsed_sexp = sexp(org_sexp.as_str()).expect("Parse failure");
|
||||||
|
println!("{:#?}", parsed_sexp);
|
||||||
shutdown_telemetry()?;
|
shutdown_telemetry()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user