CPParser Class Reference
Inherits from | NSObject |
Declared in | CPParser.h CPParser.m |
Overview
The CPParser class allows you to parse token streams.
Parsers are built by constructing a grammar, and then using it to create a parser. The parser delegate may be used to monitor and replace output from the parser.
Warning: Note that CPParser is an abstract superclass. Use one of its subclasses to construct your parser.
Tasks
Creating and Initialising a Parser
-
+ parserWithGrammar:
Creates a parser for a certain grammar.
-
– initWithGrammar:
Initialises a parser for a certain grammar.
Managing the Delegate
-
delegate
The parser’s delegate.
property
Finding out about the parsed Grammar
-
grammar
The parser’s grammar.
property
Parsing a Token Stream.
-
– parse:
Parses an input token stream.
Properties
Class Methods
parserWithGrammar:
Creates a parser for a certain grammar.
+ (id)parserWithGrammar:(CPGrammar *)grammar
Parameters
- grammar
The grammar on which to base the parser.
Return Value
Returns a parser that parses the input grammar, or nil if no such parser could be created.
Discussion
Creates a parser for a certain grammar.
Declared In
CPParser.h
Instance Methods
initWithGrammar:
Initialises a parser for a certain grammar.
- (id)initWithGrammar:(CPGrammar *)grammar
Parameters
- grammar
The grammar on which to base the parser.
Return Value
Returns a parser that parses the input grammar, or nil if no such parser could be created.
Discussion
Initialises a parser for a certain grammar.
Declared In
CPParser.h
parse:
Parses an input token stream.
- (id)parse:(CPTokenStream *)tokenStream
Parameters
- tokenStream
The token stream to parse.
Return Value
Returns the parsed syntax tree for the whole stream or nil
if the token stream could not be parsed.
Discussion
Parses an input token stream.
Currently if errors are generated, nil
is returned and the error Logged using NSLog. This behaviour may change in the future to return the error in a more usable form.
Declared In
CPParser.h