fix: make tree-sitter grammar regenerable
This commit is contained in:
parent
6a0318bcb5
commit
083e3946e6
416
grammar.js
416
grammar.js
|
|
@ -1,16 +1,68 @@
|
||||||
/// <reference types="tree-sitter-cli/dsl" />
|
/// <reference types="tree-sitter-cli/dsl" />
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waltzing Template Engine - Tree-sitter Grammar
|
||||||
|
*
|
||||||
|
* VALIDATION RULES (enforced by the compiler, not this grammar):
|
||||||
|
*
|
||||||
|
* 1. Reserved variable names - Variables named `__wtz_target` or `out` declared
|
||||||
|
* via `@let` are not allowed. This includes:
|
||||||
|
* - Direct @let declarations: @let out = "value"
|
||||||
|
* - For loop iterators: @for out in items
|
||||||
|
* - Tuple patterns: @for (a, out) in items
|
||||||
|
* - If-let patterns: @if let Some(out) = opt
|
||||||
|
* - Match arm patterns: @match status { Some(out) => { ... } }
|
||||||
|
* Workaround: Use @(out) to reference a variable with that name.
|
||||||
|
*
|
||||||
|
* 2. Function name conflicts - If a function `foo` exists, you cannot also
|
||||||
|
* have `foo_to_stream` (and vice versa). This prevents conflicts with
|
||||||
|
* the auto-generated streaming functions.
|
||||||
|
*
|
||||||
|
* 3. Special keywords (NEW SYNTAX - recommended):
|
||||||
|
* - @Out - Output target type (includes &mut): &mut _WtzTarget
|
||||||
|
* - @out - Output reference (includes &mut): &mut __wtz_buffer or __wtz_target
|
||||||
|
* - @render(T1, T2, ...) - Render callback type: impl Fn(T1, T2, ..., &mut _WtzTarget)
|
||||||
|
*
|
||||||
|
* 4. Special keywords (DEPRECATED - still supported):
|
||||||
|
* - @Target - Compiler-injected type (resolves to _WtzTarget or _WtzWriter)
|
||||||
|
* - @target - Compiler-injected variable (resolves to __wtz_buffer or __wtz_target)
|
||||||
|
*
|
||||||
|
* These rules apply only to @let template variables and @fn template functions,
|
||||||
|
* not to CSS or JavaScript code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// REGEN STATUS — read before touching this grammar.
|
||||||
|
//
|
||||||
|
// `src/parser.c`, `src/grammar.json`, and `src/node-types.json` are generated
|
||||||
|
// from this file with tree-sitter-cli v0.25.10. Regeneration is expected to
|
||||||
|
// complete quickly on local hardware (last checked: 0.60s, <90 MB RSS).
|
||||||
|
//
|
||||||
|
// The previous grammar shape made `tree-sitter generate` explore an enormous
|
||||||
|
// LR/error-recovery state space. The important constraints that keep regen
|
||||||
|
// reliable are:
|
||||||
|
// • All template-content bodies go through `_template_nodes`.
|
||||||
|
// • HTML void elements are explicit; ordinary `<tag>` starts a full element.
|
||||||
|
// • Function tags require `/>` for self-closing form.
|
||||||
|
// • Rust expressions are intentionally opaque (`rust_expression`) except for
|
||||||
|
// literals, paths, inferred enum variants, template blocks, and render
|
||||||
|
// closures. The Waltzing compiler validates Rust expression semantics.
|
||||||
|
// • Multi-depth template comments/raw blocks are not modeled as 22 token
|
||||||
|
// variants; the common one-delimiter forms are tokenized for editor use.
|
||||||
|
//
|
||||||
|
// If any of those constraints are relaxed, run `tree-sitter generate` before
|
||||||
|
// committing and watch memory/time. A return to multi-GB RSS means the grammar
|
||||||
|
// has reintroduced exponential table construction.
|
||||||
|
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: "waltzing",
|
name: "waltzing",
|
||||||
|
|
||||||
extras: ($) => [/\s/],
|
extras: ($) => [/\s/],
|
||||||
|
|
||||||
conflicts: ($) => [
|
conflicts: ($) => [
|
||||||
[$.expression, $.pattern],
|
// `|x|` — could be closure that returns `|x|` (no return type) or that's
|
||||||
[$.rust_path, $.expression],
|
// about to declare a `-> T` return type. cli 0.25 needs both parses.
|
||||||
[$.html_element],
|
[$.closure_type],
|
||||||
[$.self_closing_function_tag, $.container_function_tag],
|
|
||||||
],
|
],
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
|
@ -119,7 +171,9 @@ module.exports = grammar({
|
||||||
|
|
||||||
default_value: ($) => $.expression,
|
default_value: ($) => $.expression,
|
||||||
|
|
||||||
content_block: ($) => seq("{", repeat($.template_node), "}"),
|
content_block: ($) => seq("{", optional($._template_nodes), "}"),
|
||||||
|
|
||||||
|
_template_nodes: ($) => repeat1($.template_node),
|
||||||
|
|
||||||
// Template nodes
|
// Template nodes
|
||||||
// Note: template_control_flow must come before template_expression
|
// Note: template_control_flow must come before template_expression
|
||||||
|
|
@ -144,14 +198,14 @@ module.exports = grammar({
|
||||||
// Self-closing tag
|
// Self-closing tag
|
||||||
seq("<", $.tag_name, repeat($.attribute_or_control), "/", ">"),
|
seq("<", $.tag_name, repeat($.attribute_or_control), "/", ">"),
|
||||||
// Void elements (no closing tag needed)
|
// Void elements (no closing tag needed)
|
||||||
seq("<", $.tag_name, repeat($.attribute_or_control), ">"),
|
seq("<", alias($.void_tag_name, $.tag_name), repeat($.attribute_or_control), optional("/"), ">"),
|
||||||
// Full element with content and closing tag
|
// Full element with content and closing tag
|
||||||
seq(
|
seq(
|
||||||
"<",
|
"<",
|
||||||
$.tag_name,
|
$.tag_name,
|
||||||
repeat($.attribute_or_control),
|
repeat($.attribute_or_control),
|
||||||
">",
|
">",
|
||||||
repeat($.template_node),
|
optional($._template_nodes),
|
||||||
"</",
|
"</",
|
||||||
$.tag_name,
|
$.tag_name,
|
||||||
">",
|
">",
|
||||||
|
|
@ -161,8 +215,8 @@ module.exports = grammar({
|
||||||
// Allow either HTML attributes or control flow (@if/@for) in attribute position
|
// Allow either HTML attributes or control flow (@if/@for) in attribute position
|
||||||
attribute_or_control: ($) =>
|
attribute_or_control: ($) =>
|
||||||
choice(
|
choice(
|
||||||
$.html_attribute,
|
|
||||||
$.attribute_control_flow,
|
$.attribute_control_flow,
|
||||||
|
$.html_attribute,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Control flow in attribute context - produces attributes conditionally
|
// Control flow in attribute context - produces attributes conditionally
|
||||||
|
|
@ -195,11 +249,34 @@ module.exports = grammar({
|
||||||
|
|
||||||
tag_name: ($) => /[a-zA-Z][a-zA-Z0-9-]*/,
|
tag_name: ($) => /[a-zA-Z][a-zA-Z0-9-]*/,
|
||||||
|
|
||||||
|
void_tag_name: ($) =>
|
||||||
|
token(prec(1, choice(
|
||||||
|
"area",
|
||||||
|
"base",
|
||||||
|
"br",
|
||||||
|
"col",
|
||||||
|
"embed",
|
||||||
|
"hr",
|
||||||
|
"img",
|
||||||
|
"input",
|
||||||
|
"link",
|
||||||
|
"meta",
|
||||||
|
"param",
|
||||||
|
"source",
|
||||||
|
"track",
|
||||||
|
"wbr",
|
||||||
|
))),
|
||||||
|
|
||||||
html_attribute: ($) =>
|
html_attribute: ($) =>
|
||||||
seq($.attribute_name, optional(seq("=", $.attribute_value))),
|
seq($.attribute_name, optional(seq("=", $.attribute_value))),
|
||||||
|
|
||||||
// Attribute names: allow @ for directives like @click, but not @if/@for/@let
|
// Attribute names: allow @ directives like @click, while keeping @if/@for
|
||||||
attribute_name: ($) => /[a-zA-Z_:@][a-zA-Z0-9_:.-]*/,
|
// visible as `@` + keyword tokens for attribute_control_flow.
|
||||||
|
attribute_name: ($) =>
|
||||||
|
choice(
|
||||||
|
/[a-zA-Z_:][a-zA-Z0-9_:.-]*/,
|
||||||
|
seq("@", /[a-zA-Z_][a-zA-Z0-9_:.-]*/),
|
||||||
|
),
|
||||||
|
|
||||||
attribute_value: ($) =>
|
attribute_value: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -210,7 +287,21 @@ module.exports = grammar({
|
||||||
|
|
||||||
// Template expressions
|
// Template expressions
|
||||||
template_expression: ($) =>
|
template_expression: ($) =>
|
||||||
choice($.simple_expression, $.complex_expression, $.safe_expression),
|
choice(
|
||||||
|
$.simple_expression,
|
||||||
|
$.complex_expression,
|
||||||
|
$.safe_expression,
|
||||||
|
$.format_expression,
|
||||||
|
$.matches_expression,
|
||||||
|
$.out_ref,
|
||||||
|
$.target_ref,
|
||||||
|
),
|
||||||
|
|
||||||
|
// Compiler-injected output reference - resolves to &mut __wtz_buffer or __wtz_target
|
||||||
|
out_ref: ($) => seq("@", "out"),
|
||||||
|
|
||||||
|
// Compiler-injected target reference - DEPRECATED, use out_ref
|
||||||
|
target_ref: ($) => seq("@", "target"),
|
||||||
|
|
||||||
// High-precedence token to match @identifier before @for/@if etc keywords
|
// High-precedence token to match @identifier before @for/@if etc keywords
|
||||||
simple_expression: ($) =>
|
simple_expression: ($) =>
|
||||||
|
|
@ -231,6 +322,60 @@ module.exports = grammar({
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Format expression: @format("template {}", arg1, arg2, ...)
|
||||||
|
// Compiles to Rust's format!() macro.
|
||||||
|
format_expression: ($) =>
|
||||||
|
seq(
|
||||||
|
"@",
|
||||||
|
"format",
|
||||||
|
"(",
|
||||||
|
$.string_literal,
|
||||||
|
repeat(seq(",", $.expression)),
|
||||||
|
")",
|
||||||
|
),
|
||||||
|
|
||||||
|
// Matches expression: @matches(value, pattern) or @matches(value, pattern if guard)
|
||||||
|
// Compiles to Rust's matches!() macro.
|
||||||
|
matches_expression: ($) =>
|
||||||
|
seq(
|
||||||
|
"@",
|
||||||
|
"matches",
|
||||||
|
"(",
|
||||||
|
$.expression,
|
||||||
|
",",
|
||||||
|
$.pattern,
|
||||||
|
optional(seq("if", $.expression)),
|
||||||
|
")",
|
||||||
|
),
|
||||||
|
|
||||||
|
// Inferred enum path: ::Variant — the enum type is resolved from the
|
||||||
|
// surrounding context (function parameter type). Tokenized so `::` and
|
||||||
|
// the variant name parse as one unit.
|
||||||
|
inferred_enum_path: ($) =>
|
||||||
|
token(seq("::", /[a-zA-Z_][a-zA-Z0-9_]*/)),
|
||||||
|
|
||||||
|
// Inferred enum tuple variant: ::Variant(arg1, arg2, ...)
|
||||||
|
inferred_enum_call: ($) =>
|
||||||
|
prec(4, seq($.inferred_enum_path, "(", optional($.argument_list), ")")),
|
||||||
|
|
||||||
|
// Inferred enum struct variant: ::Variant { field: value, ... }
|
||||||
|
inferred_enum_struct: ($) =>
|
||||||
|
prec(
|
||||||
|
4,
|
||||||
|
seq(
|
||||||
|
$.inferred_enum_path,
|
||||||
|
"{",
|
||||||
|
optional(seq(
|
||||||
|
$.struct_field_init,
|
||||||
|
repeat(seq(",", $.struct_field_init)),
|
||||||
|
optional(","),
|
||||||
|
)),
|
||||||
|
"}",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
struct_field_init: ($) => seq($.identifier, ":", $.expression),
|
||||||
|
|
||||||
expression_path: ($) =>
|
expression_path: ($) =>
|
||||||
seq(
|
seq(
|
||||||
$.identifier,
|
$.identifier,
|
||||||
|
|
@ -256,9 +401,13 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
// Let binding: @let name = expression
|
// Let binding: @let name = expression
|
||||||
// Use simple_pattern to avoid confusion with if/match expressions containing { }
|
// Use simple_pattern to avoid confusion with if/match expressions
|
||||||
|
// containing { }. The `prec(3)` outranks `simple_expression`'s prec(2)
|
||||||
|
// macro form so that `@let n` commits to let_statement rather than
|
||||||
|
// parsing `@let` as `simple_expression` (= `@` + identifier `let`) and
|
||||||
|
// leaving the `= 42` orphaned.
|
||||||
let_statement: ($) =>
|
let_statement: ($) =>
|
||||||
seq(seq("@", "let"), $.simple_pattern, "=", $.expression),
|
prec(3, seq(seq("@", "let"), $.simple_pattern, "=", $.expression, optional(";"))),
|
||||||
|
|
||||||
if_statement: ($) =>
|
if_statement: ($) =>
|
||||||
seq(
|
seq(
|
||||||
|
|
@ -318,7 +467,7 @@ module.exports = grammar({
|
||||||
"<@",
|
"<@",
|
||||||
$.function_path,
|
$.function_path,
|
||||||
repeat($.function_attribute),
|
repeat($.function_attribute),
|
||||||
optional("/"),
|
"/",
|
||||||
">",
|
">",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -328,7 +477,7 @@ module.exports = grammar({
|
||||||
$.function_path,
|
$.function_path,
|
||||||
repeat($.function_attribute),
|
repeat($.function_attribute),
|
||||||
">",
|
">",
|
||||||
repeat($.template_node),
|
optional($._template_nodes),
|
||||||
"</@",
|
"</@",
|
||||||
$.function_path,
|
$.function_path,
|
||||||
">",
|
">",
|
||||||
|
|
@ -357,7 +506,7 @@ module.exports = grammar({
|
||||||
boolean_attribute: ($) => $.identifier,
|
boolean_attribute: ($) => $.identifier,
|
||||||
|
|
||||||
function_attribute_value: ($) =>
|
function_attribute_value: ($) =>
|
||||||
choice($.string_literal, seq("@", $.expression_path), $.unquoted_value),
|
choice($.string_literal, seq("@", $.expression_path), $.render_closure, $.unquoted_value),
|
||||||
|
|
||||||
unquoted_value: ($) => /[^\s>=\/]+/,
|
unquoted_value: ($) => /[^\s>=\/]+/,
|
||||||
|
|
||||||
|
|
@ -365,6 +514,7 @@ module.exports = grammar({
|
||||||
pattern: ($) =>
|
pattern: ($) =>
|
||||||
choice(
|
choice(
|
||||||
$.wildcard_pattern,
|
$.wildcard_pattern,
|
||||||
|
$.tuple_variant_pattern,
|
||||||
$.tuple_pattern,
|
$.tuple_pattern,
|
||||||
$.struct_pattern,
|
$.struct_pattern,
|
||||||
$.literal,
|
$.literal,
|
||||||
|
|
@ -395,169 +545,64 @@ module.exports = grammar({
|
||||||
|
|
||||||
field_pattern: ($) => seq($.identifier, optional(seq(":", $.pattern))),
|
field_pattern: ($) => seq($.identifier, optional(seq(":", $.pattern))),
|
||||||
|
|
||||||
|
tuple_variant_pattern: ($) =>
|
||||||
|
seq(
|
||||||
|
$.rust_path,
|
||||||
|
"(",
|
||||||
|
optional(seq($.pattern, repeat(seq(",", $.pattern)), optional(","))),
|
||||||
|
")",
|
||||||
|
),
|
||||||
|
|
||||||
tuple_pattern: ($) =>
|
tuple_pattern: ($) =>
|
||||||
seq("(", $.pattern, repeat(seq(",", $.pattern)), optional(","), ")"),
|
seq("(", $.pattern, repeat(seq(",", $.pattern)), optional(","), ")"),
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
|
//
|
||||||
|
// Rust expressions are intentionally kept mostly opaque here. Earlier
|
||||||
|
// versions modeled Rust expressions recursively (`binary_expression`,
|
||||||
|
// `method_call`, `statement_block`, etc.), but that gave the LR generator
|
||||||
|
// too many paths across every Waltzing template-content boundary. The
|
||||||
|
// compiler remains the authority for Rust expression validity; this grammar
|
||||||
|
// only needs a stable editor tree around the template syntax.
|
||||||
expression: ($) =>
|
expression: ($) =>
|
||||||
choice($.binary_expression, $.unary_expression, $.primary_expression),
|
choice(
|
||||||
|
$.template_block,
|
||||||
binary_expression: ($) =>
|
$.render_closure,
|
||||||
prec.left(1, seq($.expression, $.binary_operator, $.expression)),
|
$.primary_expression,
|
||||||
|
),
|
||||||
unary_expression: ($) => prec(2, seq($.unary_operator, $.expression)),
|
|
||||||
|
|
||||||
primary_expression: ($) =>
|
primary_expression: ($) =>
|
||||||
choice(
|
choice(
|
||||||
// if/match expressions must come first to match the keywords before rust_path
|
|
||||||
$.if_expression,
|
|
||||||
$.match_expression,
|
|
||||||
$.literal,
|
$.literal,
|
||||||
$.macro_call,
|
$.inferred_enum_call,
|
||||||
$.method_call,
|
$.inferred_enum_struct,
|
||||||
$.field_access,
|
$.inferred_enum_path,
|
||||||
$.index_access,
|
|
||||||
$.parenthesized_expression,
|
|
||||||
$.array_literal,
|
|
||||||
$.closure_expression,
|
|
||||||
// rust_path last as fallback for identifiers
|
|
||||||
$.rust_path,
|
$.rust_path,
|
||||||
|
$.rust_expression,
|
||||||
),
|
),
|
||||||
|
|
||||||
// If expression (returns a value): if cond { expr } else { expr }
|
rust_expression: ($) =>
|
||||||
if_expression: ($) =>
|
token(prec(-1, /[^{}<@,;)\]\s][^{}<@,;)\]]*/)),
|
||||||
prec.right(
|
|
||||||
10,
|
|
||||||
seq(
|
|
||||||
"if",
|
|
||||||
$.expression,
|
|
||||||
"{",
|
|
||||||
$.expression,
|
|
||||||
"}",
|
|
||||||
"else",
|
|
||||||
choice(
|
|
||||||
$.if_expression,
|
|
||||||
seq("{", $.expression, "}"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Match expression (returns a value): match expr { pat => expr, ... }
|
// Template block - explicit template content in expression position
|
||||||
match_expression: ($) =>
|
// Use @{ ... } to create template content as an expression
|
||||||
prec.right(
|
// Example: @let html = @{ <div>Hello</div> }
|
||||||
10,
|
template_block: ($) => seq("@", "{", optional($._template_nodes), "}"),
|
||||||
seq(
|
|
||||||
"match",
|
|
||||||
$.expression,
|
|
||||||
"{",
|
|
||||||
repeat($.expression_match_arm),
|
|
||||||
"}",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
expression_match_arm: ($) =>
|
// Render closure - inline closure that writes to output target
|
||||||
|
// Generates: |params..., __wtz_target: &mut _WtzTarget| { template_content }
|
||||||
|
// Auto-threading: calling a @() variable automatically appends @out
|
||||||
|
render_closure: ($) =>
|
||||||
seq(
|
seq(
|
||||||
$.pattern,
|
"@",
|
||||||
optional(seq("if", $.expression)),
|
"(",
|
||||||
"=>",
|
optional(seq($.parameter, repeat(seq(",", $.parameter)))),
|
||||||
$.expression,
|
")",
|
||||||
optional(","),
|
$.content_block,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Rust macro calls: format!(), vec![], println!(), etc.
|
|
||||||
macro_call: ($) =>
|
|
||||||
prec(
|
|
||||||
5,
|
|
||||||
seq(
|
|
||||||
$.identifier,
|
|
||||||
"!",
|
|
||||||
choice(
|
|
||||||
seq("(", optional($.macro_args), ")"),
|
|
||||||
seq("[", optional($.macro_args), "]"),
|
|
||||||
seq("{", optional($.macro_args), "}"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Macro arguments
|
|
||||||
macro_args: ($) =>
|
|
||||||
seq(
|
|
||||||
$.macro_arg,
|
|
||||||
repeat(seq(",", $.macro_arg)),
|
|
||||||
optional(","),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Macro argument - just use expression
|
|
||||||
macro_arg: ($) => $.expression,
|
|
||||||
|
|
||||||
method_call: ($) =>
|
|
||||||
prec.left(
|
|
||||||
3,
|
|
||||||
seq(
|
|
||||||
$.primary_expression,
|
|
||||||
".",
|
|
||||||
$.identifier,
|
|
||||||
"(",
|
|
||||||
optional($.argument_list),
|
|
||||||
")",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
field_access: ($) =>
|
|
||||||
prec.left(3, seq($.primary_expression, ".", $.identifier)),
|
|
||||||
|
|
||||||
index_access: ($) =>
|
|
||||||
prec.left(3, seq($.primary_expression, "[", $.expression, "]")),
|
|
||||||
|
|
||||||
parenthesized_expression: ($) => seq("(", $.expression, ")"),
|
|
||||||
|
|
||||||
array_literal: ($) =>
|
|
||||||
seq(
|
|
||||||
"[",
|
|
||||||
optional(
|
|
||||||
seq($.expression, repeat(seq(",", $.expression)), optional(",")),
|
|
||||||
),
|
|
||||||
"]",
|
|
||||||
),
|
|
||||||
|
|
||||||
closure_expression: ($) =>
|
|
||||||
seq(
|
|
||||||
"|",
|
|
||||||
optional($.closure_params),
|
|
||||||
"|",
|
|
||||||
choice($.expression, $.content_block),
|
|
||||||
),
|
|
||||||
|
|
||||||
closure_params: ($) => seq($.identifier, repeat(seq(",", $.identifier))),
|
|
||||||
|
|
||||||
argument_list: ($) =>
|
argument_list: ($) =>
|
||||||
seq($.expression, repeat(seq(",", $.expression)), optional(",")),
|
seq($.expression, repeat(seq(",", $.expression)), optional(",")),
|
||||||
|
|
||||||
// Operators
|
|
||||||
binary_operator: ($) =>
|
|
||||||
choice(
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"*",
|
|
||||||
"/",
|
|
||||||
"%",
|
|
||||||
"==",
|
|
||||||
"!=",
|
|
||||||
"<",
|
|
||||||
">",
|
|
||||||
"<=",
|
|
||||||
">=",
|
|
||||||
"&&",
|
|
||||||
"||",
|
|
||||||
"&",
|
|
||||||
"|",
|
|
||||||
"^",
|
|
||||||
"<<",
|
|
||||||
">>",
|
|
||||||
),
|
|
||||||
|
|
||||||
unary_operator: ($) => choice("!", "-", "*", "&"),
|
|
||||||
|
|
||||||
// Literals
|
// Literals
|
||||||
literal: ($) =>
|
literal: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -599,8 +644,39 @@ module.exports = grammar({
|
||||||
$.tuple_type,
|
$.tuple_type,
|
||||||
$.array_type,
|
$.array_type,
|
||||||
$.slice_type,
|
$.slice_type,
|
||||||
|
$.closure_type,
|
||||||
|
$.render_type,
|
||||||
|
$.out_type,
|
||||||
|
$.target_type,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Closure type: |[name: ]Type, ...| [-> ReturnType]
|
||||||
|
closure_type: ($) =>
|
||||||
|
seq(
|
||||||
|
"|",
|
||||||
|
optional(seq($.closure_param, repeat(seq(",", $.closure_param)))),
|
||||||
|
"|",
|
||||||
|
optional(seq("->", $.rust_type)),
|
||||||
|
),
|
||||||
|
|
||||||
|
closure_param: ($) =>
|
||||||
|
seq(optional(seq($.identifier, ":")), $.rust_type),
|
||||||
|
|
||||||
|
// Compiler-injected render callback type - generates impl Fn(T1, T2, ..., &mut _WtzTarget)
|
||||||
|
// Full syntax: @render(T1, T2, ...)
|
||||||
|
// Shorthand: @() or @(T1, T2) - equivalent to @render()/@render(T1, T2)
|
||||||
|
render_type: ($) =>
|
||||||
|
choice(
|
||||||
|
seq("@", "render", "(", optional(seq($.rust_type, repeat(seq(",", $.rust_type)))), ")"),
|
||||||
|
seq("@", "(", optional(seq($.rust_type, repeat(seq(",", $.rust_type)))), ")"),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Compiler-injected output type - generates &mut _WtzTarget
|
||||||
|
out_type: ($) => seq("@", "Out"),
|
||||||
|
|
||||||
|
// Compiler-injected target type - DEPRECATED, use out_type
|
||||||
|
target_type: ($) => seq("@", "Target"),
|
||||||
|
|
||||||
primitive_type: ($) =>
|
primitive_type: ($) =>
|
||||||
choice(
|
choice(
|
||||||
"i8",
|
"i8",
|
||||||
|
|
@ -646,10 +722,13 @@ module.exports = grammar({
|
||||||
// Comments
|
// Comments
|
||||||
comment: ($) => choice($.template_comment, $.html_comment),
|
comment: ($) => choice($.template_comment, $.html_comment),
|
||||||
|
|
||||||
// Template comments: @* ... *@ with varying asterisk counts
|
// Template comments: @* ... *@.
|
||||||
template_comment: ($) => choice(
|
//
|
||||||
...Array.from({ length: 22 }, (_, i) => $[`template_comment_${i + 1}`])
|
// The compiler supports arbitrary delimiter depth (`@** ... **@`, etc.),
|
||||||
),
|
// but modeling each depth as a separate token made error-recovery table
|
||||||
|
// construction explode. Keep the common editor token here; deeper comments
|
||||||
|
// still parse as ordinary text/error recovery until a scanner is added.
|
||||||
|
template_comment: ($) => $.template_comment_1,
|
||||||
template_comment_1: ($) => /@\*([^*]|\*[^@])*\*@/,
|
template_comment_1: ($) => /@\*([^*]|\*[^@])*\*@/,
|
||||||
template_comment_2: ($) => /@\*\*([^*]|\*[^*]|\*\*[^@])*\*\*@/,
|
template_comment_2: ($) => /@\*\*([^*]|\*[^*]|\*\*[^@])*\*\*@/,
|
||||||
template_comment_3: ($) => /@\*\*\*([^*]|\*[^*]|\*\*[^*]|\*\*\*[^@])*\*\*\*@/,
|
template_comment_3: ($) => /@\*\*\*([^*]|\*[^*]|\*\*[^*]|\*\*\*[^@])*\*\*\*@/,
|
||||||
|
|
@ -676,10 +755,11 @@ module.exports = grammar({
|
||||||
// HTML comment: <!-- ... -->
|
// HTML comment: <!-- ... -->
|
||||||
html_comment: ($) => /<!--([^-]|-[^-]|--[^>])*-->/,
|
html_comment: ($) => /<!--([^-]|-[^-]|--[^>])*-->/,
|
||||||
|
|
||||||
// Raw blocks: @# ... #@ with varying hash counts
|
// Raw blocks: @# ... #@.
|
||||||
raw_block: ($) => choice(
|
//
|
||||||
...Array.from({ length: 22 }, (_, i) => $[`raw_block_${i + 1}`])
|
// See template_comment: deeper delimiter variants are compiler-supported,
|
||||||
),
|
// but keeping 22 separate tokens prevents reliable parser regeneration.
|
||||||
|
raw_block: ($) => $.raw_block_1,
|
||||||
raw_block_1: ($) => /@#([^#]|#[^@])*#@/,
|
raw_block_1: ($) => /@#([^#]|#[^@])*#@/,
|
||||||
raw_block_2: ($) => /@##([^#]|#[^#]|##[^@])*##@/,
|
raw_block_2: ($) => /@##([^#]|#[^#]|##[^@])*##@/,
|
||||||
raw_block_3: ($) => /@###([^#]|#{1,2}[^#]|###[^@])*###@/,
|
raw_block_3: ($) => /@###([^#]|#{1,2}[^#]|###[^@])*###@/,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"nan": "^2.17.0"
|
"nan": "^2.17.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tree-sitter-cli": "^0.24.0"
|
"tree-sitter-cli": "^0.25.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nan": {
|
"node_modules/nan": {
|
||||||
|
|
@ -22,9 +22,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/tree-sitter-cli": {
|
"node_modules/tree-sitter-cli": {
|
||||||
"version": "0.24.7",
|
"version": "0.25.10",
|
||||||
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.24.7.tgz",
|
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.25.10.tgz",
|
||||||
"integrity": "sha512-o4gnE82pVmMMhJbWwD6+I9yr4lXii5Ci5qEQ2pFpUbVy1YiD8cizTJaqdcznA0qEbo7l2OneI1GocChPrI4YGQ==",
|
"integrity": "sha512-KoebQguKMCIghisEOdA372TIbrUl0kdnfZ9YQIBRAeOvNSKe85XbU4LuFW7hduRUwJj0rAG7pX5wo9sZhbBF1g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"nan": "^2.17.0"
|
"nan": "^2.17.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tree-sitter-cli": "^0.24.0"
|
"tree-sitter-cli": "^0.25.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tree-sitter generate",
|
"build": "tree-sitter generate",
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,19 @@
|
||||||
(raw_block) @string.special
|
(raw_block) @string.special
|
||||||
|
|
||||||
; Keywords - only in proper syntactic contexts
|
; Keywords - only in proper syntactic contexts
|
||||||
(use_statement "@use" @keyword)
|
(use_statement "@" @keyword "use" @keyword)
|
||||||
(import_statement "@import" @keyword)
|
(import_statement "@" @keyword "import" @keyword)
|
||||||
(struct_definition "@struct" @keyword)
|
(struct_definition "@" @keyword "struct" @keyword)
|
||||||
(enum_definition "@enum" @keyword)
|
(enum_definition "@" @keyword "enum" @keyword)
|
||||||
(function_definition "@fn" @keyword)
|
(function_definition "@" @keyword "fn" @keyword)
|
||||||
(let_statement "@let" @keyword)
|
(let_statement "@" @keyword "let" @keyword)
|
||||||
(if_statement "@if" @keyword)
|
(if_statement "@" @keyword "if" @keyword)
|
||||||
(for_loop "@for" @keyword)
|
(for_loop "@" @keyword "for" @keyword)
|
||||||
(match_statement "@match" @keyword)
|
(match_statement "@" @keyword "match" @keyword)
|
||||||
(break_statement "@break" @keyword)
|
(break_statement "@" @keyword "break" @keyword)
|
||||||
(continue_statement "@continue" @keyword)
|
(continue_statement "@" @keyword "continue" @keyword)
|
||||||
(attribute_if_statement "@if" @keyword)
|
(attribute_if_statement "@" @keyword "if" @keyword)
|
||||||
(attribute_for_loop "@for" @keyword)
|
(attribute_for_loop "@" @keyword "for" @keyword)
|
||||||
(else_if_branch "else" @keyword)
|
(else_if_branch "else" @keyword)
|
||||||
(else_if_branch "if" @keyword)
|
(else_if_branch "if" @keyword)
|
||||||
(else_branch "else" @keyword)
|
(else_branch "else" @keyword)
|
||||||
|
|
@ -39,15 +39,14 @@
|
||||||
; Functions
|
; Functions
|
||||||
(function_definition (identifier) @fn)
|
(function_definition (identifier) @fn)
|
||||||
(function_path) @fn
|
(function_path) @fn
|
||||||
(method_call (identifier) @fn)
|
|
||||||
|
|
||||||
; Parameters
|
; Parameters
|
||||||
(parameter (identifier) @variable)
|
(parameter (identifier) @variable)
|
||||||
|
|
||||||
; Properties
|
; Properties
|
||||||
(struct_field (identifier) @property)
|
(struct_field (identifier) @property)
|
||||||
(field_access (identifier) @property)
|
|
||||||
(field_pattern (identifier) @property)
|
(field_pattern (identifier) @property)
|
||||||
|
(struct_field_init (identifier) @property)
|
||||||
|
|
||||||
; Constructors
|
; Constructors
|
||||||
(enum_variant (identifier) @constructor)
|
(enum_variant (identifier) @constructor)
|
||||||
|
|
@ -65,8 +64,6 @@
|
||||||
(boolean_literal) @boolean
|
(boolean_literal) @boolean
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
(binary_operator) @operator
|
|
||||||
(unary_operator) @operator
|
|
||||||
"=>" @operator
|
"=>" @operator
|
||||||
"=" @operator
|
"=" @operator
|
||||||
|
|
||||||
|
|
|
||||||
1677
src/grammar.json
1677
src/grammar.json
File diff suppressed because it is too large
Load Diff
|
|
@ -14,21 +14,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "array_literal",
|
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": true,
|
|
||||||
"required": false,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "expression",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "array_type",
|
"type": "array_type",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -143,6 +128,11 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "attribute_name",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "attribute_or_control",
|
"type": "attribute_or_control",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -200,30 +190,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "binary_expression",
|
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": true,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "binary_operator",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "expression",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "binary_operator",
|
|
||||||
"named": true,
|
|
||||||
"fields": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "boolean_attribute",
|
"type": "boolean_attribute",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -275,30 +241,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "closure_expression",
|
"type": "closure_param",
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": true,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "closure_params",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "content_block",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "expression",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "closure_params",
|
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
|
|
@ -308,6 +251,29 @@
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "rust_type",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "closure_type",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "closure_param",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "rust_type",
|
||||||
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -521,16 +487,16 @@
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
|
||||||
"type": "binary_expression",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "primary_expression",
|
"type": "primary_expression",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "unary_expression",
|
"type": "render_closure",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "template_block",
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -559,25 +525,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "field_access",
|
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": true,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "identifier",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "primary_expression",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "field_pattern",
|
"type": "field_pattern",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -624,6 +571,25 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "format_expression",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "expression",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string_literal",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "function_attribute",
|
"type": "function_attribute",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -659,6 +625,10 @@
|
||||||
"type": "expression_path",
|
"type": "expression_path",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "render_closure",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string_literal",
|
"type": "string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -863,7 +833,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "index_access",
|
"type": "inferred_enum_call",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
|
|
@ -871,11 +841,30 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "expression",
|
"type": "argument_list",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "primary_expression",
|
"type": "inferred_enum_path",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inferred_enum_struct",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "inferred_enum_path",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "struct_field_init",
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -904,7 +893,7 @@
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "pattern",
|
"type": "simple_pattern",
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -980,7 +969,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "method_call",
|
"type": "matches_expression",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
|
|
@ -988,15 +977,11 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "argument_list",
|
"type": "expression",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "pattern",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "primary_expression",
|
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -1040,6 +1025,16 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "out_ref",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "out_type",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "parameter",
|
"type": "parameter",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1078,21 +1073,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "parenthesized_expression",
|
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": false,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "expression",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "path_type",
|
"type": "path_type",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1132,6 +1112,10 @@
|
||||||
"type": "tuple_pattern",
|
"type": "tuple_pattern",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tuple_variant_pattern",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "wildcard_pattern",
|
"type": "wildcard_pattern",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1148,19 +1132,15 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "array_literal",
|
"type": "inferred_enum_call",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "closure_expression",
|
"type": "inferred_enum_path",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "field_access",
|
"type": "inferred_enum_struct",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "index_access",
|
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1168,11 +1148,7 @@
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "method_call",
|
"type": "rust_expression",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "parenthesized_expression",
|
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1187,6 +1163,21 @@
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {}
|
"fields": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "raw_block",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "raw_block_1",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "reference_type",
|
"type": "reference_type",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1202,6 +1193,40 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "render_closure",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "content_block",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "parameter",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "render_type",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "rust_type",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "rust_path",
|
"type": "rust_path",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1219,10 +1244,18 @@
|
||||||
"type": "array_type",
|
"type": "array_type",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "closure_type",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "generic_type",
|
"type": "generic_type",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "out_type",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "path_type",
|
"type": "path_type",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1235,10 +1268,18 @@
|
||||||
"type": "reference_type",
|
"type": "reference_type",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "render_type",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "slice_type",
|
"type": "slice_type",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "target_type",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "tuple_type",
|
"type": "tuple_type",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1286,7 +1327,7 @@
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "expression_path",
|
"type": "expression_path",
|
||||||
|
|
@ -1402,6 +1443,25 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "struct_field_init",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "expression",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "struct_pattern",
|
"type": "struct_pattern",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1421,6 +1481,16 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "target_ref",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "target_type",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "template",
|
"type": "template",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1437,6 +1507,36 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "template_block",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "template_node",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "template_comment",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "template_comment_1",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "template_control_flow",
|
"type": "template_control_flow",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1519,6 +1619,18 @@
|
||||||
"type": "complex_expression",
|
"type": "complex_expression",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "format_expression",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "matches_expression",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "out_ref",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "safe_expression",
|
"type": "safe_expression",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1526,6 +1638,10 @@
|
||||||
{
|
{
|
||||||
"type": "simple_expression",
|
"type": "simple_expression",
|
||||||
"named": true
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "target_ref",
|
||||||
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1607,6 +1723,25 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tuple_variant_pattern",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "pattern",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "rust_path",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "type_expression",
|
"type": "type_expression",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1622,30 +1757,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "unary_expression",
|
|
||||||
"named": true,
|
|
||||||
"fields": {},
|
|
||||||
"children": {
|
|
||||||
"multiple": true,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "expression",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "unary_operator",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "unary_operator",
|
|
||||||
"named": true,
|
|
||||||
"fields": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "use_statement",
|
"type": "use_statement",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -1669,26 +1780,14 @@
|
||||||
"type": "!",
|
"type": "!",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "!=",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "\"",
|
"type": "\"",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "%",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "&",
|
"type": "&",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "&&",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "'",
|
"type": "'",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1701,20 +1800,12 @@
|
||||||
"type": ")",
|
"type": ")",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "*",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "+",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": ",",
|
"type": ",",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "-",
|
"type": "->",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1749,14 +1840,6 @@
|
||||||
"type": "</@",
|
"type": "</@",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "<<",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "<=",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "<@",
|
"type": "<@",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1765,10 +1848,6 @@
|
||||||
"type": "=",
|
"type": "=",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "==",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "=>",
|
"type": "=>",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1777,14 +1856,6 @@
|
||||||
"type": ">",
|
"type": ">",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": ">=",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": ">>",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "@",
|
"type": "@",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1794,53 +1865,17 @@
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "@break",
|
"type": "Out",
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@continue",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@enum",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@fn",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@for",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@if",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@import",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@let",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@match",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@struct",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "@use",
|
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "String",
|
"type": "String",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "Target",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "[",
|
"type": "[",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1849,10 +1884,6 @@
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "^",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "```@",
|
"type": "```@",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1869,18 +1900,22 @@
|
||||||
"type": "attribute_content",
|
"type": "attribute_content",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "attribute_name",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "break",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "char",
|
"type": "char",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "continue",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "css",
|
"type": "css",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1889,6 +1924,10 @@
|
||||||
"type": "else",
|
"type": "else",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "enum",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "escape_at",
|
"type": "escape_at",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1913,6 +1952,18 @@
|
||||||
"type": "float_literal",
|
"type": "float_literal",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "fn",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "for",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "format",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "html",
|
"type": "html",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1949,6 +2000,10 @@
|
||||||
"type": "if",
|
"type": "if",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "import",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "import_path",
|
"type": "import_path",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1957,6 +2012,10 @@
|
||||||
"type": "in",
|
"type": "in",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "inferred_enum_path",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "isize",
|
"type": "isize",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -1977,12 +2036,32 @@
|
||||||
"type": "let",
|
"type": "let",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "match",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "matches",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "mut",
|
"type": "mut",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "raw_block",
|
"type": "out",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "raw_block_1",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "render",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "rust_expression",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1993,6 +2072,10 @@
|
||||||
"type": "str",
|
"type": "str",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "struct",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "style",
|
"type": "style",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -2002,7 +2085,11 @@
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "template_comment",
|
"type": "target",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "template_comment_1",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -2037,6 +2124,10 @@
|
||||||
"type": "unquoted_value",
|
"type": "unquoted_value",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "use",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "usize",
|
"type": "usize",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -2053,10 +2144,6 @@
|
||||||
"type": "|",
|
"type": "|",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "||",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "}",
|
"type": "}",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
|
||||||
45288
src/parser.c
45288
src/parser.c
File diff suppressed because it is too large
Load Diff
|
|
@ -18,7 +18,6 @@ typedef uint16_t TSStateId;
|
||||||
typedef uint16_t TSSymbol;
|
typedef uint16_t TSSymbol;
|
||||||
typedef uint16_t TSFieldId;
|
typedef uint16_t TSFieldId;
|
||||||
typedef struct TSLanguage TSLanguage;
|
typedef struct TSLanguage TSLanguage;
|
||||||
typedef struct TSLanguageMetadata TSLanguageMetadata;
|
|
||||||
typedef struct TSLanguageMetadata {
|
typedef struct TSLanguageMetadata {
|
||||||
uint8_t major_version;
|
uint8_t major_version;
|
||||||
uint8_t minor_version;
|
uint8_t minor_version;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
==================
|
||||||
|
empty function
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn empty() { }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list)
|
||||||
|
(content_block))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
use statement
|
||||||
|
==================
|
||||||
|
|
||||||
|
@use std::collections::HashMap
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(use_statement
|
||||||
|
(rust_path))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
import with alias
|
||||||
|
==================
|
||||||
|
|
||||||
|
@import "/components/button" as btn
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(import_statement
|
||||||
|
(string_literal)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
struct definition
|
||||||
|
==================
|
||||||
|
|
||||||
|
@struct User {
|
||||||
|
name: String,
|
||||||
|
age: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(struct_definition
|
||||||
|
(identifier)
|
||||||
|
(struct_field
|
||||||
|
(identifier)
|
||||||
|
(type_expression
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))
|
||||||
|
(struct_field
|
||||||
|
(identifier)
|
||||||
|
(type_expression
|
||||||
|
(rust_type
|
||||||
|
(primitive_type)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
html element with text
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn greet() {
|
||||||
|
<h1>Hello</h1>
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list)
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(text_content))
|
||||||
|
(tag_name)))))))
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
==================
|
||||||
|
@if statement
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn show(x: bool) { @if x { <p>Yes</p> } }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(template_control_flow
|
||||||
|
(if_statement
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path)))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(text_content))
|
||||||
|
(tag_name)))))))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
@for loop
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn loop(items: Vec<u32>) { @for n in items { <li>@n</li> } }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(generic_type
|
||||||
|
(rust_path)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(template_control_flow
|
||||||
|
(for_loop
|
||||||
|
(simple_pattern
|
||||||
|
(identifier_pattern
|
||||||
|
(identifier)))
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path)))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(template_expression
|
||||||
|
(simple_expression
|
||||||
|
(expression_path
|
||||||
|
(identifier)))))
|
||||||
|
(tag_name)))))))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
@match with literal and wildcard
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn pick(v: u32) { @match v { 0 => { <p>zero</p> }, _ => { <p>other</p> } } }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(template_control_flow
|
||||||
|
(match_statement
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path)))
|
||||||
|
(match_arm
|
||||||
|
(pattern
|
||||||
|
(literal
|
||||||
|
(number_literal
|
||||||
|
(integer_literal))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(text_content))
|
||||||
|
(tag_name)))))
|
||||||
|
(match_arm
|
||||||
|
(pattern
|
||||||
|
(wildcard_pattern))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(text_content))
|
||||||
|
(tag_name))))))))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
@if in HTML attribute position
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn cb(active: bool) { <input @if active { checked } /> }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(attribute_or_control
|
||||||
|
(attribute_control_flow
|
||||||
|
(attribute_if_statement
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path)))
|
||||||
|
(attribute_or_control
|
||||||
|
(html_attribute
|
||||||
|
(attribute_name))))))))))))
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
==================
|
||||||
|
format expression
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn fmt(name: String) { <p>@format("Hello {}", name)</p> }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(template_expression
|
||||||
|
(format_expression
|
||||||
|
(string_literal)
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path))))))
|
||||||
|
(tag_name)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
matches expression
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn check(v: Option<u32>) { <p>@matches(v, Some(_))</p> }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(generic_type
|
||||||
|
(rust_path)
|
||||||
|
(rust_type
|
||||||
|
(primitive_type))))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(template_expression
|
||||||
|
(matches_expression
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(rust_path)))
|
||||||
|
(pattern
|
||||||
|
(tuple_variant_pattern
|
||||||
|
(rust_path)
|
||||||
|
(pattern
|
||||||
|
(wildcard_pattern)))))))
|
||||||
|
(tag_name)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
inferred enum path
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn status(s: Status) { <p>@(::Active)</p> }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list
|
||||||
|
(parameter
|
||||||
|
(identifier)
|
||||||
|
(rust_type
|
||||||
|
(path_type
|
||||||
|
(rust_path)))))
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(template_expression
|
||||||
|
(complex_expression
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(inferred_enum_path))))))
|
||||||
|
(tag_name)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
inferred enum tuple variant
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn call() { <p>@(::Some(1))</p> }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list)
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(html_element
|
||||||
|
(tag_name)
|
||||||
|
(template_node
|
||||||
|
(template_expression
|
||||||
|
(complex_expression
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(inferred_enum_call
|
||||||
|
(inferred_enum_path)
|
||||||
|
(argument_list
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(literal
|
||||||
|
(number_literal
|
||||||
|
(integer_literal))))))))))))
|
||||||
|
(tag_name)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
inferred enum struct variant
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn data() { @let x = ::User { name: "A" }; }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list)
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(template_control_flow
|
||||||
|
(let_statement
|
||||||
|
(simple_pattern
|
||||||
|
(identifier_pattern
|
||||||
|
(identifier)))
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(inferred_enum_struct
|
||||||
|
(inferred_enum_path)
|
||||||
|
(struct_field_init
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(literal
|
||||||
|
(string_literal)))))))))))))))
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
==================
|
||||||
|
@let statement
|
||||||
|
==================
|
||||||
|
|
||||||
|
@fn calc() { @let n = 42; }
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(template_element
|
||||||
|
(function_definition
|
||||||
|
(identifier)
|
||||||
|
(parameter_list)
|
||||||
|
(content_block
|
||||||
|
(template_node
|
||||||
|
(template_control_flow
|
||||||
|
(let_statement
|
||||||
|
(simple_pattern
|
||||||
|
(identifier_pattern
|
||||||
|
(identifier)))
|
||||||
|
(expression
|
||||||
|
(primary_expression
|
||||||
|
(literal
|
||||||
|
(number_literal
|
||||||
|
(integer_literal))))))))))))
|
||||||
Loading…
Reference in New Issue