Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] Function argument parser #48

Closed
Totobird-Creations opened this issue Jan 27, 2022 · 1 comment
Closed

[HELP] Function argument parser #48

Totobird-Creations opened this issue Jan 27, 2022 · 1 comment

Comments

@Totobird-Creations
Copy link

Hello. I would like to create a parser that can find LPAREN (IDENTIFIER COLON TYPE (COMMA IDENTIFIER COLON TYPE)*)? RPAREN. How can I repeatedly find a specific pattern?

pub enum DeclarationContent {
    Function {
        name : String,
        argTypes : HashMap<String, Types>, // <- I would like to find multiple of these
        returnTypes : Types,
        body : FunctionBody
    }
}

pub struct FunctionBody {
    expressions : Vec<Expression> // and multiple of these.
}

pub enum Types {
    Void,
    Integer,
    FloatingPoint,
    String,
    Character,
    Boolean,
    Array {
        length : i32,
        types  : Box<Types>
    },
    UnsizedArray {
        types : Box<Types>
    },
    Tuple {
        types : Box<Vec<Types>>
    },
    Dictionary {
        keyTypes   : Box<Types>,
        valueTypes : Box<Types>
    },
    Function {
        argsTypes   : Box<Vec<Types>>,
        returnTypes : Box<Types>
    },
    Other {
        name : String
    }
}
@Totobird-Creations
Copy link
Author

I figured out a way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant