aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-07 13:14:31 +0100
committerJonas Maier <>2026-03-07 13:14:31 +0100
commit4f9c061a348547a77635cde495ed21969efb3cc7 (patch)
treeb434c02d9ce4ac545fadfdc06a3aa867d74b05d2 /src
parent40375251d9ee63e454fc47c23fd435ac479888ae (diff)
downloadpish-4f9c061a348547a77635cde495ed21969efb3cc7.tar.gz
can parse $0 $1 etc
Diffstat (limited to 'src')
-rw-r--r--src/parse/mod.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index cec9551..853580d 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -359,7 +359,7 @@ fn is_symbol(x: u8) -> bool {
}
fn is_var_begin(x: u8) -> bool {
- x.is_ascii_alphabetic()
+ x.is_ascii_alphanumeric()
}
fn is_var_name(x: u8) -> bool {
x.is_ascii_alphanumeric() || x == b'_'
@@ -376,11 +376,19 @@ impl Parse for VarName {
return Err(ParseError::Eof);
}
+ let mut name = BString::new();
+
+ if b.peek().is_ascii_digit() {
+ while b.has() && b.peek().is_ascii_digit() {
+ name.push(b.adv());
+ }
+ return Ok(Self { name });
+ }
+
if !is_var_begin(b.peek()) {
return Err(ParseError::ExpectedAlphabetic);
}
- let mut name = BString::new();
while b.has() {
let x = b.peek();
if is_var_name(x) {