wgsl-parser 0.5.0

A zero-copy recursive-descent parser for WebGPU shading language
Documentation
use snapshot::{begin_snapshots, snapshot, snapshot_test};

use crate::{
	utils::{WithComments, WithTokens},
	SyntaxTree,
};

begin_snapshots!();

#[snapshot_test]
fn line_comment() {
	snapshot!(SyntaxTree(WithComments, WithTokens) r#"
		// Here's a line comment
		const PI: f32 = 3.14159;
	"#);

	snapshot!(SyntaxTree(WithComments, WithTokens) r#"
		// Here is
		// a sequence
		// of line comments
		// back to back
		const PI: f32 = 3.14159; // And here's another
		// for good measure
		//
	"#);
}

#[snapshot_test]
fn block_comment() {
	snapshot!(SyntaxTree(WithComments, WithTokens) r#"
		/*
		Here's a block comment
		it spans
		a few lines
		*/
		const PI: f32 = 3.14159;
	"#);

	snapshot!(SyntaxTree(WithComments, WithTokens) "/**/");

	snapshot!(SyntaxTree(WithComments, WithTokens) r#"
		/*
		Here's a /* nested block comment */
		it spans // (this is not a nested comment)
		a few lines
		*/
		const PI: f32 = 3.14159;
	"#);
}