File: rules

package info (click to toggle)
bisonc%2B%2B 6.09.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,984 kB
  • sloc: cpp: 9,375; ansic: 1,505; fortran: 1,134; makefile: 1,062; sh: 526; yacc: 84; lex: 60
file content (100 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (2)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
_precSpec:
    IDENTIFIER
    {
        $$(IDENTIFIER);
    }
|
    QUOTE
    {
        $$(QUOTE);
    }
;

_productionElement:
    QUOTE
    {
        $$ = useTerminal();
    }
|
    IDENTIFIER
    {
        $$ = useSymbol();
    }
|
    BLOCK
    {
        $$ = d_scanner.block();
    }
|
    PREC
    _precSpec
    {
        $$ = setPrecedence($2);
    }
;

_productionElements:
    _productionElements _productionElement
    {
        $$ = handleProductionElements($1, $2);
            // process the first element, return the second
            // if the 1st element is a block, handle it as a nested block
    }
|
    _productionElement
    {
        $$ = $1;
    }
;

_production:
    _productionElements
    {
        handleProductionElement($1);
        // process the returned element: if it's a block, it becomes the
        // production's action block
    }
|
    {
        // nothing to do for this empty production. But do check for a typed
        // nonterminal. 
        checkEmptyBlocktype();
    }
;

_productionSeparator:
    '|'
    {
        d_rules.addProduction(d_scanner.lineNr());
    }
;

_productionList:
    _productionList _productionSeparator _production
|
    _production
;

_ruleName:
    identifier
    ':'
    {
        openRule($1);
    }
;

_rule:
    _ruleName
    _productionList
    ';'
    {
        updateDefaultActionLineNr();
    }
;

rules:
    rules _rule
|
    // empty
;