aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-31 13:23:32 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-31 13:23:32 -0600
commit9666eea62b8cf763027d1f01acbb403c1c6097e0 (patch)
treefb7f825089323ac8ef19203e7ff80f41156ce01b /src/makefile/token.rs
parent9d3e0824a0966c648e951e5928c241700ee931fb (diff)
downloadmakers-9666eea62b8cf763027d1f01acbb403c1c6097e0.tar.gz
makers-9666eea62b8cf763027d1f01acbb403c1c6097e0.zip
issuing correction on a previous post of mine, regarding pub(crate)
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r--src/makefile/token.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs
index 508a779..dee290e 100644
--- a/src/makefile/token.rs
+++ b/src/makefile/token.rs
@@ -13,29 +13,29 @@ use nom::{
};
#[derive(PartialEq, Eq, Clone, Debug)]
-pub(crate) struct TokenString(Vec<Token>);
+pub struct TokenString(Vec<Token>);
impl TokenString {
- pub(crate) fn text(text: impl Into<String>) -> Self {
+ pub fn text(text: impl Into<String>) -> Self {
Self(vec![Token::Text(text.into())])
}
- pub(crate) fn r#macro(name: impl Into<String>) -> Self {
+ pub fn r#macro(name: impl Into<String>) -> Self {
Self(vec![Token::MacroExpansion {
name: name.into(),
replacement: None,
}])
}
- pub(crate) fn tokens(&self) -> impl Iterator<Item = &Token> {
+ pub fn tokens(&self) -> impl Iterator<Item = &Token> {
self.0.iter()
}
- pub(crate) fn first_token_mut(&mut self) -> &mut Token {
+ pub fn first_token_mut(&mut self) -> &mut Token {
&mut self.0[0]
}
- pub(crate) fn split_once(&self, delimiter: char) -> Option<(Self, Self)> {
+ pub fn split_once(&self, delimiter: char) -> Option<(Self, Self)> {
let mut result0 = vec![];
let mut iter = self.0.iter();
while let Some(t) = iter.next() {
@@ -55,21 +55,21 @@ impl TokenString {
None
}
- pub(crate) fn starts_with(&self, pattern: &str) -> bool {
+ pub fn starts_with(&self, pattern: &str) -> bool {
match self.0.first() {
Some(Token::Text(t)) => t.starts_with(pattern),
_ => false,
}
}
- pub(crate) fn ends_with(&self, pattern: &str) -> bool {
+ pub fn ends_with(&self, pattern: &str) -> bool {
match self.0.last() {
Some(Token::Text(t)) => t.ends_with(pattern),
_ => false,
}
}
- pub(crate) fn strip_prefix(&mut self, suffix: &str) {
+ pub fn strip_prefix(&mut self, suffix: &str) {
if let Some(Token::Text(t)) = self.0.first_mut() {
if let Some(x) = t.strip_prefix(suffix) {
*t = x.into()
@@ -77,7 +77,7 @@ impl TokenString {
}
}
- pub(crate) fn strip_suffix(&mut self, suffix: &str) {
+ pub fn strip_suffix(&mut self, suffix: &str) {
if let Some(Token::Text(t)) = self.0.last_mut() {
if let Some(x) = t.strip_suffix(suffix) {
*t = x.into()
@@ -85,17 +85,17 @@ impl TokenString {
}
}
- pub(crate) fn extend(&mut self, other: Self) {
+ pub fn extend(&mut self, other: Self) {
self.0.extend(other.0);
}
- pub(crate) fn trim_start(&mut self) {
+ pub fn trim_start(&mut self) {
if let Some(Token::Text(t)) = self.0.first_mut() {
*t = t.trim_start().into();
}
}
- pub(crate) fn trim_end(&mut self) {
+ pub fn trim_end(&mut self) {
if let Some(Token::Text(t)) = self.0.last_mut() {
*t = t.trim_end().into();
}
@@ -112,7 +112,7 @@ impl fmt::Display for TokenString {
}
#[derive(PartialEq, Eq, Clone, Debug)]
-pub(crate) enum Token {
+pub enum Token {
Text(String),
MacroExpansion {
name: String,
@@ -251,7 +251,7 @@ fn full_text_tokens(input: &str) -> IResult<&str, TokenString> {
all_consuming(tokens_but_not(vec![]))(input)
}
-pub(crate) fn tokenize(input: &str) -> anyhow::Result<TokenString> {
+pub fn tokenize(input: &str) -> anyhow::Result<TokenString> {
let (_, result) = full_text_tokens(input)
.finish()
.map_err(|err| anyhow::anyhow!(err.to_string()))