mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 10:34:08 +02:00
make bool handling case insensitive
This commit is contained in:
parent
a19ce28d07
commit
575d5be572
2 changed files with 9 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ use logos::Logos;
|
|||
pub enum Token {
|
||||
#[token("array")]
|
||||
Array,
|
||||
#[regex("true|false")]
|
||||
#[regex("(?i:true|false)")]
|
||||
Bool,
|
||||
#[regex("null")]
|
||||
Null,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,13 @@ pub fn parse_lexer<'source>(
|
|||
])
|
||||
.with_span(lexer.span(), source)?;
|
||||
let value = match token {
|
||||
Token::Bool => Value::Bool(lexer.slice().parse().with_span(lexer.span(), source)?),
|
||||
Token::Bool => Value::Bool(
|
||||
lexer
|
||||
.slice()
|
||||
.to_ascii_lowercase()
|
||||
.parse()
|
||||
.with_span(lexer.span(), source)?,
|
||||
),
|
||||
Token::Integer => Value::Int(parse_int(lexer.slice()).with_span(lexer.span(), source)?),
|
||||
Token::Float => Value::Float(lexer.slice().parse().with_span(lexer.span(), source)?),
|
||||
Token::LiteralString => {
|
||||
|
|
@ -282,4 +288,5 @@ fn test_parse() {
|
|||
assert_eq!(Value::Int(26), parse(r#"0x1A"#).unwrap());
|
||||
assert_eq!(Value::Int(3), parse(r#"0b11"#).unwrap());
|
||||
assert_eq!(Value::Int(12345), parse(r#"12_34_5"#).unwrap());
|
||||
assert_eq!(Value::Bool(true), parse(r#"True"#).unwrap());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue