Compiler.Parse.Variable

This module provides parsers for Gren variables and identifiers.

lowerCase : Parser Context Error String

Use this to parse lowercase variable names. It will fail if the variable is one of the reserved words.

String.Parser.run lowerCase Compiler.Parse.Context.empty source
reservedWords : Set String

Words which successfully parses as variables, but which are reserved by the language spec. This includes words like if, when, import etc.

upperCase : Parser Context Error String

Use this to parse uppercase variable names (like type constructors).

String.Parser.run upperCase Compiler.Parse.Context.empty source
foreignUpper : Parser Context Error ForeignVar

Use this to parse foreign uppercase variables (like Maybe.Just).

String.Parser.run foreignUpper Compiler.Parse.Context.empty source
foreignVar : Parser Context Error ForeignVar

Use this to parse foreign variables (like List.map or Maybe.Just).

String.Parser.run foreignVar Compiler.Parse.Context.empty source
type ForeignVar
= Unqualified String
| Qualified ({ module_ : String, name : String })

The result of using a foreign* parser. Sometimes you will get an actual foreign (qualified) var. Sometimes you just get an upper-case identifier.

foreignVarToString : ForeignVar -> String

Convert a foreign variable to its string representation.

Errors

type Error
= InvalidCharacter
| ExpectedDot
| ReservedWord String

The kind of errors that can happen while parsing variables.

errorToString : Error -> String

Returns a human-readable description of an Error.