File: VhdlParserErrorHandler.hpp

package info (click to toggle)
doxygen 1.9.8%2Bds-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,000 kB
  • sloc: cpp: 215,370; lex: 42,621; python: 32,388; ansic: 26,705; xml: 15,390; javascript: 8,352; yacc: 581; f90: 455; php: 441; perl: 378; makefile: 195; sh: 24; objc: 14; cs: 5; java: 1
file content (68 lines) | stat: -rw-r--r-- 2,023 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef VHDLPARSERERRORHANDLER_H
#define VHDLPARSERERRORHANDLER_H

#include <stdio.h>
#include <stdlib.h>
#include <exception>
#include "VhdlParser.h"
#include "ErrorHandler.h"
#include "vhdlstring.h"
#include "message.h"

const char *getVhdlFileName(void);

namespace vhdl { namespace parser {

class VhdlErrorHandler: public ErrorHandler
{
  public:
    VhdlErrorHandler(const char *fileName) : m_fileName(fileName) {}

    virtual void handleUnexpectedToken(int /* expectedKind */, const JJString& /* expectedToken */, Token *actual, VhdlParser * /* parser */)
    {
      warn(m_fileName,actual->beginLine,"syntax error '%s'",actual->image.data());
      error_count++;
      throw std::exception();
    }

    virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString& /* production */, VhdlParser * /* parser */)
    {
      warn(m_fileName,last->beginLine,"unexpected token: '%s'", unexpected->image.data());
      error_count++;
      throw std::exception();
    }

    virtual void handleOtherError(const JJString& message, VhdlParser * /* parser */)
    {
      warn(m_fileName, -1, "unexpected error: '%s'", (char*)message.c_str());
      error_count++;
      throw std::exception();
    }

  private:
    QCString m_fileName;
};

class VhdlTokenManagerErrorHandler: public TokenManagerErrorHandler
{
  public:
    VhdlTokenManagerErrorHandler(const char *fileName) : m_fileName(fileName) {}

    virtual void lexicalError(bool EOFSeen, int /* lexState */, int errorLine, int /* errorColumn */, const JJString& errorAfter, JJChar curChar, VhdlParserTokenManager* /* token_manager */)
    {
      warn(m_fileName,errorLine,"Lexical error, Encountered: '%c' after: '%s'",curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str()));
    }

    virtual void lexicalError(const JJString& errorMessage, VhdlParserTokenManager* /* token_manager */)
    {
      warn(m_fileName,-1,"Unknown error: '%s'", (char*)errorMessage.c_str());
    }

  private:
    QCString m_fileName;
};

} }

#endif