Debian Codegraph @

documentation/demos/manual/rpnparser.yo

raw
1 Before running b(), we should decide how to organize the program's source
2 code, using one or more source files. Even though the example is simple, it is
3 good practice to define all user-defined functions in source files of their
4 own. For tt(rpn) this means that a source file (tt(main.cc)) is constructed
5 holding tt(main), and a file tt(parser/lex.cc) containing the lexical
6 scanner's implementation. Note that I've put all the parser's files in a
7 separate directory as well (also see section ref(LAYOUT)).
8
9 In url(rpn's parser)(demos/rpn/parser) directory the file tt(grammar)
10 contains the grammar specification. B() constructs a parser class and a
11 parsing member function from this file after issuing the command:
12 verb(
13 b() grammar
14 )
15 From this, b() produced the following files:
16 itemization(
17 itt(Parser.h), the parser class definition;
18 itt(Parserbase.h), the parser's em(base) class definition, defining, among
19 other, the grammatical tokens to be used by externally defined lexical
20 scanners;
21 itt(Parser.ih), the em(internal header file), to be included by all
22 implementations of the parser class' members;
23 itt(parse.cc), the parsing member function.
24 )
25 By default, tt(Parserbase.h) and tt(parse.cc) will be em(re-created) each
26 time b() is re-run. tt(Parser.h) and tt(Parser.ih) may safely be modified
27 by the programmer, e.g., to add new members to to the parser class. These two
28 files will not be overwritten by b(), unless explicitly instructed to do
29 so.