Gyoji Compiler
|
Represents tokens from the lexer used to represent keywords and identifiers found in the source. More...
#include <tree.hpp>
Public Types | |
enum | IdentifierType { IDENTIFIER_GLOBAL_SCOPE , IDENTIFIER_LOCAL_SCOPE , IDENTIFIER_UNCATEGORIZED } |
Public Member Functions | |
Terminal (const Gyoji::context::Token &_token) | |
~Terminal () | |
const Gyoji::context::TokenID & | get_type () const |
const std::string & | get_value () const |
const Gyoji::context::SourceReference & | get_terminal_source_ref () const |
std::string | get_fully_qualified_name () const |
std::string | get_name () const |
![]() | |
SyntaxNode (Gyoji::context::TokenID _type, specific_type_t _data, const Gyoji::context::SourceReference &_source_ref) | |
const std::vector< std::reference_wrapper< const SyntaxNode > > & | get_children () const |
const Gyoji::context::TokenID & | get_type () const |
template<class T > | |
bool | has_data () const |
template<class T > | |
const T & | get_data () const |
const SyntaxNode & | get_syntax_node () const |
const Gyoji::context::SourceReference & | get_source_ref () const |
Represents tokens from the lexer used to represent keywords and identifiers found in the source.
Terminals are the raw tokens received by the lexer. They carry the token information as well as any "Non-syntax" data like comments and whitespace.
This is the type for identifiers. Identifiers may be global symbols like functions or global/static variables. In this case, they must be resolved by the parser because resolution depends on the namespace context which is available only during parsing. This is a quirk of the C/C++ syntax. Identifiers may also be "local" identifiers like member variables or local variables which exist in a scope other than that global/namespace scope. In the 'local' case, resolution of these is deferred to the MIR layer, so we may end up passing invalid tokens to the MIR where the resolution may fail at that point or somewhere in the analysis phase.
Terminal::Terminal | ( | const Gyoji::context::Token & | _token | ) |
Construct a terminal from the corresponding lexer token.
Terminal::~Terminal | ( | ) |
Destructor, nothing special.
std::string Terminal::get_fully_qualified_name | ( | ) | const |
For the case of identifier tokens, this returns the fully-qualified name of the type, namespace, or identifier once namespace resolution has identified it.
std::string Terminal::get_name | ( | ) | const |
Return the 'leaf node' name.
const SourceReference & Terminal::get_terminal_source_ref | ( | ) | const |
Returns a reference to the place in the source-file where this terminal occurred.
const TokenID & Terminal::get_type | ( | ) | const |
Returns the type of the correspinding lexer token.
const std::string & Terminal::get_value | ( | ) | const |
Returns the matched data from the input that matched the token.