HaXml-1.25.9: Utilities for manipulating XML documents
Safe HaskellSafe-Inferred
LanguageHaskell98

Text.XML.HaXml.Lex

Description

You don't normally need to use this Lex module directly - it is called automatically by the parser. (This interface is only exposed for debugging purposes.)

This is a hand-written lexer for tokenising the text of an XML document so that it is ready for parsing. It attaches position information in (line,column) format to every token. The main entry point is xmlLex. A secondary entry point, xmlReLex, is provided for when the parser needs to stuff a string back onto the front of the text and re-tokenise it (typically when expanding macros).

As one would expect, the lexer is essentially a small finite state machine.

Synopsis

Entry points to the lexer

xmlLex :: String -> String -> [Token] Source #

The first argument to xmlLex is the filename (used for source positions, especially in error messages), and the second is the string content of the XML file.

xmlReLex :: Posn -> String -> [Token] Source #

xmlReLex is used when the parser expands a macro (PE reference). The expansion of the macro must be re-lexed as if for the first time.

reLexEntityValue :: (String -> Maybe String) -> Posn -> String -> [Token] Source #

reLexEntityValue is used solely within parsing an entityvalue. Normally, a PERef is logically separated from its surroundings by whitespace. But in an entityvalue, a PERef can be juxtaposed to an identifier, so the expansion forms a new identifier. Thus the need to rescan the whole text for possible PERefs.

Token types

type Token = (Posn, TokenT) Source #

All tokens are paired up with a source position. Lexical errors are passed back as a special TokenT value.

data TokenT Source #

The basic token type.

Instances

Instances details
Eq TokenT Source # 
Instance details

Defined in Text.XML.HaXml.Lex

Methods

(==) :: TokenT -> TokenT -> Bool #

(/=) :: TokenT -> TokenT -> Bool #

Show TokenT Source # 
Instance details

Defined in Text.XML.HaXml.Lex

data Special Source #

Instances

Instances details
Eq Special Source # 
Instance details

Defined in Text.XML.HaXml.Lex

Methods

(==) :: Special -> Special -> Bool #

(/=) :: Special -> Special -> Bool #

Show Special Source # 
Instance details

Defined in Text.XML.HaXml.Lex

data Section Source #

Constructors

CDATAx 
INCLUDEx 
IGNOREx 

Instances

Instances details
Eq Section Source # 
Instance details

Defined in Text.XML.HaXml.Lex

Methods

(==) :: Section -> Section -> Bool #

(/=) :: Section -> Section -> Bool #

Show Section Source # 
Instance details

Defined in Text.XML.HaXml.Lex