The src/parse
Directory
Namespace parse
, delivered during TC-1/2 & TC-EXTS.
Scan and parse Tiger programs.
File: local.am (src/parse/)
This is a Makefile configuration relative to the
src/parse/
directory. It is responsible for the generation of the scanner and parser, the integration into thelibtc
library with everything exported from theparse
module, and the linkage of the directory’s unit tests in the test-suite.
File: libparse.* (src/parse/)
The interface of the
parse
module. It exports theparse
procedure and wrappers around it.
File: tasks.* (src/parse/)
Tasks related to the
parse
module (see: The src/task Directory).
File: fwd.hh (src/parse/)
Forward declarations for the
parse
module.
File: location.hh (src/parse/)
Keeps track of a range (two cursors) in a (or two) file. It is generated by Bison.
File: metavar-map.* (src/parse/)
Maps metavariables with
AST
nodes. Works in pair withtweasts
.
File: parsetiger.yy (src/parse/)
Bison directives to describe our grammar and our parser.
File: parsetiger.* (src/parse/)
The generated parser.
File: parsetiger.{output|xml|html} (src/parse/)
Generated reports on the parser automaton. Contains tokens, states, conflicts and counter-examples. The
xml
is used to generate thehtml
which is easier to read and navigate.
File: parsetiger.stamp (src/parse/)
Generated stamp used by
bison++.in
to avoid useless regeneration and gain time (see The build-aux Directory).
File: scantiger.ll (src/parse/)
RE/flex directives to describe our tokens and our scanner.
File: scantiger.* (src/parse/)
The generated scanner.
File: tweast.* (src/parse/)
TWEAST stands for
Text With Embedded AST
. It works in pair withmetavarmap.*
and permits to use a string withAST
nodes (stored as metavariables) as a parser input.The tweasts were born out of Project Tiger and led to a research paper.
For example, if we see the
_main
function added with the Tweast:Tweast in; in << "function _main() = (" << *exp << "; ())"; res = td.parse(in);
exp
is theAST
returned by the parser above.td.parse(...)
runs the parsing on thetweast
and produces the correspondingAST
.Some files are given at TC-1/2.
File: tiger-driver.* (src/parse/)
Given at TC-1/2. A class which drives the lexing and parsing of input files.
File: generate-prelude.sh (src/parse/)
Generate the Tiger prelude (builtin primitives as a string).
File: prelude.cc (src/parse/)
Given at TC-1/2. It contains the builtin primitives of Tiger as a string. They will be inserted before the input code using a
tweast
if--no-prelude
nor-X
is activated.
File: tiger-factory.* (src/parse/)
Given at TC-1/2. It is a factory containing functions for
AST
nodes creation and deletion.
File: test-{parse|tweast}.cc (src/parse/)
Given at TC-1/2. Unit tests.