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

Fix errors in the parsing docs #135

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions content/courses/hoon-school/Q2-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ we have to wade directly into a sea of new types and processes. To wit:
- A {% tooltip label="tape" href="/glossary/tape" /%} is the string to
be parsed.
- A `hair` is the position in the text the parser is at, as a cell of
column & line, `[p=@ud q=@ud]`.
line & column, `[p=@ud q=@ud]`.
- A `nail` is parser input, a cell of `hair` and `tape`.
- An `edge` is parser output, a cell of `hair` and a `unit` of `hair`
- An `edge` is parser output, a cell of `hair` and a `unit` of `*`
johnhyde marked this conversation as resolved.
Show resolved Hide resolved
and `nail`. (There are some subtleties around failure-to-parse here
that we'll defer a moment.)
- A `rule` is a parser, a gate which applies a `nail` to yield an
Expand Down
8 changes: 4 additions & 4 deletions content/language/hoon/guides/parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ A `hair` is a pair of `@ud` used to keep track of what has already been parsed
for stack tracing purposes. This allows the parser to reveal where the problem
is in case it hits something unexpected during parsing.

`p` represents the column and `q` represents the line.
`p` represents the line and `q` represents the column.

### `nail`

Expand Down Expand Up @@ -173,7 +173,7 @@ We note that `p.edg` is `[p=1 q=2]`, indicating that the next character to be
parsed is in line 1, column 2. `q.edg` is not null, indicating that parsing
succeeded. `p.q.edg` is `'a'`, which is the result of the parse. `p.q.q.edg` is the same as `p.edg`, which is always the case for
`rule`s built using standard library functions when parsing succeeds. Lastly,
`q.q.edg` is `"bc"`, which is the part of the input `tape` that has yet to be parsed.
`q.q.q.edg` is `"bc"`, which is the part of the input `tape` that has yet to be parsed.
johnhyde marked this conversation as resolved.
Show resolved Hide resolved

Now let's see what happens when parsing fails.

Expand Down Expand Up @@ -208,7 +208,7 @@ Let's see what happens when we successfully parse the entire input `tape`.
line 1, column 4. Of course, this does not exist since the input `tape` was only
3 characters long, so this actually indicates that the entire `tape` has been
successfully parsed (since the `hair` does not advance in the case of failure).
`p.q.edg` is `'abc'`, as expected. `q.q.edg` is `""`, indicating that nothing
`p.q.edg` is `'abc'`, as expected. `q.q.q.edg` is `""`, indicating that nothing
johnhyde marked this conversation as resolved.
Show resolved Hide resolved
remains to be parsed.

What happens if we only match some of the input `tape`?
Expand Down Expand Up @@ -267,7 +267,7 @@ is `%foo`.

```
> ((cold %foo (just 'a')) [[1 1] "abc"])
[p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]]
[p=[p=1 q=2] q=[~ [p=%foo q=[p=[p=1 q=2] q="bc"]]]]
johnhyde marked this conversation as resolved.
Show resolved Hide resolved
```

One common scenario where `+cold` sees play is when writing [command line
Expand Down