pub fn from_tokens(
        id: &mut i64,
        content: &Vec<Token>,
        ind: usize,
        comment_mark: &CommentMarkPair,
    ) -> Result<SExpression> {
        //check first token
        if &content[ind] != "(" {
            return Err(Error::new(ErrorKind::InvalidInput, "Wrong input."));
        }

        Self::find_wrap_parentheses(ind, content)?;

        let mut result = SExpression {
            id: *id,
            expression: vec![],
        };
        *id += 1;

        //clean first "("
        let mut ind_inner = ind + 1;
        loop {
            match content[ind_inner].as_str() {
                "(" => {
                    let end = Self::find_wrap_parentheses(ind_inner, content)?;

                    result
                        .expression
                        .push(ExpressionNode::SExpression(Self::from_tokens(
                            id,
                            content,
                            ind_inner,
                            comment_mark,
                        )?));

                    ind_inner = end;
                    continue;
                }
                ")" => {
                    break;
                }
                "\n" => {
                    ind_inner += 1;
                }
                _ => {
                    let end_mark = comment_mark.if_comment(&content[ind_inner]);
                    if let Some(end_) = end_mark {
                        result.expression.push(Self::pick_comment_out(
                            content,
                            &mut ind_inner,
                            end_,
                        ))
                    } else {
                        result
                            .expression
                            .push(ExpressionNode::Symbol(content[ind_inner].clone()));
                        ind_inner += 1;
                    }
                }
            }
        }

        Ok(result)
    }
// id is total number of scopes
id is total number of scopes
id is total number of scopes
pub fn from_tokens(
        id: &mut i64,
        content: &Vec<Token>,
        ind: usize,
        comment_mark: &CommentMarkPair,
    ) -> Result<SExpression> {
        //check first token
        if &content[ind] != "(" {
            return Err(Error::new(ErrorKind::InvalidInput, "Wrong input."));
        }
        Self::find_wrap_parentheses(ind, content)?;
        let mut result = SExpression {
            id: *id,
            expression: vec![],
        };
        *id += 1;
        //clean first "("
        let mut ind_inner = ind + 1;
        loop {
            match content[ind_inner].as_str() {
                "(" => {
                    let end = Self::find_wrap_parentheses(ind_inner, content)?;
                    result
                        .expression
                        .push(ExpressionNode::SExpression(Self::from_tokens(
                            id,
                            content,
                            ind_inner,
                            comment_mark,
                        )?));
                    ind_inner = end;
                    continue;
                }
                ")" => {
                    break;
                }
                "\n" => {
                    ind_inner += 1;
                }
                _ => {
                    let end_mark = comment_mark.if_comment(&content[ind_inner]);
                    if let Some(end_) = end_mark {
                        result.expression.push(Self::pick_comment_out(
                            content,
                            &mut ind_inner,
                            end_,
                        ))
                    } else {
                        result
                            .expression
                            .push(ExpressionNode::Symbol(content[ind_inner].clone()));
                        ind_inner += 1;
                    }
                }
            }
        }
        Ok(result)
    }
pub fn from_tokens ( id : & mut i64 , content : & Vec < Token > , ind : usize , comment_mark : & CommentMarkPair , ) -> Result < SExpression > { //check first token if & content [ ind ] != " " { return Err ( Error :: new ( ErrorKind :: InvalidInput , " " ) ) ; } Self :: find_wrap_parentheses ( ind , content ) ? ; let mut result = SExpression { id : * id , expression : vec ! [ ] , } ; * id += 1 ; //clean first "(" let mut ind_inner = ind + 1 ; loop { match content [ ind_inner ] . as_str ( ) { " " => { let end = Self :: find_wrap_parentheses ( ind_inner , content ) ? ; result . expression . push ( ExpressionNode :: SExpression ( Self :: from_tokens ( id , content , ind_inner , comment_mark , ) ? ) ) ; ind_inner = end ; continue ; } " " => { break ; } " \n " => { ind_inner += 1 ; } _ => { let end_mark = comment_mark . if_comment ( & content [ ind_inner ] ) ; if let Some ( end_ ) = end_mark { result . expression . push ( Self :: pick_comment_out ( content , & mut ind_inner , end_ , ) ) } else { result . expression . push ( ExpressionNode :: Symbol ( content [ ind_inner ] . clone ( ) ) ) ; ind_inner += 1 ; } } } } Ok ( result ) }
id is total number of scopes
id is total number of scopes
id
&mut i64
content
&Vec<Token>
ind
usize
comment_mark
&CommentMarkPair
id
&mut i64
content
&Vec<Token>
ind
usize
comment_mark
&CommentMarkPair