LLVM 22.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::omp::DirectiveNameParser Struct Reference

Parser class for OpenMP directive names. More...

#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"

Classes

struct  State
 

Public Member Functions

LLVM_ABI DirectiveNameParser (SourceLanguage L=SourceLanguage::C)
 
const Stateinitial () const
 
LLVM_ABI const Stateconsume (const State *Current, StringRef Tok) const
 

Static Public Member Functions

static LLVM_ABI SmallVector< StringReftokenize (StringRef N)
 

Detailed Description

Parser class for OpenMP directive names.

It only recognizes names listed in OMP.td, in particular it does not recognize Fortran's end-directives if they are not explicitly listed in OMP.td.

The class itself may be a singleton, once it's constructed it never changes.

Usage: { DirectiveNameParser Parser; // Could be static const.

DirectiveNameParser::State *S = Parser.initial(); for (StringRef Token : Tokens) S = Parser.consume(S, Token); // Passing nullptr is ok.

if (S == nullptr) { // Error: ended up in a state from which there is no possible path // to a successful parse. } else if (S->Value == OMPD_unknown) { // Parsed a sequence of tokens that are not a complete name, but // parsing more tokens could lead to a successful parse. } else { // Success. ParsedId = S->Value; } }

Definition at line 47 of file DirectiveNameParser.h.

Constructor & Destructor Documentation

◆ DirectiveNameParser()

llvm::omp::DirectiveNameParser::DirectiveNameParser ( SourceLanguage  L = SourceLanguage::C)

Definition at line 19 of file DirectiveNameParser.cpp.

References D, llvm::omp::getOpenMPVersions(), and I.

Member Function Documentation

◆ consume()

const DirectiveNameParser::State * llvm::omp::DirectiveNameParser::consume ( const State Current,
StringRef  Tok 
) const

Definition at line 32 of file DirectiveNameParser.cpp.

References assert().

◆ initial()

const State * llvm::omp::DirectiveNameParser::initial ( ) const
inline

Definition at line 65 of file DirectiveNameParser.h.

◆ tokenize()

SmallVector< StringRef > llvm::omp::DirectiveNameParser::tokenize ( StringRef  N)
static

Definition at line 41 of file DirectiveNameParser.cpp.


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