mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:16 +01:00
Fix var underscores
This commit is contained in:
@@ -271,7 +271,7 @@ impl Parser {
|
||||
let is_valid = if start_pos == self.pos {
|
||||
ch.is_alphabetic() // First char has to be alphabetic
|
||||
} else {
|
||||
ch.is_alphanumeric() || ch == '-' || ch == '-'
|
||||
ch.is_alphanumeric() || ch == '-' || ch == '_'
|
||||
};
|
||||
if is_valid {
|
||||
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]
|
||||
fn var_prefixes() {
|
||||
let mut p = Parser::new("${[ -a ]}${[ _a ]}${[ 0a ]}");
|
||||
|
||||
Reference in New Issue
Block a user