add integer support to parser

This commit is contained in:
Alain Zscheile 2023-05-20 00:52:51 +02:00
parent 579662c69d
commit a76dc04211

View file

@ -38,6 +38,7 @@ pub enum CodeObject {
ret: Option<Statement>,
},
Alias(Identifier),
Integer(i64),
}
#[derive(Clone, Debug)]
@ -211,9 +212,16 @@ impl CodeObject {
ret,
})
} else if !cfe {
// we have no proper recursive delimiting, so just resort to the parsing which we
// also do for other such items, expect a single code object descriptor => alias.
Identifier::parse_step_high(ctx).map(CodeObject::Alias)
// we have no proper recursive delimiting,
// so just resort to the parsing which we also do for other such items,
// expect a single code object descriptor => alias, or number.
if let Some((_, Token::Integer(i))) =
ctx.pklx.next_if(|(_, t)| matches!(t, Token::Integer(_)))
{
Ok(CodeObject::Integer(i))
} else {
Identifier::parse_step_high(ctx).map(CodeObject::Alias)
}
} else {
Err(match ctx.pklx.next() {
Some((loc, _)) => Error {