Configuring the Lexer (parsley.token.descriptions)

The Lexer is configured primarily by providing it a LexicalDesc. This is a structure built up of many substructures that each configure a specific part of the overall functionality available. In general, many parts of this hierarchy have "sensible defaults" in the form of their plain value within their companion objects; these document what choices were made in each individual case. There may also be some values crafted to adhere to some specific language specification; for instance, EscapeDesc.haskell describes escape characters that adhere to the Haskell Report.

This page does not aim to document everything that is configurable within LexicalDesc, but it will outline the general design and how things slot together.

Diagram of Dependencies

The hierarchy of types involved with lexical configuration can be daunting. The following diagram illustrates both the "has-a" and "is-a" relationships between the types. For instance, TextDesc contains an EscapeDesc, and NumericEscape may be implemented by either NumericEscape.Illegal or NumericEscape.Supported.

classDiagram
direction LR

LexicalDesc *-- NumericDesc
LexicalDesc *-- NameDesc
LexicalDesc *-- SpaceDesc
LexicalDesc *-- SymbolDesc
LexicalDesc *-- TextDesc

TextDesc *-- EscapeDesc
EscapeDesc *-- NumericEscape
NumericEscape_Illegal --|> NumericEscape
NumericEscape_Supported --|> NumericEscape
NumericEscape_Supported *-- NumberOfDigits
NumberOfDigits_AtMost --|> NumberOfDigits
NumberOfDigits_Exactly --|> NumberOfDigits
NumberOfDigits_Unbounded --|> NumberOfDigits

ExponentDesc --* NumericDesc
ExponentDesc_Supported --|> ExponentDesc
ExponentDesc_NoExponents --|> ExponentDesc
NumericDesc *-- BreakCharDesc
ExponentDesc_Supported *-- PlusSignPresence

BreakCharDesc <|-- BreakCharDesc_Supported
BreakCharDesc <|-- BreakCharDesc_NoBreakChar

PlusSignPresence <|-- PlusSignPresence_Illegal
PlusSignPresence <|-- PlusSignPresence_Optional
PlusSignPresence <|-- PlusSignPrecense_Required
NumericDesc *-- PlusSignPresence

In the above diagram, an _ represents a .

The types in the diagram that have alternative implements are as follows: