From 70a36b938c0defae289c1f7d8d30081f5dace8d2 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Fri, 7 Mar 2025 15:34:07 +0000 Subject: [PATCH] Add README --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4823c79 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Well-parenthesized language parser +This project is a JavaCC parser configuration which generates a parser for a language with well-balanced parentheses. +The features that this language has is: +- Each string accepted by the language consists of multiple lines (but at least 1 line). +- Lines must not be empty. +- Lines must contain well-balanced parentheses, e.g. `()`, `()()()`, `(()())`, `(((())))`. +- Only parentheses are allowed, so any other character makes the input invalid. +- (As an exception to the first rule) there must be a blank final line at the end of the input. + +E.g. the following is a good input to the parser: +``` +()(()) +(())(((()()))) +((((((((((())))))))))) +(())()()()()() +((()()())()()(()(())))() + +``` + +## How to run +To build the Java code and run: +`./run.sh`. This is an alias for: +```bash +javacc assignment.jj && javac *.java && java Assignment < test.txt > output.txt 2> err.txt +``` + +### Output +The standard output stream will contain the parser's decision as to whether the string is valid — the output will either be `PASS` or `FAIL`. +If it is `FAIL`, the standard error will also contain the line number of the first error that caused the invalidity. \ No newline at end of file