-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
66 lines (42 loc) · 2.71 KB
/
README
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
README file for CS 5363 Project 2 submission
Troy Toman
troytoman@mac.com
This parser currently recognizes all token types and language constructs as specified in the Project 1 guidelines. It was corrected based on Project1 feedback to handle:
nested if fails
else if fails
var dec + initialization fails
complex expression evaluation fails
commenting fails
keywords cannot be identifiers
I believe these are all working correctly at this time. The program has been updated for project 2 so that it produces a type-checked AST. The tree can be printed to the screen or converted to json format. The resulting json format can be then used to re-create the AST tree.
This project was implemented using the Ruby language and leverages a Ruby Parser library called Treetop which is available as open source.
You can find more information about Treetop at
http://treetop.rubyforge.org/
INSTALLATION INSTRUCTIONS
- You must install Ruby on the system
- Information on installing Ruby on Mac, Windows, Linux or Solaris can be found at:
http://www.ruby-lang.org/en/downloads/
- This was developed using Ruby 1.9.2 on a Mac
- Once Ruby is installed you must install the Treetop gem
- gem install treetop
- At this point you can run the program with the following command:
> ruby project1.rb
You will be prompted for an input file. I have provided "testinput.c" which contains the sample input from the project specification. I have also included "badtestinput.c" which has a syntax error and will be rejected by the parser.
In this version of the program, a json version of the tree will be output in addition to printing out the tree on the screen.
CURRENT STATE OF THE COMPILER
- The project is complete as specified.
- Type checking will validate int variables are not assigned a float value.
- Type checking does allow float variables to be assigned integer values
- Type checking also validates that only integers are used as array indices
- Known bugs: None known.
PROJECT TESTING
I tested the program manually with the two input files mentioned above.
I also used TDD (test driven development) to build the program using a tool called Rspec. You can run the unit test by installing Rspec:
gem install rspec
To run tests (with little output) use following command (assuming rspec 2.0):
>rspec parser_spec.rb --format d
To run tests (with verbose output) use following command (assuming rspec 2.0):
>rspec parser_spec_w_print.rb --format d
if you are running a prior version of rspec then the command is:
>spec parser_spec.rb --format specdoc
In parser_spec.rb and parser_spec_w_print.rb, you will find the tests used on the project. I have incorporated the additional tests that were provided after the Project 1 feedback.