Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
ElftosbLexer.h
1 /*
2  * File: ElftosbLexer.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 
8 // This header just wraps the standard flex C++ header to make it easier to include
9 // without having to worry about redefinitions of the class name every time.
10 
11 #if !defined(_ElftosbLexer_h_)
12 #define _ElftosbLexer_h_
13 
14 #include "ElftosbAST.h"
15 #include "FlexLexer.h"
16 #include "elftosb_parser.tab.hpp"
17 #include <vector>
18 #include <string>
19 #include <stdexcept>
20 #include "Blob.h"
21 
22 using namespace std;
23 
24 namespace elftosb
25 {
29 class syntax_error : public std::runtime_error
30 {
31 public:
32  explicit syntax_error(const std::string &__arg)
33  : std::runtime_error(__arg)
34  {
35  }
36 };
37 
41 class lexical_error : public std::runtime_error
42 {
43 public:
44  explicit lexical_error(const std::string &__arg)
45  : std::runtime_error(__arg)
46  {
47  }
48 };
49 
62 class ElftosbLexer : public yyFlexLexer
63 {
64 public:
66  ElftosbLexer(istream &inputStream);
67 
69  virtual int yylex();
70 
72  virtual void getSymbolValue(YYSTYPE *value);
73 
75  inline token_loc_t &getLocation() { return m_location; }
77 
78  void addSourceName(std::string *ident);
79  bool isSourceName(std::string *ident);
81 
82 protected:
84  int m_line;
88 
89  typedef std::vector<std::string> string_vector_t;
90  string_vector_t m_sources;
91 
93  virtual void LexerError(const char *msg);
94 
96  int processStringEscapes(const char *in, char *out);
97 };
98 
99 }; // namespace elftosb
100 
101 #endif // _ElftosbLexer_h_
int m_line
Current line number.
Definition: ElftosbLexer.h:84
string_vector_t m_sources
Vector of source identifiers;.
Definition: ElftosbLexer.h:90
STL namespace.
Definition: elftosb_parser.tab.cpp:238
token_loc_t m_location
Location for the current token.
Definition: ElftosbLexer.h:85
Definition: BootImage.h:13
Token location in the source file.
Definition: ElftosbAST.h:24
YYSTYPE m_symbolValue
Value for the current token.
Definition: ElftosbLexer.h:83
int m_blobFirstLine
Line number for the first character of a blob.
Definition: ElftosbLexer.h:87
Definition: FlexLexer.h:107
Manages a binary object of arbitrary length.
Definition: apps/elftosb/common/Blob.h:18
token_loc_t & getLocation()
Returns the current token&#39;s location in loc.
Definition: ElftosbLexer.h:75
Exception class for syntax errors.
Definition: ElftosbLexer.h:29
Blob * m_blob
The binary object value as its being constructed.
Definition: ElftosbLexer.h:86
Lexical scanner class for elftosb command files.
Definition: ElftosbLexer.h:62
Exception class for lexical errors.
Definition: ElftosbLexer.h:41