Skip to main content

Crate wgslift_syntax

Crate wgslift_syntax 

Source
Expand description

The front end of wgslift: an HLSL preprocessor, lexer and parser.

It turns HLSL source text into a syntax tree with source spans. It does no type checking and no translation; the wgslift crate does that on top of this tree.

let parsed = wgslift_syntax::parse("main.hlsl", "float4 tint : register(c0);", Default::default());
assert!(!parsed.has_errors());
assert_eq!(parsed.unit.items.len(), 1);

Re-exports§

pub use ast::TranslationUnit;
pub use diagnostic::Diagnostic;
pub use diagnostic::Severity;
pub use lexer::Punct;
pub use lexer::Token;
pub use lexer::TokenKind;
pub use pp::IncludeResolver;
pub use pp::NoIncludes;
pub use span::FileId;
pub use span::SourceFile;
pub use span::SourceFiles;
pub use span::Span;

Modules§

ast
The syntax tree. Every node has the span of the source text it came from.
diagnostic
Errors and warnings with the source span they refer to.
lexer
Splits source text into tokens.
parser
The parser: preprocessed tokens to a syntax tree.
pp
The C-style preprocessor: macros, conditional blocks and includes.
span
Source files and byte spans into them.

Structs§

Options
Settings for one parse.
Parsed
The result of a parse.

Functions§

parse
Preprocesses and parses the HLSL source text. name is the file name in diagnostics.
parse_into
Like parse, but adds the files to files, so the spans of several parses share one file table.