aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/config/markupfsm.h.rl6
blob: b709faaebffdbd372c6bc6aa51d5f3bae62904f9 (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
%%{
    machine ParseXml;

    action startText {
        l = p;
    }

    action endText {
        cb->DoText(TStringBuf(l + 1, p));
    }

    action startSTag {
        l = p;
    }

    action endSTag {
        cb->DoTagOpen(TStringBuf(l, p));
    }

    action startETag {
        l = p;
    }

    action endETag {
        cb->DoTagClose(TStringBuf(l, p));
    }

    action startKey {
        l = p;
    }

    action endKey {
        cb->DoAttrKey(TStringBuf(l, p));
    }

    action startValue {
        l = p;
    }

    action endValue {
        cb->DoAttrValue(TStringBuf(l, p));
    }

    spacesym = [ \r\n\t];
    gsym     = (spacesym | '<' | '>' | '/');
    sym      = any -- gsym;
    asym     = sym -- ('=' | '"');
    tag      = sym+;
    xattrkey = asym+;
    xattrval = asym*;
    xspace   = spacesym*;
    mspace   = spacesym+;
    attr     = (xattrkey >startKey %endKey) '=' '"' (xattrval >startValue %endValue) '"';
    attrs    = (mspace attr)*;
    text     = ('>' (any -- '<')*) >startText %endText;
    stag     = '<' xspace (tag >startSTag %endSTag) attrs xspace;
    etag     = '<' xspace '/' xspace (tag >startETag %endETag) xspace;

    main    := spacesym* ((stag | etag) text)*;
}%%

#if defined(MACHINE_DATA)
#undef MACHINE_DATA
%%{
    write data;
}%%
#endif

#if defined(MACHINE_INIT)
#undef MACHINE_INIT
%%{
    write init;
}%%
#endif

#if defined(MACHINE_EXEC)
#undef MACHINE_EXEC
%%{
    write exec;
}%%
#endif