Compiler.Parse.Space

This module provides parsers for whitespace and comments in Gren code.

parser : Parser Context Error {}

Use this to parse whitespace and comments. This will change lineStart and comments fields of Context.

String.Parser.run parser Compiler.Parse.Context.empty source
type Error
= ExpectedLineComment
| ExpectedMultiLineOpen
| ExpectedMultiLineClose
| InvalidWhiteSpace

The kind of errors that can happen while parsing whitespace and comments.

errorToString : Error -> String

Returns a human-readable description of an Error.

Indentation helpers

scopeIndentToLineStart : Parser Context e v -> Parser Context e v

This will set Context.indent to be ´Context.startLine` for the duration of the provided parser.

checkIndent : Parser Context {} {}

Use this to check that the current indentation is valid. That is, the current column has to be greater than Context.indent.

This allows you to stop parsing when the indentation level decreases.