Skip to content
Snippets Groups Projects
Commit b3c96df4 authored by Nicholas Robinson's avatar Nicholas Robinson
Browse files

methodOrFieldInvocs & statement type

- added new methodOrField thing that lets you invoc methods and fields
recursively infinitely
- statement can now declare and define any type
- removed arrayID nonterminal
- adjusted arrayAccess because of arrayID removal
- added a cmd in README to make my workflow more convenient
- commented out all the many many many prints in Test.py
parent ecd5a07a
No related branches found
No related tags found
No related merge requests found
...@@ -32,10 +32,10 @@ def main(): ...@@ -32,10 +32,10 @@ def main():
for token in tokens: for token in tokens:
if (token.name and token.lex): if (token.name and token.lex):
s += '(' + token.name + ',' + token.lex + '), ' s += '(' + token.name + ',' + token.lex + '), '
print(s) # print(s)
# Parsing # Parsing
print("Parsing starts") # print("Parsing starts")
try: try:
(steps, errorString) = parse(tokens) (steps, errorString) = parse(tokens)
...@@ -48,8 +48,8 @@ def main(): ...@@ -48,8 +48,8 @@ def main():
print("**********************************************************") print("**********************************************************")
continue continue
print("All Steps:") # print("All Steps:")
print(steps) # print(steps)
print("**********************************************************") print("**********************************************************")
......
...@@ -2,3 +2,4 @@ compile Jlr1.java into it's own folder called 'jlar' ...@@ -2,3 +2,4 @@ compile Jlr1.java into it's own folder called 'jlar'
javac Jlr1.java javac Jlr1.java
cat lr1GenInput.cfg | java jlalr.Jlr1 cat lr1GenInput.cfg | java jlalr.Jlr1
cat cs444/cfg/lr1GenInput.cfg | java jlalr.Jlr1 > cs444/cfg/trans.txt
\ No newline at end of file
...@@ -62,7 +62,7 @@ COMMA ...@@ -62,7 +62,7 @@ COMMA
PERIOD PERIOD
COMPID COMPID
IMPORTALL IMPORTALL
95 98
start start
packageDcl packageDcl
importDcls importDcls
...@@ -137,6 +137,9 @@ unqualClassCreate ...@@ -137,6 +137,9 @@ unqualClassCreate
unqualCreate unqualCreate
fieldAccess fieldAccess
arrayAccess arrayAccess
methodOrFieldInvocs
methodOrFieldInvoc
fieldInvoc
methodInvoc methodInvoc
literal literal
expr expr
...@@ -157,9 +160,9 @@ castExpr ...@@ -157,9 +160,9 @@ castExpr
postfixExpr postfixExpr
primaryNoArrayAccess primaryNoArrayAccess
arrayID arrayID
methodID methodOrFieldID
start start
199 205
start BOF packageDcl importDcls topDcls EOF start BOF packageDcl importDcls topDcls EOF
packageDcl PACKAGE name SEMICO packageDcl PACKAGE name SEMICO
packageDcl PACKAGE ID SEMICO packageDcl PACKAGE ID SEMICO
...@@ -264,7 +267,7 @@ statement ifElseStatement ...@@ -264,7 +267,7 @@ statement ifElseStatement
statement forStatement statement forStatement
statement whileStatement statement whileStatement
statement variableDcl SEMICO statement variableDcl SEMICO
statement primitiveType variableDcl SEMICO statement type variableDcl SEMICO
noTailStatement block noTailStatement block
noTailStatement SEMICO noTailStatement SEMICO
noTailStatement exprStatement noTailStatement exprStatement
...@@ -300,19 +303,23 @@ primary arrayAccess ...@@ -300,19 +303,23 @@ primary arrayAccess
primary primaryNoArrayAccess primary primaryNoArrayAccess
primaryNoArrayAccess literal primaryNoArrayAccess literal
primaryNoArrayAccess LPAREN expr RPAREN primaryNoArrayAccess LPAREN expr RPAREN
primaryNoArrayAccess classInstanceCreate primaryNoArrayAccess classInstanceCreate methodOrFieldInvocs
primaryNoArrayAccess fieldAccess primaryNoArrayAccess fieldAccess
primaryNoArrayAccess methodInvoc primaryNoArrayAccess methodInvoc
classInstanceCreate unqualCreate classInstanceCreate unqualCreate
unqualCreate NEW name LPAREN args RPAREN unqualCreate NEW name LPAREN args RPAREN
unqualCreate NEW ID LPAREN args RPAREN unqualCreate NEW ID LPAREN args RPAREN
arrayAccess arrayID LSQRBRACK expr RSQRBRACK arrayAccess name LSQRBRACK expr RSQRBRACK
arrayAccess ID LSQRBRACK expr RSQRBRACK
arrayAccess primaryNoArrayAccess LSQRBRACK expr RSQRBRACK arrayAccess primaryNoArrayAccess LSQRBRACK expr RSQRBRACK
arrayID name methodOrFieldInvocs
arrayID ID methodOrFieldInvocs PERIOD methodOrFieldInvoc methodOrFieldInvocs
methodInvoc methodID LPAREN args RPAREN methodOrFieldInvoc methodInvoc
methodID ID methodOrFieldInvoc fieldInvoc
methodID name fieldInvoc methodOrFieldID
methodInvoc methodOrFieldID LPAREN args RPAREN
methodOrFieldID ID
methodOrFieldID name
literal LITERALBOOL literal LITERALBOOL
literal LITERALCHAR literal LITERALCHAR
literal LITERALSTRING literal LITERALSTRING
...@@ -342,6 +349,8 @@ relationalExpr relationalExpr LE addExpr ...@@ -342,6 +349,8 @@ relationalExpr relationalExpr LE addExpr
relationalExpr relationalExpr GE addExpr relationalExpr relationalExpr GE addExpr
relationalExpr relationalExpr LT addExpr relationalExpr relationalExpr LT addExpr
relationalExpr relationalExpr GT addExpr relationalExpr relationalExpr GT addExpr
relationalExpr relationalExpr EQUAL addExpr
relationalExpr relationalExpr NE addExpr
addExpr multExpr addExpr multExpr
addExpr addExpr ADD multExpr addExpr addExpr ADD multExpr
addExpr addExpr SUB multExpr addExpr addExpr SUB multExpr
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment