Patched if statements acting like structs
This commit is contained in:
@@ -401,7 +401,7 @@ control_flow = {
|
|||||||
| unsafe_block
|
| unsafe_block
|
||||||
}
|
}
|
||||||
|
|
||||||
statement_branch = { expr ~ block }
|
statement_branch = { (expr_no_struct | ("(" ~ expr ~ ")")) ~ block }
|
||||||
|
|
||||||
else_if = _{
|
else_if = _{
|
||||||
"else" ~ "if" ~ statement_branch
|
"else" ~ "if" ~ statement_branch
|
||||||
@@ -446,7 +446,7 @@ match_item = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match_stmt = {
|
match_stmt = {
|
||||||
"match" ~ expr ~ "{" ~ match_item* ~ "}"
|
"match" ~ (expr_no_struct | "(" ~ expr ~ ")") ~ "{" ~ match_item* ~ "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
@@ -561,14 +561,13 @@ decrement = {
|
|||||||
"--"
|
"--"
|
||||||
}
|
}
|
||||||
|
|
||||||
postfix = {
|
postfix_no_struct = _{
|
||||||
field_px
|
field_px
|
||||||
| tuple_field_px
|
| tuple_field_px
|
||||||
| call_px
|
| call_px
|
||||||
| macro_call_paren
|
| macro_call_paren
|
||||||
| macro_call_bracket
|
| macro_call_bracket
|
||||||
| macro_call_brace
|
| macro_call_brace
|
||||||
| struct_px
|
|
||||||
| index_px
|
| index_px
|
||||||
| as_px
|
| as_px
|
||||||
| try_px
|
| try_px
|
||||||
@@ -576,6 +575,11 @@ postfix = {
|
|||||||
| decrement
|
| decrement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postfix = {
|
||||||
|
postfix_no_struct
|
||||||
|
| struct_px
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
// PREFIX EXPRESSIONS
|
// PREFIX EXPRESSIONS
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
@@ -640,3 +644,7 @@ bin_op = {
|
|||||||
expr = { term ~ (bin_op ~ term)* }
|
expr = { term ~ (bin_op ~ term)* }
|
||||||
|
|
||||||
term = { prefix* ~ primary ~ postfix* }
|
term = { prefix* ~ primary ~ postfix* }
|
||||||
|
|
||||||
|
expr_no_struct = { term_no_struct ~ (bin_op ~ term)* }
|
||||||
|
|
||||||
|
term_no_struct = { prefix* ~ primary ~ postfix_no_struct* }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Expression {
|
|||||||
let mut inner = pair.clone().into_inner();
|
let mut inner = pair.clone().into_inner();
|
||||||
|
|
||||||
match rule {
|
match rule {
|
||||||
Rule::expr => {
|
Rule::expr | Rule::expr_no_struct => {
|
||||||
static PRATT_PARSER: OnceLock<PrattParser<Rule>> = OnceLock::new();
|
static PRATT_PARSER: OnceLock<PrattParser<Rule>> = OnceLock::new();
|
||||||
let pratt = PRATT_PARSER.get_or_init(|| {
|
let pratt = PRATT_PARSER.get_or_init(|| {
|
||||||
use pest::pratt_parser::{Assoc::*, Op};
|
use pest::pratt_parser::{Assoc::*, Op};
|
||||||
@@ -36,7 +36,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Expression {
|
|||||||
.parse(inner)
|
.parse(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
Rule::term => {
|
Rule::term | Rule::term_no_struct => {
|
||||||
let mut prefix_pairs = Vec::new();
|
let mut prefix_pairs = Vec::new();
|
||||||
let mut primary_pair = None;
|
let mut primary_pair = None;
|
||||||
let mut postfix_pairs = Vec::new();
|
let mut postfix_pairs = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user