File: markerpattern.cc

package info (click to toggle)
yodl 4.04.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,720 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 164
file content (42 lines) | stat: -rw-r--r-- 1,281 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
42
#include "line.ih"

bool Line::markerPattern()
{
    smatch result;
                                            // first match the end target
                                            // 'ignore' is set at, e.g., -A
    if (regex_match(d_line, result, s_markerEnd))
    {
        d_type = d_ignore ? IGNORE : ENDTARGET;
        return true;
    }
                                            // no end target: match targets
    if (regex_match(d_line, result, s_markerBegin))
    {
        if (result[0] != d_target)          // no target, so it's text
            d_type = d_ignore ? IGNORE : TEXT;
        else if (d_target[2] != '+')        // target w/o +, so std. target
            d_type = d_ignore ? IGNORE : TARGET;
        else
        {                                   // `+' target, toggle begin/end
            d_type = d_begin ? TARGET : ENDTARGET;
            d_begin = not d_begin;
        }

        return true;
    }

    return false;
}

/*
    If end-marker is matched, ignore (-A, //+...) or return ENDTARGET
    At //+ target specifications: ignore all markers, toggle TARGET and
        ENDTARGET if line == target
    If a line matches a begin marker, but not the non //+ target, then return
        it as text, or IGNORE if -A was specified
*/