s-cargot-0.1.0.0: A flexible, extensible s-expression library.

Safe HaskellSafe
LanguageHaskell2010

Data.SCargot.Common

Contents

Synopsis

Documentation

This module contains a selection of parsers for different kinds of identifiers and literals, from which more elaborate parsers can be assembled. These can afford the user a quick way of building parsers for different atom types.

parseR5RSIdent :: Parser Text Source

Parse an identifier according to the R5RS Scheme standard. This will not normalize case, even though the R5RS standard specifies that all identifiers be normalized to lower case first.

An R5RS identifier is, broadly speaking, alphabetic or numeric and may include various symbols, but no escapes.

parseR6RSIdent :: Parser Text Source

Parse an identifier according to the R6RS Scheme standard. An R6RS identifier may include inline hexadecimal escape sequences so that, for example, foo is equivalent to f\x6f;o, and is more liberal than R5RS as to which Unicode characters it may accept.

parseR7RSIdent :: Parser Text Source

Parse an identifier according to the R7RS Scheme standard. An R7RS identifier, in addition to a typical identifier format, can also be a chunk of text surrounded by vertical bars that can contain spaces and other characters. Unlike R6RS, it does not allow escapes to be included in identifiers unless those identifiers are surrounded by vertical bars.

Numeric Literal Parsers

signed :: Num a => Parser a -> Parser a Source

Given a parser for some kind of numeric literal, this will attempt to parse a leading + or a leading - followed by the numeric literal, and if a - is found, negate that literal.

prefixedNumber :: Parser Integer Source

Parses a number, determining which numeric base to use by examining the literal's prefix: 0x for a hexadecimal number, 0z for a dozenal number, 0o for an octal number, and 0b for a binary number (as well as the upper-case versions of the same.) If the base is omitted entirely, then it is treated as a decimal number.

signedPrefixedNumber :: Parser Integer Source

Parses a number in the same way as prefixedNumber, with an optional leading + or -.

binNumber :: Parser Integer Source

A parser for non-signed binary numbers

signedBinNumber :: Parser Integer Source

A parser for signed binary numbers, with an optional leading + or -.

octNumber :: Parser Integer Source

A parser for non-signed octal numbers

signedOctNumber :: Parser Integer Source

A parser for signed octal numbers, with an optional leading + or -.

decNumber :: Parser Integer Source

A parser for non-signed decimal numbers

signedDecNumber :: Parser Integer Source

A parser for signed decimal numbers, with an optional leading + or -.

dozNumber :: Parser Integer Source

A parser for non-signed duodecimal (dozenal) numbers. This understands both the ASCII characters a and b and the Unicode characters '\x218a' (↊) and '\x218b' (↋) as digits with the decimal values 10 and 11 respectively.

signedDozNumber :: Parser Integer Source

A parser for signed duodecimal (dozenal) numbers, with an optional leading + or -.

hexNumber :: Parser Integer Source

A parser for non-signed hexadecimal numbers

signedHexNumber :: Parser Integer Source

A parser for signed hexadecimal numbers, with an optional leading + or -.