Gyoji Compiler
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Gyoji::frontend::tree::Terminal Class Reference

Represents tokens from the lexer used to represent keywords and identifiers found in the source. More...

#include <tree.hpp>

Inheritance diagram for Gyoji::frontend::tree::Terminal:
Inheritance graph
[legend]
Collaboration diagram for Gyoji::frontend::tree::Terminal:
Collaboration graph
[legend]

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::stringget_value () const
 
const Gyoji::context::SourceReferenceget_terminal_source_ref () const
 
std::string get_fully_qualified_name () const
 
std::string get_name () const
 
- Public Member Functions inherited from Gyoji::frontend::ast::SyntaxNode
 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 SyntaxNodeget_syntax_node () const
 
const Gyoji::context::SourceReferenceget_source_ref () const
 

Detailed Description

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.

Member Enumeration Documentation

◆ IdentifierType

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.

Enumerator
IDENTIFIER_GLOBAL_SCOPE 

Indicates that this identifier is something in a 'global' scope, for example, in the root namespace or in a sub-namespace. For example, the variable 'g' in 'namespace { u32 g; }' would be an identifier in global scope.

IDENTIFIER_LOCAL_SCOPE 

Indicates that the identifier is something in a 'local' scope such as an argument of a function, a local variable in a scope, or a class member.

IDENTIFIER_UNCATEGORIZED 

This is an uncategorized identifier. It is not in local scope nor is it in global scope. For example, this may be the name of a namespace or other thing that is consumed only at the syntax level and has no semantic meaning.

Constructor & Destructor Documentation

◆ Terminal()

Terminal::Terminal ( const Gyoji::context::Token _token)

Construct a terminal from the corresponding lexer token.

◆ ~Terminal()

Terminal::~Terminal ( )

Destructor, nothing special.

Member Function Documentation

◆ get_fully_qualified_name()

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.

◆ get_name()

std::string Terminal::get_name ( ) const

Return the 'leaf node' name.

◆ get_terminal_source_ref()

const SourceReference & Terminal::get_terminal_source_ref ( ) const

Returns a reference to the place in the source-file where this terminal occurred.

◆ get_type()

const TokenID & Terminal::get_type ( ) const

Returns the type of the correspinding lexer token.

◆ get_value()

const std::string & Terminal::get_value ( ) const

Returns the matched data from the input that matched the token.


The documentation for this class was generated from the following files: