[fine] Dump CSTs and an example zoo

This commit is contained in:
John Doty 2024-01-04 13:25:17 -08:00
parent 757db0ba3e
commit 1f6d7ec131
9 changed files with 357 additions and 32 deletions

View file

@ -0,0 +1,8 @@
use fine::parser::concrete::Tree;
use pretty_assertions::assert_eq;
fn assert_concrete(tree: &Tree, expected: &str) {
assert_eq!(tree.dump(), expected, "concrete syntax trees did not match");
}
include!(concat!(env!("OUT_DIR"), "/generated_tests.rs"));

View file

@ -0,0 +1,27 @@
// concrete:
// | File
// | ExpressionStatement
// | LiteralExpression
// | Number:'"42"'
// | Semicolon:'";"'
// | ExpressionStatement
// | BinaryExpression
// | BinaryExpression
// | LiteralExpression
// | Number:'"1"'
// | Star:'"*"'
// | LiteralExpression
// | Number:'"2"'
// | Plus:'"+"'
// | BinaryExpression
// | UnaryExpression
// | Minus:'"-"'
// | LiteralExpression
// | Number:'"3"'
// | Star:'"*"'
// | LiteralExpression
// | Number:'"4"'
// | Semicolon:'";"'
//
42;
1 * 2 + -3 * 4;