build(rust): vendor rnix parser crate
This commit was merged in pull request #57.
This commit is contained in:
29
third_party/crates/rnix-0.14.0/src/ast/expr_ext.rs
vendored
Normal file
29
third_party/crates/rnix-0.14.0/src/ast/expr_ext.rs
vendored
Normal 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!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user