Spicy
Public Types | Public Member Functions | List of all members
hilti::util::SourceCodePreprocessor Class Reference

#include <preprocessor.h>

Public Types

enum  State { Include, Skip }
 
using ID = std::string
 
using Value = int
 

Public Member Functions

 SourceCodePreprocessor (std::map< ID, Value > constants)
 
Result< StateprocessLine (std::string_view directive, std::string_view expression="")
 
State state () const
 
bool expectingDirective ()
 

Detailed Description

Helper to preprocess/@ directives in lines of input.

This currently supports the following set of directives:

- `[!] < [!] <

Member Enumeration Documentation

◆ State

Current inclusion state while processing input.

Constructor & Destructor Documentation

◆ SourceCodePreprocessor()

hilti::util::SourceCodePreprocessor::SourceCodePreprocessor ( std::map< ID, Value >  constants)
inline

Constructor.

Parameters
constantsmap of constants that preprocessor directives can work on

Member Function Documentation

◆ expectingDirective()

bool hilti::util::SourceCodePreprocessor::expectingDirective ( )
inline

Returns true if the proprocessor expects further directives that closed previously opened blocks

◆ processLine()

hilti::Result< hilti::util::SourceCodePreprocessor::State > hilti::util::SourceCodePreprocessor::processLine ( std::string_view  directive,
std::string_view  expression = "" 
)

Process one preprocessor directive of the form @<id> [expression].

This evaluates the directive and updates internal state accordingly.

Parameters
directivea supported directive ID, which must start with @.
expressionstring with expression that the directive is taking
Returns
the new inclusion state for subsequent input, or an error if the directive could not be processed

◆ state()

State hilti::util::SourceCodePreprocessor::state ( ) const
inline

Returns the current inclusion state.


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