Class Parser.

Inherits Garbage

The Parser class does basic C++ parsing.

It doesn't actually parse C++: all it does is lend some support to the header and source handling, which needs to find certain constructs and look at them.

Parser::Parser( const String & s )

Constructs a Parser for string s. The parser's cursor is left at the beginning of s.

String Parser::argumentList()

Parses an argument list (for a particularly misleading meaning of parse) and returns it. The cursor must be on the leading '(', it will be left immediately after the trailing ')'.

The argument list is returned including parentheses. In case of an error, an empty string is returned and the cursor is left near the error.

bool Parser::atEnd() const

Returns true if the parser has reached the end of its input, and false if not.

uint Parser::complexIdentifier( uint j )

Scans past the complex identifier starting at j, returning the first position after the identifier. If something goes wrong, complexIdentifier() returns j.

A complex identifier is anything that may be used as an identifier in C++, even "operator const char *".

String Parser::identifier()

Returns the C++ identifier at the cursor, or an empty string if there isn't any. Steps past the identifier and any trailing whitespace.

uint Parser::line()

Returns the parser's current line number.

The line number is that of the first unparsed nonwhitespace character. This implies that if the parser's cursor is at the end of a line, then the line number returned is that of the next nonempty line.

bool Parser::lookingAt( const String & pattern )

Returns true if the first unparsed characters of the string are the same as pattern, and false if not.

uint Parser::operatorHack( uint j )

Reads past an operator name starting at j and returns the index of the following characters. If j does not point to an operator name, operatorHack() returns j.

void Parser::scan( const String & text )

Scans forward until an instance of text is found, and positions the cursor at the first character after that string.

uint Parser::simpleIdentifier( uint j )

Scans past the simpler identifier starting at j, returning the first position afte the identifier. If something goes wrong, simpleIdentifier() returns j.

A simple identifier is a text label not containing ::, <, >, whitespace or the like.

void Parser::step()

Steps the Parser past one character.

String Parser::textUntil( const String & text )

Scans for text and returns all the text, without the trailing instance of text. The cursor is left after text.

uint Parser::type( uint j )

Parses a type name starting at j and returns the first character after the type name (and after trailing whitespace). If a type name can't be parsed, j is returned.

String Parser::type()

Parses a type specifier and returns it as a string. If the cursor doesn't point to one, type() returns an empty string.

String Parser::value()

Parses and steps past a single value, which is either a number of an identifier.

uint Parser::whitespace( uint j )

Steps past the whitespace starting at j and return the index of the first following nonwhitespace character.

void Parser::whitespace()

Scans past whitespace, leaving the cursor at the end or at a nonwhitespace character.

String Parser::word()

Parses and steps past a single word. If the next nonwhitespace character is not a word character, this function returns an empty string.

This web page based on source code belonging to Oryx Mail Systems GmbH. All rights reserved.