pub use pp_rs::token::{Float, Integer, Location, Token as PPToken};
use super::ast::Precision;
use crate::{Interpolation, Sampling, Span, Type};
impl From<Location> for Span {
fn from(loc: Location) -> Self {
Span::new(loc.start, loc.end)
}
}
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub struct Token {
pub value: TokenValue,
pub meta: Span,
}
#[derive(Clone, Debug, PartialEq)]
pub enum TokenValue {
Identifier(String),
FloatConstant(Float),
IntConstant(Integer),
BoolConstant(bool),
Layout,
In,
Out,
InOut,
Uniform,
Buffer,
Const,
Shared,
Restrict,
MemoryQualifier(crate::StorageAccess),
Invariant,
Interpolation(Interpolation),
Sampling(Sampling),
Precision,
PrecisionQualifier(Precision),
Continue,
Break,
Return,
Discard,
If,
Else,
Switch,
Case,
Default,
While,
Do,
For,
Void,
Struct,
TypeName(Type),
Assign,
AddAssign,
SubAssign,
MulAssign,
DivAssign,
ModAssign,
LeftShiftAssign,
RightShiftAssign,
AndAssign,
XorAssign,
OrAssign,
Increment,
Decrement,
LogicalOr,
LogicalAnd,
LogicalXor,
LessEqual,
GreaterEqual,
Equal,
NotEqual,
LeftShift,
RightShift,
LeftBrace,
RightBrace,
LeftParen,
RightParen,
LeftBracket,
RightBracket,
LeftAngle,
RightAngle,
Comma,
Semicolon,
Colon,
Dot,
Bang,
Dash,
Tilde,
Plus,
Star,
Slash,
Percent,
VerticalBar,
Caret,
Ampersand,
Question,
}
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub struct Directive {
pub kind: DirectiveKind,
pub tokens: Vec<PPToken>,
}
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub enum DirectiveKind {
Version { is_first_directive: bool },
Extension,
Pragma,
}