|
FE 0.6.1
A header-only C++ library for writing frontends
|
The blueprint for a recursive descent/ ascent parser using a K lookahead of Tokens.
More...
#include <fe/parser.h>
Classes | |
| class | Tracker |
Protected Member Functions | |
Construction | |
| void | init (const std::filesystem::path *path) |
Tracker | |
Track Location in Source File. Use like this: auto track = tracker();
auto foo = parse_foo();
auto bar = parse_bar();
auto foobar = new FooBar(track, foo, bar);
| |
| Tracker | tracker () |
| Factory method to build a Parser::Tracker. | |
| Tracker | tracker (Pos begin) |
As above but start tracking at begin. | |
| Tracker | tracker (Loc begin) |
Shift Token | |
| Tok | ahead (size_t i=0) const |
| Tok | lex () |
| Invoke Lexer to retrieve next Token. | |
| Tok | accept (Tag tag) |
If Parser::ahead() is a tag, consume and return it, otherwise yield std::nullopt. | |
| Tok | expect (Tag tag, std::string_view ctxt) |
Parser::lex Parser::ahead() which must be a tag. | |
| Tok | eat (Tag tag) |
Consume Parser::ahead which must be a tag; asserts otherwise. | |
Protected Attributes | |
| Ring< Tok, K > | ahead_ |
| Loc | curr_ |
The blueprint for a recursive descent/ ascent parser using a K lookahead of Tokens.
Parser::accept and Parser::expect indicate failure by constructing a Token with its default constructor. Provide a conversion operator to bool to check for an error:
|
inlineprotected |
If Parser::ahead() is a tag, consume and return it, otherwise yield std::nullopt.
|
inlineprotected |
|
inlineprotected |
Consume Parser::ahead which must be a tag; asserts otherwise.
|
inlineprotected |
Parser::lex Parser::ahead() which must be a tag.
Issue error with ctxt otherwise.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Factory method to build a Parser::Tracker.
|
inlineprotected |
Definition at line 75 of file parser.h.
References fe::Loc::begin.
|
inlineprotected |
|
protected |
|
protected |