CppParser
Loading...
Searching...
No Matches
parser.l File Reference
#include "cpptoken.h"
#include "cppvarinit.h"
#include "parser.l.h"
#include "lexer-helper.h"
#include <iostream>
Include dependency graph for parser.l:

Go to the source code of this file.

Macros

#define register
 
#define BEGINCONTEXT(ctx)
 
#define ENDCONTEXT()
 
#define RETURN(ret)   return LogAndReturn(ret, __LINE__, g.mLineNo)
 
#define LOG()   Log(__LINE__, g.mLineNo)
 
#define INCREMENT_INPUT_LINE_NUM()
 

Typedefs

using YYLessProc = std::function< void(int)>
 

Functions

const char * contextNameFromState (int ctx)
 
static int LogAndReturn (int ret, int codelinenum, int srclinenum)
 
static void Log (int codelinenum, int srclinenum)
 
int getLexerContext ()
 
static void setOldYytext (const char *p)
 
static void setCommentTokenizationState (TokenSetupFlag flag)
 
static void setupToken (const char *text, size_t len, TokenSetupFlag flag=TokenSetupFlag::DisableCommentTokenization)
 
static void setupToken (TokenSetupFlag flag=TokenSetupFlag::DisableCommentTokenization)
 
static void setBlobToken (TokenSetupFlag flag=TokenSetupFlag::None)
 
static void tokenizeBracketedContent (YYLessProc yylessfn)
 
static const char * findMatchedClosingBracket (const char *start, char openingBracketType='(')
 
static bool codeSegmentDependsOnMacroDefinition ()
 
static void startNewMacroDependentParsing ()
 
static void updateMacroDependence ()
 
int yylex (void)
 
void setupScanBuffer (char *buf, size_t bufsize)
 
void cleanupScanBuffer ()
 

Variables

static YY_BUFFER_STATE gParseBuffer = nullptr
 
LexerData g
 Global data. More...
 
bool gParseEnumBodyAsBlob
 
bool gParseFunctionBodyAsBlob
 
std::set< std::string > gMacroNames
 
std::set< std::string > gKnownApiDecorNames
 
std::map< std::string, int > gDefinedNames
 
std::set< std::string > gUndefinedNames
 
std::set< std::string > gIgnorableMacroNames
 
std::map< std::string, int > gRenamedKeywords
 

Macro Definition Documentation

◆ BEGINCONTEXT

#define BEGINCONTEXT (   ctx)
Value:
{ \
int prevState = YYSTATE; \
yy_push_state(ctx); \
if (g.mLexLog) \
printf("parser.l line#%4d: pushed %s(%d) and started %s(%d) from input-line#%d\n", __LINE__, contextNameFromState(prevState), prevState, contextNameFromState(YYSTATE), YYSTATE, g.mLineNo); \
}
LexerData g
Global data.
Definition: parser.l:44
const char * contextNameFromState(int ctx)
Definition: parser.l:1871
int mLexLog
Definition: parser.l.h:86
int mLineNo
Definition: parser.l.h:87

Definition at line 62 of file parser.l.

◆ ENDCONTEXT

#define ENDCONTEXT ( )
Value:
{ \
int prevState = YYSTATE; \
yy_pop_state(); \
if (g.mLexLog) \
printf("parser.l line#%4d: ended %s(%d) and starting %s(%d) from input-line#%d\n", __LINE__, contextNameFromState(prevState), prevState, contextNameFromState(YYSTATE), YYSTATE, g.mLineNo); \
}

Definition at line 69 of file parser.l.

◆ INCREMENT_INPUT_LINE_NUM

#define INCREMENT_INPUT_LINE_NUM ( )
Value:
{\
if (g.mLexLog) \
{ \
printf("parser.l line#%4d: Incrementing g.mLineNo, found @input-line#%d\n", __LINE__, g.mLineNo); \
} \
++g.mLineNo; \
}

Definition at line 97 of file parser.l.

◆ LOG

#define LOG ( )    Log(__LINE__, g.mLineNo)

Definition at line 96 of file parser.l.

◆ register

#define register

Definition at line 35 of file parser.l.

◆ RETURN

#define RETURN (   ret)    return LogAndReturn(ret, __LINE__, g.mLineNo)

Definition at line 95 of file parser.l.

Typedef Documentation

◆ YYLessProc

using YYLessProc = std::function<void(int)>

Definition at line 160 of file parser.l.

Function Documentation

◆ cleanupScanBuffer()

void cleanupScanBuffer ( )

Definition at line 1917 of file parser.l.

◆ codeSegmentDependsOnMacroDefinition()

static bool codeSegmentDependsOnMacroDefinition ( )
static

Definition at line 231 of file parser.l.

Here is the caller graph for this function:

◆ contextNameFromState()

const char * contextNameFromState ( int  ctx)

Definition at line 1871 of file parser.l.

◆ findMatchedClosingBracket()

static const char * findMatchedClosingBracket ( const char *  start,
char  openingBracketType = '(' 
)
static

Definition at line 205 of file parser.l.

◆ getLexerContext()

int getLexerContext ( )

Definition at line 112 of file parser.l.

◆ Log()

static void Log ( int  codelinenum,
int  srclinenum 
)
static

Definition at line 86 of file parser.l.

◆ LogAndReturn()

static int LogAndReturn ( int  ret,
int  codelinenum,
int  srclinenum 
)
static

Definition at line 76 of file parser.l.

◆ setBlobToken()

static void setBlobToken ( TokenSetupFlag  flag = TokenSetupFlag::None)
static

Definition at line 155 of file parser.l.

Here is the call graph for this function:

◆ setCommentTokenizationState()

static void setCommentTokenizationState ( TokenSetupFlag  flag)
static

Definition at line 122 of file parser.l.

Here is the caller graph for this function:

◆ setOldYytext()

static void setOldYytext ( const char *  p)
static

Definition at line 117 of file parser.l.

◆ setupScanBuffer()

void setupScanBuffer ( char *  buf,
size_t  bufsize 
)

Definition at line 1908 of file parser.l.

◆ setupToken() [1/2]

static void setupToken ( const char *  text,
size_t  len,
TokenSetupFlag  flag = TokenSetupFlag::DisableCommentTokenization 
)
static

Definition at line 141 of file parser.l.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupToken() [2/2]

static void setupToken ( TokenSetupFlag  flag = TokenSetupFlag::DisableCommentTokenization)
static

Definition at line 150 of file parser.l.

Here is the call graph for this function:

◆ startNewMacroDependentParsing()

static void startNewMacroDependentParsing ( )
static

Definition at line 236 of file parser.l.

Here is the call graph for this function:

◆ tokenizeBracketedContent()

static void tokenizeBracketedContent ( YYLessProc  yylessfn)
static

Definition at line 165 of file parser.l.

Here is the call graph for this function:

◆ updateMacroDependence()

static void updateMacroDependence ( )
static

Definition at line 244 of file parser.l.

◆ yylex()

int yylex ( void  )

Definition at line 345 of file parser.l.

Variable Documentation

◆ g

Global data.

Definition at line 44 of file parser.l.

◆ gDefinedNames

std::map<std::string, int> gDefinedNames
extern

Definition at line 44 of file cppparser.cpp.

◆ gIgnorableMacroNames

std::set<std::string> gIgnorableMacroNames
extern

Definition at line 46 of file cppparser.cpp.

◆ gKnownApiDecorNames

std::set<std::string> gKnownApiDecorNames
extern

Definition at line 43 of file cppparser.cpp.

◆ gMacroNames

std::set<std::string> gMacroNames
extern

Definition at line 42 of file cppparser.cpp.

◆ gParseBuffer

YY_BUFFER_STATE gParseBuffer = nullptr
static

Definition at line 1907 of file parser.l.

◆ gParseEnumBodyAsBlob

bool gParseEnumBodyAsBlob
extern

Definition at line 49 of file cppparser.cpp.

◆ gParseFunctionBodyAsBlob

bool gParseFunctionBodyAsBlob
extern

Definition at line 50 of file cppparser.cpp.

◆ gRenamedKeywords

std::map<std::string, int> gRenamedKeywords
extern

Definition at line 47 of file cppparser.cpp.

◆ gUndefinedNames

std::set<std::string> gUndefinedNames
extern

Definition at line 45 of file cppparser.cpp.