| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

ErpcLexer.h
1 /*
2 * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3 * Copyright 2016 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 // This header just wraps the standard flex C++ header to make it easier to include
11 // without having to worry about redefinitions of the class name every time.
12
13 #ifndef _EMBEDDED_RPC__ERPCLEXER_H_
14 #define _EMBEDDED_RPC__ERPCLEXER_H_
15
16 #undef yyFlexLexer
17 #include "AstNode.h"
18 #include "ParseErrors.h"
19
20 #include <FlexLexer.h>
21 #include <fstream>
22 #include <string>
23 #include <vector>
24
26 // Definitions
28
29 #ifndef YY_BUF_SIZE
30 #define YY_BUF_SIZE 16384
31 #endif
32
34 // Classes
36
37 namespace erpcgen {
38
39 class ErpcLexer;
40 }
41 #include "erpcgen_parser.tab.hpp"
42
43 using namespace std;
44
45 namespace erpcgen {
46
50 class CurrentFileInfo
51 {
52 public:
63 CurrentFileInfo(std::ifstream *savedFile, std::string fileName, std::string currentFolderPath)
64 : m_savedFile(savedFile)
65 , m_previous(NULL)
66 , m_line(1)
67 , m_column(0)
68 , m_fileName(fileName)
69 , m_currentFolderPath(currentFolderPath)
70 {
71 }
72
78 ~CurrentFileInfo()
79 {
80 m_savedFile->close();
81 m_savedFile.safe_delete();
82 }
83
84 smart_ptr<std::ifstream> m_savedFile;
85 CurrentFileInfo *m_previous;
86 int m_line;
87 int m_column;
88 std::string m_fileName;
89 std::string m_currentFolderPath;
90 };
91
100 class ErpcLexer : public yyFlexLexer
101 {
102 public:
111 ErpcLexer(const char *inputFile);
112
116 ~ErpcLexer();
117
125 virtual Token *getNextToken();
126
132 inline token_loc_t &getLocation() { return m_location; }
133
141 void pushFile(const std::string &fileName);
142
146 void popFile();
147
153 inline std::string &getFileName() { return m_currentFileInfo->m_fileName; }
154
160 uint16_t getIdlCrc16() { return m_idlCrc16; }
161
162 protected:
163 Value *m_value;
164 token_loc_t m_location;
165 uint32_t m_indents;
166 CurrentFileInfo *m_currentFileInfo;
167 uint16_t m_idlCrc16;
176 virtual void LexerError(const char *msg);
177
190 int processStringEscapes(const char *in, char *out);
191
197 virtual int yylex();
198
216 CurrentFileInfo *openFile(const std::string &fileName);
217 };
218
219 } // namespace erpcgen
220
221 #endif // _EMBEDDED_RPC__ERPCLEXER_H_
erpcgen::ErpcLexer::m_currentFileInfo
CurrentFileInfo * m_currentFileInfo
Definition: ErpcLexer.h:166
erpcgen::ErpcLexer
Lexical scanner class for erpcgen interface files.
Definition: ErpcLexer.h:100
erpcgen::CurrentFileInfo::m_previous
CurrentFileInfo * m_previous
Definition: ErpcLexer.h:85
erpcgen::ErpcLexer::getFileName
std::string & getFileName()
return current file name
Definition: ErpcLexer.h:153
erpcgen::CurrentFileInfo::m_fileName
std::string m_fileName
Definition: ErpcLexer.h:88
std
STL namespace.
erpcgen::CurrentFileInfo::m_currentFolderPath
std::string m_currentFolderPath
Definition: ErpcLexer.h:89
erpcgen::CurrentFileInfo::~CurrentFileInfo
~CurrentFileInfo()
Destructor.
Definition: ErpcLexer.h:78
Value
Abstract base class for values of arbitrary types.
Definition: Value.h:27
erpcgen::ErpcLexer::m_location
token_loc_t m_location
Definition: ErpcLexer.h:164
erpcgen::ErpcLexer::getLocation
token_loc_t & getLocation()
returns the current token&#39;s location in loc.
Definition: ErpcLexer.h:132
erpcgen::ErpcLexer::getIdlCrc16
uint16_t getIdlCrc16()
This function returns crc16 of all used IDL files.
Definition: ErpcLexer.h:160
erpcgen::ErpcLexer::m_indents
uint32_t m_indents
Definition: ErpcLexer.h:165
erpcgen::CurrentFileInfo::CurrentFileInfo
CurrentFileInfo(std::ifstream *savedFile, std::string fileName, std::string currentFolderPath)
Constructor.
Definition: ErpcLexer.h:63
erpcgen::ErpcLexer::m_value
Value * m_value
Definition: ErpcLexer.h:163
erpcgen::Token
Encapsulates all information about a token.
Definition: Token.h:60
erpcgen::CurrentFileInfo::m_column
int m_column
Definition: ErpcLexer.h:87
erpcgen::CurrentFileInfo::m_line
int m_line
Definition: ErpcLexer.h:86
erpcgen::token_loc_t
Token location in the source file.
Definition: Token.h:25
erpcgen::ErpcLexer::m_idlCrc16
uint16_t m_idlCrc16
Definition: ErpcLexer.h:167
erpcgen
Definition: AstNode.h:26
erpcgen::CurrentFileInfo::m_savedFile
smart_ptr< std::ifstream > m_savedFile
Definition: ErpcLexer.h:84
erpcgen::CurrentFileInfo
This class contains necessary information about analyzed file.
Definition: ErpcLexer.h:50