/home/runner/work/neco-project/neco-project/gen1/felis-syn/src/syn_expr/syn_expr_app.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use crate::{ |
2 | | decoration::{Decoration, UD}, |
3 | | parse::Parse, |
4 | | to_felis_string::ToFelisString, |
5 | | token::Token, |
6 | | }; |
7 | | |
8 | | use super::{SynExpr, SynExprNoApp}; |
9 | | |
10 | 13 | #[derive(Debug0 , Clone, P0 artialEq0 , Eq, Hash0 )] |
11 | | pub struct SynExprApp<D: Decoration> { |
12 | | pub exprs: Vec<SynExpr<D>>, |
13 | | pub ext: D::ExprApp, |
14 | | } |
15 | | |
16 | | impl<D: Decoration> ToFelisString for SynExprApp<D> { |
17 | 1 | fn to_felis_string(&self) -> String { |
18 | 1 | let mut res = String::new(); |
19 | 1 | res.push_str(&self.exprs[0].to_felis_string()); |
20 | 1 | for expr in self.exprs.iter().skip(1) { |
21 | 1 | res.push(' '); |
22 | 1 | res.push_str(&expr.to_felis_string()); |
23 | 1 | } |
24 | 1 | res |
25 | 1 | } |
26 | | } |
27 | | |
28 | | impl Parse for SynExprApp<UD> { |
29 | 140 | fn parse(tokens: &[Token], i: &mut usize) -> Result<Option<Self>, ()> { |
30 | 140 | let mut k = *i; |
31 | 140 | |
32 | 140 | let mut exprs = vec![]; |
33 | 286 | while let Some(expr146 ) = SynExprNoApp::parse(tokens, &mut k)?0 { |
34 | 146 | exprs.push(expr.into()); |
35 | 146 | } |
36 | | |
37 | 140 | if exprs.len() <= 1 { |
38 | 98 | return Ok(None); |
39 | 42 | } |
40 | 42 | |
41 | 42 | *i = k; |
42 | 42 | Ok(Some(SynExprApp { exprs, ext: () })) |
43 | 140 | } |
44 | | } |