Skip to content

Commit 6211f10

Browse files
author
Alex Gryzlov
committed
minor syntax fixes
1 parent 99cbe38 commit 6211f10

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/ImpParser.lidr

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
>
55

66
The development of the Imp language in `Imp.lidr` completely ignores issues of
7-
concrete syntax -- how an ascii string that a programmer might write gets
7+
concrete syntax -- how an ASCII string that a programmer might write gets
88
translated into abstract syntax trees defined by the datatypes \idr{AExp},
9-
\idr{BExp}, and \idr{Com}. In this chapter, we illustrate how the rest of the
9+
\idr{BExp}, and \idr{Com}. In this chapter, we illustrate how the rest of the
1010
story can be filled in by building a simple lexical analyzer and parser using
1111
Idris's functional programming facilities.
1212

1313
It is not important to understand all the details here (and accordingly, the
14-
explanations are fairly terse and there are no exercises). The main point is
15-
simply to demonstrate that it can be done. You are invited to look through the
14+
explanations are fairly terse and there are no exercises). The main point is
15+
simply to demonstrate that it can be done. You are invited to look through the
1616
code -- most of it is not very complicated, though the parser relies on some
1717
"monadic" programming idioms that may require a little work to make out -- but
18-
most readers will probably want to just skim down to the Examples section at the
19-
very end to get the punchline.
18+
most readers will probably want to just skim down to the `Examples` section at
19+
the very end to get the punchline.
2020

2121
> import Maps
2222
> import Imp
@@ -79,15 +79,15 @@ very end to get the punchline.
7979

8080
==== Options With Errors
8181

82-
An `option` type with error messages:
82+
An \idr{Option} type with error messages:
8383

8484
> data OptionE : (x : Type) -> Type where
8585
> SomeE : x -> OptionE x
8686
> NoneE : String -> OptionE x
8787
>
8888

89-
Some interface instances to make writing nested match-expressions on `OptionE`
90-
more convenient.
89+
Some interface instances to make writing nested match-expressions on
90+
\idr{OptionE} more convenient.
9191

9292
\todo[inline]{Explain these/link to Haskell etc?}
9393

@@ -123,13 +123,13 @@ more convenient.
123123
> | SomeE (t', xs') = manyHelper p (t'::acc) steps' xs'
124124
>
125125

126-
A (step-indexed) parser that expects zero or more `p`s:
126+
A (step-indexed) parser that expects zero or more \idr{p}s:
127127

128128
> many : (p : Parser t) -> (steps : Nat) -> Parser (List t)
129129
> many p steps = manyHelper p [] steps
130130
>
131131

132-
A parser that expects a given token, followed by `p`:
132+
A parser that expects a given token, followed by \idr{p}:
133133

134134
> firstExpect : (a : Token) -> (p : Parser t) -> Parser t
135135
> firstExpect a p (x::xs) = if x == a then p xs else NoneE ("Expected '" ++ a ++ "'")
@@ -316,6 +316,7 @@ SomeE (CIf (BEq (AId (MkId "x")) (APlus (AMinus (APlus (APlus (AId (MkId "y")) (
316316
\todo[inline]{This one is repeated twice in the book for some reason}
317317

318318
```idris
319+
λΠ> parse "SKIP;; z:=x*y*(x*x);; WHILE x==x DO IF z <= z*z && not x == 2 THEN x := z;; y := z ELSE SKIP END;; SKIP END;; x:=z"
319320
SomeE (CSeq CSkip
320321
(CSeq (CAss (MkId "z") (AMult (AMult (AId (MkId "x")) (AId (MkId "y"))) (AMult (AId (MkId "x")) (AId (MkId "x")))))
321322
(CSeq (CWhile (BEq (AId (MkId "x")) (AId (MkId "x")))

0 commit comments

Comments
 (0)