summaryrefslogtreecommitdiff
path: root/Homework/cs5300/project-three
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
commit6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch)
treeed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs5300/project-three
downloadmisc-undergrad-main.tar.gz
misc-undergrad-main.zip
Diffstat (limited to 'Homework/cs5300/project-three')
-rw-r--r--Homework/cs5300/project-three/antlr-4.9.1-complete.jarbin0 -> 2100605 bytes
-rw-r--r--Homework/cs5300/project-three/cfgparser/Grammar.java65
-rw-r--r--Homework/cs5300/project-three/cfgparser/GrammarBaseListener.java135
-rw-r--r--Homework/cs5300/project-three/cfgparser/GrammarLexer.java137
-rw-r--r--Homework/cs5300/project-three/cfgparser/GrammarListener.java90
-rw-r--r--Homework/cs5300/project-three/cfgparser/GrammarListenerImpl.java71
-rw-r--r--Homework/cs5300/project-three/cfgparser/GrammarParser.java503
-rw-r--r--Homework/cs5300/project-three/data/Expr.cfg25
-rw-r--r--Homework/cs5300/project-three/data/ExprLexer.tokens39
-rw-r--r--Homework/cs5300/project-three/data/Paren.cfg17
-rw-r--r--Homework/cs5300/project-three/data/ParenLexer.tokens19
-rw-r--r--Homework/cs5300/project-three/data/Simple.cfg13
-rw-r--r--Homework/cs5300/project-three/data/SimpleLexer.tokens15
-rw-r--r--Homework/cs5300/project-three/data/Tiny copy.cfg63
-rw-r--r--Homework/cs5300/project-three/data/Tiny.cfg63
-rw-r--r--Homework/cs5300/project-three/data/TinyLexer.tokens41
-rw-r--r--Homework/cs5300/project-three/data/expr1.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr2.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr3.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr4.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr5.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr6.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren0.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren1.dat3
-rw-r--r--Homework/cs5300/project-three/data/paren2.dat3
-rw-r--r--Homework/cs5300/project-three/data/paren3.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren4.dat1
-rw-r--r--Homework/cs5300/project-three/data/tiny1.dat3
-rw-r--r--Homework/cs5300/project-three/data/tiny2.dat7
-rw-r--r--Homework/cs5300/project-three/data/tiny3.dat4
-rw-r--r--Homework/cs5300/project-three/data/tiny4.dat4
-rw-r--r--Homework/cs5300/project-three/data/tinyGrammar.pdfbin0 -> 83316 bytes
-rw-r--r--Homework/cs5300/project-three/lexer/ExprLexer.interp52
-rw-r--r--Homework/cs5300/project-three/lexer/ExprLexer.java145
-rw-r--r--Homework/cs5300/project-three/lexer/ExprLexer.tokens17
-rw-r--r--Homework/cs5300/project-three/lexer/ParenLexer.interp26
-rw-r--r--Homework/cs5300/project-three/lexer/ParenLexer.java121
-rw-r--r--Homework/cs5300/project-three/lexer/ParenLexer.tokens5
-rw-r--r--Homework/cs5300/project-three/lexer/SimpleLexer.interp23
-rw-r--r--Homework/cs5300/project-three/lexer/SimpleLexer.java120
-rw-r--r--Homework/cs5300/project-three/lexer/SimpleLexer.tokens3
-rw-r--r--Homework/cs5300/project-three/lexer/TinyLexer.interp79
-rw-r--r--Homework/cs5300/project-three/lexer/TinyLexer.java164
-rw-r--r--Homework/cs5300/project-three/lexer/TinyLexer.tokens36
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/antlr-4.9.1-complete.jarbin0 -> 2100605 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/Grammar.classbin0 -> 2902 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarBaseListener.classbin0 -> 3509 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarLexer.classbin0 -> 4786 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListener.classbin0 -> 1459 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListenerImpl.classbin0 -> 2645 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$GoalContext.classbin0 -> 1736 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$LhsContext.classbin0 -> 1260 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$NameContext.classbin0 -> 1266 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Or_listContext.classbin0 -> 1487 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$RhsContext.classbin0 -> 1373 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Rule_listContext.classbin0 -> 1869 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$SymbolContext.classbin0 -> 1279 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Symbol_listContext.classbin0 -> 1532 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser.classbin0 -> 9618 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/Expr.cfg25
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/ExprLexer.tokens39
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/Paren.cfg17
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/ParenLexer.tokens19
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/Simple.cfg13
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/SimpleLexer.tokens15
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/Tiny.cfg19
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/TinyLexer.tokens41
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr1.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr2.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr3.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr4.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr5.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/expr6.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/paren0.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/paren1.dat3
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/paren2.dat3
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/paren3.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/paren4.dat1
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/tiny1.dat3
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/tiny2.dat7
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/tiny3.dat4
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/tiny4.dat4
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/data/tinyGrammar.pdfbin0 -> 83316 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.classbin0 -> 5198 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.interp52
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.tokens17
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.classbin0 -> 3982 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.interp26
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.tokens5
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.classbin0 -> 3890 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.interp23
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.tokens3
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.classbin0 -> 6203 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.interp79
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.tokens36
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/p3-parser.iml12
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Action$Act.classbin0 -> 1018 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Action.classbin0 -> 1927 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Grammar.classbin0 -> 4671 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Item.classbin0 -> 3359 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Main.classbin0 -> 12149 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Parser.classbin0 -> 4884 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/ParserException.classbin0 -> 2027 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Rule.classbin0 -> 2203 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/State.classbin0 -> 2281 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/States.classbin0 -> 950 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Tests.classbin0 -> 2150 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/Util.classbin0 -> 5297 bytes
-rw-r--r--Homework/cs5300/project-three/out/production/p3-parser/parser/util/SymbolComparator.classbin0 -> 1181 bytes
-rw-r--r--Homework/cs5300/project-three/parser/Action.java70
-rw-r--r--Homework/cs5300/project-three/parser/Grammar.java125
-rw-r--r--Homework/cs5300/project-three/parser/Item.java151
-rw-r--r--Homework/cs5300/project-three/parser/Main.java337
-rw-r--r--Homework/cs5300/project-three/parser/Parser.java341
-rw-r--r--Homework/cs5300/project-three/parser/ParserException.java81
-rw-r--r--Homework/cs5300/project-three/parser/Rule.java93
-rw-r--r--Homework/cs5300/project-three/parser/State.java94
-rw-r--r--Homework/cs5300/project-three/parser/States.java44
-rw-r--r--Homework/cs5300/project-three/parser/Tests.java69
-rw-r--r--Homework/cs5300/project-three/parser/Util.java132
-rw-r--r--Homework/cs5300/project-three/parser/util/SymbolComparator.java38
121 files changed, 4169 insertions, 0 deletions
diff --git a/Homework/cs5300/project-three/antlr-4.9.1-complete.jar b/Homework/cs5300/project-three/antlr-4.9.1-complete.jar
new file mode 100644
index 0000000..1bb7e8c
--- /dev/null
+++ b/Homework/cs5300/project-three/antlr-4.9.1-complete.jar
Binary files differ
diff --git a/Homework/cs5300/project-three/cfgparser/Grammar.java b/Homework/cs5300/project-three/cfgparser/Grammar.java
new file mode 100644
index 0000000..4de9ae4
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/Grammar.java
@@ -0,0 +1,65 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cfgparser;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import org.antlr.v4.runtime.ANTLRFileStream;
+import org.antlr.v4.runtime.BufferedTokenStream;
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import parser.Rule;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class Grammar {
+
+ private String name;
+ private ArrayList<Rule> rules;
+ private String startSymbol;
+
+ public Grammar(String filename) throws IOException {
+ GrammarLexer cfglexer = new GrammarLexer(new ANTLRFileStream(filename));
+ GrammarParser cfgparser = new GrammarParser(new BufferedTokenStream(cfglexer));
+ ParserRuleContext tree = cfgparser.getContext(); // parse
+
+ GrammarParser.GoalContext context = cfgparser.goal();
+
+ // Walk it and attach our listener
+ GrammarListenerImpl listener = new GrammarListenerImpl();
+ ParseTreeWalker walker = new ParseTreeWalker();
+ walker.walk(listener, context);
+ name = listener.name;
+ rules = listener.rules;
+ startSymbol = listener.startSymbol;
+ }
+
+ public ArrayList<Rule> getRules() {
+ return rules;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ArrayList<String> getSymbols() {
+ HashSet<String> symbols = new HashSet<>();
+ for (Rule rule : rules) {
+ symbols.add(rule.getLhs());
+ for (String symbol : rule.getRhs()) {
+ symbols.add(symbol);
+ }
+ }
+ return new ArrayList<>(symbols);
+ }
+
+ public String getStartSymbol() {
+ return startSymbol;
+ }
+}
diff --git a/Homework/cs5300/project-three/cfgparser/GrammarBaseListener.java b/Homework/cs5300/project-three/cfgparser/GrammarBaseListener.java
new file mode 100644
index 0000000..29038f1
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/GrammarBaseListener.java
@@ -0,0 +1,135 @@
+// Generated from Grammar.g4 by ANTLR 4.9.1
+package cfgparser;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import org.antlr.v4.runtime.tree.TerminalNode;
+
+/**
+ * This class provides an empty implementation of {@link GrammarListener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+public class GrammarBaseListener implements GrammarListener {
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterGoal(GrammarParser.GoalContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitGoal(GrammarParser.GoalContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterName(GrammarParser.NameContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitName(GrammarParser.NameContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterRule_list(GrammarParser.Rule_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitRule_list(GrammarParser.Rule_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterLhs(GrammarParser.LhsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitLhs(GrammarParser.LhsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterRhs(GrammarParser.RhsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitRhs(GrammarParser.RhsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterOr_list(GrammarParser.Or_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitOr_list(GrammarParser.Or_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterSymbol_list(GrammarParser.Symbol_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitSymbol_list(GrammarParser.Symbol_listContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterSymbol(GrammarParser.SymbolContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitSymbol(GrammarParser.SymbolContext ctx) { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void visitTerminal(TerminalNode node) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void visitErrorNode(ErrorNode node) { }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/cfgparser/GrammarLexer.java b/Homework/cs5300/project-three/cfgparser/GrammarLexer.java
new file mode 100644
index 0000000..653cc9c
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/GrammarLexer.java
@@ -0,0 +1,137 @@
+// Generated from Grammar.g4 by ANTLR 4.9.1
+package cfgparser;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class GrammarLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, GRAMMAR=4, IDENT=5, WS=6, COMMENT=7;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "T__0", "T__1", "T__2", "GRAMMAR", "IDENT", "WS", "COMMENT", "LETTER",
+ "DIGIT"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "';'", "':'", "'|'", "'grammar'"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, null, null, null, "GRAMMAR", "IDENT", "WS", "COMMENT"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public GrammarLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "Grammar.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\tR\b\1\4\2\t\2\4"+
+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\3\2\3\2"+
+ "\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\7\6\'\n\6"+
+ "\f\6\16\6*\13\6\3\7\6\7-\n\7\r\7\16\7.\3\7\3\7\3\b\3\b\3\b\3\b\7\b\67"+
+ "\n\b\f\b\16\b:\13\b\3\b\5\b=\n\b\3\b\3\b\3\b\3\b\3\b\7\bD\n\b\f\b\16\b"+
+ "G\13\b\3\b\3\b\5\bK\n\b\3\b\3\b\3\t\3\t\3\n\3\n\3E\2\13\3\3\5\4\7\5\t"+
+ "\6\13\7\r\b\17\t\21\2\23\2\3\2\5\5\2\13\f\16\17\"\"\4\2\f\f\17\17\4\2"+
+ "C\\c|\2V\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2"+
+ "\2\r\3\2\2\2\2\17\3\2\2\2\3\25\3\2\2\2\5\27\3\2\2\2\7\31\3\2\2\2\t\33"+
+ "\3\2\2\2\13#\3\2\2\2\r,\3\2\2\2\17J\3\2\2\2\21N\3\2\2\2\23P\3\2\2\2\25"+
+ "\26\7=\2\2\26\4\3\2\2\2\27\30\7<\2\2\30\6\3\2\2\2\31\32\7~\2\2\32\b\3"+
+ "\2\2\2\33\34\7i\2\2\34\35\7t\2\2\35\36\7c\2\2\36\37\7o\2\2\37 \7o\2\2"+
+ " !\7c\2\2!\"\7t\2\2\"\n\3\2\2\2#(\5\21\t\2$\'\5\21\t\2%\'\5\23\n\2&$\3"+
+ "\2\2\2&%\3\2\2\2\'*\3\2\2\2(&\3\2\2\2()\3\2\2\2)\f\3\2\2\2*(\3\2\2\2+"+
+ "-\t\2\2\2,+\3\2\2\2-.\3\2\2\2.,\3\2\2\2./\3\2\2\2/\60\3\2\2\2\60\61\b"+
+ "\7\2\2\61\16\3\2\2\2\62\63\7\61\2\2\63\64\7\61\2\2\648\3\2\2\2\65\67\n"+
+ "\3\2\2\66\65\3\2\2\2\67:\3\2\2\28\66\3\2\2\289\3\2\2\29<\3\2\2\2:8\3\2"+
+ "\2\2;=\7\17\2\2<;\3\2\2\2<=\3\2\2\2=>\3\2\2\2>K\7\f\2\2?@\7\61\2\2@A\7"+
+ ",\2\2AE\3\2\2\2BD\13\2\2\2CB\3\2\2\2DG\3\2\2\2EF\3\2\2\2EC\3\2\2\2FH\3"+
+ "\2\2\2GE\3\2\2\2HI\7,\2\2IK\7\61\2\2J\62\3\2\2\2J?\3\2\2\2KL\3\2\2\2L"+
+ "M\b\b\2\2M\20\3\2\2\2NO\t\4\2\2O\22\3\2\2\2PQ\4\62;\2Q\24\3\2\2\2\n\2"+
+ "&(.8<EJ\3\b\2\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/cfgparser/GrammarListener.java b/Homework/cs5300/project-three/cfgparser/GrammarListener.java
new file mode 100644
index 0000000..e24999c
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/GrammarListener.java
@@ -0,0 +1,90 @@
+// Generated from Grammar.g4 by ANTLR 4.9.1
+package cfgparser;
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link GrammarParser}.
+ */
+public interface GrammarListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#goal}.
+ * @param ctx the parse tree
+ */
+ void enterGoal(GrammarParser.GoalContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#goal}.
+ * @param ctx the parse tree
+ */
+ void exitGoal(GrammarParser.GoalContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#name}.
+ * @param ctx the parse tree
+ */
+ void enterName(GrammarParser.NameContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#name}.
+ * @param ctx the parse tree
+ */
+ void exitName(GrammarParser.NameContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#rule_list}.
+ * @param ctx the parse tree
+ */
+ void enterRule_list(GrammarParser.Rule_listContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#rule_list}.
+ * @param ctx the parse tree
+ */
+ void exitRule_list(GrammarParser.Rule_listContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#lhs}.
+ * @param ctx the parse tree
+ */
+ void enterLhs(GrammarParser.LhsContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#lhs}.
+ * @param ctx the parse tree
+ */
+ void exitLhs(GrammarParser.LhsContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#rhs}.
+ * @param ctx the parse tree
+ */
+ void enterRhs(GrammarParser.RhsContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#rhs}.
+ * @param ctx the parse tree
+ */
+ void exitRhs(GrammarParser.RhsContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#or_list}.
+ * @param ctx the parse tree
+ */
+ void enterOr_list(GrammarParser.Or_listContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#or_list}.
+ * @param ctx the parse tree
+ */
+ void exitOr_list(GrammarParser.Or_listContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#symbol_list}.
+ * @param ctx the parse tree
+ */
+ void enterSymbol_list(GrammarParser.Symbol_listContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#symbol_list}.
+ * @param ctx the parse tree
+ */
+ void exitSymbol_list(GrammarParser.Symbol_listContext ctx);
+ /**
+ * Enter a parse tree produced by {@link GrammarParser#symbol}.
+ * @param ctx the parse tree
+ */
+ void enterSymbol(GrammarParser.SymbolContext ctx);
+ /**
+ * Exit a parse tree produced by {@link GrammarParser#symbol}.
+ * @param ctx the parse tree
+ */
+ void exitSymbol(GrammarParser.SymbolContext ctx);
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/cfgparser/GrammarListenerImpl.java b/Homework/cs5300/project-three/cfgparser/GrammarListenerImpl.java
new file mode 100644
index 0000000..560b412
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/GrammarListenerImpl.java
@@ -0,0 +1,71 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cfgparser;
+
+import cfgparser.GrammarBaseListener;
+import cfgparser.GrammarParser;
+import java.util.ArrayList;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import parser.Rule;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class GrammarListenerImpl extends GrammarBaseListener {
+
+ String name;
+ String curLhs;
+ Rule curRule;
+ ArrayList<Rule> rules;
+ String startSymbol;
+
+ public GrammarListenerImpl() {
+ rules = new ArrayList<>();
+ startSymbol = null;
+ }
+
+ public void print() {
+ for (Rule rule : rules) {
+ System.out.println(rule);
+ }
+ }
+
+ @Override
+ public void enterName(GrammarParser.NameContext ctx) {
+ name = ctx.getText();
+ }
+
+ @Override
+ public void enterLhs(GrammarParser.LhsContext ctx) {
+ curLhs = ctx.getText();
+ if (startSymbol == null) {
+ startSymbol = curLhs;
+ }
+ }
+
+ @Override
+ public void enterRhs(GrammarParser.RhsContext ctx) {
+ curRule = new Rule(curLhs);
+ }
+
+ @Override
+ public void exitRhs(GrammarParser.RhsContext ctx) {
+ curRule.setName(rules.size());
+ rules.add(curRule);
+ }
+
+ @Override
+ public void enterSymbol(GrammarParser.SymbolContext ctx) {
+ curRule.addRhs(ctx.getText());
+ }
+
+ @Override
+ public void visitErrorNode(ErrorNode node) {
+ System.out.println("Error!");
+ }
+
+}
diff --git a/Homework/cs5300/project-three/cfgparser/GrammarParser.java b/Homework/cs5300/project-three/cfgparser/GrammarParser.java
new file mode 100644
index 0000000..20c523c
--- /dev/null
+++ b/Homework/cs5300/project-three/cfgparser/GrammarParser.java
@@ -0,0 +1,503 @@
+// Generated from Grammar.g4 by ANTLR 4.9.1
+package cfgparser;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.misc.*;
+import org.antlr.v4.runtime.tree.*;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class GrammarParser extends Parser {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, GRAMMAR=4, IDENT=5, WS=6, COMMENT=7;
+ public static final int
+ RULE_goal = 0, RULE_name = 1, RULE_rule_list = 2, RULE_lhs = 3, RULE_rhs = 4,
+ RULE_or_list = 5, RULE_symbol_list = 6, RULE_symbol = 7;
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "goal", "name", "rule_list", "lhs", "rhs", "or_list", "symbol_list",
+ "symbol"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "';'", "':'", "'|'", "'grammar'"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, null, null, null, "GRAMMAR", "IDENT", "WS", "COMMENT"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+ @Override
+ public String getGrammarFileName() { return "Grammar.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public GrammarParser(TokenStream input) {
+ super(input);
+ _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ public static class GoalContext extends ParserRuleContext {
+ public TerminalNode GRAMMAR() { return getToken(GrammarParser.GRAMMAR, 0); }
+ public NameContext name() {
+ return getRuleContext(NameContext.class,0);
+ }
+ public Rule_listContext rule_list() {
+ return getRuleContext(Rule_listContext.class,0);
+ }
+ public GoalContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_goal; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterGoal(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitGoal(this);
+ }
+ }
+
+ public final GoalContext goal() throws RecognitionException {
+ GoalContext _localctx = new GoalContext(_ctx, getState());
+ enterRule(_localctx, 0, RULE_goal);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(16);
+ match(GRAMMAR);
+ setState(17);
+ name();
+ setState(18);
+ match(T__0);
+ setState(19);
+ rule_list();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class NameContext extends ParserRuleContext {
+ public TerminalNode IDENT() { return getToken(GrammarParser.IDENT, 0); }
+ public NameContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_name; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterName(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitName(this);
+ }
+ }
+
+ public final NameContext name() throws RecognitionException {
+ NameContext _localctx = new NameContext(_ctx, getState());
+ enterRule(_localctx, 2, RULE_name);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(21);
+ match(IDENT);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class Rule_listContext extends ParserRuleContext {
+ public LhsContext lhs() {
+ return getRuleContext(LhsContext.class,0);
+ }
+ public RhsContext rhs() {
+ return getRuleContext(RhsContext.class,0);
+ }
+ public Or_listContext or_list() {
+ return getRuleContext(Or_listContext.class,0);
+ }
+ public Rule_listContext rule_list() {
+ return getRuleContext(Rule_listContext.class,0);
+ }
+ public Rule_listContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_rule_list; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterRule_list(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitRule_list(this);
+ }
+ }
+
+ public final Rule_listContext rule_list() throws RecognitionException {
+ Rule_listContext _localctx = new Rule_listContext(_ctx, getState());
+ enterRule(_localctx, 4, RULE_rule_list);
+ try {
+ setState(31);
+ _errHandler.sync(this);
+ switch (_input.LA(1)) {
+ case IDENT:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(23);
+ lhs();
+ setState(24);
+ match(T__1);
+ setState(25);
+ rhs();
+ setState(26);
+ or_list();
+ setState(27);
+ match(T__0);
+ setState(28);
+ rule_list();
+ }
+ break;
+ case EOF:
+ enterOuterAlt(_localctx, 2);
+ {
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class LhsContext extends ParserRuleContext {
+ public TerminalNode IDENT() { return getToken(GrammarParser.IDENT, 0); }
+ public LhsContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_lhs; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterLhs(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitLhs(this);
+ }
+ }
+
+ public final LhsContext lhs() throws RecognitionException {
+ LhsContext _localctx = new LhsContext(_ctx, getState());
+ enterRule(_localctx, 6, RULE_lhs);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(33);
+ match(IDENT);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class RhsContext extends ParserRuleContext {
+ public Symbol_listContext symbol_list() {
+ return getRuleContext(Symbol_listContext.class,0);
+ }
+ public RhsContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_rhs; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterRhs(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitRhs(this);
+ }
+ }
+
+ public final RhsContext rhs() throws RecognitionException {
+ RhsContext _localctx = new RhsContext(_ctx, getState());
+ enterRule(_localctx, 8, RULE_rhs);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(35);
+ symbol_list();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class Or_listContext extends ParserRuleContext {
+ public RhsContext rhs() {
+ return getRuleContext(RhsContext.class,0);
+ }
+ public Or_listContext or_list() {
+ return getRuleContext(Or_listContext.class,0);
+ }
+ public Or_listContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_or_list; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterOr_list(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitOr_list(this);
+ }
+ }
+
+ public final Or_listContext or_list() throws RecognitionException {
+ Or_listContext _localctx = new Or_listContext(_ctx, getState());
+ enterRule(_localctx, 10, RULE_or_list);
+ try {
+ setState(42);
+ _errHandler.sync(this);
+ switch (_input.LA(1)) {
+ case T__2:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(37);
+ match(T__2);
+ setState(38);
+ rhs();
+ setState(39);
+ or_list();
+ }
+ break;
+ case T__0:
+ enterOuterAlt(_localctx, 2);
+ {
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class Symbol_listContext extends ParserRuleContext {
+ public SymbolContext symbol() {
+ return getRuleContext(SymbolContext.class,0);
+ }
+ public Symbol_listContext symbol_list() {
+ return getRuleContext(Symbol_listContext.class,0);
+ }
+ public Symbol_listContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_symbol_list; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterSymbol_list(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitSymbol_list(this);
+ }
+ }
+
+ public final Symbol_listContext symbol_list() throws RecognitionException {
+ Symbol_listContext _localctx = new Symbol_listContext(_ctx, getState());
+ enterRule(_localctx, 12, RULE_symbol_list);
+ try {
+ setState(48);
+ _errHandler.sync(this);
+ switch (_input.LA(1)) {
+ case IDENT:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(44);
+ symbol();
+ setState(45);
+ symbol_list();
+ }
+ break;
+ case T__0:
+ case T__2:
+ enterOuterAlt(_localctx, 2);
+ {
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class SymbolContext extends ParserRuleContext {
+ public TerminalNode IDENT() { return getToken(GrammarParser.IDENT, 0); }
+ public SymbolContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_symbol; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterSymbol(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitSymbol(this);
+ }
+ }
+
+ public final SymbolContext symbol() throws RecognitionException {
+ SymbolContext _localctx = new SymbolContext(_ctx, getState());
+ enterRule(_localctx, 14, RULE_symbol);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(50);
+ match(IDENT);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\t\67\4\2\t\2\4\3"+
+ "\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\3\2\3\2\3\2\3"+
+ "\2\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4\"\n\4\3\5\3\5\3\6\3\6\3"+
+ "\7\3\7\3\7\3\7\3\7\5\7-\n\7\3\b\3\b\3\b\3\b\5\b\63\n\b\3\t\3\t\3\t\2\2"+
+ "\n\2\4\6\b\n\f\16\20\2\2\2\61\2\22\3\2\2\2\4\27\3\2\2\2\6!\3\2\2\2\b#"+
+ "\3\2\2\2\n%\3\2\2\2\f,\3\2\2\2\16\62\3\2\2\2\20\64\3\2\2\2\22\23\7\6\2"+
+ "\2\23\24\5\4\3\2\24\25\7\3\2\2\25\26\5\6\4\2\26\3\3\2\2\2\27\30\7\7\2"+
+ "\2\30\5\3\2\2\2\31\32\5\b\5\2\32\33\7\4\2\2\33\34\5\n\6\2\34\35\5\f\7"+
+ "\2\35\36\7\3\2\2\36\37\5\6\4\2\37\"\3\2\2\2 \"\3\2\2\2!\31\3\2\2\2! \3"+
+ "\2\2\2\"\7\3\2\2\2#$\7\7\2\2$\t\3\2\2\2%&\5\16\b\2&\13\3\2\2\2\'(\7\5"+
+ "\2\2()\5\n\6\2)*\5\f\7\2*-\3\2\2\2+-\3\2\2\2,\'\3\2\2\2,+\3\2\2\2-\r\3"+
+ "\2\2\2./\5\20\t\2/\60\5\16\b\2\60\63\3\2\2\2\61\63\3\2\2\2\62.\3\2\2\2"+
+ "\62\61\3\2\2\2\63\17\3\2\2\2\64\65\7\7\2\2\65\21\3\2\2\2\5!,\62";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/Expr.cfg b/Homework/cs5300/project-three/data/Expr.cfg
new file mode 100644
index 0000000..7493e3e
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Expr.cfg
@@ -0,0 +1,25 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ExprLexer.tokens.
+
+grammar Expr;
+
+goal: expr;
+
+expr: expr PLUS term
+ | expr MINUS term
+ | term
+ ;
+
+term : term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN expr CPAREN
+ | INT
+ | FLOAT
+ | IDENTIFIER
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/ExprLexer.tokens b/Homework/cs5300/project-three/data/ExprLexer.tokens
new file mode 100644
index 0000000..ccb798a
--- /dev/null
+++ b/Homework/cs5300/project-three/data/ExprLexer.tokens
@@ -0,0 +1,39 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Expr.cfg.
+
+lexer grammar ExprLexer;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+OPAREN: '(' ;
+CPAREN: ')' ;
+
+FLOAT
+ : DIGIT+ '.' DIGIT+
+ ;
+
+INT
+ : DIGIT+
+ ;
+
+IDENTIFIER
+ : LETTER (LETTER | DIGIT)*
+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/Paren.cfg b/Homework/cs5300/project-three/data/Paren.cfg
new file mode 100644
index 0000000..184b11c
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Paren.cfg
@@ -0,0 +1,17 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Paren;
+
+goal: list;
+
+list: list pair
+ | pair
+ ;
+
+pair: OPAREN list CPAREN
+ | OPAREN CPAREN
+ ;
diff --git a/Homework/cs5300/project-three/data/ParenLexer.tokens b/Homework/cs5300/project-three/data/ParenLexer.tokens
new file mode 100644
index 0000000..51e5258
--- /dev/null
+++ b/Homework/cs5300/project-three/data/ParenLexer.tokens
@@ -0,0 +1,19 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Paren.cfg.
+
+lexer grammar ParenLexer;
+
+OPAREN
+ : '('
+ ;
+
+CPAREN
+ : ')'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/data/Simple.cfg b/Homework/cs5300/project-three/data/Simple.cfg
new file mode 100644
index 0000000..80c1e18
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Simple.cfg
@@ -0,0 +1,13 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Simple;
+
+G: N;
+
+N: N X
+ | X
+ ;
diff --git a/Homework/cs5300/project-three/data/SimpleLexer.tokens b/Homework/cs5300/project-three/data/SimpleLexer.tokens
new file mode 100644
index 0000000..64ec3c1
--- /dev/null
+++ b/Homework/cs5300/project-three/data/SimpleLexer.tokens
@@ -0,0 +1,15 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Simple.cfg.
+
+lexer grammar SimpleLexer;
+
+X
+ : 'x'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/data/Tiny copy.cfg b/Homework/cs5300/project-three/data/Tiny copy.cfg
new file mode 100644
index 0000000..71fb8d9
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Tiny copy.cfg
@@ -0,0 +1,63 @@
+//
+// WRITE A CORRECT GRAMMAR FOR THE TINY LANGUAGE IN THIS FILE.
+//
+// The grammar is described in data/tinyGrammar.pdf. Do not use dashes
+// in your non-terminal names. I recommend you use mixed case naming for your
+// non-terminals instead (e.g. stmtSeq).
+//
+// Do not put any string literals in this grammar (e.g. "="). Use only token
+// names given in TinyLexer.tokens.
+//
+// This file contains an expression grammar that uses tokens described in
+// TinyLexer.tokens.
+//
+// NOTE ONE ERROR in the pdf: the second production rule should read:
+// stmt-seq -> stmt-seq stmt | stmt
+
+grammar Tiny;
+
+goal: program;
+
+program: stmtseq;
+
+stmtseq: stmtseq stmt
+ | stmt;
+
+stmt: ifstmt
+ | repeatstmt
+ | assignstmt
+ | readstmt
+ | writestmt
+ ;
+
+ifstmt: IF exp THEN stmtseq END
+ | IF exp THEN stmtseq ELSE stmtseq END
+ ;
+
+repeatstmt: REPEAT stmtseq UNTIL exp;
+
+assignstmt: ID EQUAL exp;
+
+readstmt: READ ID;
+
+writestmt: WRITE exp;
+
+exp: simpleexp LT simpleexp
+ | simpleexp EQUAL simpleexp
+ | simpleexp
+ ;
+
+simpleexp: simpleexp PLUS term
+ | simpleexp MINUS term
+ | term
+ ;
+
+term: term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN exp CPAREN
+ | NUM
+ | ID
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/Tiny.cfg b/Homework/cs5300/project-three/data/Tiny.cfg
new file mode 100644
index 0000000..71fb8d9
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Tiny.cfg
@@ -0,0 +1,63 @@
+//
+// WRITE A CORRECT GRAMMAR FOR THE TINY LANGUAGE IN THIS FILE.
+//
+// The grammar is described in data/tinyGrammar.pdf. Do not use dashes
+// in your non-terminal names. I recommend you use mixed case naming for your
+// non-terminals instead (e.g. stmtSeq).
+//
+// Do not put any string literals in this grammar (e.g. "="). Use only token
+// names given in TinyLexer.tokens.
+//
+// This file contains an expression grammar that uses tokens described in
+// TinyLexer.tokens.
+//
+// NOTE ONE ERROR in the pdf: the second production rule should read:
+// stmt-seq -> stmt-seq stmt | stmt
+
+grammar Tiny;
+
+goal: program;
+
+program: stmtseq;
+
+stmtseq: stmtseq stmt
+ | stmt;
+
+stmt: ifstmt
+ | repeatstmt
+ | assignstmt
+ | readstmt
+ | writestmt
+ ;
+
+ifstmt: IF exp THEN stmtseq END
+ | IF exp THEN stmtseq ELSE stmtseq END
+ ;
+
+repeatstmt: REPEAT stmtseq UNTIL exp;
+
+assignstmt: ID EQUAL exp;
+
+readstmt: READ ID;
+
+writestmt: WRITE exp;
+
+exp: simpleexp LT simpleexp
+ | simpleexp EQUAL simpleexp
+ | simpleexp
+ ;
+
+simpleexp: simpleexp PLUS term
+ | simpleexp MINUS term
+ | term
+ ;
+
+term: term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN exp CPAREN
+ | NUM
+ | ID
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/TinyLexer.tokens b/Homework/cs5300/project-three/data/TinyLexer.tokens
new file mode 100644
index 0000000..ad6b2a7
--- /dev/null
+++ b/Homework/cs5300/project-three/data/TinyLexer.tokens
@@ -0,0 +1,41 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Tiny.cfg.
+
+lexer grammar TinyLexer;
+
+IF : 'if' ;
+THEN : 'then' ;
+ELSE : 'else' ;
+END : 'end' ;
+REPEAT : 'repeat' ;
+UNTIL : 'until' ;
+READ : 'read' ;
+WRITE : 'write' ;
+OPAREN : '(' ;
+CPAREN : ')' ;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+LT: '<' ;
+EQUAL: '=' ;
+
+NUM : DIGIT+ ;
+ID : LETTER+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr1.dat b/Homework/cs5300/project-three/data/expr1.dat
new file mode 100644
index 0000000..846e7d3
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr1.dat
@@ -0,0 +1 @@
+3 + 4 * 5 / 8 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr2.dat b/Homework/cs5300/project-three/data/expr2.dat
new file mode 100644
index 0000000..8e0c0b7
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr2.dat
@@ -0,0 +1 @@
+3 + + 42 * 34 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr3.dat b/Homework/cs5300/project-three/data/expr3.dat
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr3.dat
@@ -0,0 +1 @@
+3
diff --git a/Homework/cs5300/project-three/data/expr4.dat b/Homework/cs5300/project-three/data/expr4.dat
new file mode 100644
index 0000000..84a357a
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr4.dat
@@ -0,0 +1 @@
+(a + b) * ((c-def)/43) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr5.dat b/Homework/cs5300/project-three/data/expr5.dat
new file mode 100644
index 0000000..c2c433b
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr5.dat
@@ -0,0 +1 @@
+(a + b) * ((c-d)/43
diff --git a/Homework/cs5300/project-three/data/expr6.dat b/Homework/cs5300/project-three/data/expr6.dat
new file mode 100644
index 0000000..f46d387
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr6.dat
@@ -0,0 +1 @@
+( \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren0.dat b/Homework/cs5300/project-three/data/paren0.dat
new file mode 100644
index 0000000..dd626a0
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren0.dat
@@ -0,0 +1 @@
+() \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren1.dat b/Homework/cs5300/project-three/data/paren1.dat
new file mode 100644
index 0000000..f7e9493
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren1.dat
@@ -0,0 +1,3 @@
+((
+))(
+)(((()))()(())) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren2.dat b/Homework/cs5300/project-three/data/paren2.dat
new file mode 100644
index 0000000..4f879eb
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren2.dat
@@ -0,0 +1,3 @@
+(
+))(
+) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren3.dat b/Homework/cs5300/project-three/data/paren3.dat
new file mode 100644
index 0000000..e4a2fe8
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren3.dat
@@ -0,0 +1 @@
+)()(
diff --git a/Homework/cs5300/project-three/data/paren4.dat b/Homework/cs5300/project-three/data/paren4.dat
new file mode 100644
index 0000000..3077d74
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren4.dat
@@ -0,0 +1 @@
+()()(()())
diff --git a/Homework/cs5300/project-three/data/tiny1.dat b/Homework/cs5300/project-three/data/tiny1.dat
new file mode 100644
index 0000000..7f9078f
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny1.dat
@@ -0,0 +1,3 @@
+a = 3
+b = 4
+c = a + b
diff --git a/Homework/cs5300/project-three/data/tiny2.dat b/Homework/cs5300/project-three/data/tiny2.dat
new file mode 100644
index 0000000..09195b8
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny2.dat
@@ -0,0 +1,7 @@
+a = 3
+b = 4
+if a = b then
+ write (a + b * (c - d))
+else
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tiny3.dat b/Homework/cs5300/project-three/data/tiny3.dat
new file mode 100644
index 0000000..768addd
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny3.dat
@@ -0,0 +1,4 @@
+a = 3
+if a = then
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tiny4.dat b/Homework/cs5300/project-three/data/tiny4.dat
new file mode 100644
index 0000000..1d66283
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny4.dat
@@ -0,0 +1,4 @@
+a = 3
+if (a = b) then
+ write a = 3)
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tinyGrammar.pdf b/Homework/cs5300/project-three/data/tinyGrammar.pdf
new file mode 100644
index 0000000..855d45b
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tinyGrammar.pdf
Binary files differ
diff --git a/Homework/cs5300/project-three/lexer/ExprLexer.interp b/Homework/cs5300/project-three/lexer/ExprLexer.interp
new file mode 100644
index 0000000..c9ec8c0
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ExprLexer.interp
@@ -0,0 +1,52 @@
+token literal names:
+null
+'+'
+'-'
+'*'
+'/'
+'('
+')'
+null
+null
+null
+null
+null
+
+token symbolic names:
+null
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+OPAREN
+CPAREN
+FLOAT
+INT
+IDENTIFIER
+COMMENT
+WS
+
+rule names:
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+OPAREN
+CPAREN
+FLOAT
+INT
+IDENTIFIER
+COMMENT
+WS
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 104, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 6, 8, 43, 10, 8, 13, 8, 14, 8, 44, 3, 8, 3, 8, 6, 8, 49, 10, 8, 13, 8, 14, 8, 50, 3, 9, 6, 9, 54, 10, 9, 13, 9, 14, 9, 55, 3, 10, 3, 10, 3, 10, 7, 10, 61, 10, 10, 12, 10, 14, 10, 64, 11, 10, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 70, 10, 11, 12, 11, 14, 11, 73, 11, 11, 3, 11, 5, 11, 76, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 83, 10, 11, 12, 11, 14, 11, 86, 11, 11, 3, 11, 3, 11, 5, 11, 90, 10, 11, 3, 11, 3, 11, 3, 12, 6, 12, 95, 10, 12, 13, 12, 14, 12, 96, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 84, 2, 15, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 2, 27, 2, 3, 2, 5, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 67, 92, 99, 124, 2, 111, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 3, 29, 3, 2, 2, 2, 5, 31, 3, 2, 2, 2, 7, 33, 3, 2, 2, 2, 9, 35, 3, 2, 2, 2, 11, 37, 3, 2, 2, 2, 13, 39, 3, 2, 2, 2, 15, 42, 3, 2, 2, 2, 17, 53, 3, 2, 2, 2, 19, 57, 3, 2, 2, 2, 21, 89, 3, 2, 2, 2, 23, 94, 3, 2, 2, 2, 25, 100, 3, 2, 2, 2, 27, 102, 3, 2, 2, 2, 29, 30, 7, 45, 2, 2, 30, 4, 3, 2, 2, 2, 31, 32, 7, 47, 2, 2, 32, 6, 3, 2, 2, 2, 33, 34, 7, 44, 2, 2, 34, 8, 3, 2, 2, 2, 35, 36, 7, 49, 2, 2, 36, 10, 3, 2, 2, 2, 37, 38, 7, 42, 2, 2, 38, 12, 3, 2, 2, 2, 39, 40, 7, 43, 2, 2, 40, 14, 3, 2, 2, 2, 41, 43, 5, 27, 14, 2, 42, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 48, 7, 48, 2, 2, 47, 49, 5, 27, 14, 2, 48, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 16, 3, 2, 2, 2, 52, 54, 5, 27, 14, 2, 53, 52, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 55, 56, 3, 2, 2, 2, 56, 18, 3, 2, 2, 2, 57, 62, 5, 25, 13, 2, 58, 61, 5, 25, 13, 2, 59, 61, 5, 27, 14, 2, 60, 58, 3, 2, 2, 2, 60, 59, 3, 2, 2, 2, 61, 64, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 63, 3, 2, 2, 2, 63, 20, 3, 2, 2, 2, 64, 62, 3, 2, 2, 2, 65, 66, 7, 49, 2, 2, 66, 67, 7, 49, 2, 2, 67, 71, 3, 2, 2, 2, 68, 70, 10, 2, 2, 2, 69, 68, 3, 2, 2, 2, 70, 73, 3, 2, 2, 2, 71, 69, 3, 2, 2, 2, 71, 72, 3, 2, 2, 2, 72, 75, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 74, 76, 7, 15, 2, 2, 75, 74, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 77, 3, 2, 2, 2, 77, 90, 7, 12, 2, 2, 78, 79, 7, 49, 2, 2, 79, 80, 7, 44, 2, 2, 80, 84, 3, 2, 2, 2, 81, 83, 11, 2, 2, 2, 82, 81, 3, 2, 2, 2, 83, 86, 3, 2, 2, 2, 84, 85, 3, 2, 2, 2, 84, 82, 3, 2, 2, 2, 85, 87, 3, 2, 2, 2, 86, 84, 3, 2, 2, 2, 87, 88, 7, 44, 2, 2, 88, 90, 7, 49, 2, 2, 89, 65, 3, 2, 2, 2, 89, 78, 3, 2, 2, 2, 90, 91, 3, 2, 2, 2, 91, 92, 8, 11, 2, 2, 92, 22, 3, 2, 2, 2, 93, 95, 9, 3, 2, 2, 94, 93, 3, 2, 2, 2, 95, 96, 3, 2, 2, 2, 96, 94, 3, 2, 2, 2, 96, 97, 3, 2, 2, 2, 97, 98, 3, 2, 2, 2, 98, 99, 8, 12, 2, 2, 99, 24, 3, 2, 2, 2, 100, 101, 9, 4, 2, 2, 101, 26, 3, 2, 2, 2, 102, 103, 4, 50, 59, 2, 103, 28, 3, 2, 2, 2, 13, 2, 44, 50, 55, 60, 62, 71, 75, 84, 89, 96, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/ExprLexer.java b/Homework/cs5300/project-three/lexer/ExprLexer.java
new file mode 100644
index 0000000..b9d760b
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ExprLexer.java
@@ -0,0 +1,145 @@
+// Generated from ExprLexer.tokens by ANTLR 4.9.1
+package lexer;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class ExprLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ PLUS=1, MINUS=2, MULTIPLY=3, DIVIDE=4, OPAREN=5, CPAREN=6, FLOAT=7, INT=8,
+ IDENTIFIER=9, COMMENT=10, WS=11;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "OPAREN", "CPAREN", "FLOAT", "INT",
+ "IDENTIFIER", "COMMENT", "WS", "LETTER", "DIGIT"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "'+'", "'-'", "'*'", "'/'", "'('", "')'"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "OPAREN", "CPAREN", "FLOAT",
+ "INT", "IDENTIFIER", "COMMENT", "WS"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public ExprLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "ExprLexer.tokens"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\rh\b\1\4\2\t\2\4"+
+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+
+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6"+
+ "\3\7\3\7\3\b\6\b+\n\b\r\b\16\b,\3\b\3\b\6\b\61\n\b\r\b\16\b\62\3\t\6\t"+
+ "\66\n\t\r\t\16\t\67\3\n\3\n\3\n\7\n=\n\n\f\n\16\n@\13\n\3\13\3\13\3\13"+
+ "\3\13\7\13F\n\13\f\13\16\13I\13\13\3\13\5\13L\n\13\3\13\3\13\3\13\3\13"+
+ "\3\13\7\13S\n\13\f\13\16\13V\13\13\3\13\3\13\5\13Z\n\13\3\13\3\13\3\f"+
+ "\6\f_\n\f\r\f\16\f`\3\f\3\f\3\r\3\r\3\16\3\16\3T\2\17\3\3\5\4\7\5\t\6"+
+ "\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\2\33\2\3\2\5\4\2\f\f\17\17\5\2"+
+ "\13\f\16\17\"\"\4\2C\\c|\2o\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3"+
+ "\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2"+
+ "\2\25\3\2\2\2\2\27\3\2\2\2\3\35\3\2\2\2\5\37\3\2\2\2\7!\3\2\2\2\t#\3\2"+
+ "\2\2\13%\3\2\2\2\r\'\3\2\2\2\17*\3\2\2\2\21\65\3\2\2\2\239\3\2\2\2\25"+
+ "Y\3\2\2\2\27^\3\2\2\2\31d\3\2\2\2\33f\3\2\2\2\35\36\7-\2\2\36\4\3\2\2"+
+ "\2\37 \7/\2\2 \6\3\2\2\2!\"\7,\2\2\"\b\3\2\2\2#$\7\61\2\2$\n\3\2\2\2%"+
+ "&\7*\2\2&\f\3\2\2\2\'(\7+\2\2(\16\3\2\2\2)+\5\33\16\2*)\3\2\2\2+,\3\2"+
+ "\2\2,*\3\2\2\2,-\3\2\2\2-.\3\2\2\2.\60\7\60\2\2/\61\5\33\16\2\60/\3\2"+
+ "\2\2\61\62\3\2\2\2\62\60\3\2\2\2\62\63\3\2\2\2\63\20\3\2\2\2\64\66\5\33"+
+ "\16\2\65\64\3\2\2\2\66\67\3\2\2\2\67\65\3\2\2\2\678\3\2\2\28\22\3\2\2"+
+ "\29>\5\31\r\2:=\5\31\r\2;=\5\33\16\2<:\3\2\2\2<;\3\2\2\2=@\3\2\2\2><\3"+
+ "\2\2\2>?\3\2\2\2?\24\3\2\2\2@>\3\2\2\2AB\7\61\2\2BC\7\61\2\2CG\3\2\2\2"+
+ "DF\n\2\2\2ED\3\2\2\2FI\3\2\2\2GE\3\2\2\2GH\3\2\2\2HK\3\2\2\2IG\3\2\2\2"+
+ "JL\7\17\2\2KJ\3\2\2\2KL\3\2\2\2LM\3\2\2\2MZ\7\f\2\2NO\7\61\2\2OP\7,\2"+
+ "\2PT\3\2\2\2QS\13\2\2\2RQ\3\2\2\2SV\3\2\2\2TU\3\2\2\2TR\3\2\2\2UW\3\2"+
+ "\2\2VT\3\2\2\2WX\7,\2\2XZ\7\61\2\2YA\3\2\2\2YN\3\2\2\2Z[\3\2\2\2[\\\b"+
+ "\13\2\2\\\26\3\2\2\2]_\t\3\2\2^]\3\2\2\2_`\3\2\2\2`^\3\2\2\2`a\3\2\2\2"+
+ "ab\3\2\2\2bc\b\f\2\2c\30\3\2\2\2de\t\4\2\2e\32\3\2\2\2fg\4\62;\2g\34\3"+
+ "\2\2\2\r\2,\62\67<>GKTY`\3\b\2\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/ExprLexer.tokens b/Homework/cs5300/project-three/lexer/ExprLexer.tokens
new file mode 100644
index 0000000..295e180
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ExprLexer.tokens
@@ -0,0 +1,17 @@
+PLUS=1
+MINUS=2
+MULTIPLY=3
+DIVIDE=4
+OPAREN=5
+CPAREN=6
+FLOAT=7
+INT=8
+IDENTIFIER=9
+COMMENT=10
+WS=11
+'+'=1
+'-'=2
+'*'=3
+'/'=4
+'('=5
+')'=6
diff --git a/Homework/cs5300/project-three/lexer/ParenLexer.interp b/Homework/cs5300/project-three/lexer/ParenLexer.interp
new file mode 100644
index 0000000..d973cba
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ParenLexer.interp
@@ -0,0 +1,26 @@
+token literal names:
+null
+'('
+')'
+null
+
+token symbolic names:
+null
+OPAREN
+CPAREN
+WS
+
+rule names:
+OPAREN
+CPAREN
+WS
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 5, 20, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 6, 4, 15, 10, 4, 13, 4, 14, 4, 16, 3, 4, 3, 4, 2, 2, 5, 3, 3, 5, 4, 7, 5, 3, 2, 3, 5, 2, 11, 12, 14, 15, 34, 34, 2, 20, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 3, 9, 3, 2, 2, 2, 5, 11, 3, 2, 2, 2, 7, 14, 3, 2, 2, 2, 9, 10, 7, 42, 2, 2, 10, 4, 3, 2, 2, 2, 11, 12, 7, 43, 2, 2, 12, 6, 3, 2, 2, 2, 13, 15, 9, 2, 2, 2, 14, 13, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 18, 3, 2, 2, 2, 18, 19, 8, 4, 2, 2, 19, 8, 3, 2, 2, 2, 4, 2, 16, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/ParenLexer.java b/Homework/cs5300/project-three/lexer/ParenLexer.java
new file mode 100644
index 0000000..3ac9511
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ParenLexer.java
@@ -0,0 +1,121 @@
+// Generated from ParenLexer.tokens by ANTLR 4.9.1
+package lexer;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class ParenLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ OPAREN=1, CPAREN=2, WS=3;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "OPAREN", "CPAREN", "WS"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "'('", "')'"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, "OPAREN", "CPAREN", "WS"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public ParenLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "ParenLexer.tokens"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\5\24\b\1\4\2\t\2"+
+ "\4\3\t\3\4\4\t\4\3\2\3\2\3\3\3\3\3\4\6\4\17\n\4\r\4\16\4\20\3\4\3\4\2"+
+ "\2\5\3\3\5\4\7\5\3\2\3\5\2\13\f\16\17\"\"\2\24\2\3\3\2\2\2\2\5\3\2\2\2"+
+ "\2\7\3\2\2\2\3\t\3\2\2\2\5\13\3\2\2\2\7\16\3\2\2\2\t\n\7*\2\2\n\4\3\2"+
+ "\2\2\13\f\7+\2\2\f\6\3\2\2\2\r\17\t\2\2\2\16\r\3\2\2\2\17\20\3\2\2\2\20"+
+ "\16\3\2\2\2\20\21\3\2\2\2\21\22\3\2\2\2\22\23\b\4\2\2\23\b\3\2\2\2\4\2"+
+ "\20\3\b\2\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/ParenLexer.tokens b/Homework/cs5300/project-three/lexer/ParenLexer.tokens
new file mode 100644
index 0000000..a29ddff
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/ParenLexer.tokens
@@ -0,0 +1,5 @@
+OPAREN=1
+CPAREN=2
+WS=3
+'('=1
+')'=2
diff --git a/Homework/cs5300/project-three/lexer/SimpleLexer.interp b/Homework/cs5300/project-three/lexer/SimpleLexer.interp
new file mode 100644
index 0000000..8d4c41c
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/SimpleLexer.interp
@@ -0,0 +1,23 @@
+token literal names:
+null
+'x'
+null
+
+token symbolic names:
+null
+X
+WS
+
+rule names:
+X
+WS
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 4, 16, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 3, 2, 3, 3, 6, 3, 11, 10, 3, 13, 3, 14, 3, 12, 3, 3, 3, 3, 2, 2, 4, 3, 3, 5, 4, 3, 2, 3, 5, 2, 11, 12, 14, 15, 34, 34, 2, 16, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 3, 7, 3, 2, 2, 2, 5, 10, 3, 2, 2, 2, 7, 8, 7, 122, 2, 2, 8, 4, 3, 2, 2, 2, 9, 11, 9, 2, 2, 2, 10, 9, 3, 2, 2, 2, 11, 12, 3, 2, 2, 2, 12, 10, 3, 2, 2, 2, 12, 13, 3, 2, 2, 2, 13, 14, 3, 2, 2, 2, 14, 15, 8, 3, 2, 2, 15, 6, 3, 2, 2, 2, 4, 2, 12, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/SimpleLexer.java b/Homework/cs5300/project-three/lexer/SimpleLexer.java
new file mode 100644
index 0000000..f6ce847
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/SimpleLexer.java
@@ -0,0 +1,120 @@
+// Generated from SimpleLexer.tokens by ANTLR 4.9.1
+package lexer;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class SimpleLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ X=1, WS=2;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "X", "WS"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "'x'"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, "X", "WS"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public SimpleLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "SimpleLexer.tokens"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\4\20\b\1\4\2\t\2"+
+ "\4\3\t\3\3\2\3\2\3\3\6\3\13\n\3\r\3\16\3\f\3\3\3\3\2\2\4\3\3\5\4\3\2\3"+
+ "\5\2\13\f\16\17\"\"\2\20\2\3\3\2\2\2\2\5\3\2\2\2\3\7\3\2\2\2\5\n\3\2\2"+
+ "\2\7\b\7z\2\2\b\4\3\2\2\2\t\13\t\2\2\2\n\t\3\2\2\2\13\f\3\2\2\2\f\n\3"+
+ "\2\2\2\f\r\3\2\2\2\r\16\3\2\2\2\16\17\b\3\2\2\17\6\3\2\2\2\4\2\f\3\b\2"+
+ "\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/SimpleLexer.tokens b/Homework/cs5300/project-three/lexer/SimpleLexer.tokens
new file mode 100644
index 0000000..dc07319
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/SimpleLexer.tokens
@@ -0,0 +1,3 @@
+X=1
+WS=2
+'x'=1
diff --git a/Homework/cs5300/project-three/lexer/TinyLexer.interp b/Homework/cs5300/project-three/lexer/TinyLexer.interp
new file mode 100644
index 0000000..a2db21e
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/TinyLexer.interp
@@ -0,0 +1,79 @@
+token literal names:
+null
+'if'
+'then'
+'else'
+'end'
+'repeat'
+'until'
+'read'
+'write'
+'('
+')'
+'+'
+'-'
+'*'
+'/'
+'<'
+'='
+null
+null
+null
+null
+
+token symbolic names:
+null
+IF
+THEN
+ELSE
+END
+REPEAT
+UNTIL
+READ
+WRITE
+OPAREN
+CPAREN
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+LT
+EQUAL
+NUM
+ID
+COMMENT
+WS
+
+rule names:
+IF
+THEN
+ELSE
+END
+REPEAT
+UNTIL
+READ
+WRITE
+OPAREN
+CPAREN
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+LT
+EQUAL
+NUM
+ID
+COMMENT
+WS
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 22, 153, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 6, 18, 106, 10, 18, 13, 18, 14, 18, 107, 3, 19, 6, 19, 111, 10, 19, 13, 19, 14, 19, 112, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 119, 10, 20, 12, 20, 14, 20, 122, 11, 20, 3, 20, 5, 20, 125, 10, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 132, 10, 20, 12, 20, 14, 20, 135, 11, 20, 3, 20, 3, 20, 5, 20, 139, 10, 20, 3, 20, 3, 20, 3, 21, 6, 21, 144, 10, 21, 13, 21, 14, 21, 145, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 133, 2, 24, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 2, 45, 2, 3, 2, 5, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 67, 92, 99, 124, 2, 157, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 3, 47, 3, 2, 2, 2, 5, 50, 3, 2, 2, 2, 7, 55, 3, 2, 2, 2, 9, 60, 3, 2, 2, 2, 11, 64, 3, 2, 2, 2, 13, 71, 3, 2, 2, 2, 15, 77, 3, 2, 2, 2, 17, 82, 3, 2, 2, 2, 19, 88, 3, 2, 2, 2, 21, 90, 3, 2, 2, 2, 23, 92, 3, 2, 2, 2, 25, 94, 3, 2, 2, 2, 27, 96, 3, 2, 2, 2, 29, 98, 3, 2, 2, 2, 31, 100, 3, 2, 2, 2, 33, 102, 3, 2, 2, 2, 35, 105, 3, 2, 2, 2, 37, 110, 3, 2, 2, 2, 39, 138, 3, 2, 2, 2, 41, 143, 3, 2, 2, 2, 43, 149, 3, 2, 2, 2, 45, 151, 3, 2, 2, 2, 47, 48, 7, 107, 2, 2, 48, 49, 7, 104, 2, 2, 49, 4, 3, 2, 2, 2, 50, 51, 7, 118, 2, 2, 51, 52, 7, 106, 2, 2, 52, 53, 7, 103, 2, 2, 53, 54, 7, 112, 2, 2, 54, 6, 3, 2, 2, 2, 55, 56, 7, 103, 2, 2, 56, 57, 7, 110, 2, 2, 57, 58, 7, 117, 2, 2, 58, 59, 7, 103, 2, 2, 59, 8, 3, 2, 2, 2, 60, 61, 7, 103, 2, 2, 61, 62, 7, 112, 2, 2, 62, 63, 7, 102, 2, 2, 63, 10, 3, 2, 2, 2, 64, 65, 7, 116, 2, 2, 65, 66, 7, 103, 2, 2, 66, 67, 7, 114, 2, 2, 67, 68, 7, 103, 2, 2, 68, 69, 7, 99, 2, 2, 69, 70, 7, 118, 2, 2, 70, 12, 3, 2, 2, 2, 71, 72, 7, 119, 2, 2, 72, 73, 7, 112, 2, 2, 73, 74, 7, 118, 2, 2, 74, 75, 7, 107, 2, 2, 75, 76, 7, 110, 2, 2, 76, 14, 3, 2, 2, 2, 77, 78, 7, 116, 2, 2, 78, 79, 7, 103, 2, 2, 79, 80, 7, 99, 2, 2, 80, 81, 7, 102, 2, 2, 81, 16, 3, 2, 2, 2, 82, 83, 7, 121, 2, 2, 83, 84, 7, 116, 2, 2, 84, 85, 7, 107, 2, 2, 85, 86, 7, 118, 2, 2, 86, 87, 7, 103, 2, 2, 87, 18, 3, 2, 2, 2, 88, 89, 7, 42, 2, 2, 89, 20, 3, 2, 2, 2, 90, 91, 7, 43, 2, 2, 91, 22, 3, 2, 2, 2, 92, 93, 7, 45, 2, 2, 93, 24, 3, 2, 2, 2, 94, 95, 7, 47, 2, 2, 95, 26, 3, 2, 2, 2, 96, 97, 7, 44, 2, 2, 97, 28, 3, 2, 2, 2, 98, 99, 7, 49, 2, 2, 99, 30, 3, 2, 2, 2, 100, 101, 7, 62, 2, 2, 101, 32, 3, 2, 2, 2, 102, 103, 7, 63, 2, 2, 103, 34, 3, 2, 2, 2, 104, 106, 5, 45, 23, 2, 105, 104, 3, 2, 2, 2, 106, 107, 3, 2, 2, 2, 107, 105, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 36, 3, 2, 2, 2, 109, 111, 5, 43, 22, 2, 110, 109, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 110, 3, 2, 2, 2, 112, 113, 3, 2, 2, 2, 113, 38, 3, 2, 2, 2, 114, 115, 7, 49, 2, 2, 115, 116, 7, 49, 2, 2, 116, 120, 3, 2, 2, 2, 117, 119, 10, 2, 2, 2, 118, 117, 3, 2, 2, 2, 119, 122, 3, 2, 2, 2, 120, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 123, 125, 7, 15, 2, 2, 124, 123, 3, 2, 2, 2, 124, 125, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 139, 7, 12, 2, 2, 127, 128, 7, 49, 2, 2, 128, 129, 7, 44, 2, 2, 129, 133, 3, 2, 2, 2, 130, 132, 11, 2, 2, 2, 131, 130, 3, 2, 2, 2, 132, 135, 3, 2, 2, 2, 133, 134, 3, 2, 2, 2, 133, 131, 3, 2, 2, 2, 134, 136, 3, 2, 2, 2, 135, 133, 3, 2, 2, 2, 136, 137, 7, 44, 2, 2, 137, 139, 7, 49, 2, 2, 138, 114, 3, 2, 2, 2, 138, 127, 3, 2, 2, 2, 139, 140, 3, 2, 2, 2, 140, 141, 8, 20, 2, 2, 141, 40, 3, 2, 2, 2, 142, 144, 9, 3, 2, 2, 143, 142, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 143, 3, 2, 2, 2, 145, 146, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 148, 8, 21, 2, 2, 148, 42, 3, 2, 2, 2, 149, 150, 9, 4, 2, 2, 150, 44, 3, 2, 2, 2, 151, 152, 4, 50, 59, 2, 152, 46, 3, 2, 2, 2, 10, 2, 107, 112, 120, 124, 133, 138, 145, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/TinyLexer.java b/Homework/cs5300/project-three/lexer/TinyLexer.java
new file mode 100644
index 0000000..f1213fb
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/TinyLexer.java
@@ -0,0 +1,164 @@
+// Generated from TinyLexer.tokens by ANTLR 4.9.1
+package lexer;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class TinyLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ IF=1, THEN=2, ELSE=3, END=4, REPEAT=5, UNTIL=6, READ=7, WRITE=8, OPAREN=9,
+ CPAREN=10, PLUS=11, MINUS=12, MULTIPLY=13, DIVIDE=14, LT=15, EQUAL=16,
+ NUM=17, ID=18, COMMENT=19, WS=20;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ private static String[] makeRuleNames() {
+ return new String[] {
+ "IF", "THEN", "ELSE", "END", "REPEAT", "UNTIL", "READ", "WRITE", "OPAREN",
+ "CPAREN", "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "LT", "EQUAL", "NUM",
+ "ID", "COMMENT", "WS", "LETTER", "DIGIT"
+ };
+ }
+ public static final String[] ruleNames = makeRuleNames();
+
+ private static String[] makeLiteralNames() {
+ return new String[] {
+ null, "'if'", "'then'", "'else'", "'end'", "'repeat'", "'until'", "'read'",
+ "'write'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", "'<'", "'='"
+ };
+ }
+ private static final String[] _LITERAL_NAMES = makeLiteralNames();
+ private static String[] makeSymbolicNames() {
+ return new String[] {
+ null, "IF", "THEN", "ELSE", "END", "REPEAT", "UNTIL", "READ", "WRITE",
+ "OPAREN", "CPAREN", "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "LT", "EQUAL",
+ "NUM", "ID", "COMMENT", "WS"
+ };
+ }
+ private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public TinyLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "TinyLexer.tokens"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\26\u0099\b\1\4\2"+
+ "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+
+ "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+
+ "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\3\2\3\2\3\2\3"+
+ "\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6"+
+ "\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3"+
+ "\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16\3\17\3\17\3\20"+
+ "\3\20\3\21\3\21\3\22\6\22j\n\22\r\22\16\22k\3\23\6\23o\n\23\r\23\16\23"+
+ "p\3\24\3\24\3\24\3\24\7\24w\n\24\f\24\16\24z\13\24\3\24\5\24}\n\24\3\24"+
+ "\3\24\3\24\3\24\3\24\7\24\u0084\n\24\f\24\16\24\u0087\13\24\3\24\3\24"+
+ "\5\24\u008b\n\24\3\24\3\24\3\25\6\25\u0090\n\25\r\25\16\25\u0091\3\25"+
+ "\3\25\3\26\3\26\3\27\3\27\3\u0085\2\30\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21"+
+ "\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\2-\2"+
+ "\3\2\5\4\2\f\f\17\17\5\2\13\f\16\17\"\"\4\2C\\c|\2\u009d\2\3\3\2\2\2\2"+
+ "\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2"+
+ "\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2"+
+ "\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2"+
+ "\2\'\3\2\2\2\2)\3\2\2\2\3/\3\2\2\2\5\62\3\2\2\2\7\67\3\2\2\2\t<\3\2\2"+
+ "\2\13@\3\2\2\2\rG\3\2\2\2\17M\3\2\2\2\21R\3\2\2\2\23X\3\2\2\2\25Z\3\2"+
+ "\2\2\27\\\3\2\2\2\31^\3\2\2\2\33`\3\2\2\2\35b\3\2\2\2\37d\3\2\2\2!f\3"+
+ "\2\2\2#i\3\2\2\2%n\3\2\2\2\'\u008a\3\2\2\2)\u008f\3\2\2\2+\u0095\3\2\2"+
+ "\2-\u0097\3\2\2\2/\60\7k\2\2\60\61\7h\2\2\61\4\3\2\2\2\62\63\7v\2\2\63"+
+ "\64\7j\2\2\64\65\7g\2\2\65\66\7p\2\2\66\6\3\2\2\2\678\7g\2\289\7n\2\2"+
+ "9:\7u\2\2:;\7g\2\2;\b\3\2\2\2<=\7g\2\2=>\7p\2\2>?\7f\2\2?\n\3\2\2\2@A"+
+ "\7t\2\2AB\7g\2\2BC\7r\2\2CD\7g\2\2DE\7c\2\2EF\7v\2\2F\f\3\2\2\2GH\7w\2"+
+ "\2HI\7p\2\2IJ\7v\2\2JK\7k\2\2KL\7n\2\2L\16\3\2\2\2MN\7t\2\2NO\7g\2\2O"+
+ "P\7c\2\2PQ\7f\2\2Q\20\3\2\2\2RS\7y\2\2ST\7t\2\2TU\7k\2\2UV\7v\2\2VW\7"+
+ "g\2\2W\22\3\2\2\2XY\7*\2\2Y\24\3\2\2\2Z[\7+\2\2[\26\3\2\2\2\\]\7-\2\2"+
+ "]\30\3\2\2\2^_\7/\2\2_\32\3\2\2\2`a\7,\2\2a\34\3\2\2\2bc\7\61\2\2c\36"+
+ "\3\2\2\2de\7>\2\2e \3\2\2\2fg\7?\2\2g\"\3\2\2\2hj\5-\27\2ih\3\2\2\2jk"+
+ "\3\2\2\2ki\3\2\2\2kl\3\2\2\2l$\3\2\2\2mo\5+\26\2nm\3\2\2\2op\3\2\2\2p"+
+ "n\3\2\2\2pq\3\2\2\2q&\3\2\2\2rs\7\61\2\2st\7\61\2\2tx\3\2\2\2uw\n\2\2"+
+ "\2vu\3\2\2\2wz\3\2\2\2xv\3\2\2\2xy\3\2\2\2y|\3\2\2\2zx\3\2\2\2{}\7\17"+
+ "\2\2|{\3\2\2\2|}\3\2\2\2}~\3\2\2\2~\u008b\7\f\2\2\177\u0080\7\61\2\2\u0080"+
+ "\u0081\7,\2\2\u0081\u0085\3\2\2\2\u0082\u0084\13\2\2\2\u0083\u0082\3\2"+
+ "\2\2\u0084\u0087\3\2\2\2\u0085\u0086\3\2\2\2\u0085\u0083\3\2\2\2\u0086"+
+ "\u0088\3\2\2\2\u0087\u0085\3\2\2\2\u0088\u0089\7,\2\2\u0089\u008b\7\61"+
+ "\2\2\u008ar\3\2\2\2\u008a\177\3\2\2\2\u008b\u008c\3\2\2\2\u008c\u008d"+
+ "\b\24\2\2\u008d(\3\2\2\2\u008e\u0090\t\3\2\2\u008f\u008e\3\2\2\2\u0090"+
+ "\u0091\3\2\2\2\u0091\u008f\3\2\2\2\u0091\u0092\3\2\2\2\u0092\u0093\3\2"+
+ "\2\2\u0093\u0094\b\25\2\2\u0094*\3\2\2\2\u0095\u0096\t\4\2\2\u0096,\3"+
+ "\2\2\2\u0097\u0098\4\62;\2\u0098.\3\2\2\2\n\2kpx|\u0085\u008a\u0091\3"+
+ "\b\2\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/lexer/TinyLexer.tokens b/Homework/cs5300/project-three/lexer/TinyLexer.tokens
new file mode 100644
index 0000000..2d6fdc7
--- /dev/null
+++ b/Homework/cs5300/project-three/lexer/TinyLexer.tokens
@@ -0,0 +1,36 @@
+IF=1
+THEN=2
+ELSE=3
+END=4
+REPEAT=5
+UNTIL=6
+READ=7
+WRITE=8
+OPAREN=9
+CPAREN=10
+PLUS=11
+MINUS=12
+MULTIPLY=13
+DIVIDE=14
+LT=15
+EQUAL=16
+NUM=17
+ID=18
+COMMENT=19
+WS=20
+'if'=1
+'then'=2
+'else'=3
+'end'=4
+'repeat'=5
+'until'=6
+'read'=7
+'write'=8
+'('=9
+')'=10
+'+'=11
+'-'=12
+'*'=13
+'/'=14
+'<'=15
+'='=16
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/antlr-4.9.1-complete.jar b/Homework/cs5300/project-three/out/production/p3-parser/antlr-4.9.1-complete.jar
new file mode 100644
index 0000000..1bb7e8c
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/antlr-4.9.1-complete.jar
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/Grammar.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/Grammar.class
new file mode 100644
index 0000000..34912da
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/Grammar.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarBaseListener.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarBaseListener.class
new file mode 100644
index 0000000..b3e115e
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarBaseListener.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarLexer.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarLexer.class
new file mode 100644
index 0000000..9fc843f
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarLexer.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListener.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListener.class
new file mode 100644
index 0000000..fa64aeb
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListener.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListenerImpl.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListenerImpl.class
new file mode 100644
index 0000000..2b52242
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarListenerImpl.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$GoalContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$GoalContext.class
new file mode 100644
index 0000000..25e5c2e
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$GoalContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$LhsContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$LhsContext.class
new file mode 100644
index 0000000..c5580c2
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$LhsContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$NameContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$NameContext.class
new file mode 100644
index 0000000..32cd8ee
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$NameContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Or_listContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Or_listContext.class
new file mode 100644
index 0000000..82b869a
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Or_listContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$RhsContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$RhsContext.class
new file mode 100644
index 0000000..90dd7d3
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$RhsContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Rule_listContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Rule_listContext.class
new file mode 100644
index 0000000..7501d1f
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Rule_listContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$SymbolContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$SymbolContext.class
new file mode 100644
index 0000000..ed3da97
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$SymbolContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Symbol_listContext.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Symbol_listContext.class
new file mode 100644
index 0000000..34d9e0c
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser$Symbol_listContext.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser.class b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser.class
new file mode 100644
index 0000000..6f2d6ae
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/cfgparser/GrammarParser.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/Expr.cfg b/Homework/cs5300/project-three/out/production/p3-parser/data/Expr.cfg
new file mode 100644
index 0000000..7493e3e
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/Expr.cfg
@@ -0,0 +1,25 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ExprLexer.tokens.
+
+grammar Expr;
+
+goal: expr;
+
+expr: expr PLUS term
+ | expr MINUS term
+ | term
+ ;
+
+term : term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN expr CPAREN
+ | INT
+ | FLOAT
+ | IDENTIFIER
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/ExprLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/data/ExprLexer.tokens
new file mode 100644
index 0000000..ccb798a
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/ExprLexer.tokens
@@ -0,0 +1,39 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Expr.cfg.
+
+lexer grammar ExprLexer;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+OPAREN: '(' ;
+CPAREN: ')' ;
+
+FLOAT
+ : DIGIT+ '.' DIGIT+
+ ;
+
+INT
+ : DIGIT+
+ ;
+
+IDENTIFIER
+ : LETTER (LETTER | DIGIT)*
+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/Paren.cfg b/Homework/cs5300/project-three/out/production/p3-parser/data/Paren.cfg
new file mode 100644
index 0000000..184b11c
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/Paren.cfg
@@ -0,0 +1,17 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Paren;
+
+goal: list;
+
+list: list pair
+ | pair
+ ;
+
+pair: OPAREN list CPAREN
+ | OPAREN CPAREN
+ ;
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/ParenLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/data/ParenLexer.tokens
new file mode 100644
index 0000000..51e5258
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/ParenLexer.tokens
@@ -0,0 +1,19 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Paren.cfg.
+
+lexer grammar ParenLexer;
+
+OPAREN
+ : '('
+ ;
+
+CPAREN
+ : ')'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/Simple.cfg b/Homework/cs5300/project-three/out/production/p3-parser/data/Simple.cfg
new file mode 100644
index 0000000..80c1e18
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/Simple.cfg
@@ -0,0 +1,13 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Simple;
+
+G: N;
+
+N: N X
+ | X
+ ;
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/SimpleLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/data/SimpleLexer.tokens
new file mode 100644
index 0000000..64ec3c1
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/SimpleLexer.tokens
@@ -0,0 +1,15 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Simple.cfg.
+
+lexer grammar SimpleLexer;
+
+X
+ : 'x'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/Tiny.cfg b/Homework/cs5300/project-three/out/production/p3-parser/data/Tiny.cfg
new file mode 100644
index 0000000..a7a28a3
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/Tiny.cfg
@@ -0,0 +1,19 @@
+//
+// WRITE A CORRECT GRAMMAR FOR THE TINY LANGUAGE IN THIS FILE.
+//
+// The grammar is described in data/tinyGrammar.pdf. Do not use dashes
+// in your non-terminal names. I recommend you use mixed case naming for your
+// non-terminals instead (e.g. stmtSeq).
+//
+// Do not put any string literals in this grammar (e.g. "="). Use only token
+// names given in TinyLexer.tokens.
+//
+// This file contains an expression grammar that uses tokens described in
+// TinyLexer.tokens.
+//
+// NOTE ONE ERROR in the pdf: the second production rule should read:
+// stmt-seq -> stmt-seq stmt | stmt
+
+grammar Tiny;
+
+goal: program;
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/TinyLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/data/TinyLexer.tokens
new file mode 100644
index 0000000..ad6b2a7
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/TinyLexer.tokens
@@ -0,0 +1,41 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Tiny.cfg.
+
+lexer grammar TinyLexer;
+
+IF : 'if' ;
+THEN : 'then' ;
+ELSE : 'else' ;
+END : 'end' ;
+REPEAT : 'repeat' ;
+UNTIL : 'until' ;
+READ : 'read' ;
+WRITE : 'write' ;
+OPAREN : '(' ;
+CPAREN : ')' ;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+LT: '<' ;
+EQUAL: '=' ;
+
+NUM : DIGIT+ ;
+ID : LETTER+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr1.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr1.dat
new file mode 100644
index 0000000..846e7d3
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr1.dat
@@ -0,0 +1 @@
+3 + 4 * 5 / 8 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr2.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr2.dat
new file mode 100644
index 0000000..8e0c0b7
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr2.dat
@@ -0,0 +1 @@
+3 + + 42 * 34 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr3.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr3.dat
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr3.dat
@@ -0,0 +1 @@
+3
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr4.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr4.dat
new file mode 100644
index 0000000..84a357a
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr4.dat
@@ -0,0 +1 @@
+(a + b) * ((c-def)/43) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr5.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr5.dat
new file mode 100644
index 0000000..c2c433b
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr5.dat
@@ -0,0 +1 @@
+(a + b) * ((c-d)/43
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/expr6.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/expr6.dat
new file mode 100644
index 0000000..f46d387
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/expr6.dat
@@ -0,0 +1 @@
+( \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/paren0.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/paren0.dat
new file mode 100644
index 0000000..dd626a0
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/paren0.dat
@@ -0,0 +1 @@
+() \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/paren1.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/paren1.dat
new file mode 100644
index 0000000..f7e9493
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/paren1.dat
@@ -0,0 +1,3 @@
+((
+))(
+)(((()))()(())) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/paren2.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/paren2.dat
new file mode 100644
index 0000000..4f879eb
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/paren2.dat
@@ -0,0 +1,3 @@
+(
+))(
+) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/paren3.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/paren3.dat
new file mode 100644
index 0000000..e4a2fe8
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/paren3.dat
@@ -0,0 +1 @@
+)()(
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/paren4.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/paren4.dat
new file mode 100644
index 0000000..3077d74
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/paren4.dat
@@ -0,0 +1 @@
+()()(()())
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/tiny1.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny1.dat
new file mode 100644
index 0000000..7f9078f
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny1.dat
@@ -0,0 +1,3 @@
+a = 3
+b = 4
+c = a + b
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/tiny2.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny2.dat
new file mode 100644
index 0000000..09195b8
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny2.dat
@@ -0,0 +1,7 @@
+a = 3
+b = 4
+if a = b then
+ write (a + b * (c - d))
+else
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/tiny3.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny3.dat
new file mode 100644
index 0000000..768addd
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny3.dat
@@ -0,0 +1,4 @@
+a = 3
+if a = then
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/tiny4.dat b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny4.dat
new file mode 100644
index 0000000..1d66283
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/tiny4.dat
@@ -0,0 +1,4 @@
+a = 3
+if (a = b) then
+ write a = 3)
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/data/tinyGrammar.pdf b/Homework/cs5300/project-three/out/production/p3-parser/data/tinyGrammar.pdf
new file mode 100644
index 0000000..855d45b
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/data/tinyGrammar.pdf
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.class b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.class
new file mode 100644
index 0000000..34e7d89
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.interp b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.interp
new file mode 100644
index 0000000..c9ec8c0
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.interp
@@ -0,0 +1,52 @@
+token literal names:
+null
+'+'
+'-'
+'*'
+'/'
+'('
+')'
+null
+null
+null
+null
+null
+
+token symbolic names:
+null
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+OPAREN
+CPAREN
+FLOAT
+INT
+IDENTIFIER
+COMMENT
+WS
+
+rule names:
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+OPAREN
+CPAREN
+FLOAT
+INT
+IDENTIFIER
+COMMENT
+WS
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 104, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 6, 8, 43, 10, 8, 13, 8, 14, 8, 44, 3, 8, 3, 8, 6, 8, 49, 10, 8, 13, 8, 14, 8, 50, 3, 9, 6, 9, 54, 10, 9, 13, 9, 14, 9, 55, 3, 10, 3, 10, 3, 10, 7, 10, 61, 10, 10, 12, 10, 14, 10, 64, 11, 10, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 70, 10, 11, 12, 11, 14, 11, 73, 11, 11, 3, 11, 5, 11, 76, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 83, 10, 11, 12, 11, 14, 11, 86, 11, 11, 3, 11, 3, 11, 5, 11, 90, 10, 11, 3, 11, 3, 11, 3, 12, 6, 12, 95, 10, 12, 13, 12, 14, 12, 96, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 84, 2, 15, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 2, 27, 2, 3, 2, 5, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 67, 92, 99, 124, 2, 111, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 3, 29, 3, 2, 2, 2, 5, 31, 3, 2, 2, 2, 7, 33, 3, 2, 2, 2, 9, 35, 3, 2, 2, 2, 11, 37, 3, 2, 2, 2, 13, 39, 3, 2, 2, 2, 15, 42, 3, 2, 2, 2, 17, 53, 3, 2, 2, 2, 19, 57, 3, 2, 2, 2, 21, 89, 3, 2, 2, 2, 23, 94, 3, 2, 2, 2, 25, 100, 3, 2, 2, 2, 27, 102, 3, 2, 2, 2, 29, 30, 7, 45, 2, 2, 30, 4, 3, 2, 2, 2, 31, 32, 7, 47, 2, 2, 32, 6, 3, 2, 2, 2, 33, 34, 7, 44, 2, 2, 34, 8, 3, 2, 2, 2, 35, 36, 7, 49, 2, 2, 36, 10, 3, 2, 2, 2, 37, 38, 7, 42, 2, 2, 38, 12, 3, 2, 2, 2, 39, 40, 7, 43, 2, 2, 40, 14, 3, 2, 2, 2, 41, 43, 5, 27, 14, 2, 42, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 48, 7, 48, 2, 2, 47, 49, 5, 27, 14, 2, 48, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 16, 3, 2, 2, 2, 52, 54, 5, 27, 14, 2, 53, 52, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 55, 56, 3, 2, 2, 2, 56, 18, 3, 2, 2, 2, 57, 62, 5, 25, 13, 2, 58, 61, 5, 25, 13, 2, 59, 61, 5, 27, 14, 2, 60, 58, 3, 2, 2, 2, 60, 59, 3, 2, 2, 2, 61, 64, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 63, 3, 2, 2, 2, 63, 20, 3, 2, 2, 2, 64, 62, 3, 2, 2, 2, 65, 66, 7, 49, 2, 2, 66, 67, 7, 49, 2, 2, 67, 71, 3, 2, 2, 2, 68, 70, 10, 2, 2, 2, 69, 68, 3, 2, 2, 2, 70, 73, 3, 2, 2, 2, 71, 69, 3, 2, 2, 2, 71, 72, 3, 2, 2, 2, 72, 75, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 74, 76, 7, 15, 2, 2, 75, 74, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 77, 3, 2, 2, 2, 77, 90, 7, 12, 2, 2, 78, 79, 7, 49, 2, 2, 79, 80, 7, 44, 2, 2, 80, 84, 3, 2, 2, 2, 81, 83, 11, 2, 2, 2, 82, 81, 3, 2, 2, 2, 83, 86, 3, 2, 2, 2, 84, 85, 3, 2, 2, 2, 84, 82, 3, 2, 2, 2, 85, 87, 3, 2, 2, 2, 86, 84, 3, 2, 2, 2, 87, 88, 7, 44, 2, 2, 88, 90, 7, 49, 2, 2, 89, 65, 3, 2, 2, 2, 89, 78, 3, 2, 2, 2, 90, 91, 3, 2, 2, 2, 91, 92, 8, 11, 2, 2, 92, 22, 3, 2, 2, 2, 93, 95, 9, 3, 2, 2, 94, 93, 3, 2, 2, 2, 95, 96, 3, 2, 2, 2, 96, 94, 3, 2, 2, 2, 96, 97, 3, 2, 2, 2, 97, 98, 3, 2, 2, 2, 98, 99, 8, 12, 2, 2, 99, 24, 3, 2, 2, 2, 100, 101, 9, 4, 2, 2, 101, 26, 3, 2, 2, 2, 102, 103, 4, 50, 59, 2, 103, 28, 3, 2, 2, 2, 13, 2, 44, 50, 55, 60, 62, 71, 75, 84, 89, 96, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.tokens
new file mode 100644
index 0000000..295e180
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ExprLexer.tokens
@@ -0,0 +1,17 @@
+PLUS=1
+MINUS=2
+MULTIPLY=3
+DIVIDE=4
+OPAREN=5
+CPAREN=6
+FLOAT=7
+INT=8
+IDENTIFIER=9
+COMMENT=10
+WS=11
+'+'=1
+'-'=2
+'*'=3
+'/'=4
+'('=5
+')'=6
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.class b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.class
new file mode 100644
index 0000000..f499161
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.interp b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.interp
new file mode 100644
index 0000000..d973cba
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.interp
@@ -0,0 +1,26 @@
+token literal names:
+null
+'('
+')'
+null
+
+token symbolic names:
+null
+OPAREN
+CPAREN
+WS
+
+rule names:
+OPAREN
+CPAREN
+WS
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 5, 20, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 6, 4, 15, 10, 4, 13, 4, 14, 4, 16, 3, 4, 3, 4, 2, 2, 5, 3, 3, 5, 4, 7, 5, 3, 2, 3, 5, 2, 11, 12, 14, 15, 34, 34, 2, 20, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 3, 9, 3, 2, 2, 2, 5, 11, 3, 2, 2, 2, 7, 14, 3, 2, 2, 2, 9, 10, 7, 42, 2, 2, 10, 4, 3, 2, 2, 2, 11, 12, 7, 43, 2, 2, 12, 6, 3, 2, 2, 2, 13, 15, 9, 2, 2, 2, 14, 13, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 18, 3, 2, 2, 2, 18, 19, 8, 4, 2, 2, 19, 8, 3, 2, 2, 2, 4, 2, 16, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.tokens
new file mode 100644
index 0000000..a29ddff
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/ParenLexer.tokens
@@ -0,0 +1,5 @@
+OPAREN=1
+CPAREN=2
+WS=3
+'('=1
+')'=2
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.class b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.class
new file mode 100644
index 0000000..d9ec81d
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.interp b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.interp
new file mode 100644
index 0000000..8d4c41c
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.interp
@@ -0,0 +1,23 @@
+token literal names:
+null
+'x'
+null
+
+token symbolic names:
+null
+X
+WS
+
+rule names:
+X
+WS
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 4, 16, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 3, 2, 3, 3, 6, 3, 11, 10, 3, 13, 3, 14, 3, 12, 3, 3, 3, 3, 2, 2, 4, 3, 3, 5, 4, 3, 2, 3, 5, 2, 11, 12, 14, 15, 34, 34, 2, 16, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 3, 7, 3, 2, 2, 2, 5, 10, 3, 2, 2, 2, 7, 8, 7, 122, 2, 2, 8, 4, 3, 2, 2, 2, 9, 11, 9, 2, 2, 2, 10, 9, 3, 2, 2, 2, 11, 12, 3, 2, 2, 2, 12, 10, 3, 2, 2, 2, 12, 13, 3, 2, 2, 2, 13, 14, 3, 2, 2, 2, 14, 15, 8, 3, 2, 2, 15, 6, 3, 2, 2, 2, 4, 2, 12, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.tokens
new file mode 100644
index 0000000..dc07319
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/SimpleLexer.tokens
@@ -0,0 +1,3 @@
+X=1
+WS=2
+'x'=1
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.class b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.class
new file mode 100644
index 0000000..ce45364
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.interp b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.interp
new file mode 100644
index 0000000..a2db21e
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.interp
@@ -0,0 +1,79 @@
+token literal names:
+null
+'if'
+'then'
+'else'
+'end'
+'repeat'
+'until'
+'read'
+'write'
+'('
+')'
+'+'
+'-'
+'*'
+'/'
+'<'
+'='
+null
+null
+null
+null
+
+token symbolic names:
+null
+IF
+THEN
+ELSE
+END
+REPEAT
+UNTIL
+READ
+WRITE
+OPAREN
+CPAREN
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+LT
+EQUAL
+NUM
+ID
+COMMENT
+WS
+
+rule names:
+IF
+THEN
+ELSE
+END
+REPEAT
+UNTIL
+READ
+WRITE
+OPAREN
+CPAREN
+PLUS
+MINUS
+MULTIPLY
+DIVIDE
+LT
+EQUAL
+NUM
+ID
+COMMENT
+WS
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 22, 153, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 6, 18, 106, 10, 18, 13, 18, 14, 18, 107, 3, 19, 6, 19, 111, 10, 19, 13, 19, 14, 19, 112, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 119, 10, 20, 12, 20, 14, 20, 122, 11, 20, 3, 20, 5, 20, 125, 10, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 132, 10, 20, 12, 20, 14, 20, 135, 11, 20, 3, 20, 3, 20, 5, 20, 139, 10, 20, 3, 20, 3, 20, 3, 21, 6, 21, 144, 10, 21, 13, 21, 14, 21, 145, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 133, 2, 24, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 2, 45, 2, 3, 2, 5, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 67, 92, 99, 124, 2, 157, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 3, 47, 3, 2, 2, 2, 5, 50, 3, 2, 2, 2, 7, 55, 3, 2, 2, 2, 9, 60, 3, 2, 2, 2, 11, 64, 3, 2, 2, 2, 13, 71, 3, 2, 2, 2, 15, 77, 3, 2, 2, 2, 17, 82, 3, 2, 2, 2, 19, 88, 3, 2, 2, 2, 21, 90, 3, 2, 2, 2, 23, 92, 3, 2, 2, 2, 25, 94, 3, 2, 2, 2, 27, 96, 3, 2, 2, 2, 29, 98, 3, 2, 2, 2, 31, 100, 3, 2, 2, 2, 33, 102, 3, 2, 2, 2, 35, 105, 3, 2, 2, 2, 37, 110, 3, 2, 2, 2, 39, 138, 3, 2, 2, 2, 41, 143, 3, 2, 2, 2, 43, 149, 3, 2, 2, 2, 45, 151, 3, 2, 2, 2, 47, 48, 7, 107, 2, 2, 48, 49, 7, 104, 2, 2, 49, 4, 3, 2, 2, 2, 50, 51, 7, 118, 2, 2, 51, 52, 7, 106, 2, 2, 52, 53, 7, 103, 2, 2, 53, 54, 7, 112, 2, 2, 54, 6, 3, 2, 2, 2, 55, 56, 7, 103, 2, 2, 56, 57, 7, 110, 2, 2, 57, 58, 7, 117, 2, 2, 58, 59, 7, 103, 2, 2, 59, 8, 3, 2, 2, 2, 60, 61, 7, 103, 2, 2, 61, 62, 7, 112, 2, 2, 62, 63, 7, 102, 2, 2, 63, 10, 3, 2, 2, 2, 64, 65, 7, 116, 2, 2, 65, 66, 7, 103, 2, 2, 66, 67, 7, 114, 2, 2, 67, 68, 7, 103, 2, 2, 68, 69, 7, 99, 2, 2, 69, 70, 7, 118, 2, 2, 70, 12, 3, 2, 2, 2, 71, 72, 7, 119, 2, 2, 72, 73, 7, 112, 2, 2, 73, 74, 7, 118, 2, 2, 74, 75, 7, 107, 2, 2, 75, 76, 7, 110, 2, 2, 76, 14, 3, 2, 2, 2, 77, 78, 7, 116, 2, 2, 78, 79, 7, 103, 2, 2, 79, 80, 7, 99, 2, 2, 80, 81, 7, 102, 2, 2, 81, 16, 3, 2, 2, 2, 82, 83, 7, 121, 2, 2, 83, 84, 7, 116, 2, 2, 84, 85, 7, 107, 2, 2, 85, 86, 7, 118, 2, 2, 86, 87, 7, 103, 2, 2, 87, 18, 3, 2, 2, 2, 88, 89, 7, 42, 2, 2, 89, 20, 3, 2, 2, 2, 90, 91, 7, 43, 2, 2, 91, 22, 3, 2, 2, 2, 92, 93, 7, 45, 2, 2, 93, 24, 3, 2, 2, 2, 94, 95, 7, 47, 2, 2, 95, 26, 3, 2, 2, 2, 96, 97, 7, 44, 2, 2, 97, 28, 3, 2, 2, 2, 98, 99, 7, 49, 2, 2, 99, 30, 3, 2, 2, 2, 100, 101, 7, 62, 2, 2, 101, 32, 3, 2, 2, 2, 102, 103, 7, 63, 2, 2, 103, 34, 3, 2, 2, 2, 104, 106, 5, 45, 23, 2, 105, 104, 3, 2, 2, 2, 106, 107, 3, 2, 2, 2, 107, 105, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 36, 3, 2, 2, 2, 109, 111, 5, 43, 22, 2, 110, 109, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 110, 3, 2, 2, 2, 112, 113, 3, 2, 2, 2, 113, 38, 3, 2, 2, 2, 114, 115, 7, 49, 2, 2, 115, 116, 7, 49, 2, 2, 116, 120, 3, 2, 2, 2, 117, 119, 10, 2, 2, 2, 118, 117, 3, 2, 2, 2, 119, 122, 3, 2, 2, 2, 120, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 123, 125, 7, 15, 2, 2, 124, 123, 3, 2, 2, 2, 124, 125, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 139, 7, 12, 2, 2, 127, 128, 7, 49, 2, 2, 128, 129, 7, 44, 2, 2, 129, 133, 3, 2, 2, 2, 130, 132, 11, 2, 2, 2, 131, 130, 3, 2, 2, 2, 132, 135, 3, 2, 2, 2, 133, 134, 3, 2, 2, 2, 133, 131, 3, 2, 2, 2, 134, 136, 3, 2, 2, 2, 135, 133, 3, 2, 2, 2, 136, 137, 7, 44, 2, 2, 137, 139, 7, 49, 2, 2, 138, 114, 3, 2, 2, 2, 138, 127, 3, 2, 2, 2, 139, 140, 3, 2, 2, 2, 140, 141, 8, 20, 2, 2, 141, 40, 3, 2, 2, 2, 142, 144, 9, 3, 2, 2, 143, 142, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 143, 3, 2, 2, 2, 145, 146, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 148, 8, 21, 2, 2, 148, 42, 3, 2, 2, 2, 149, 150, 9, 4, 2, 2, 150, 44, 3, 2, 2, 2, 151, 152, 4, 50, 59, 2, 152, 46, 3, 2, 2, 2, 10, 2, 107, 112, 120, 124, 133, 138, 145, 3, 8, 2, 2] \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.tokens b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.tokens
new file mode 100644
index 0000000..2d6fdc7
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/lexer/TinyLexer.tokens
@@ -0,0 +1,36 @@
+IF=1
+THEN=2
+ELSE=3
+END=4
+REPEAT=5
+UNTIL=6
+READ=7
+WRITE=8
+OPAREN=9
+CPAREN=10
+PLUS=11
+MINUS=12
+MULTIPLY=13
+DIVIDE=14
+LT=15
+EQUAL=16
+NUM=17
+ID=18
+COMMENT=19
+WS=20
+'if'=1
+'then'=2
+'else'=3
+'end'=4
+'repeat'=5
+'until'=6
+'read'=7
+'write'=8
+'('=9
+')'=10
+'+'=11
+'-'=12
+'*'=13
+'/'=14
+'<'=15
+'='=16
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/p3-parser.iml b/Homework/cs5300/project-three/out/production/p3-parser/p3-parser.iml
new file mode 100644
index 0000000..8c27921
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/p3-parser.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="antlr-4.9.1-complete" level="project" />
+ </component>
+</module> \ No newline at end of file
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Action$Act.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Action$Act.class
new file mode 100644
index 0000000..2c89b29
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Action$Act.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Action.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Action.class
new file mode 100644
index 0000000..9cde3de
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Action.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Grammar.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Grammar.class
new file mode 100644
index 0000000..309a19a
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Grammar.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Item.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Item.class
new file mode 100644
index 0000000..980e93c
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Item.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Main.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Main.class
new file mode 100644
index 0000000..64b8ee0
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Main.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Parser.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Parser.class
new file mode 100644
index 0000000..2804ef3
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Parser.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/ParserException.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/ParserException.class
new file mode 100644
index 0000000..3c2a702
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/ParserException.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Rule.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Rule.class
new file mode 100644
index 0000000..048edb2
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Rule.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/State.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/State.class
new file mode 100644
index 0000000..720f6c8
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/State.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/States.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/States.class
new file mode 100644
index 0000000..fb1c4c1
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/States.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Tests.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Tests.class
new file mode 100644
index 0000000..74aa50e
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Tests.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/Util.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/Util.class
new file mode 100644
index 0000000..14780ec
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/Util.class
Binary files differ
diff --git a/Homework/cs5300/project-three/out/production/p3-parser/parser/util/SymbolComparator.class b/Homework/cs5300/project-three/out/production/p3-parser/parser/util/SymbolComparator.class
new file mode 100644
index 0000000..fd23969
--- /dev/null
+++ b/Homework/cs5300/project-three/out/production/p3-parser/parser/util/SymbolComparator.class
Binary files differ
diff --git a/Homework/cs5300/project-three/parser/Action.java b/Homework/cs5300/project-three/parser/Action.java
new file mode 100644
index 0000000..040daab
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Action.java
@@ -0,0 +1,70 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class Action {
+
+ enum Act {
+ SHIFT, REDUCE, ACCEPT
+ };
+
+ private final Act act;
+ private final Integer state;
+ private final Rule rule;
+
+ static Action createShift(Integer state) {
+ return new Action(Act.SHIFT, state, null);
+ }
+
+ static Action createReduce(Rule rule) {
+ return new Action(Act.REDUCE, null, rule);
+ }
+
+ static Action createAccept() {
+ return new Action(Act.ACCEPT, null, null);
+ }
+
+ private Action(Act act, Integer state, Rule rule) {
+ this.act = act;
+ this.state = state;
+ this.rule = rule;
+ }
+
+ public boolean isShift() {
+ return act == Act.SHIFT;
+ }
+
+ public boolean isReduce() {
+ return act == Act.REDUCE;
+ }
+
+ public boolean isAccept() {
+ return act == Act.ACCEPT;
+ }
+
+ public Integer getState() {
+ return state;
+ }
+
+ public Rule getRule() {
+ return rule;
+ }
+
+ @Override
+ public String toString() {
+ if (isShift()) {
+ return "S" + state;
+ }
+ if (isReduce()) {
+ return "R" + rule.getName();
+ }
+ return "acc";
+ }
+}
diff --git a/Homework/cs5300/project-three/parser/Grammar.java b/Homework/cs5300/project-three/parser/Grammar.java
new file mode 100644
index 0000000..0050cd1
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Grammar.java
@@ -0,0 +1,125 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser;
+
+import java.io.IOException;
+import java.util.*;
+
+import parser.util.SymbolComparator;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class Grammar {
+
+ /**
+ * Name of the grammar from the grammar file. This is computed for you.
+ */
+ final String grammarName;
+ /**
+ * The list of rules found in the input grammar file. This is computed for
+ * you.
+ */
+ final ArrayList<Rule> rules;
+ /**
+ * The list of all symbols found in the input grammar file. This is computed
+ * for you.
+ */
+ final ArrayList<String> symbols;
+ /**
+ * The set of all terminal symbols. To see if a symbol is terminal or not:
+ * terminals.contains(symbol). This is computed for you.
+ */
+ final HashSet<String> terminals;
+ /**
+ * The set of all nonterminal symbols. To see if a symbol is nonterminal:
+ * nonterminals.contains(symbol). This is computed for you.
+ */
+ final HashSet<String> nonterminals;
+ /**
+ * Start symbol that is provided for you.
+ */
+ final String startSymbol;
+ /**
+ * Start production rule that is provided for you.
+ */
+ final Rule startRule;
+ /**
+ * Maps non-terminals to all rules that have the non-terminal on the lhs.
+ */
+ HashMap<String, ArrayList<Rule>> nt2rules;
+
+ final HashMap<String, HashSet<String>> first;
+ final HashMap<String, HashSet<String>> follow;
+ final HashMap<Rule, HashSet<String>> firstPlus;
+
+ public Grammar(String grammarFilename) throws IOException {
+ System.out.println("Reading grammar " + grammarFilename);
+ cfgparser.Grammar grammar = new cfgparser.Grammar(grammarFilename);
+
+ this.grammarName = grammar.getName();
+ this.rules = grammar.getRules();
+ this.symbols = grammar.getSymbols();
+ this.startSymbol = grammar.getStartSymbol();
+ this.terminals = new HashSet<>(symbols);
+ this.nonterminals = new HashSet<>();
+
+ Rule start = null;
+ for (Rule rule : this.rules) {
+ if (rule.getLhs().equals(this.startSymbol)) {
+ start = rule;
+ }
+ }
+ if (start == null) {
+ throw new RuntimeException("Unexpected null start production rule");
+ }
+ this.startRule = start;
+
+ nt2rules = new HashMap<>();
+ System.out.println("\nRules");
+ for (Rule rule : rules) {
+ System.out.println(rule.toString());
+ final String lhs = rule.getLhs();
+ terminals.remove(lhs);
+ nonterminals.add(lhs);
+ if (!nt2rules.containsKey(lhs)) {
+ nt2rules.put(lhs, new ArrayList<>());
+ }
+ nt2rules.get(lhs).add(rule);
+ }
+
+ // Sort the list of symbols for easy reading of output.
+ symbols.sort(new SymbolComparator(terminals));
+
+ // Compute first, follow and firstPlus sets.
+ first = Util.computeFirst(symbols, terminals, rules);
+ follow = Util.computeFollow(symbols, terminals, rules, first);
+ firstPlus = Util.computeFirstPlus(symbols, terminals, rules, first, follow);
+ }
+
+ public boolean isTerminal(String symbol) {
+ return terminals.contains(symbol);
+ }
+
+ public boolean isNonterminal(String symbol) {
+ return nonterminals.contains(symbol);
+ }
+
+ public Rule findRule(String lhs, List<String> rhs) {
+ for (Rule rule : rules) {
+ if (rule.getLhs().equals(lhs) && rule.getRhs().equals(rhs)) {
+ return rule;
+ }
+ }
+ return null;
+ }
+
+ public Rule findRule(String s) {
+ List<String> symbols = Arrays.asList(s.split(" "));
+ return findRule(symbols.get(0), symbols.subList(2, symbols.size()));
+ }
+}
diff --git a/Homework/cs5300/project-three/parser/Item.java b/Homework/cs5300/project-three/parser/Item.java
new file mode 100644
index 0000000..1cdb134
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Item.java
@@ -0,0 +1,151 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser;
+
+import java.util.ArrayList;
+import java.util.Objects;
+
+/**
+ * An LR(1) item.
+ *
+ */
+public class Item implements Comparable {
+
+ private Rule rule;
+ /**
+ * Position of the stack top in the production's RHS.
+ */
+ private int dot;
+ /**
+ * The lookahead symbol
+ */
+ private String a;
+
+ /**
+ * Creates a set of items given the rule and lookahead, one item per potential
+ * stack position placement. The number of item is the number of symbols on
+ * the rhs of the rule plus one.
+ *
+ * @param rule
+ * @param a
+ * @return
+ */
+ static ArrayList<Item> create(Rule rule, String a) {
+ ArrayList<Item> ret = new ArrayList<>();
+ final ArrayList<String> rhs = rule.getRhs();
+ for (int i = 0; i < rhs.size(); ++i) {
+ ret.add(new Item(rule, i, a));
+ }
+ ret.add(new Item(rule, rhs.size(), a));
+ return ret;
+ }
+
+ public Item(Rule rule, int dot, String a) {
+ this.rule = rule;
+ this.dot = dot;
+ this.a = a;
+ }
+
+ public Rule getRule() {
+ return rule;
+ }
+
+ public int getDot() {
+ return dot;
+ }
+
+ /**
+ * @return the lookahead symbol
+ */
+ public String getA() {
+ return a;
+ }
+
+ public String getLookahead() {
+ return getA();
+ }
+
+ /**
+ * Returns the symbol following the stack pointer. Returns null if the pointer
+ * is at the end of the rhs list.
+ *
+ * @return
+ */
+ public String getNextSymbol() {
+ if (dot < rule.getRhs().size()) {
+ return rule.getRhs().get(dot);
+ }
+ return null;
+ }
+
+ public String getNextNextSymbol() {
+ if (dot < rule.getRhs().size() - 1) {
+ return rule.getRhs().get(dot + 1);
+ }
+ return null;
+ }
+
+ public Item advance() {
+ return new Item(rule, dot + 1, a);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 37 * hash + Objects.hashCode(this.rule);
+ hash = 37 * hash + this.dot;
+ hash = 37 * hash + Objects.hashCode(this.a);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Item other = (Item) obj;
+ if (!Objects.equals(this.rule, other.rule)) {
+ return false;
+ }
+ if (this.dot != other.dot) {
+ return false;
+ }
+ if (!Objects.equals(this.a, other.a)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ String ret = "[" + rule.getLhs() + " -> ";
+ final ArrayList<String> rhs = rule.getRhs();
+ for (int i = 0; i < dot; ++i) {
+ ret += rhs.get(i) + " ";
+ }
+ ret += Character.toString((char) 0x25CF);
+ if (dot < rhs.size()) {
+ ret += " ";
+ }
+ for (int i = dot; i < rhs.size(); ++i) {
+ ret += rhs.get(i);
+ if (i < rhs.size() - 1) {
+ ret += " ";
+ }
+ }
+ ret += ", " + a + "]";
+ return ret;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return toString().compareTo(o.toString());
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/Main.java b/Homework/cs5300/project-three/parser/Main.java
new file mode 100644
index 0000000..62ca0a3
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Main.java
@@ -0,0 +1,337 @@
+package parser;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ *
+ */
+public class Main {
+ static final String dot = Character.toString((char) 0x25CF);
+
+ /**
+ * @param args the command line arguments
+ * @throws java.io.IOException
+ */
+ public static void main(String[] args) throws IOException {
+ Tests tests = new Tests();
+ testClosure(tests);
+ testStates(tests);
+ testTables(tests);
+ testParser(tests);
+
+ // ------------------------------------------------------------
+ // Output number of tests that succeeded
+ // ------------------------------------------------------------
+ System.out.println(tests.getSuccesses() + "/" + tests.getN()
+ + " tests succeeded");
+ // return tests.getFailures();
+
+ }
+
+ public static void testClosure(Tests tests) throws FileNotFoundException, IOException {
+ // TODO: uncomment tests as you develop code
+ {
+ // TODO: Become familiar with the Grammar class. You will use it a lot.
+ Grammar grammar = new Grammar("data/Simple.cfg");
+
+ // Find the closure of [N -> ● X, $]
+ Rule rule = grammar.findRule("N -> X");
+ State state = Parser.computeClosure(new Item(rule, 0, Util.EOF), grammar);
+ state.setName(0);
+ tests.test(state, "0: [[N -> ● X, $]]");
+
+ // Find the closure of [N -> ● N X, $]
+ rule = grammar.findRule("N -> N X");
+ state = Parser.computeClosure(new Item(rule, 0, Util.EOF), grammar);
+ state.setName(0);
+ // [[N -> ● N X, $], [N -> ● N X, X], [N -> ● X, X]]
+ tests.test(state.size(), 3);
+
+ // Find the start state
+ Item head = new Item(grammar.startRule, 0, Util.EOF);
+ state = Parser.computeClosure(head, grammar);
+ // [[G -> ● N, $], [N -> ● N X, $], [N -> ● N X, X], [N -> ● X, X], [N -> ● X,
+ // $]]
+ tests.test(state.size(), 5);
+ }
+ {
+ Grammar grammar = new Grammar("data/Paren.cfg");
+
+ // Find the closure of [list -> list ● pair, $]
+ Rule rule = grammar.findRule("list -> list pair");
+ State state = Parser.computeClosure(new Item(rule, 1, Util.EOF), grammar);
+ // [[list -> list ● pair, $], [pair -> ● OPAREN list CPAREN, $], [pair -> ●
+ // OPAREN CPAREN, $]]
+ tests.test(state.size(), 3);
+
+ // Find the closure of [pair -> OPAREN ● list CPAREN, $]
+ rule = grammar.findRule("pair -> OPAREN list CPAREN");
+ state = Parser.computeClosure(new Item(rule, 1, Util.EOF), grammar);
+ // [[pair -> OPAREN ● list CPAREN, $], [list -> ● list pair, CPAREN]
+ // [list -> ● list pair, OPAREN], [list -> ● pair, OPAREN], [pair -> ● OPAREN
+ // list CPAREN, OPAREN]
+ // [pair -> ● OPAREN CPAREN, OPAREN], [list -> ● pair, CPAREN], [pair -> ●
+ // OPAREN list CPAREN, CPAREN]
+ // [pair -> ● OPAREN CPAREN, CPAREN]]
+ tests.test(state.size(), 9);
+
+ // Find the start state
+ Item head = new Item(grammar.startRule, 0, Util.EOF);
+ state = Parser.computeClosure(head, grammar);
+ // [[goal -> ● list, $], [list -> ● list pair, $], [list -> ● list pair, OPAREN]
+ // [list -> ● pair, OPAREN], [pair -> ● OPAREN list CPAREN, OPAREN], [pair -> ●
+ // OPAREN CPAREN, OPAREN]
+ // [list -> ● pair, $], [pair -> ● OPAREN list CPAREN, $], [pair -> ● OPAREN
+ // CPAREN, $]]
+ tests.test(state.size(), 9);
+ }
+ {
+ Grammar grammar = new Grammar("data/Expr.cfg");
+
+ // Find the start state
+ Item head = new Item(grammar.startRule, 0, Util.EOF);
+ State state = Parser.computeClosure(head, grammar);
+ // [[goal -> ● expr, $], [expr -> ● expr PLUS term, $], [expr -> ● expr PLUS
+ // term, PLUS], [expr -> ● expr MINUS term, PLUS], [expr -> ● expr PLUS term,
+ // MINUS], [expr -> ● term, PLUS], [term -> ● term MULTIPLY factor, PLUS], [term
+ // -> ● term MULTIPLY factor, MULTIPLY], [term -> ● term DIVIDE factor,
+ // MULTIPLY], [term -> ● term MULTIPLY factor, DIVIDE], [term -> ● factor,
+ // MULTIPLY], [factor -> ● OPAREN expr CPAREN, MULTIPLY], [factor -> ● INT,
+ // MULTIPLY], [factor -> ● FLOAT, MULTIPLY], [factor -> ● IDENTIFIER, MULTIPLY],
+ // [term -> ● term DIVIDE factor, DIVIDE], [term -> ● factor, DIVIDE], [factor
+ // -> ● OPAREN expr CPAREN, DIVIDE], [factor -> ● INT, DIVIDE], [factor -> ●
+ // FLOAT, DIVIDE], [factor -> ● IDENTIFIER, DIVIDE], [term -> ● term DIVIDE
+ // factor, PLUS], [term -> ● factor, PLUS], [factor -> ● OPAREN expr CPAREN,
+ // PLUS], [factor -> ● INT, PLUS], [factor -> ● FLOAT, PLUS], [factor -> ●
+ // IDENTIFIER, PLUS], [expr -> ● expr MINUS term, MINUS], [expr -> ● term,
+ // MINUS], [term -> ● term MULTIPLY factor, MINUS], [term -> ● term DIVIDE
+ // factor, MINUS], [term -> ● factor, MINUS], [factor -> ● OPAREN expr CPAREN,
+ // MINUS], [factor -> ● INT, MINUS], [factor -> ● FLOAT, MINUS], [factor -> ●
+ // IDENTIFIER, MINUS], [expr -> ● expr MINUS term, $], [expr -> ● term, $],
+ // [term -> ● term MULTIPLY factor, $], [term -> ● term DIVIDE factor, $], [term
+ // -> ● factor, $], [factor -> ● OPAREN expr CPAREN, $], [factor -> ● INT, $],
+ // [factor -> ● FLOAT, $], [factor -> ● IDENTIFIER, $]]
+ tests.test(state.size(), 45);
+ }
+ }
+
+ public static void testStates(Tests tests) throws FileNotFoundException, IOException {
+ {
+ Parser parser = new Parser("data/Simple.cfg");
+ States states = parser.getStates();
+ tests.test(states.size(), 4);
+ }
+ {
+ Parser parser = new Parser("data/Paren.cfg");
+ States states = parser.getStates();
+ tests.test(states.size(), 14);
+ }
+ {
+ Parser parser = new Parser("data/Expr.cfg");
+ States states = parser.getStates();
+ tests.test(states.size(), 34);
+ }
+ }
+
+ public static void testTables(Tests tests) throws FileNotFoundException, IOException {
+ {
+ Parser parser = new Parser("data/Simple.cfg");
+ String actionTable = parser.actionTableToString();
+ tests.test(countMatches(actionTable, 'S'), 2); // 2 shifts
+ tests.test(countMatches(actionTable, 'R'), 4); // 4 reduces
+ tests.test(countMatches(actionTable, "acc"), 1); // 1 accept
+ }
+ {
+ Parser parser = new Parser("data/Paren.cfg");
+ String actionTable = parser.actionTableToString();
+ tests.test(countMatches(actionTable, 'S'), 10); // 10 shifts
+ tests.test(countMatches(actionTable, 'R'), 18); // 18 reduces (2 of the Rs are in the header)
+ tests.test(countMatches(actionTable, "acc"), 1); // 1 accept
+ }
+ {
+ Parser parser = new Parser("data/Expr.cfg");
+ String actionTable = parser.actionTableToString();
+ tests.test(countMatches(actionTable, 'S'), 66);
+ tests.test(countMatches(actionTable, 'R'), 91);
+ tests.test(countMatches(actionTable, "acc"), 1);
+ }
+ }
+
+ public static void testParser(Tests tests) throws FileNotFoundException, IOException {
+ {
+ Parser parser = new Parser("data/Simple.cfg");
+
+ String s = "xxx";
+ try {
+ List<Action> actions = parser.parseFromString(s);
+ tests.test(countMatches(actions.toString(), 'S'), 3); // 3 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 3); // 3 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + s + ": " + e.getMessage());
+ }
+
+ s = "xxxxx";
+ try {
+ List<Action> actions = parser.parseFromString(s);
+ tests.test(countMatches(actions.toString(), 'S'), 5); // 5 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 5); // 5 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + s + ": " + e.getMessage());
+ }
+
+ s = "";
+ try {
+ List<Action> actions = parser.parseFromString(s);
+ tests.addFailure("Should have failed to parse");
+ } catch (ParserException e) {
+ }
+ }
+
+ {
+ Parser parser = new Parser("data/Paren.cfg");
+
+ String fn = "data/paren0.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 2); // 2 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 2); // 2 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/paren1.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 20); // 20 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 20); // 20 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/paren2.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ fn = "data/paren3.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ fn = "data/paren4.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 10); // 10 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 10); // 10 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+ }
+ {
+ Parser parser = new Parser("data/Expr.cfg");
+
+ String fn = "data/expr1.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 7); // 7 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 10); // 10 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/expr2.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ fn = "data/expr3.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 1); // 1 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 3); // 3 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/expr4.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 15); // 15 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 22); // 22 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/expr5.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ fn = "data/expr6.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ }
+
+ {
+ // TODO: To pass these tests you must implement data/Tiny.cfg
+ // according to the grammar given in data/tinyGrammar.pdf.
+ // See notes in data/Tiny.cfg (be sure to read all of them!).
+ Parser parser = new Parser("data/Tiny.cfg");
+
+ String fn = "data/tiny1.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 11); // 11 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 25); // 25 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/tiny2.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.test(countMatches(actions.toString(), 'S'), 27); // 27 shift actions
+ tests.test(countMatches(actions.toString(), 'R'), 55); // 55 reduce actions
+ } catch (ParserException e) {
+ tests.addFailure("Failed to parse " + fn + ": " + e.getMessage());
+ }
+
+ fn = "data/tiny3.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ fn = "data/tiny4.dat";
+ try {
+ List<Action> actions = parser.parseFromFile(fn);
+ tests.addFailure("Should have failed to parse " + fn);
+ } catch (ParserException e) {
+ }
+
+ }
+ }
+
+ private static int countMatches(String s, char c) {
+ return (int) s.chars().filter(ch -> ch == c).count();
+ }
+
+ private static int countMatches(String s, String c) {
+ return s.split(c, -1).length - 1;
+ }
+} \ No newline at end of file
diff --git a/Homework/cs5300/project-three/parser/Parser.java b/Homework/cs5300/project-three/parser/Parser.java
new file mode 100644
index 0000000..67d723a
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Parser.java
@@ -0,0 +1,341 @@
+/*
+ * Look for TODO comments in this file for suggestions on how to implement
+ * your parser.
+ */
+package parser;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.lang.model.util.ElementScanner6;
+
+import lexer.ExprLexer;
+import lexer.ParenLexer;
+import lexer.SimpleLexer;
+import lexer.TinyLexer;
+import org.antlr.v4.runtime.*;
+
+/**
+ *
+ */
+public class Parser {
+
+ final Grammar grammar;
+
+ /**
+ * All states in the parser.
+ */
+ private final States states;
+
+ /**
+ * Action table for bottom-up parsing. Accessed as
+ * actionTable.get(state).get(terminal). You may replace
+ * the Integer with a State class if you choose.
+ */
+ private final HashMap<Integer, HashMap<String, Action>> actionTable;
+ /**
+ * Goto table for bottom-up parsing. Accessed as
+ * gotoTable.get(state).get(nonterminal).
+ * You may replace the Integers with State classes if you choose.
+ */
+ private final HashMap<Integer, HashMap<String, Integer>> gotoTable;
+
+ public Parser(String grammarFilename) throws IOException {
+ actionTable = new HashMap<>();
+ gotoTable = new HashMap<>();
+
+ grammar = new Grammar(grammarFilename);
+
+ states = new States();
+
+ initializeStates();
+ constructActionTable();
+ constructGotoTable();
+ }
+
+ private int findState(State state) {
+ for (State f_state : states.getStateList())
+ if (f_state.equals(state))
+ return f_state.getName();
+ return -1;
+ }
+
+ private void constructActionTable() {
+ for (State state : states.getStateList()) {
+ int name = state.getName();
+ actionTable.computeIfAbsent(name, k -> new HashMap<String, Action>());
+
+ for (Item item : state.getItems()) {
+ String nextSymbol = item.getNextSymbol();
+
+ if (nextSymbol != null && grammar.isTerminal(nextSymbol))
+ actionTable.get(name).put(nextSymbol, Action.createShift(findState(Parser.GOTO(state, nextSymbol, grammar))));
+ else if (nextSymbol == null) {
+ Rule rule = item.getRule();
+ if (rule.equals(grammar.startRule) && item.getLookahead() == Util.EOF)
+ actionTable.get(name).put(Util.EOF, Action.createAccept());
+ else
+ actionTable.get(name).put(item.getLookahead(), Action.createReduce(item.getRule()));
+ }
+ }
+ }
+ }
+
+ private void constructGotoTable() {
+ for (State state : states.getStateList()) {
+ int name = state.getName();
+ gotoTable.computeIfAbsent(name, k -> new HashMap<String, Integer>());
+ for (String nonTerminal : grammar.nonterminals) {
+ int goTo = findState(Parser.GOTO(state, nonTerminal, grammar));
+ if (goTo != -1)
+ gotoTable.get(name).put(nonTerminal, goTo);
+ }
+ }
+ }
+
+ private void initializeStates() {
+ int stateId = 0;
+
+ State closure = Parser.computeClosure(new Item(grammar.startRule, 0, Util.EOF), grammar);
+ closure.setName(stateId++);
+ states.addState(closure);
+
+ boolean added = true;
+ while (added) {
+ added = false;
+
+ ArrayList<State> stateList = new ArrayList<>(states.getStateList());
+ for (State state : stateList)
+ for (String symbol : grammar.symbols) {
+ State goTo = Parser.GOTO(state, symbol, grammar);
+ if (goTo.getItems().size() > 0 && states.addState(goTo)) {
+ goTo.setName(stateId++);
+ added = true;
+ }
+ }
+ }
+ }
+
+ public States getStates() {
+ return states;
+ }
+
+ static public State computeClosure(Item I, Grammar grammar) {
+ State closure = new State(I);
+
+ boolean added = true;
+ while (added) {
+ added = false;
+
+ List<Item> items = new ArrayList<Item>(closure.getItems());
+
+ for (Item item : items) {
+ String symbol = item.getNextSymbol();
+
+ if (grammar.isNonterminal(symbol)) {
+ List<Rule> symbolRules = grammar.rules.stream().filter(rule -> rule.getLhs().equals(symbol))
+ .collect(Collectors.toList());
+
+ ArrayList<String> firstOperand = new ArrayList<>();
+ if (item.getNextNextSymbol() != null) {
+ List<String> rhs = item.getRule().getRhs();
+ firstOperand.addAll(rhs.subList(item.getDot() + 1, rhs.size()));
+ }
+ firstOperand.add(item.getLookahead());
+
+ HashSet<String> firstSet = new HashSet<>();
+ for (String firstSymbol : firstOperand) {
+ if (grammar.first.containsKey(firstSymbol)) {
+ firstSet.addAll(grammar.first.get(firstSymbol));
+ if (!grammar.first.get(firstSymbol).contains(Util.EPSILON))
+ break;
+ } else if (firstSymbol.equals(Util.EOF)) {
+ firstSet.add(firstSymbol);
+ }
+ }
+
+ for (Rule rule : symbolRules)
+ for (String terminal : firstSet)
+ added = closure.addItem(new Item(rule, 0, terminal)) || added;
+ }
+ }
+ }
+
+ return closure;
+ }
+
+ // This returns a new state that represents the transition from
+ // the given state on the symbol X.
+ static public State GOTO(State state, String X, Grammar grammar) {
+ State gotoState = new State();
+
+ for (Item item : state.getItems())
+ if (item.getNextSymbol() != null && item.getNextSymbol().equals(X))
+ gotoState.addItem(new Item(item.getRule(), item.getDot() + 1, item.getLookahead()));
+
+ List<Item> gotoItems = new ArrayList<>(gotoState.getItems());
+ for (Item gotoItem : gotoItems)
+ for (Item closureItem : Parser.computeClosure(gotoItem, grammar).getItems())
+ gotoState.addItem(closureItem);
+
+ return gotoState;
+ }
+
+ // You will want to use StringBuilder. Another useful method will be
+ // String.format: for
+ // printing a value in the table, use
+ // String.format("%8s", value)
+ // How much whitespace you have shouldn't matter with regard to the tests, but
+ // it will
+ // help you debug if you can format it nicely.
+ public String actionTableToString() {
+ StringBuilder builder = new StringBuilder();
+
+ List<String> terminalsPlusEof = new ArrayList<String>(grammar.terminals);
+ terminalsPlusEof.add(Util.EOF);
+
+ builder.append("state");
+ for (String terminal : terminalsPlusEof)
+ builder.append(String.format("%8s", terminal));
+ builder.append("\n");
+
+ for (State state : states.getStateList()) {
+ int stateName = state.getName();
+ HashMap<String, Action> actionRow = actionTable.get(stateName);
+ builder.append(String.format("%5s", stateName));
+
+ for (String terminal : terminalsPlusEof) {
+ Action action = actionRow.get(terminal);
+ builder.append(String.format("%8s", action != null ? action.toString() : ""));
+ }
+ builder.append("\n");
+ }
+ return builder.toString();
+ }
+
+ // You will want to use StringBuilder. Another useful method will be
+ // String.format: for
+ // printing a value in the table, use
+ // String.format("%8s", value)
+ // How much whitespace you have shouldn't matter with regard to the tests, but
+ // it will
+ // help you debug if you can format it nicely.
+ public String gotoTableToString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("state");
+ for (String nonTerminal : grammar.nonterminals)
+ builder.append(String.format("%8s", nonTerminal));
+ builder.append("\n");
+
+ for (State state : states.getStateList()) {
+ int stateName = state.getName();
+ HashMap<String, Integer> gotoTableRow = gotoTable.get(stateName);
+ builder.append(String.format("%5s", stateName));
+
+ for (String nonTerminal : grammar.nonterminals) {
+ if (gotoTableRow.containsKey(nonTerminal))
+ builder.append(String.format("%8s", gotoTableRow.get(nonTerminal)));
+ else
+ builder.append(String.format("%8s", ""));
+ }
+
+ builder.append("\n");
+ }
+ return builder.toString();
+ }
+
+ // You should return a list of the actions taken.
+ public List<Action> parse(Lexer scanner) throws ParserException {
+ // tokens is the output from the scanner. It is the list of tokens
+ // scanned from the input file.
+ // To get the token type: v.getSymbolicName(t.getType())
+ // To get the token lexeme: t.getText()
+ ArrayList<? extends Token> tokens = new ArrayList<>(scanner.getAllTokens());
+ Vocabulary v = scanner.getVocabulary();
+
+ Stack<String> input = new Stack<>();
+ Collections.reverse(tokens);
+ input.add(Util.EOF);
+ for (Token t : tokens) {
+ input.push(v.getSymbolicName(t.getType()));
+ }
+ Collections.reverse(tokens);
+
+ List<Action> actions = new ArrayList<>();
+
+ Stack<State> stack = new Stack<>();
+ stack.push(states.getState(0));
+
+ String currentInput = input.pop();
+ while (true) {
+ State s = stack.peek();
+ Action action = actionTable.get(s.getName()).get(currentInput);
+
+ if (action == null)
+ throw ParserException.create(tokens, input.size());
+
+ actions.add(action);
+
+ if (action.isShift()) {
+ stack.push(states.getState(action.getState()));
+ currentInput = input.pop();
+ } else if (action.isReduce()) {
+ Rule rule = action.getRule();
+ for (int i = 0; i < rule.getRhs().size(); i++)
+ stack.pop();
+
+ s = stack.peek();
+ stack.push(states.getState(gotoTable.get(s.getName()).get(rule.getLhs())));
+ } else if (action.isAccept()) {
+ break;
+ } else {
+ throw ParserException.create(tokens, input.size());
+ }
+ }
+
+ return actions;
+ }
+
+ // -------------------------------------------------------------------
+ // Convenience functions
+ // -------------------------------------------------------------------
+
+ public List<Action> parseFromFile(String filename) throws IOException, ParserException {
+ // System.out.println("\nReading input file " + filename + "\n");
+ final CharStream charStream = CharStreams.fromFileName(filename);
+ Lexer scanner = scanFile(charStream);
+ return parse(scanner);
+ }
+
+ public List<Action> parseFromString(String program) throws ParserException {
+ Lexer scanner = scanFile(CharStreams.fromString(program));
+ return parse(scanner);
+ }
+
+ private Lexer scanFile(CharStream charStream) {
+ // We use ANTLR's scanner (lexer) to produce the tokens.
+ Lexer scanner = null;
+ switch (grammar.grammarName) {
+ case "Simple":
+ scanner = new SimpleLexer(charStream);
+ break;
+ case "Paren":
+ scanner = new ParenLexer(charStream);
+ break;
+ case "Expr":
+ scanner = new ExprLexer(charStream);
+ break;
+ case "Tiny":
+ scanner = new TinyLexer(charStream);
+ break;
+ default:
+ System.out.println("Unknown scanner");
+ break;
+ }
+
+ return scanner;
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/ParserException.java b/Homework/cs5300/project-three/parser/ParserException.java
new file mode 100644
index 0000000..1c32080
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/ParserException.java
@@ -0,0 +1,81 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser;
+
+import java.util.ArrayList;
+import org.antlr.v4.runtime.Token;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class ParserException extends Exception {
+
+ /**
+ * Create a ParserException. This is a convenience factory method to easily
+ * format your output to meet project specification.
+ *
+ * @param words the words being parsed
+ * @param i the index to the current word being parsed
+ * @return
+ */
+ public static ParserException create(final ArrayList<? extends Token> words, final int i) {
+ String msg;
+ if (i < words.size()) {
+ msg = "Error parsing token \"" + words.get(i).getText() + "\" in \n ";
+ int preLen = 4;
+ for (int j = 0; j < i; ++j) {
+ Token token = words.get(j);
+ msg = msg + token.getText() + " ";
+ preLen += token.getText().length() + 1;
+ }
+ final int curLen = words.get(i).getText().length();
+ msg = msg + words.get(i).getText();
+ if (i < words.size() - 1) {
+ msg = msg + " ";
+ }
+ for (int j = i + 1; j < words.size(); ++j) {
+ Token token = words.get(j);
+ msg = msg + token.getText();
+ if (j < words.size() - 1) {
+ msg = msg + " ";
+ }
+ }
+
+ msg = msg + "\n";
+ for (int j = 0; j < preLen; ++j) {
+ msg += " ";
+ }
+ for (int j = 0; j < curLen; ++j) {
+ msg += "^";
+ }
+ } else {
+ msg = "Unexpectedly reached end of file in\n";
+ for (int j = 0; j < words.size(); ++j) {
+ Token token = words.get(j);
+ msg = msg + token.getText();
+ if (j < words.size() - 1) {
+ msg = msg + " ";
+ }
+ }
+
+ }
+ return new ParserException(msg);
+ }
+
+ /**
+ * Constructor. You will most likely NOT use this constructor directly, but
+ * rather use the convenience factory method create(). You may choose to use
+ * this constructor, however, if your data structures are set up differently
+ * than what the factory method expects.
+ *
+ * @param msg
+ */
+ public ParserException(String msg) {
+ super(msg);
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/Rule.java b/Homework/cs5300/project-three/parser/Rule.java
new file mode 100644
index 0000000..b251e84
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Rule.java
@@ -0,0 +1,93 @@
+/*
+ * Do not modify this file.
+ */
+package parser;
+
+import java.util.ArrayList;
+import java.util.Objects;
+
+/**
+ *
+ */
+public class Rule {
+
+ private int name;
+ private final String lhs;
+ private ArrayList<String> rhs;
+
+ public Rule(String lhs) {
+ this.name = 0;
+ this.lhs = lhs;
+ rhs = new ArrayList<>();
+ }
+
+ public void setName(int name) {
+ this.name = name;
+ }
+
+ public int getName() {
+ return this.name;
+ }
+
+ @Override
+ public String toString() {
+ String ret = "R" + name + " " + lhs + " -> ";
+ for (String symbol : getRhs()) {
+ ret = ret + symbol + " ";
+ }
+ return ret;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 37 * hash + Objects.hashCode(this.lhs);
+ hash = 37 * hash + this.name;
+ for (int i = 0; i < this.rhs.size(); ++i) {
+ hash = 37 * hash + Objects.hashCode(this.rhs.get(i));
+ }
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Rule other = (Rule) obj;
+ if (!this.lhs.equals(other.lhs)) {
+ return false;
+ }
+ if (this.name != other.name) {
+ return false;
+ }
+ if (this.rhs.size() != other.rhs.size()) {
+ return false;
+ }
+ for (int i = 0; i < this.rhs.size(); ++i) {
+ if (!this.rhs.get(i).equals(other.rhs.get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String getLhs() {
+ return lhs;
+ }
+
+ public ArrayList<String> getRhs() {
+ if (rhs.isEmpty()) {
+ rhs.add("EPSILON");
+ }
+ return rhs;
+ }
+
+ public void addRhs(String symbol) {
+ rhs.add(symbol);
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/State.java b/Homework/cs5300/project-three/parser/State.java
new file mode 100644
index 0000000..90c9c33
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/State.java
@@ -0,0 +1,94 @@
+package parser;
+
+import java.util.*;
+
+public class State implements Comparable<State> {
+ private Set<Item> itemSet;
+ private List<Item> items;
+ private int name;
+
+ public State(int name) {
+ this.itemSet = new HashSet<>();
+ this.items = new ArrayList<>();
+ this.name = name;
+ }
+
+ public State() {
+ this(0);
+ }
+
+ public State(Item item) {
+ this();
+ addItem(item);
+ }
+
+ public void setName(int name) {
+ this.name = name;
+ }
+
+ public int getName() {
+ return this.name;
+ }
+
+ public List<Item> getItems() {
+ return this.items;
+ }
+
+ public int size() {
+ return items.size();
+ }
+
+ /*
+ * true if the item was added, false if it was already in the set
+ */
+ public boolean addItem(Item item) {
+ if (!itemSet.contains(item)) {
+ itemSet.add(item);
+ items.add(item);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ ArrayList<Item> sortedList = new ArrayList<>(items);
+ sortedList.sort(Comparator.comparingInt(Item::hashCode));
+ for (Item item : sortedList) {
+ hash = 37 * hash + Objects.hashCode(item);
+ }
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final State other = (State) obj;
+ if (items.size() != other.items.size()) {
+ return false;
+ }
+ for (Item item : items) {
+ if (!other.itemSet.contains(item)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return this.name + ": " + items.toString();
+ }
+
+ @Override
+ public int compareTo(State o) {
+ return Integer.valueOf(this.name).compareTo(Integer.valueOf(o.name));
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/States.java b/Homework/cs5300/project-three/parser/States.java
new file mode 100644
index 0000000..7002f53
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/States.java
@@ -0,0 +1,44 @@
+package parser;
+
+import java.util.*;
+
+public class States {
+ private Set<State> stateSet;
+ private List<State> states;
+ private int id = 0;
+
+ public States() {
+ this.stateSet = new HashSet<>();
+ this.states = new ArrayList<>();
+ }
+
+ public int size() {
+ return this.states.size();
+ }
+
+ public boolean addState(State state) {
+ if (!this.stateSet.contains(state)) {
+ this.stateSet.add(state);
+ this.states.add(state);
+ return true;
+ }
+ return false;
+ }
+
+ public List<State> getStateList() {
+ return states;
+ }
+
+ public State getState(int name) {
+ if (name >= states.size()) {
+ return null;
+ }
+ return states.get(name);
+ }
+
+ @Override
+ public String toString() {
+ return states.toString();
+ }
+
+}
diff --git a/Homework/cs5300/project-three/parser/Tests.java b/Homework/cs5300/project-three/parser/Tests.java
new file mode 100644
index 0000000..73732af
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Tests.java
@@ -0,0 +1,69 @@
+package parser;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class Tests {
+
+ private int N = 0;
+ private int failures = 0;
+
+ public void test(boolean b) {
+ N++;
+ if (!b) {
+ System.err.println("Failed test " + N);
+ failures++;
+ }
+ }
+
+ public void test(boolean b, String message) {
+ test(b);
+ if (!b) {
+ System.err.println(message);
+ }
+ }
+
+ public void test(Object a, Object target) {
+ N++;
+ if (a == null && target == null) {
+ return;
+ }
+ if (a == null || target == null || !a.equals(target)) {
+ System.err.println("Failed test " + N);
+ System.err.println(" " + a + " not equal to target " + target);
+ failures++;
+ }
+ }
+
+ public void test(Object a, String target) {
+ N++;
+ if (a == null && target == null) {
+ return;
+ }
+ if (a == null || target == null || !a.toString().equals(target)) {
+ System.err.println("Failed test " + N);
+ System.err.println(" " + a + " not equal to target " + target);
+ failures++;
+ }
+ }
+
+ public void addFailure(String msg) {
+ N++;
+ System.err.println("Failed test " + N);
+ System.err.println(msg);
+ failures++;
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getSuccesses() {
+ return N - failures;
+ }
+
+ public int getFailures() {
+ return failures;
+ }
+}
diff --git a/Homework/cs5300/project-three/parser/Util.java b/Homework/cs5300/project-three/parser/Util.java
new file mode 100644
index 0000000..fe7d9ab
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/Util.java
@@ -0,0 +1,132 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class Util {
+
+ public static final String EPSILON = "EPSILON";
+ public static final String EOF = "$";
+
+ public static HashMap<String, HashSet<String>> computeFirst(ArrayList<String> symbols, HashSet<String> terminals, ArrayList<Rule> rules) {
+ HashMap<String, HashSet<String>> first = new HashMap<>();
+ for (String symbol : symbols) {
+ first.put(symbol, new HashSet<>());
+ }
+ for (String terminal : terminals) {
+ first.get(terminal).add(terminal);
+ }
+ // Algorithm 3.7
+ boolean changed = true;
+ while (changed) {
+ changed = false;
+ for (Rule rule : rules) {
+ ArrayList<String> rhsSymbols = rule.getRhs();
+ HashSet<String> rhs = new HashSet<>();
+ final String B0 = rhsSymbols.get(0);
+ rhs.addAll(noEpsilon(first.get(B0)));
+ boolean stop = !first.get(B0).contains(EPSILON);
+ for (int i = 0; !stop && i < rhsSymbols.size() - 1; ++i) {
+ final String B = rhsSymbols.get(i + 1);
+ rhs.addAll(noEpsilon(first.get(B0)));
+ stop = !first.get(B).contains(EPSILON);
+ }
+ if (!stop) {
+ rhs.add(EPSILON);
+ }
+ final String A = rule.getLhs();
+ if (!first.get(A).containsAll(rhs)) {
+ first.get(A).addAll(rhs);
+ changed = true;
+ }
+ }
+ }
+// System.out.println("\n");
+// for (String symbol : symbols) {
+// final String A = symbol;
+// System.out.println("FIRST(" + A + ") = " + first.get(A));
+// }
+ return first;
+ }
+
+ public static HashMap<String, HashSet<String>> computeFollow(
+ ArrayList<String> symbols, HashSet<String> terminals, ArrayList<Rule> rules,
+ HashMap<String, HashSet<String>> first) {
+ HashMap<String, HashSet<String>> follow = new HashMap<>();
+ for (String symbol : symbols) {
+ follow.put(symbol, new HashSet<>());
+ }
+ follow.get(rules.get(0).getLhs()).add(EOF);
+ boolean changed = true;
+ while (changed) {
+ changed = false;
+ for (Rule rule : rules) {
+ HashSet<String> trailer = new HashSet<>(follow.get(rule.getLhs()));
+ final ArrayList<String> rhsSymbols = rule.getRhs();
+ for (int i = rhsSymbols.size() - 1; i >= 0; --i) {
+ final String Bi = rhsSymbols.get(i);
+ if (!terminals.contains(Bi)) {
+ if (!follow.get(Bi).containsAll(trailer)) {
+ follow.get(Bi).addAll(trailer);
+ changed = true;
+ }
+ if (first.get(Bi).contains(EPSILON)) {
+ trailer.addAll(noEpsilon(first.get(Bi)));
+ } else {
+ trailer = first.get(Bi);
+ }
+ } else {
+ trailer = first.get(Bi);
+ }
+ }
+ }
+ }
+// System.out.println("\n");
+// for (String symbol : symbols) {
+// if (!terminals.contains(symbol)) {
+// System.out.println("FOLLOW(" + symbol + ") = " + follow.get(symbol));
+// }
+// }
+ return follow;
+ }
+
+ public static HashMap<Rule, HashSet<String>> computeFirstPlus(
+ ArrayList<String> symbols, HashSet<String> terminals, ArrayList<Rule> rules,
+ HashMap<String, HashSet<String>> first, HashMap<String, HashSet<String>> follow) {
+ HashMap<Rule, HashSet<String>> firstPlus = new HashMap<>();
+ for (Rule rule : rules) {
+ final String A = rule.getLhs();
+ final String B = rule.getRhs().get(0);
+ HashSet<String> firstPlusA = new HashSet<>();
+ if (!first.get(B).contains(EPSILON)) {
+ firstPlusA.addAll(first.get(B));
+ } else {
+ firstPlusA.addAll(first.get(B));
+ firstPlusA.addAll(follow.get(A));
+ }
+ firstPlus.put(rule, firstPlusA);
+ }
+// System.out.println("\n");
+// for (Rule rule : rules) {
+// System.out.println("FIRST+(" + rule + ") = " + firstPlus.get(rule));
+// }
+ return firstPlus;
+ }
+
+ private static HashSet<String> noEpsilon(final HashSet<String> set) {
+ HashSet<String> s = new HashSet<>(set);
+ s.remove(EPSILON);
+ return s;
+ }
+}
diff --git a/Homework/cs5300/project-three/parser/util/SymbolComparator.java b/Homework/cs5300/project-three/parser/util/SymbolComparator.java
new file mode 100644
index 0000000..e131c79
--- /dev/null
+++ b/Homework/cs5300/project-three/parser/util/SymbolComparator.java
@@ -0,0 +1,38 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parser.util;
+
+import java.util.Comparator;
+import java.util.HashSet;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class SymbolComparator implements Comparator<String> {
+
+ private final HashSet<String> terminals;
+
+ public SymbolComparator(HashSet<String> terminals) {
+ this.terminals = terminals;
+ }
+
+ @Override
+ public int compare(String o1, String o2) {
+ // Slightly less efficient code for clarity.
+ if (terminals.contains(o1) && terminals.contains(o2)) {
+ return o1.compareTo(o2);
+ }
+ if (terminals.contains(o1)) {
+ return 1;
+ }
+ if (terminals.contains(o2)) {
+ return -1;
+ }
+ return o1.compareTo(o2);
+ }
+
+}