diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-14 20:13:50 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-14 20:13:50 +0200 |
| commit | 1fb2d5103d0840f24ae588f4a05ed20a13f621d0 (patch) | |
| tree | d3875bc617e253876249d2ea9a2aa0b231f661c7 /src/func.rs | |
| parent | 0ac2e86feb09cabd11c93bad325ab4acead8ccbe (diff) | |
Always parse bodies as syntax trees 🌳
Previously they were passed as strings to the function parser, now they are parsed and then passed as trees to the function. This allows making bodies sugar for a last content argument. While it removes some flexibility allowing function to parse arbitrary syntaxes in their bodies, these can be modelled as (raw) string arguments.
Diffstat (limited to 'src/func.rs')
| -rw-r--r-- | src/func.rs | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/func.rs b/src/func.rs index 57dad103..016770cb 100644 --- a/src/func.rs +++ b/src/func.rs @@ -56,21 +56,8 @@ pub fn drain_args(args: FuncArgs, f: &mut Feedback) { } } -/// Parse a function's body if there is one or return `None` otherwise. -pub fn parse_body_maybe( - body: Option<Spanned<&str>>, - state: &ParseState, - f: &mut Feedback, -) -> Option<SyntaxTree> { - body.map(|body| { - let parsed = parse(body.v, body.span.start, state); - f.extend(parsed.feedback); - parsed.output - }) -} - /// Generate an error if there is function body even though none was expected. -pub fn expect_no_body(body: Option<Spanned<&str>>, f: &mut Feedback) { +pub fn expect_no_body(body: FuncBody, f: &mut Feedback) { if let Some(body) = body { error!(@f, body.span, "unexpected body"); } |
