build(rust): vendor rnix parser crate

This commit was merged in pull request #57.
This commit is contained in:
2026-09-16 15:51:43 -04:00
parent cbdf482422
commit 82ad65a3a4
492 changed files with 67785 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
use crate::ast::{self, support::*};
// this is a separate type because it mixes tokens and nodes
// for example, a Str is a node because it can contain nested subexpressions but an Integer is a token.
// This means that we have to write it out manually instead of using the macro to create the type for us.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum LiteralKind {
Float(ast::Float),
Integer(ast::Integer),
Uri(ast::Uri),
}
impl ast::Literal {
pub fn kind(&self) -> LiteralKind {
if let Some(it) = token(self) {
return LiteralKind::Float(it);
}
if let Some(it) = token(self) {
return LiteralKind::Integer(it);
}
if let Some(it) = token(self) {
return LiteralKind::Uri(it);
}
unreachable!()
}
}