This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
README
57 lines (45 loc) · 2.3 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
#README for CS3240 Project 1
#LL(1) scanner parser
# Authors: James McCarty
# Logan Blyth
# Rob Rayborn
C/Java impelmentation of an LL(1) parser of the Tiny language described in "Compiler Construction: Principles and Practice" by Kenneth C. Louden
This program requries two inputs:
1. An LL(1) grammar file, i.e. tiny.g
2. A tiny source file to test, i.e. tiny.t
To run the project:
./run.sh tiny_file.t input_grammar.g <parsing_table_output_filename.csv>
parsing_table_output_filename is an optional parameter for parse table output,
if not provided the parse table is saved to parseTable.csv
The project runs in two parts:
1. The scanner tokenizes the input source file into symbols.
- If errors are enountered, they are dumped to the terminal and the
script exits.
- If no errors are encountered, the script gives no output.
- If the scan was successful, a file named tiny.t.tok will exist
in the run directory, where 'tint.t' was the input file name.
2. The parser/generator runs on the tokenized input and grammar file.
- It outputs the LL(1) parsing table to the name specified, or
to parseTable.csv by default.
- If the parse was successful, the message:
"Parse completed successfully! No errors detected."
will print to the console.
- If there are errors in the input grammar, a useful message will
be printed to the console.
- If there is an error in parsing, the current token, current token's
location in the input file, and the parse stack will be dumped to
the console.
NOTE: The symbol we used for epsilon is the string "EPSILON"
To compile files with out run.sh:
Type 'make all'
To run the scanner and generate tokens on an input file without run.sh:
Run ./scanner tiny_file.t
Output of the scanner goes to stdout.
To run the Parser/Generator without running run.sh:
Run java ParserDriver tiny_token_file.tok grammar_file.g parsing_table_output_filename.csv <-v>
-v is an optional flag to use verbose mode which prints helpful data (grammar, first set, follow set, etc.)
to the terminal.
To simply build a parse table without running run.sh:
Run java ParserDriver grammar_file.g <parsing_table_output_filename.csv>
parsing_table_output_filename is an optional parameter for parse table output,
if not provided the parse table is saved to parseTable.csv