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
|
The calculator is built using tt(bisonc++) and tt(flexc++). Here is the
implementation of the calculator's tt(main) function:
verbinclude(-a bisonc++/calculator.cc)
The parser's files tt(parse.cc) and tt(parserbase.h) are generated by the
command:
verb( bisonc++ grammar)
The file tt(parser.h) is created only once, to allow the developer to add
members to the tt(Parser) class occe the need for them arises.
The program ti(flexc++) is used to create a lexical scanner:
verb( flexc++ lexer)
On i(Unix) systems a command like
verb( g++ -Wall -o calc *.cc -lbobcat -s)
can be used to compile and link the source of the main program and the
sources produced by the scanner and parser generators. The example uses the
tt(A2x) class, which is part of the ti(bobcat) library (cf. section
ref(BUILDFLEX)) (the bobcat library is available on systems offering either
tt(bisonc++) or tt(flexc++)). tt(Bisonc++) can be downloaded from
hi(http://fbb-git.gitlab.io/bisoncpp/)
tlurl(http://fbb-git.gitlab.io/bisoncpp/).
|