ElftosbLexer.h
/*
* File: ElftosbLexer.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
// This header just wraps the standard flex C++ header to make it easier to include
// without having to worry about redefinitions of the class name every time.
#if !defined(_ElftosbLexer_h_)
#define _ElftosbLexer_h_
#include "ElftosbAST.h"
#include "FlexLexer.h"
#include "elftosb_parser.tab.hpp"
#include <vector>
#include <string>
#include <stdexcept>
#include "Blob.h"
using namespace std;
namespace elftosb
{
class syntax_error : public std::runtime_error
{
public:
explicit syntax_error(const std::string &__arg)
: std::runtime_error(__arg)
{
}
};
class lexical_error : public std::runtime_error
{
public:
explicit lexical_error(const std::string &__arg)
: std::runtime_error(__arg)
{
}
};
class ElftosbLexer : public yyFlexLexer
{
public:
ElftosbLexer(istream &inputStream);
virtual int yylex();
virtual void getSymbolValue(YYSTYPE *value);
inline token_loc_t &getLocation() { return m_location; }
void addSourceName(std::string *ident);
bool isSourceName(std::string *ident);
protected:
YYSTYPE m_symbolValue;
int m_line;
token_loc_t m_location;
Blob *m_blob;
int m_blobFirstLine;
typedef std::vector<std::string> string_vector_t;
string_vector_t m_sources;
virtual void LexerError(const char *msg);
int processStringEscapes(const char *in, char *out);
};
}; // namespace elftosb
#endif // _ElftosbLexer_h_
elftosb::ElftosbLexer::m_line
int m_line
Current line number.
Definition: ElftosbLexer.h:84
elftosb::ElftosbLexer::m_sources
string_vector_t m_sources
Vector of source identifiers;.
Definition: ElftosbLexer.h:90
std
STL namespace.
YYSTYPE
Definition: elftosb_parser.tab.cpp:238
elftosb::ElftosbLexer::m_location
token_loc_t m_location
Location for the current token.
Definition: ElftosbLexer.h:85
elftosb
Definition: BootImage.h:13
elftosb::token_loc_t
Token location in the source file.
Definition: ElftosbAST.h:24
elftosb::ElftosbLexer::m_symbolValue
YYSTYPE m_symbolValue
Value for the current token.
Definition: ElftosbLexer.h:83
elftosb::ElftosbLexer::m_blobFirstLine
int m_blobFirstLine
Line number for the first character of a blob.
Definition: ElftosbLexer.h:87
yyFlexLexer
Definition: FlexLexer.h:107
Blob
Manages a binary object of arbitrary length.
Definition: apps/elftosb/common/Blob.h:18
elftosb::ElftosbLexer::getLocation
token_loc_t & getLocation()
Returns the current token&#39;s location in loc.
Definition: ElftosbLexer.h:75
elftosb::syntax_error
Exception class for syntax errors.
Definition: ElftosbLexer.h:29
elftosb::ElftosbLexer::m_blob
Blob * m_blob
The binary object value as its being constructed.
Definition: ElftosbLexer.h:86
elftosb::ElftosbLexer
Lexical scanner class for elftosb command files.
Definition: ElftosbLexer.h:62
elftosb::lexical_error
Exception class for lexical errors.
Definition: ElftosbLexer.h:41