Skip to content
Discussion options

You must be logged in to vote

You can think of the array notation as being a postfix unary operator. You'd do well to split the definition of your type syntax into 'atoms' (self-delimiting types) and other operators, as when parsing expressions (I find it easier to think of type syntax as being 'type-level expressions'). Then, array access can look something like this:

let atom = ... ;

let array = atom
    .then(just("[]").repeated())
    .foldl(|ty, _| Type::Array(ty));

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@numToStr
Comment options

@zesterer
Comment options

@numToStr
Comment options

Answer selected by numToStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants