File: block.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 (56 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (6)
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
#include "parser.ih"

void Parser::block()
{
    bool warnMissingEoln = false;

    d_block.open(d_scanner.lineNr(), d_scanner.filename());

    while (true)
    {
        int token = d_scanner.lex();

        switch (token)
        {
            case 0:
                if (not warnMissingEoln)
                {
                    warnMissingEoln = true;
                    wmsg << "missing newline: improperly ending action" <<
                            endl; 
                }
                while (d_block.close()) 
                    ;                       // append lacking closing braces
                d_block += "\n";
                d_scanner.blockEnds();
            return;
            
            case '{':
                d_block.open(d_scanner.lineNr(), d_scanner.filename());
            break;
            
            case '}':
                d_block.close();
            break;
    
            case '\n':
                d_block += d_matched;

                if (d_block.level() == 1)
                {
                    d_block.close();
                    d_scanner.accept(0);        // rescan the \n
                    d_scanner.blockEnds();
    // cout << "\nRETURNING BLOCK:\n" << d_block << "\n";
                    return;
                }

                d_block.indent();
            break;
                
            default:
                d_block += d_matched;
            break;
        }
    }
}