aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/parser.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-22 15:55:25 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-22 15:55:25 +0100
commitb4a779f040f18257fde1c357626461ab187490db (patch)
treeff4006cff95e0048a6c2816678a640ca0891fe60 /lib/xixanta/src/parser.rs
parente3e54cfee6ebc17281bbbf906ff9035f594313cd (diff)
downloadtools.nes-b4a779f040f18257fde1c357626461ab187490db.tar.gz
tools.nes-b4a779f040f18257fde1c357626461ab187490db.zip
Remove dependency to the rand crate
This dependency was easily avoidable and it brought with it a lot of inner dependencies of its own, most notably 'zerocopy-derive', which forbid us to compile the affected programs purely statically. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/parser.rs')
-rw-r--r--lib/xixanta/src/parser.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index 0a4d2b8..d508003 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -1,7 +1,6 @@
use crate::node::{ControlType, NodeBodyType, NodeType, OperationType, PNode, PString};
use crate::opcodes::{CONTROL_FUNCTIONS, INSTRUCTIONS};
use crate::{Error, SourceInfo};
-use rand::distributions::{Alphanumeric, DistString};
use std::cmp::Ordering;
use std::io::{self, BufRead, Read};
use std::path;
@@ -61,6 +60,12 @@ pub struct Parser {
/// look ahead to know where the literal ends before dealing with further
/// operators.
look_ahead_index: usize,
+
+ /// Number that keeps track of random identifiers being generated so far.
+ /// This is because certain anonymous identifiers are not to be exposed to
+ /// the human eye, and we just care about them being unique. Hence this
+ /// counter.
+ generated_identifiers: usize,
}
impl Parser {
@@ -1338,8 +1343,10 @@ impl Parser {
}
// Generate a unique identifier with the given prefix.
- fn unique_identifier(&self, prefix: String) -> String {
- prefix + &String::from("-") + &Alphanumeric.sample_string(&mut rand::thread_rng(), 16)
+ fn unique_identifier(&mut self, prefix: String) -> String {
+ let res = prefix + &String::from("-") + &self.generated_identifiers.to_string();
+ self.generated_identifiers += 1;
+ res
}
// Returns a NodeType::Control node with whatever could be parsed