CPShiftReduceParser Class Reference
Inherits from | CPParser : NSObject |
Conforms to | NSCoding |
Declared in | CPShiftReduceParser.h CPShiftReduceParser.m |
Overview
The CPShiftReduceParser is a further abstract class based on CPParser. This implements the parts of a parser in common between all shift/reduce type parsers.
Warning: Note that to create a parser you should use one of CPShiftReduceParser’s subclasses.
Tasks
-
– initWithGrammar:
Initialises a parser for a certain grammar.
-
– parse:
Parses an input token stream.
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