aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/args.rs34
-rw-r--r--src/makefile/command_line.rs6
-rw-r--r--src/makefile/conditional.rs14
-rw-r--r--src/makefile/functions.rs24
-rw-r--r--src/makefile/inference_rules.rs8
-rw-r--r--src/makefile/macro.rs29
-rw-r--r--src/makefile/mod.rs14
-rw-r--r--src/makefile/pattern.rs2
-rw-r--r--src/makefile/target.rs14
-rw-r--r--src/makefile/token.rs30
10 files changed, 84 insertions, 91 deletions
diff --git a/src/args.rs b/src/args.rs
index 134f785..4f36c03 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -8,11 +8,11 @@ use structopt::StructOpt;
#[derive(StructOpt, Debug, PartialEq, Eq, Clone)]
#[structopt(author, about)]
#[allow(clippy::struct_excessive_bools)]
-pub(crate) struct Args {
+pub struct Args {
/// Cause environment variables, including those with null values, to override macro
/// assignments within makefiles.
#[structopt(short, long)]
- pub(crate) environment_overrides: bool,
+ pub environment_overrides: bool,
/// Specify a different makefile (or '-' for standard input).
///
@@ -28,14 +28,14 @@ pub(crate) struct Args {
number_of_values = 1,
parse(from_os_str)
)]
- pub(crate) makefile: Vec<PathBuf>,
+ pub makefile: Vec<PathBuf>,
/// Ignore error codes returned by invoked commands.
///
/// This mode is the same as if the special target .IGNORE were specified without
/// prerequisites.
#[structopt(short, long)]
- pub(crate) ignore_errors: bool,
+ pub ignore_errors: bool,
/// Continue to update other targets that do not depend on the current target if a
/// non-ignored error occurs while executing the commands to bring a target
@@ -46,7 +46,7 @@ pub(crate) struct Args {
overrides_with = "keep-going",
overrides_with = "no-keep-going"
)]
- pub(crate) keep_going: bool,
+ pub keep_going: bool,
/// Write commands that would be executed on standard output, but do not execute them
/// (but execute lines starting with '+').
@@ -60,14 +60,14 @@ pub(crate) struct Args {
visible_alias = "just-print",
visible_alias = "recon"
)]
- pub(crate) dry_run: bool,
+ pub dry_run: bool,
/// Write to standard output the complete set of macro definitions and target
/// descriptions.
///
/// The output format is unspecified.
#[structopt(short, long, visible_alias = "print-data-base")]
- pub(crate) print_everything: bool,
+ pub print_everything: bool,
/// Return a zero exit value if the target file is up-to-date; otherwise, return an
/// exit value of 1.
@@ -76,11 +76,11 @@ pub(crate) struct Args {
/// command line (associated with the targets) with a <plus-sign> ( '+' ) prefix
/// shall be executed.
#[structopt(short, long)]
- pub(crate) question: bool,
+ pub question: bool,
/// Clear the suffix list and do not use the built-in rules.
#[structopt(short = "r", long)]
- pub(crate) no_builtin_rules: bool,
+ pub no_builtin_rules: bool,
/// Terminate make if an error occurs while executing the commands to bring a target
/// up-to-date (default behavior, required by POSIX to be also a flag for some
@@ -95,7 +95,7 @@ pub(crate) struct Args {
overrides_with = "keep-going",
overrides_with = "no-keep-going"
)]
- pub(crate) no_keep_going: bool,
+ pub no_keep_going: bool,
/// Do not write makefile command lines or touch messages to standard output before
/// executing.
@@ -103,7 +103,7 @@ pub(crate) struct Args {
/// This mode shall be the same as if the special target .SILENT were specified
/// without prerequisites.
#[structopt(short, long, visible_alias = "quiet")]
- pub(crate) silent: bool,
+ pub silent: bool,
/// Update the modification time of each target as though a touch target had been
/// executed.
@@ -114,14 +114,14 @@ pub(crate) struct Args {
/// the makefile command lines associated with each target are not executed. However,
/// a command line with a <plus-sign> ( '+' ) prefix shall be executed.
#[structopt(short, long)]
- pub(crate) touch: bool,
+ pub touch: bool,
/// Target names or macro definitions.
///
/// If no target is specified, while make is processing the makefiles, the first
/// target that make encounters that is not a special target or an inference rule
/// shall be used.
- pub(crate) targets_or_macros: Vec<String>,
+ pub targets_or_macros: Vec<String>,
}
impl Args {
@@ -159,24 +159,24 @@ impl Args {
Self::from_iter(args)
}
- pub(crate) fn from_env_and_args() -> Self {
+ pub fn from_env_and_args() -> Self {
let env_makeflags = env::var("MAKEFLAGS").unwrap_or_default();
let args = env::args_os();
Self::from_given_args_and_given_env(args, env_makeflags)
}
#[cfg(test)]
- pub(crate) fn empty() -> Self {
+ pub fn empty() -> Self {
let env_makeflags = String::new();
let args = vec![OsString::from("makers")];
Self::from_given_args_and_given_env(args.into_iter(), env_makeflags)
}
- pub(crate) fn targets(&self) -> impl Iterator<Item = &String> {
+ pub fn targets(&self) -> impl Iterator<Item = &String> {
self.targets_or_macros.iter().filter(|x| !x.contains('='))
}
- pub(crate) fn macros(&self) -> impl Iterator<Item = &String> {
+ pub fn macros(&self) -> impl Iterator<Item = &String> {
self.targets_or_macros.iter().filter(|x| x.contains('='))
}
}
diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs
index fd1ef97..050488c 100644
--- a/src/makefile/command_line.rs
+++ b/src/makefile/command_line.rs
@@ -26,7 +26,7 @@ fn execute_command_line(command_line: &str, ignore_errors: bool) -> Result<ExitS
}
#[derive(PartialEq, Eq, Clone, Debug)]
-pub(crate) struct CommandLine {
+pub struct CommandLine {
/// If the command prefix contains a <hyphen-minus>, or the -i option is present, or
/// the special target .IGNORE has either the current target as a prerequisite or has
/// no prerequisites, any error found while executing the command shall be ignored.
@@ -43,7 +43,7 @@ pub(crate) struct CommandLine {
}
impl CommandLine {
- pub(crate) fn from(mut line: TokenString) -> Self {
+ pub fn from(mut line: TokenString) -> Self {
let mut ignore_errors = false;
let mut silent = false;
let mut always_execute = false;
@@ -69,7 +69,7 @@ impl CommandLine {
}
}
- pub(crate) fn execute(&self, file: &Makefile, target: &Target) -> anyhow::Result<()> {
+ pub fn execute(&self, file: &Makefile, target: &Target) -> anyhow::Result<()> {
let ignore_error = self.ignore_errors
|| file.args.ignore_errors
|| file.special_target_has_prereq(".IGNORE", &target.name);
diff --git a/src/makefile/conditional.rs b/src/makefile/conditional.rs
index bf373bd..a3c3e0d 100644
--- a/src/makefile/conditional.rs
+++ b/src/makefile/conditional.rs
@@ -1,6 +1,6 @@
use super::token::TokenString;
-pub(crate) enum ConditionalLine {
+pub enum ConditionalLine {
/// spelled "ifeq"
IfEqual(TokenString, TokenString),
/// spelled "ifneq"
@@ -17,7 +17,7 @@ pub(crate) enum ConditionalLine {
EndIf,
}
-pub(crate) enum ConditionalState {
+pub enum ConditionalState {
/// we saw a conditional, the condition was true, we're executing now
/// and if we hit an else we will start SkippingUntilEndIf
Executing,
@@ -32,7 +32,7 @@ pub(crate) enum ConditionalState {
}
impl ConditionalState {
- pub(crate) const fn skipping(&self) -> bool {
+ pub const fn skipping(&self) -> bool {
match self {
Self::Executing => false,
Self::SkippingUntilElseOrEndIf | Self::SkippingUntilEndIf => true,
@@ -40,14 +40,14 @@ impl ConditionalState {
}
}
-pub(crate) enum ConditionalStateAction {
+pub enum ConditionalStateAction {
Push(ConditionalState),
Replace(ConditionalState),
Pop,
}
impl ConditionalStateAction {
- pub(crate) fn apply_to(self, stack: &mut Vec<ConditionalState>) {
+ pub fn apply_to(self, stack: &mut Vec<ConditionalState>) {
match self {
Self::Push(state) => stack.push(state),
Self::Replace(state) => match stack.last_mut() {
@@ -78,7 +78,7 @@ fn decode_condition_args(line_body: &str) -> Option<(TokenString, TokenString)>
}
impl ConditionalLine {
- pub(crate) fn from(
+ pub fn from(
line: &str,
expand_macro: impl Fn(&TokenString) -> anyhow::Result<String>,
) -> anyhow::Result<Option<Self>> {
@@ -110,7 +110,7 @@ impl ConditionalLine {
}))
}
- pub(crate) fn action(
+ pub fn action(
&self,
current_state: Option<&ConditionalState>,
is_macro_defined: impl Fn(&str) -> bool,
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index 880ee7f..c73d7e7 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -2,11 +2,7 @@ use super::pattern::r#match;
use super::r#macro::{MacroSet, MacroSource};
use super::token::TokenString;
-pub(crate) fn expand_call(
- name: &str,
- args: &[TokenString],
- macros: &MacroSet,
-) -> anyhow::Result<String> {
+pub fn expand_call(name: &str, args: &[TokenString], macros: &MacroSet) -> anyhow::Result<String> {
match name {
"filter" => {
assert_eq!(args.len(), 2);
@@ -67,7 +63,7 @@ mod text {
use super::MacroSet;
use super::TokenString;
- pub(crate) fn filter(
+ pub fn filter(
macros: &MacroSet,
patterns: &TokenString,
text: &TokenString,
@@ -88,7 +84,7 @@ mod text {
Ok(result_pieces.join(" "))
}
- pub(crate) fn filter_out(
+ pub fn filter_out(
macros: &MacroSet,
patterns: &TokenString,
text: &TokenString,
@@ -109,7 +105,7 @@ mod text {
Ok(result_pieces.join(" "))
}
- pub(crate) fn sort(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
+ pub fn sort(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
let words = macros.expand(words)?;
let mut words = words.split_whitespace().collect::<Vec<_>>();
words.sort_unstable();
@@ -129,7 +125,7 @@ mod file_name {
use super::MacroSet;
use super::TokenString;
- pub(crate) fn notdir(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
+ pub fn notdir(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
let words = macros.expand(words)?;
let words = words
.split_whitespace()
@@ -143,7 +139,7 @@ mod file_name {
Ok(words.join(" "))
}
- pub(crate) fn basename(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
+ pub fn basename(macros: &MacroSet, words: &TokenString) -> anyhow::Result<String> {
let words = macros.expand(words)?;
let words = words
.split_whitespace()
@@ -157,7 +153,7 @@ mod file_name {
Ok(words.join(" "))
}
- pub(crate) fn addprefix(
+ pub fn addprefix(
macros: &MacroSet,
prefix: &TokenString,
targets: &TokenString,
@@ -171,7 +167,7 @@ mod file_name {
Ok(results.join(" "))
}
- pub(crate) fn wildcard(macros: &MacroSet, pattern: &TokenString) -> anyhow::Result<String> {
+ pub fn wildcard(macros: &MacroSet, pattern: &TokenString) -> anyhow::Result<String> {
let pattern = macros.expand(pattern)?;
let home_dir = env::var("HOME")
.ok()
@@ -198,7 +194,7 @@ mod foreach {
use super::MacroSource;
use super::TokenString;
- pub(crate) fn foreach(
+ pub fn foreach(
macros: &MacroSet,
var: &TokenString,
list: &TokenString,
@@ -225,7 +221,7 @@ mod call {
use super::MacroSource;
use super::TokenString;
- pub(crate) fn call<'a>(
+ pub fn call<'a>(
macros: &MacroSet,
args: impl Iterator<Item = &'a TokenString>,
) -> anyhow::Result<String> {
diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs
index 397008b..3d18730 100644
--- a/src/makefile/inference_rules.rs
+++ b/src/makefile/inference_rules.rs
@@ -3,12 +3,12 @@ use std::fmt;
use crate::makefile::command_line::CommandLine;
#[derive(PartialEq, Eq, Clone, Debug)]
-pub(crate) struct InferenceRule {
+pub struct InferenceRule {
/// POSIX calls this ".s1" but that's not useful.
- pub(crate) product: String,
+ pub product: String,
/// POSIX calls this ".s2" but that's not useful.
- pub(crate) prereq: String,
- pub(crate) commands: Vec<CommandLine>,
+ pub prereq: String,
+ pub commands: Vec<CommandLine>,
}
impl fmt::Display for InferenceRule {
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs
index 88397c5..0b7a27d 100644
--- a/src/makefile/macro.rs
+++ b/src/makefile/macro.rs
@@ -9,26 +9,26 @@ use super::functions;
use super::token::{Token, TokenString};
#[derive(Debug, Clone)]
-pub(crate) enum MacroSource {
+pub enum MacroSource {
File,
CommandLineOrMakeflags,
Environment,
Builtin,
}
-pub(crate) trait LookupInternal: for<'a> Fn(&'a str) -> anyhow::Result<String> {}
+pub trait LookupInternal: for<'a> Fn(&'a str) -> anyhow::Result<String> {}
impl<F: for<'a> Fn(&'a str) -> anyhow::Result<String>> LookupInternal for F {}
#[derive(Clone)]
-pub(crate) struct MacroSet<'parent, 'lookup> {
+pub struct MacroSet<'parent, 'lookup> {
parent: Option<&'parent MacroSet<'parent, 'lookup>>,
data: HashMap<String, (MacroSource, TokenString)>,
lookup_internal: Option<&'lookup dyn LookupInternal>,
}
impl<'parent, 'lookup> MacroSet<'parent, 'lookup> {
- pub(crate) fn new() -> Self {
+ pub fn new() -> Self {
Self {
parent: None,
data: HashMap::new(),
@@ -36,13 +36,13 @@ impl<'parent, 'lookup> MacroSet<'parent, 'lookup> {
}
}
- pub(crate) fn add_builtins(&mut self) {
+ pub fn add_builtins(&mut self) {
for (k, v) in builtins() {
self.data.insert(k.into(), (MacroSource::Builtin, v));
}
}
- pub(crate) fn add_env(&mut self) {
+ pub fn add_env(&mut self) {
for (k, v) in env::vars() {
if k != "MAKEFLAGS" && k != "SHELL" {
self.data
@@ -61,26 +61,26 @@ impl<'parent, 'lookup> MacroSet<'parent, 'lookup> {
}
}
- pub(crate) fn get(&self, name: &str) -> Option<&(MacroSource, TokenString)> {
+ pub fn get(&self, name: &str) -> Option<&(MacroSource, TokenString)> {
self.data
.get(name)
.or_else(|| self.parent.and_then(|parent| parent.get(name)))
}
- pub(crate) fn set(&mut self, name: String, source: MacroSource, text: TokenString) {
+ pub fn set(&mut self, name: String, source: MacroSource, text: TokenString) {
self.data.insert(name, (source, text));
}
- pub(crate) fn is_defined(&self, name: &str) -> bool {
+ pub fn is_defined(&self, name: &str) -> bool {
self.data.contains_key(name)
}
// `remove` is fine, but I think for "remove-and-return" `pop` is better
- pub(crate) fn pop(&mut self, name: &str) -> Option<(MacroSource, TokenString)> {
+ pub fn pop(&mut self, name: &str) -> Option<(MacroSource, TokenString)> {
self.data.remove(name)
}
- pub(crate) fn expand(&self, text: &TokenString) -> anyhow::Result<String> {
+ pub fn expand(&self, text: &TokenString) -> anyhow::Result<String> {
let mut result = String::new();
for token in text.tokens() {
match token {
@@ -121,10 +121,7 @@ impl<'parent, 'lookup> MacroSet<'parent, 'lookup> {
Ok(result)
}
- pub(crate) fn with_lookup<'l, 's: 'l>(
- &'s self,
- lookup: &'l dyn LookupInternal,
- ) -> MacroSet<'s, 'l> {
+ pub fn with_lookup<'l, 's: 'l>(&'s self, lookup: &'l dyn LookupInternal) -> MacroSet<'s, 'l> {
MacroSet {
parent: Some(self),
data: HashMap::new(),
@@ -132,7 +129,7 @@ impl<'parent, 'lookup> MacroSet<'parent, 'lookup> {
}
}
- pub(crate) fn with_overlay<'s>(&'s self) -> MacroSet<'s, 'lookup> {
+ pub fn with_overlay<'s>(&'s self) -> MacroSet<'s, 'lookup> {
MacroSet {
parent: Some(self),
data: HashMap::new(),
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index 270dd46..d9c9b46 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -85,17 +85,17 @@ fn inference_match<'a>(
}
}
-pub(crate) struct Makefile<'a> {
+pub struct Makefile<'a> {
inference_rules: Vec<InferenceRule>,
macros: MacroSet<'static, 'static>,
targets: RefCell<HashMap<String, Rc<RefCell<Target>>>>,
- pub(crate) first_non_special_target: Option<String>,
+ pub first_non_special_target: Option<String>,
args: &'a Args,
// TODO borrow warnings from Python version
}
impl<'a> Makefile<'a> {
- pub(crate) fn new(args: &'a Args) -> Self {
+ pub fn new(args: &'a Args) -> Self {
let mut inference_rules = vec![];
let mut macros = MacroSet::new();
let mut targets = HashMap::new();
@@ -132,7 +132,7 @@ impl<'a> Makefile<'a> {
}
}
- pub(crate) fn and_read_file(&mut self, path: impl AsRef<Path>) -> anyhow::Result<()> {
+ pub fn and_read_file(&mut self, path: impl AsRef<Path>) -> anyhow::Result<()> {
let file = File::open(path);
// TODO handle errors
let file = file.context("couldn't open makefile!")?;
@@ -140,7 +140,7 @@ impl<'a> Makefile<'a> {
self.and_read(file_reader)
}
- pub(crate) fn and_read(&mut self, source: impl BufRead) -> anyhow::Result<()> {
+ pub fn and_read(&mut self, source: impl BufRead) -> anyhow::Result<()> {
let mut lines_iter = source
.lines()
.enumerate()
@@ -416,7 +416,7 @@ impl<'a> Makefile<'a> {
}
}
- pub(crate) fn get_target(&self, name: &str) -> anyhow::Result<Rc<RefCell<Target>>> {
+ pub fn get_target(&self, name: &str) -> anyhow::Result<Rc<RefCell<Target>>> {
// TODO implement .POSIX
let follow_gnu = true;
@@ -514,7 +514,7 @@ impl<'a> Makefile<'a> {
Ok(targets.get(name).context("Target not found!")?.clone())
}
- pub(crate) fn update_target(&self, name: &str) -> anyhow::Result<()> {
+ pub fn update_target(&self, name: &str) -> anyhow::Result<()> {
self.get_target(name)?.borrow().update(self)
}
diff --git a/src/makefile/pattern.rs b/src/makefile/pattern.rs
index e4077cd..6648851 100644
--- a/src/makefile/pattern.rs
+++ b/src/makefile/pattern.rs
@@ -24,7 +24,7 @@ fn compile_pattern(pattern: &str) -> anyhow::Result<Regex> {
Ok(Regex::new(&result)?)
}
-pub(crate) fn r#match<'a>(pattern: &str, text: &'a str) -> anyhow::Result<Option<Captures<'a>>> {
+pub fn r#match<'a>(pattern: &str, text: &'a str) -> anyhow::Result<Option<Captures<'a>>> {
Ok(compile_pattern(pattern)?.captures(text))
}
diff --git a/src/makefile/target.rs b/src/makefile/target.rs
index 04603c9..64fdb7d 100644
--- a/src/makefile/target.rs
+++ b/src/makefile/target.rs
@@ -8,11 +8,11 @@ use crate::makefile::command_line::CommandLine;
use super::Makefile;
#[derive(PartialEq, Eq, Clone, Debug)]
-pub(crate) struct Target {
- pub(crate) name: String,
- pub(crate) prerequisites: Vec<String>,
- pub(crate) commands: Vec<CommandLine>,
- pub(crate) already_updated: Cell<bool>,
+pub struct Target {
+ pub name: String,
+ pub prerequisites: Vec<String>,
+ pub commands: Vec<CommandLine>,
+ pub already_updated: Cell<bool>,
}
impl Target {
@@ -22,7 +22,7 @@ impl Target {
.ok()
}
- pub(crate) fn newer_than(&self, other: &Self) -> Option<bool> {
+ pub fn newer_than(&self, other: &Self) -> Option<bool> {
let self_updated = self.already_updated.get();
let other_updated = other.already_updated.get();
Some(match (self.modified_time(), other.modified_time()) {
@@ -50,7 +50,7 @@ impl Target {
exists && newer_than_all_dependencies
}
- pub(crate) fn update(&self, file: &Makefile) -> anyhow::Result<()> {
+ pub fn update(&self, file: &Makefile) -> anyhow::Result<()> {
for prereq in &self.prerequisites {
file.update_target(prereq)?;
}
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()))