Defined in header <cparse/Parser.hh>

protected:
virtual bool start() = 0;

The grammar entry point. Called once per top-level parse(). The subclass implements the whole grammar in and beneath this method — reading the cursor, calling extractToken() / extractCharacter(), tracking scopes, building an AST.

Parameters

None.

Return value

  • true — the input was fully accepted. parse() returns true provided the cursor is at end-of-input and the return-point stack is empty (see parse() Lifecycle Phase 4).
  • false — a fatal grammar error occurred that was not signalled via exit(). parse() will append an Internal-kind "unexpected file parsing result" entry to the error collector so the failure is not silent.

Non-fatal errors (bad tokens, missing punctuation the grammar can recover from) do not affect the return value — record them via recordError() and keep going.

Exceptions

Implementations may propagate std::ios_base::failure from the cursor at end-of-input; parse() catches this and translates it to success or failure based on openScopeDepth().

Implementations may call exit(), which throws a private Exited exception caught by parse() — this is the intended fatal-error path.

Any other exception that escapes start() is caught by parse() and translated to a ParseError entry — see parse() Lifecycle Phase 5.

Notes

Concrete implementations typically dispatch to a family of private helpers, one per grammar production:

bool start() override
{
    skipCommentsBlock();
    if (!parseDocument())
    {
        recordError(ParseError::Kind::Syntax, "malformed document");
        return false;
    }
    return true;
}

Returning false and calling exit(1) are subtly different: the first appends the automatic "unexpected file parsing result" Internal diagnostic on top of whatever the grammar itself recorded, the second does not. If the grammar has already recorded a precise diagnostic and wants no boilerplate on top of it, exit(1) is the cleaner choice.

See also