next node: ParserLCombinator,
prev node: ParserLMap,
up to node: Subsystem Parser Light


ParserLBasic

Signature of ParserLBasic

List of Import References :
See BOOL
See Char
See DENOTATION
See Int
See Nat
See Option
See ParserL
See Real
See Seq
See String
See Void

SIGNATURE ParserLBasic

$Date: 2010-09-30 18:24:17 +0200 (Do, 30. Sep 2010) $ ($Revision: 616 $)

Imports

IMPORT ParserL[bool] ONLY parser
       ParserL[nat] ONLY parser
       Nat ONLY nat
       ParserL[int] ONLY parser
       Int ONLY int
       ParserL[char] ONLY parser
       Char ONLY char
       ParserL[real] ONLY parser
       Real ONLY real
       ParserL[denotation] ONLY parser
       ParserL[string] ONLY parser
       String ONLY string
       ParserL[void] ONLY parser
       Void ONLY void

Parsers for basic types

FUN parse: parser[bool]
FUN parse: parser[nat]
FUN parse: parser[int]
FUN parse: parser[char]
FUN parse: parser[real]

These two recognize the rest of the string

FUN parse: parser[denotation]
FUN parse: parser[string]

These recognize upto (and excluding) the character / predicate

FUN upto: char -> parser[denotation]
FUN upto: (char -> bool) -> parser[denotation]
FUN upto: char -> parser[string]
FUN upto: (char -> bool) -> parser[string]

These recognize maximal consecutive characters fullfilling predicate

FUN * : (char -> bool) -> parser[string]
FUN * : (char -> bool) -> parser[denotation]

These recognize at least one character fullfilling predicate. Breaks if first character does not match.

FUN + : (char -> bool) -> parser[string]
FUN + : (char -> bool) -> parser[denotation]

These recognize characters upto a newline. Removes newline from context, but breaks only for the empty context.

FUN line: parser[denotation]
FUN line: parser[string]

recognize next n characters. Breaks if context is too short.

FUN chunk : nat -> parser[denotation]
FUN chunk : nat -> parser[string]

recognize zero or more consecutive whitespace characters

FUN skip: parser[void]

recognize words or numbers. The first character must be a letter / digit. Results are non-empty.

FUN letters : parser[denotation]
FUN letters : parser[string]
FUN digits : parser[denotation]
FUN digits : parser[string]

Special Character Parsers

recognize only the given character

FUN ! : char -> parser[char]

recognize all characters which fulfill the predicate

FUN ! : (char -> bool) -> parser[char]

build a range of characters

FUN - : char ** char -> (char -> bool)

Parser for text to be checked

We employ the type parser[void] for this purpose

recognize a whitespace character

FUN ws: parser[void]

recognize the given denotation

FUN ! : denotation -> parser[void]

recognize the empty string

FUN <> : parser[void]

recognizes the empty string, but succeeds only if current context is the empty string.

FUN $ : parser[void]

Side-effects

All of the following parsers always succeed.

change context as indicated by function

FUN upd: (string -> string) -> parser[void]

insert string before context

FUN insert: string -> parser[void]

insert character before context

FUN unget: char -> parser[void]

switch to given context

FUN switch: string -> parser[void]

clear context

FUN clear: parser[void]


next node: ParserLCombinator,
prev node: ParserLMap,
up to node: Subsystem Parser Light