Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
/ LL-1--Parser Public archive

C impelmentation of an LL(1) parser of the Tiny language

Notifications You must be signed in to change notification settings

mrbojangles3/LL-1--Parser

Repository files navigation

#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

About

C impelmentation of an LL(1) parser of the Tiny language

Resources

Stars

Watchers

Forks