File: bison.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (57 lines) | stat: -rw-r--r-- 3,003 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
The i(grammar specification file) required by ti(bisonc++) is comparable to
the specification file required by ti(bison). Differences are related to the
class nature of the resulting parser. Our calculator distinguishes real
numbers from integers, and supports a basic set of arithmetic operators.

tt(Bisonc++) should be used as follows:
    itemization(
    it() As usual, a grammar is  defined. With tt(bisonc++) this is no
        different, and tt(bisonc++) grammar definitions are for all practical
        purposes identical to tt(bison)'s grammar definitions.
    it() Having specified the grammar and (usually) some declarations
        tt(bisonc++) can generate files defining the parser class and
        the implementation of the member function tt(parse).
    it() All class members (except those that are required for the proper
        functioning of the member tt(parse)) must be
        separately implemented.  Of course, they should also be
        declared in the parser class's header.  At the very least the member
        ti(lex) must be implemented. This member is called by tt(parse) to
        obtain the next available token.  However, tt(bisonc++) offers a
        facility providing a standard implementation of the function
        tt(lex). The member function
            hi(error)tt(error(char const *msg))
       is given a simple default implementation that may be modified by the
        programmer. The member function tt(error) is called when tt(parse)
        detects (syntactic) errors.
    it() The parser can now be used in a program. A very simple example would
        be:
    verb(int main()
{
    Parser parser;
    return parser.parse();
})

)

The tt(bisonc++) hi(bisonc++: grammar file) specification file has two
sections:
    itemization(
    it() The em(declaration section). In this section bison's tokens, and the
        priority rules for the operators are declared. However, tt(bisonc++)
        also supports several new declarations.  These new declarations are
        important and are discussed below.
    it() The em(rules section). The i(grammatical rules) define the
        grammar. This section is identical to the one required by tt(bison),
        albeit that some members that were available in tt(bison) and
        tt(bison++) are obsolete in tt(bisonc++), while other members can be
        used in a wider context.  For example, bf(ACCEPT) and bf(ABORT) can be
        called from any member called from the parser's action blocks to
        terminate the parsing process.
    )
 Readers familiar with tt(bison) may note that there is no
    emi(header section) anymore. Header sections are used by bison to provide
for the necessary declarations allowing the compiler to compile the bf(C)
function generated by tt(bison). In bf(C++) declarations are part of or
already used by class definitions. Therefore, a parser generator generating a
bf(C++) class and some of its member functions does not require a header
section anymore.