File: empty.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 (32 lines) | stat: -rw-r--r-- 977 bytes parent folder | download
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
#include "fpattern.ih"

bool FPattern::empty(set<size_t> &indices, States const &states, size_t idx)
{
    State const &state = states[idx];

    switch (state.type())
    {
        case EMPTY:
            indices.insert(idx);
        
            if (indices.find(state.next1()) != indices.end() or 
                indices.find(state.next2()) != indices.end()
            )
                fmsg << 
                    "Internal error: specified scanner regexes cause "
                    "flexc++'s parser to recursively check grammar state " << 
                    idx << ". This error is commonly caused by scanner "
                    "regexes that can be simplified without loss of meaning "
                    "(e.g., '.*+' can be simplified to '.*').";
        
        return empty(indices, states, state.next1()) or 
               empty(indices, states, state.next2());

        case FINAL:
        return true;

        default:
        return false;
    }
}