File: error.cc

package info (click to toggle)
flexc%2B%2B 2.17.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,180 kB
  • sloc: cpp: 6,467; makefile: 148; sh: 130; ansic: 18
file content (41 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (4)
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
#include "parser.ih"

namespace
{
    bool repeated;
    string eoln("<EOLN>");
}

void Parser::error()
{
    if (!d_doError)         // this allows functions to call ERROR and handle
    {                       // their own error message
        d_doError = true;
        return;
    }
        
    if (d_expect.empty())
    {
        if (not repeated)
            emsg << "unrecognized input (`" << d_matched << 
                         "') encountered" << endl;
        repeated = true;
    }
    else
    {
        string const *txt = &d_matched;
        if (*txt == "\n")
            txt = &::eoln;

        if (s_lastMsg != d_expect)
        {
            if (txt == &::eoln)
                emsg.setLineNr(d_scanner.lineNr());
            emsg << "at `" << *txt << "': " << d_expect << " expected." << endl;

            repeated = false;
        }
    }

    s_lastMsg = d_expect;
}