Give identifier and int ast types

This commit is contained in:
Jeong YunWon 2023-05-10 19:17:11 +09:00
parent d495cd9129
commit 455bcc01a0
88 changed files with 3288 additions and 2300 deletions

View file

@ -1,5 +1,5 @@
use crate::attributed::Attributed;
use rustpython_parser_core::source_code::{SourceLocator, SourceRange};
use crate::builtin::Attributed;
use rustpython_parser_core::source_code::{SourceLocation, SourceLocator, SourceRange};
impl crate::fold::Fold<()> for SourceLocator<'_> {
type TargetU = SourceRange;
@ -23,3 +23,17 @@ impl crate::fold::Fold<()> for SourceLocator<'_> {
})
}
}
impl<T> Attributed<T, SourceRange> {
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn location(&self) -> SourceLocation {
self.custom.start
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end_location(&self) -> Option<SourceLocation> {
self.custom.end
}
}