Description
Notation3 parsing.
The document may arrive whole or in chunks. Unlike the RDF parsers it emits nothing as it reads, and that is a difference in the grammar rather than an omission: an N3 formula is a term, a term is not meaningful until it is closed, and a document whose outermost construct is a formula offers no boundary to hand anything back at. What chunks buy is the scanner, which is where splitting hurts -- input may be cut at any byte, including inside an escape, a literal or an IRI, and the formula that comes out is the one the whole text would have given.
Create
function Create
(Base_IRI : String := "";
Limits : Parse_Limits := (others => <>)) return Parser
Start a parser.
Parameters
- Base_IRI
Absolute IRI relative references resolve against
- Limits
Return value
A parser awaiting its first chunk
Feed
procedure Feed (Into : in out Parser; Bytes : String)
Supply the next piece of the document.
Parameters
- Into
The parser
- Bytes
The next bytes, split at any boundary
Raised exceptions
- Parse_Error
The bytes cannot begin a token
- Parser_State_Error
The parser has already finished
Finish
function Finish (Into : in out Parser) return Model.Term
Close the input and parse what arrived.
Parameters
- Into
The parser
Return value
The document as a formula
Raised exceptions
- Parse_Error
The document is not well-formed
- Parser_State_Error
The parser has already finished
Parse
function Parse
(Document : String;
Base_IRI : String := "";
Limits : Parse_Limits := (others => <>)) return Model.Term
Parameters
- Document
- Base_IRI
- Limits
Return value
Parse_Error
Parse_Error : exception;
Raised when a document is not well-formed N3. The message names the line and column.
Parse_Limits
subtype Parse_Limits is Flyology_RDF.Chunk_Scanners.Scan_Limits;
Parse a document into the formula it denotes.
The result is a formula whose statements are the document's top-level statements, which is what N3 means by the document itself. @param Document The N3 text @param Base_IRI Absolute IRI relative references resolve against @return The document as a formula @exception Parse_Error The document is not well-formed What one document may cost to read. A caller taking input from a network must be able to say what it will accept, and the defaults are the same as the RDF parser's.
Parser
type Parser is limited private;
A document read from input that arrives in pieces.
Parser_State_Error
Parser_State_Error : exception;
Raised when a parser is fed or finished twice.