Skip to content

Commit

Permalink
Improve documentation of lexeme conventions
Browse files Browse the repository at this point in the history
[skip ci]

Move the discussion of lexeme assumptions from the bottom of the already
very long documentation for ‘space’ to the top-level module documentation,
and bold the key convention that lexeme parsers assume no space before and
consume all space after the lexeme they parse.
  • Loading branch information
ntc2 authored and mrkkrp committed Nov 16, 2017
1 parent b99174d commit 8dc7165
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Text/Megaparsec/Char/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
-- more elegant than others. Especially important theme is parsing of white
-- space, comments, and indentation.
--
-- Parsing of white space is an important part of any parser. We propose a
-- convention where __every lexeme parser assumes no spaces before the__
-- __lexeme and consumes all spaces after the lexeme__; this is what the
-- 'lexeme' combinator does, and so it's enough to wrap every lexeme parser
-- with 'lexeme' to achieve this. Note that you'll need to call 'space'
-- manually to consume any white space before the first lexeme (i.e. at the
-- beginning of the file).
--
-- This module is intended to be imported qualified:
--
-- > import qualified Text.Megaparsec.Char.Lexer as L
Expand Down Expand Up @@ -95,14 +103,6 @@ import qualified Text.Megaparsec.Char as C
-- will fail instantly when parsing of that sort of comment is attempted and
-- 'space' will just move on or finish depending on whether there is more
-- white space for it to consume.
--
-- Parsing of white space is an important part of any parser. We propose a
-- convention where every lexeme parser assumes no spaces before the lexeme
-- and consumes all spaces after the lexeme; this is what the 'lexeme'
-- combinator does, and so it's enough to wrap every lexeme parser with
-- 'lexeme' to achieve this. Note that you'll need to call 'space' manually
-- to consume any white space before the first lexeme (i.e. at the beginning
-- of the file).

space :: MonadParsec e s m
=> m () -- ^ A parser for space characters which does not accept empty
Expand Down

0 comments on commit 8dc7165

Please sign in to comment.