I'm studying pest parser from https://pest.rs/book/intro.html
and here is the .pest file below
num = @{ int ~ ("." ~ ASCII_DIGIT*)? ~ (^"e" ~ int)? }
int = { ("+" | "-")? ~ ASCII_DIGIT+ }
operation = _{ add | subtract | multiply | divide | power }
add = { "+" }
subtract = { "-" }
multiply = { "*" }
divide = { "/" }
power = { "^" }
expr = { term ~ (operation ~ term)* }
term = _{ num | "(" ~ expr ~ ")" }
calculation = _{ SOI ~ expr ~ EOI }
WHITESPACE = _{ " " | "\t" }
Now here, I'm curious about how to parse parentheses part,
For example,
num = @{ int ~ ("." ~ ASCII_DIGIT*)? ~ (^"e" ~ int)? }
int = { ("+" | "-")? ~ ASCII_DIGIT+ }
expr = { term ~ (operation ~ term)* }
I wanna know how to parse these things, more precisely,
ASCII_DIGIT*)?,
(^"e" ~ int)?,
("+" | "-")?,
ASCII_DIGIT+,
(operation ~ term)*
Can I just parse like the other regardless of ?, +, * things?
Furthermore,
expr = { term ~ (operation ~ term)* }
This thing seems like recursion.
How can I parse this recursive thing?