From 9e5079151bd3377486701fceafcb223e203b048a Mon Sep 17 00:00:00 2001 From: Leo dev Date: Thu, 11 Jul 2024 18:02:53 +0200 Subject: [PATCH] fixed bugs --- src/parser.rs | 6 +++--- src/wyst.pest | 31 +++++++++++++------------------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index d161d4a..6625ca9 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -9,9 +9,9 @@ pub fn parse(input: String, rule: Rule) { match WystParser::parse(rule, &input) { Ok(parsed) => { for pair in parsed { - for inner in pair.into_inner() { - println!("{:?}", inner.into_inner()) - } + println!("---------START--------"); + println!("{:?}", pair); + println!("---------END--------"); } // println!("{:#?}", parsed); } diff --git a/src/wyst.pest b/src/wyst.pest index d6e9e37..34386e4 100644 --- a/src/wyst.pest +++ b/src/wyst.pest @@ -1,6 +1,10 @@ WHITESPACE = _{ " " | "\t" | "\n" } + // [literals] +filepath = { ("/" | identifier | "-" | "." )+ } +include = { "#" ~ "include" ~ "\"" ~ filepath ~ "\"" } +include_global = { "#" ~ "include" ~ "<" ~ filepath ~ ">" } round = { "(" ~ (expr)* ~ ")" } curly = { "{" ~ (code_expr)* ~ "}" } escape = { "\\" ~ ANY } @@ -23,7 +27,7 @@ var_def = { identifier ~ identifier } var_def_set = { var_def ~ "=" ~ expr ~ semicolon } func_def = { identifier ~ identifier ~ round ~ curly } -expr = {( +expr = { round | curly | char | @@ -32,27 +36,18 @@ expr = {( int | bool | identifier | - string | - semicolon -)+} + string +} -code_expr = {( - round | - curly | - char | +code_expr = { var_def_set | - (var_def ~ semicolon) | - hex | - float | - int | - bool | - // identifier | - string | - semicolon -)+} + (var_def ~ semicolon) +} top_expr = { ( - func_def + func_def | + include | + include_global )+ } \ No newline at end of file