File: nestedblock.cc

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 (28 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (8)
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
#include "parser.ih"

// Add a hidden rule consisting of one action block. 

void Parser::nestedBlock(Block &block) 
{
    string name = nextHiddenName();

    // Since the inner block is a block, simply assume that its return value
    // matches the type of the rule in which it is nested.
    NonTerminal *np = NonTerminal::downcast(
                            defineNonTerminal(name, d_rules.sType())
                      );

    d_rules.addElement(np);             // add the block as a hidden rule

                                        // process the block as a nested block
                                        // preceded by nElements() -1 
                                        // production elements.
    substituteBlock(-d_rules.nElements(), block);

    d_rules.setHiddenAction(block);     // define the action in the hidden
                                        // terminal's production rule
}