Skip to content

Commit

Permalink
Update grammar for func in WIT.md (#238)
Browse files Browse the repository at this point in the history
* Update grammar for `func` in `WIT.md`

* Also change the bindgen demo to use `func` instead of `function`.

* Update parser error message from `fn` to `func`.
  • Loading branch information
eyebrowsoffire committed Jun 11, 2022
1 parent c169314 commit de91e00
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ union-cases ::= ty,
| ty ',' union-cases?
```

## Item: `function`
## Item: `func`

Functions can also be defined in a `*.wit` document. Functions have a name,
parameters, and results. Functions can optionally also be declared as `async`
Expand All @@ -383,7 +383,7 @@ sleep: async func(ms: u64)
Specifically functions have the structure:

```wit
func-item ::= id ':' 'async'? 'function' '(' func-args ')' func-ret
func-item ::= id ':' 'async'? 'func' '(' func-args ')' func-ret
func-args ::= func-arg
| func-arg ',' func-args?
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<'a> Item<'a> {
Some((_span, Token::Id)) | Some((_span, Token::ExplicitId)) => {
Value::parse(tokens, docs).map(Item::Value)
}
other => Err(err_expected(tokens, "`type`, `resource`, or `fn`", other).into()),
other => Err(err_expected(tokens, "`type`, `resource`, or `func`", other).into()),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-bindgen-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1>Input <code>*.wit</code></h1>
name: string,
age: u32,
}
hello: function(who: person) -&gt; string
hello: func(who: person) -&gt; string
</textarea>
</div>
<div class='area'>
Expand Down

0 comments on commit de91e00

Please sign in to comment.