mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 16:48:30 +02:00
Fix var underscores
This commit is contained in:
@@ -271,7 +271,7 @@ impl Parser {
|
|||||||
let is_valid = if start_pos == self.pos {
|
let is_valid = if start_pos == self.pos {
|
||||||
ch.is_alphabetic() // First char has to be alphabetic
|
ch.is_alphabetic() // First char has to be alphabetic
|
||||||
} else {
|
} else {
|
||||||
ch.is_alphanumeric() || ch == '-' || ch == '-'
|
ch.is_alphanumeric() || ch == '-' || ch == '_'
|
||||||
};
|
};
|
||||||
if is_valid {
|
if is_valid {
|
||||||
text.push(ch);
|
text.push(ch);
|
||||||
@@ -441,6 +441,20 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn var_underscores() {
|
||||||
|
let mut p = Parser::new("${[ a_b ]}");
|
||||||
|
assert_eq!(
|
||||||
|
p.parse().tokens,
|
||||||
|
vec![
|
||||||
|
Token::Tag {
|
||||||
|
val: Val::Var { name: "a_b".into() }
|
||||||
|
},
|
||||||
|
Token::Eof
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn var_prefixes() {
|
fn var_prefixes() {
|
||||||
let mut p = Parser::new("${[ -a ]}${[ _a ]}${[ 0a ]}");
|
let mut p = Parser::new("${[ -a ]}${[ _a ]}${[ 0a ]}");
|
||||||
|
|||||||
Reference in New Issue
Block a user