Skip to content

Commit 2aac31d

Browse files
authored
Create problem_statement.md
1 parent 65eb780 commit 2aac31d

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

milestone1/doc/problem_statement.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
In this assignment, you have to construct a scanner and a parser for
2+
your source language that outputs the abstract syntax tree (AST) in a
3+
graphical form.
4+
5+
To draw the tree, use a tool called
6+
graphviz(http://www.graphviz.org/). There are two components of
7+
graphviz that you will have to use: The language for describing
8+
the tree called DOT and a tool called dot. For example, if
9+
graph1.dot is a DOT script describing the tree, then
10+
11+
$ dot -Tps graph1.dot -o graph1.ps
12+
13+
generates a postscript program containing the drawing of the tree. The
14+
dot tool will completely take care of the tree layout. You just have
15+
to specify through the DOT language, the nodes, their labels and the
16+
edges.
17+
18+
Study the documentation of YACC tool you use to understand how
19+
actions are specified. Read about the DOT language from
20+
http://www.graphviz.org/Documentation.php
21+
22+
23+
Specifically you have to do the following:
24+
0. Start from the Assignment 1 (Lexer). You must have the lexer and
25+
grammar specifications for your source language.
26+
27+
1. Modify the lexer script to send tokens to parser.
28+
NOTE: In some implementation tools, lexer is always integrated
29+
with the parser. You *can skip* this step for such tools.
30+
31+
2. Now take the grammar itself and convert it to a script
32+
accepted by YACC like tool. Link it with the scanner
33+
generated earlier (if the lexer is separate).
34+
35+
3. Add actions to the grammar script so that the output of the
36+
parser is a DOT script representing the abstract syntax tree.
37+
38+
4. This DOT script, when processed by the graphviz tool called
39+
dot should produce a postscript file with the diagram of the
40+
parse tree.
41+
42+
For some implementation languages, there are libraries that may
43+
allow you to merge step 3 and 4. If so, you are allowed to use them.
44+
45+
5. Submit 10 non-trivial programs written in your source language
46+
that can be compiled with your compiler
47+
48+
6. Handle erroneous source program. Print a suitable error message for
49+
the error(s) encountered. You can chose to exit after the first error
50+
encountered.
51+
52+
The leafs of the AST are to be labeled either by the token names or
53+
the lexemes (or both).
54+
55+
56+
DETAILS
57+
58+
* Follow the above steps. Any deviations must be approved
59+
over CANVAS discussion forum (You post the proposed deviation
60+
and the instructor will approve/disapprove it in the discussion
61+
forum so that everyone is informed.).
62+
63+
* Your program must accept input file(s) and other options as
64+
command line parameters. Use sensible like options (--help,
65+
--out, --verbose etc).
66+
67+
* Follow the directory structure as mentioned in Assignment 1.
68+
All your source must be in <project-top>/src directory,
69+
70+
* Use Makefile (or an equivalent build tool like "ant") to build the
71+
implementation
72+
73+
* Update documentation in the "doc/" folder with a brief description
74+
of your project and the steps to build and run it. Also describe
75+
all the command line options.
76+
77+
* Add a new directory "tests/input2", and add few more (10 or more)
78+
interesting test cases for the AST generator you have developed.
79+
80+
* The TAs will spend approx 15-20 minutes with you for
81+
evaluation. Make sure that your implementation builds and
82+
runs correctly with minimum number of commands.
83+
84+
A typical example session could be:
85+
86+
$ cd <project-top>/src
87+
$ make
88+
$ ./myASTGenerator ../tests/input/test1.c --out=test1.dot
89+
(to execute the tool on test-case file test1.c and generate the dot file test1.dot)

0 commit comments

Comments
 (0)