Compiler.Parse.Context

This module defines the data which can be inferred from a Gren source file during parsing, but which won't end up in the resulting AST. This includes the current indentation level while parsing, and the comments picked up along the way.

The reason we store comments is that they're useful when formatting or generating code.

type alias Context =
{ indent : Int
, lineStart : Int
, comments : Builder (Located Comment)
}

The "hidden" state of a parser when parsing Gren code.

  • indent - the current indentation level
  • lineStart - the first non-whitespace character on the current line
  • comments - comments we've parsed from the source code
empty : Context

The initial Context. Use this to start parsing.

type Comment
= Line String
| Block String

There are two types of comments. Line- and block-comments.