File: output.yo

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 (58 lines) | stat: -rw-r--r-- 3,402 bytes parent folder | download | duplicates (6)
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
When b() is run, it processes a grammar file. If the grammar is error-free b()
produces a bf(C++) em(class), in which several em(members) have already been
defined. Therefore, b()'s em(output) consists of em(header files) and a
bf(C++) source file, defining a member (tt(parse)) that parses the language
described by the grammar. The class and its implementation is called a b()
em(parser class). Keep in mind that the b() utility and the produced parser
classes are distinct pieces of software: the b() utility is a program whose
output is the b() parser class that is used by your program.

More specifically, b() generates the following files from a b()
grammar file:
    itemization(
    it() A em(baseclass header), which can be included by em(lexical scanners)
(see below), primarily defining the em(lexical tokens) that the parser expects
the lexical scanner to return;
    it() A em(class header), defining the b() parser class interface;
    it() An em(implementation header), which is used to declare all entities
which are em(only) used by b()'s parser class em(implementation) (and not
required by the remaining parts of your program);
    it() The em(parsing member), actually performing the parsing of a
provided input according to the rules of the defined b() grammar (that
you, as b()'s user, defined).
    )

The task of b()'s tt(parse) member is to group tokens according to rules
defined in the grammar -- for example, to combine identifiers and operators
into expressions. As it does this, it executes the actions of the grammar
rules it has recognized.

The tokens processed by the parser produced by b() are made available by an
object called the em(lexical analyzer) or em(lexical scanner). The scanner is
not produced by b(), but must somehow be supplied (e.g., by writing it
yourself). The tt(parse) member requests the next token from the lexical
analyzer whenever it needs another token. The parser itself doesn't know the
semantic values of the received tokens. Typically the lexical scanner produces
tokens by parsing the characters of the program's input text. This, however,
is not something that b() concerns itself with. See also section ref(LEX).

B()'s parsing function is a member function named tt(parse). This parsing
function nor the parser object for which it is called defines a complete
bf(C++) program: you must supply some additional details. One `detail' to be
supplied is is the lexical analyzer. The parser class itself declares several
additional members which can easily be redefined to fit your needs. One of
these additional members is the error-reporting function called by tt(parse)
to report errors. By default b() provides simple, but sensible,
implementations for such members.

Having constructed a parser class and a lexical scanner class, em(objects) of
those classes must be defined in a complete bf(C++) program. Usually such
objects are defined in tt(main); you have to provide this function, and
arrange for it to call the parser's tt(parse) function, lest the parser never
run. See chapter ref(INTERFACE).

Note that, different from conventions used by Bison and Bison++, b() does not
impose a particular name convention. In particular, there is em(no) need to
begin all variable and function names used in the b() parser with `yy' or
`YY'. However, some name restrictions on symbolic tokens exist. See section
ref(IMPROPER) for details.