linc 0.7
Linc is a general-purpose programming language inspired by C
Loading...
Searching...
No Matches
linc::Parser Class Referencefinal

Class responsible for the parsing stage of compilation. Parses a list of tokens into AST nodes. More...

#include <Parser.hpp>

Classes

struct  Definition
 A symbol generic definition representation. More...
 

Public Types

using TokenList = std::vector<Token>
 
using TokenSize = TokenList::size_type
 

Public Member Functions

 Parser ()
 Constructor: begin a scope and append all internal symbols as valid definitions.
 
Program operator() () const
 Parse the current list of tokens as a program.
 
void set (std::vector< Token > tokens, std::string_view filepath)
 Set the current list of tokens, as well as their corresponding filepath.
 
template<typename FUNC >
auto parseNodeListClause (FUNC parse_function, Token::Type end_token_type=Token::Type::ParenthesisRight, Token::Type delimiter_type=Token::Type::Comma) const
 Parse the following tokens as a list of delimited types (or nothing if a 'terminating' token is found).
 
std::unique_ptr< const class MatchClauseparseMatchClause () const
 Parse the following tokens as a match clause.
 
std::unique_ptr< const class EnumeratorClauseparseEnumeratorClause () const
 Parse the following tokens as an enumerator clause.
 
std::optional< class LoopLabelparseLoopLabel () const
 Parse the following tokens as an optional loop identifier.
 
std::unique_ptr< const class StatementparseStatement () const
 Parse the following tokens as an AST statement.
 
std::unique_ptr< const class DeclarationparseDeclaration () const
 Parse the following tokens as an AST declaration.
 
std::unique_ptr< const class NodeparseVariant () const
 Parse the following tokens as an AST variant node (i.e. either a statement or an expression).
 
std::unique_ptr< const class VariableDeclarationparseVariableDeclaration () const
 Parse the following tokens as an AST variable declaration.
 
std::unique_ptr< const class DirectVariableDeclarationparseDirectVariableDeclaration () const
 Parse the following tokens as a direct variable declaration (implicit typing).
 
std::unique_ptr< const class FunctionDeclarationparseFunctionDeclaration () const
 Parse the following tokens as an AST function declaration.
 
std::unique_ptr< const class ExternalDeclarationparseExternalDeclaration () const
 Parse the following tokens as an AST external declaration.
 
std::unique_ptr< const class StructureDeclarationparseStructureDeclaration () const
 Parse the following tokens as an AST structure declaration.
 
std::unique_ptr< const class EnumerationDeclarationparseEnumerationDeclaration () const
 Parse the following tokens as an AST enumeration declaration.
 
std::unique_ptr< const class ExpressionparseModifierExpression () const
 Parse the following tokens as an AST modifier expression.
 
std::unique_ptr< const class ExpressionparseExpression (uint16_t parent_precedence=0) const
 Parse the following tokens as an AST expression.
 
std::unique_ptr< const class ExpressionparsePrimaryExpression () const
 Parse the following tokens as an AST primary expression.
 
std::unique_ptr< const class ArrayInitializerExpressionparseArrayInitializerExpression () const
 Parse the following tokens as an AST array initializer expression.
 
std::unique_ptr< const class BlockExpressionparseBlockExpression () const
 Parse the following tokens as an AST block expression.
 
std::unique_ptr< const class ParenthesisExpressionparseParenthesisExpression () const
 Parse the following tokens as an AST parenthesis expression.
 
std::unique_ptr< const class IfExpressionparseIfExpression () const
 Parse the following tokens as an AST if(/else) expression.
 
std::unique_ptr< const class ForExpressionparseForExpression (class std::optional< LoopLabel > label) const
 Parse the following tokens as an AST for expression.
 
std::unique_ptr< const class WhileExpressionparseWhileExpression (class std::optional< LoopLabel > label) const
 Parse the following tokens as an AST while(/else/finally) expression.
 
std::unique_ptr< const class MatchExpressionparseMatchExpression () const
 Parse the following tokens as an AST match expression.
 
std::unique_ptr< const class ConversionExpressionparseConversionExpression () const
 Parse the following tokens as an AST conversion expression.
 
std::unique_ptr< const class StructureInitializerExpressionparseStructureInitializerExpression () const
 Parse the following tokens as an AST conversion expression.
 
std::unique_ptr< const class LiteralExpressionparseLiteralExpression () const
 Parse the following tokens as an AST literal expression.
 
std::unique_ptr< const class IdentifierExpressionparseIdentifierExpression (bool type_inclusive=false) const
 Parse the following tokens as an AST identifier expression.
 
std::unique_ptr< const class CallExpressionparseCallExpression () const
 Parse the following tokens as an AST function call expression.
 
std::unique_ptr< const class EnumeratorExpressionparseEnumeratorExpression () const
 Parse the following tokens as an AST namespace access expression.
 
std::unique_ptr< const class TypeExpressionparseTypeExpression () const
 Parse the following tokens as an AST type expression.
 
auto parseEndOfFile () const
 Require the next token to be an EOF token (used when appropriate).
 

Detailed Description

Class responsible for the parsing stage of compilation. Parses a list of tokens into AST nodes.

Member Function Documentation

◆ operator()()

Program linc::Parser::operator() ( ) const

Parse the current list of tokens as a program.

Returns
The resulting program.

◆ parseIdentifierExpression()

std::unique_ptr< const IdentifierExpression > linc::Parser::parseIdentifierExpression ( bool type_inclusive = false) const

Parse the following tokens as an AST identifier expression.

Parameters
type_inclusiveTreat type identifiers as valid.

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