@@ -48,13 +48,13 @@ This is added to the ``TokenMap`` like this:
48 (operator, \x => Operator x),
48 (operator, \x => Operator x),
49 (is '(' ,\x => OParen),
49 (is '(' ,\x => OParen),
50 (is ')' ,\x => CParen),
50 (is ')' ,\x => CParen),
51− (space, Comment),
51+ (spaces, Comment),
52 (comment, Comment)]
52 (comment, Comment)]
54As you can see, the comment is defined like a single line Idris comment,
54As you can see, the comment is defined like a single line Idris comment,
55it starts with ``--`` and continues for the remainder of the line.
55it starts with ``--`` and continues for the remainder of the line.
57−We don't need to define ``space`` because it is already defined in
57+We don't need to define ``spaces`` because it is already defined in
58: https://github.com/idris-lang/Idris-dev/blob/master/libs/contrib/Text/Lexer.idr
58: https://github.com/idris-lang/Idris-dev/blob/master/libs/contrib/Text/Lexer.idr
@@ -75,11 +75,6 @@ Whitespace and Comments in Parser
76Now that there are ``Comment`` tokens the parser needs to be able to handle them.
76Now that there are ``Comment`` tokens the parser needs to be able to handle them.
78−So far we don't have any syntax that requires spaces to be significant so we
79−need to define the grammar so that it will parse with, or without, spaces.
80−This needs to be done in a systematic way, here I have defined the grammar so
81−that there is an optional space to the right of every atom or operator:
83.. code-block:: idris
78.. code-block:: idris
85 commentSpace : Rule Integer
80 commentSpace : Rule Integer
@@ -87,6 +82,11 @@ that there is an optional space to the right of every atom or operator:
87 Comment s => Just 0
82 Comment s => Just 0
88 _ => Nothing)
83 _ => Nothing)
85+So far we don't have any syntax that requires spaces to be significant so we
86+need to define the grammar so that it will parse with, or without, spaces.
87+This needs to be done in a systematic way, here I have defined the grammar so
88+that there is an optional space to the right of every atom or operator:
90.. code-block:: idris
90.. code-block:: idris
@@ -122,6 +122,24 @@ that there is an optional space to the right of every atom or operator:
123 expr = expr3 <|> exprAdd
123 expr = expr3 <|> exprAdd
125+Defining Block Structure using Indents
126+--------------------------------------
128+Many languages such as Python, Haskell and Idris use indents to delimit
129+the block structure of the language.
131+We can see how Idris2 does it here
132+: https://github.com/edwinb/Idris2/blob/master/src/Parser/Support.idr
134+.. code-block:: idris