-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 51c7ed8
Showing
18 changed files
with
1,330 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "orgparse" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bitflags = "2.1.0" | ||
derive_more = { version = "0.99.17", features = ["from"] } | ||
phf = {version = "0.11.1", features = ["macros"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
use crate::types::{Node, ParseOpts, Parseable, Result}; | ||
|
||
#[derive(Debug)] | ||
pub struct Block<'a> { | ||
name: &'a str, | ||
data: Option<&'a str>, | ||
contents: &'a str, | ||
} | ||
|
||
impl<'a> Parseable<'a> for Block<'a> { | ||
fn parse(byte_arr: &'a [u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::types::{Node, ParseOpts, Parseable, Result}; | ||
|
||
#[derive(Debug)] | ||
pub struct Comment<'a> { | ||
content: &'a str, | ||
} | ||
|
||
impl<'a> Parseable<'a> for Comment<'a> { | ||
fn parse(byte_arr: &'a [u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::types::{Node, ParseOpts, Parseable, Result}; | ||
|
||
// STARS KEYWORD PRIORITY TITLE TAGS | ||
#[derive(Debug)] | ||
pub struct Heading<'a> { | ||
level: u8, | ||
// Org-Todo type stuff | ||
keyword: Option<&'a str>, | ||
priority: Option<char>, | ||
title: Option<Vec<Node<'a>>>, | ||
} | ||
|
||
impl<'a> Parseable<'a> for Heading<'a> { | ||
fn parse(byte_arr: &'a [u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<'a> Heading<'a> { | ||
fn parse_stars() { | ||
todo!() | ||
} | ||
fn parse_keyword() { | ||
todo!() | ||
} | ||
fn parse_priority() { | ||
todo!() | ||
} | ||
fn parse_tag() { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::types::{Node, ParseOpts, Parseable, Result}; | ||
|
||
#[derive(Debug)] | ||
pub struct Keyword<'a> { | ||
key: &'a str, | ||
val: &'a str, | ||
} | ||
|
||
impl<'a> Parseable<'a> for Keyword<'a> { | ||
fn parse(byte_arr: &[u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
mod block; | ||
mod comment; | ||
mod heading; | ||
mod keyword; | ||
mod paragraph; | ||
|
||
pub use comment::Comment; | ||
pub use heading::Heading; | ||
pub use keyword::Keyword; | ||
pub use block::Block; | ||
pub use paragraph::Paragraph; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::types::{Node, ParseOpts, Parseable, Result}; | ||
|
||
#[derive(Debug)] | ||
pub struct Paragraph<'a> { | ||
pub contents: Vec<Node<'a>> | ||
} | ||
|
||
impl<'a> Parseable<'a> for Paragraph<'a> { | ||
fn parse(byte_arr: &'a [u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// use std::cell::RefCell; | ||
// use std::rc::Rc; | ||
// use Node::*; | ||
|
||
// use crate::constants::*; | ||
// use crate::types::{Match, MatchError, Node, ParseOpts, Parseable, Result}; | ||
// use crate::utils::{bytes_to_str, fn_until, word}; | ||
|
||
// #[derive(Debug)] | ||
// pub struct InlineSrc<'a> { | ||
// lang: &'a str, | ||
// headers: Option<&'a str>, | ||
// body: &'a str, | ||
// } | ||
|
||
// // pub fn create_node(node: Match<Node>) -> Match<Node> { | ||
// // return Match { | ||
// // obj: "meow", | ||
// // start: 1, | ||
// // end: 2 | ||
// // } | ||
// // } | ||
|
||
|
||
// impl<'a> Parseable<'a> for InlineSrc<'a> { | ||
// fn parse(byte_arr: &'a [u8], index: usize, parse_opts: ParseOpts) -> Result<Node> { | ||
// // TODO: cache this | ||
// let src_word = word(byte_arr, index, "src_")?; | ||
|
||
// let lang = fn_until(byte_arr, src_word.end, |chr: u8| { | ||
// !(chr == b'[' || chr == b'{' || chr.is_ascii_whitespace()) | ||
// })?; | ||
|
||
// match byte_arr[lang.end] { | ||
// LBRACE => { | ||
// let body = Self::parse_body(byte_arr, index)?; | ||
// Ok(ParseNode::new(Match { | ||
// obj: Node::InlineSrc(Self { | ||
// lang: lang.obj, | ||
// headers: None, | ||
// body: body.obj, | ||
// }), | ||
// start: index, | ||
// end: body.end, | ||
// })) | ||
|
||
// // Ok(ParseNode::new(Match { | ||
// // obj: InlineSrc { | ||
// // lang: "meow", | ||
// // headers: None, | ||
// // body: "cu,", | ||
// // }, | ||
// // start: 1, | ||
// // end: 5, | ||
// // })) | ||
// } | ||
// LBRACK => { | ||
// let header = Self::parse_header(byte_arr, lang.end)?; | ||
// if byte_arr[header.end] != LBRACE { | ||
// Err(MatchError) | ||
// } else { | ||
// let body = Self::parse_body(byte_arr, index)?; | ||
// Ok(ParseNode::new(Match { | ||
// obj: Node::InlineSrc(Self { | ||
// lang: lang.obj, | ||
// headers: Some(header.obj), | ||
// body: body.obj, | ||
// }), | ||
// start: index, | ||
// end: body.end, | ||
// })) | ||
// } | ||
// } | ||
// _ => return Err(MatchError), | ||
// } | ||
// } | ||
// } | ||
|
||
// impl<'a> InlineSrc<'a> { | ||
// // the logic is exactly the same, except for the perimeters | ||
// fn parse_header(byte_arr: &'a [u8], index: usize) -> Result<Match<&'a str>> { | ||
// InlineSrc::parse_src(byte_arr, index, LBRACK, RBRACK) | ||
// } | ||
// fn parse_body(byte_arr: &'a [u8], index: usize) -> Result<Match<&'a str>> { | ||
// InlineSrc::parse_src(byte_arr, index, LBRACE, RBRACE) | ||
// } | ||
// #[inline(always)] | ||
// fn parse_src( | ||
// byte_arr: &'a [u8], | ||
// index: usize, | ||
// lperim: u8, | ||
// rperim: u8, | ||
// ) -> Result<Match<&'a str>> { | ||
// // Brackets have to be balanced | ||
// // -1 for left bracket | ||
// // +1 for right bracket | ||
// let mut bracket_count: i32 = 0; | ||
|
||
// let mut j: usize = index; | ||
|
||
// loop { | ||
// match byte_arr[j] { | ||
// chr if chr == lperim => { | ||
// bracket_count -= 1; | ||
// } | ||
// chr if chr == rperim => { | ||
// bracket_count += 1; | ||
// if bracket_count == 0 { | ||
// let start = index; | ||
// let end = j + 1; | ||
// return Ok(Match { | ||
// obj: bytes_to_str(&byte_arr[start..end]), | ||
// start, | ||
// end, | ||
// }); | ||
// } | ||
// } | ||
// NEWLINE => { | ||
// return Err(MatchError); | ||
// } | ||
// _ => {} | ||
// } | ||
// j += 1; | ||
// } | ||
// } | ||
// } |
Oops, something went wrong.