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.
lvalsupports strings, integers and even symbols. Nevertheless, symbols (i.e., identifiers) are returned as plain C++ strings for the time being: the classmisc::symbolis introduced in TC-1.If the environment variable
SCANis defined (to whatever value) Flex scanner debugging traces are enabled, i.e., set the variableyy_flex_debugto 1.- src/parsetiger.yy
The parser, and maybe
mainif 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 0to 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 variantdirective 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.constructordirective 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
PARSEto enable parser traces, i.e., to setyydebugto 1, run:PARSE=1 tc foo.tig
Use
%printerto 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
makemust build an executabletcin 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 runconfigurebeforemake.