Skip to content

Commit

Permalink
Merge pull request #1122 from onflow/bastian/fix-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Aug 23, 2021
2 parents 0a7100c + cd1e270 commit 31d41e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ to determine if the value declaration should be available/declared in the given
For example, this allows declaring a function that is only available in the service account.
In this case, the availability function would need to check if the location is an `AddressLocation`,
and that the address of the address location is the address of the service account.

## How is Cadence parsed?

Cadence's parser is implemented as a hand-written recursive descent parser which uses operator precedence parsing.
The recursive decent parsing technique allows for greater control, e.g. when implementing whitespace sensitivity, ambiguities, etc.
The handwritten parser also allows for better / great custom error reporting and recovery.

The operator precedence parsing technique avoids constructing a CST and the associated overhead, where each grammar rule is translated to a CST node.
For example, a simple integer literal would be "boxed" in several outer grammar rule nodes.
2 changes: 1 addition & 1 deletion docs/language/built-in-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: Built-in Functions
and reports a message which explains why the unrecoverable error occurred.

```cadence
let optionalAccount: Account? = // ...
let optionalAccount: AuthAccount? = // ...
let account = optionalAccount ?? panic("missing account")
```

Expand Down
12 changes: 7 additions & 5 deletions docs/language/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ import FungibleToken from 0x42
let newVault <- create FungibleToken.createVault(initialBalance: 10)
```

Contracts have the implicit field `let account: Account`,
## Account access

Contracts have the implicit field `let account: AuthAccount`,
which is the account in which the contract is deployed too.
This gives the contract the ability to e.g. read and write to the account's storage.

Expand Down Expand Up @@ -294,7 +296,7 @@ let code = "70756220636f6e...".decodeHex()
// `code` has type `[UInt8]`
let signer: Account = ...
let signer: AuthAccount = ...
signer.contracts.add(
name: "Test",
code: code,
Expand Down Expand Up @@ -356,7 +358,7 @@ let code = "70756220636f6e...".decodeHex()
// `code` has type `[UInt8]`
let signer: Account = ...
let signer: AuthAccount = ...
signer.contracts.update__experimental(name: "Test", code: code)
```

Expand All @@ -375,7 +377,7 @@ A deployed contract can be get from an account using the `get` function:
For example, assuming that a contract named `Test` is deployed to an account, the contract can be retrieved as follows:

```cadence
let signer: Account = ...
let signer: AuthAccount = ...
let contract = signer.contracts.get(name: "Test")
```

Expand All @@ -396,7 +398,7 @@ A deployed contract can be removed from an account using the `remove` function:
For example, assuming that a contract named `Test` is deployed to an account, the contract can be removed as follows:

```cadence
let signer: Account = ...
let signer: AuthAccount = ...
let contract = signer.contracts.remove(name: "Test")
```

Expand Down

0 comments on commit 31d41e7

Please sign in to comment.