PTHL Code to Write
We don’t need several directories, you can program in the top level of the package.
You must write:
- src/scantiger.ll
The scanner.
lval
supports strings, integers and even symbols. Nevertheless, symbols (i.e., identifiers) are returned as plain C++ strings for the time being: the classmisc::symbol
is introduced in TC-1.If the environment variable
SCAN
is defined (to whatever value) Flex scanner debugging traces are enabled, i.e., set the variableyy_flex_debug
to 1.- src/parsetiger.yy
The parser, and maybe
main
if you wish. Bison advanced features will be used in TC-1.Use C++ (e.g., C++ I/O streams, strings, etc.)
Use C++ features of Bison.
Use locations.
Use
%expect 0
to have Bison report conflicts are genuine errors.Use the
%require "3.0"
directive to prevent any problem due to old versions of Bison.Use the
%define api.value.type variant
directive to ask Bison for C++ object support in the semantic values. Without this, Bison usesunion
, which can be used to store objects (just Plain Old Data), hence pointers and dynamic allocation must be used.Use the
%define api.token.constructor
directive to request that symbols be handled as a whole (token type, location, and possibly semantic value) in the scanner throughparse::parser::make_{SYMBOL}
routines.Use the environment variable
PARSE
to enable parser traces, i.e., to setyydebug
to 1, run:PARSE=1 tc foo.tig
Use
%printer
to improve the tracing of semantic values. For instance,%define api.value.type variant %token <int> INT "integer" %printer { yyo << $$; } <int>
- Makefile
This file is mandatory. Running
make
must build an executabletc
in the root directory. The GNU Build System is not mandatory: TC-1 introduces Autoconf, Automake etc. You may use it, in which case we will runconfigure
beforemake
.