Skip to content

Some questions on the WIT format #154

Closed
@huwaireb

Description

@huwaireb

Hi,

[1] Comments

is there any reason why comments aren't treated as white-space and are as things stand, included in the AST?

I know that doc-comments are used somewhere, however cant we just get it from the CST then? Or at least exclude comments in the AST.

[2] Operators

operator ::= '=' | ',' | ':' | ';' | '(' | ')' | '{' | '}' | '<' | '>' | '*' | '->'
  1. I don't understand why are these operators grouped together, and why is (), <>, ,, {}, ;, -> operators?
    The only things that could could qualify as an operator here are assignment operators = and possibly :. What is an operator in this context?

  2. What is *? If we have tuple<>

[3] Reserved Keywords

  1. Is there any reason we are hard-coding builtin types as reserved types in the grammar, shouldn't that be up to a validator?
  2. Why is the keyword as treated as reserved. How its used allows it to be used as an identifier

[4] Types

  1. Is there any reason we are hard-coding builtin types into the grammar? Is there any hard-coded type with a different format than simply being an id? I don't think so? Actually, I don't know if the types with generic parameters are hard-coded yet, Option, Tuple, Record, List. However other than that none? Consider it in the context of an AST, do we need to explicitly state that a type is for example u32, Any benefit of doing so in the AST?

These builtin types are fine placed elsewhere, outside the grammar.

  1. Shouldn't unit being _ be its own type? As it stands we can't define a unit type outside a result.

I was going to open PR, however I thought it would've been appropriate to raise an issue first.

I'm not an expert of any kind in (E)BNF nor do I have experience writing an (E)BNF, so do feel free to correct me if I'm wrong.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions