Compiler.Parse.Module

This will let you parse entire modules of Gren code.

parser : Parser Context Error Module

Use this to parse an entire module (file) of Gren code.

String.Parser.run parser Compiler.Parse.Context.empty source
type Error
= ExpectedKeyword String
| ExpectedChar Char
| VariableError Error
| OperatorError Error
| ExpectedIntPrecedence
| DeclarationError Error
| SpaceError Error
| ExpectedEnd

The kind of errors that can happen while parsing Gren modules.

errorToString : Error -> String

Returns a human-readable description of an Error.

errorsToString : String -> Array (DeadEnd Context Error) -> String

Use this when parsing fails to give the user a good idea of where the parser failed, and why.

import Compiler.Parse.Module as PM
import Compiler.Parser.Context as Context
import String.Parser.Advanced as Parser

when Parser.run PM.parser Context.empty source is
    Ok _ -> 
        "Parsed OK"

    Err errs ->
        PM.errorsToString source errs