Updated readme

This commit is contained in:
Niles Rogoff 2017-03-25 15:11:34 -04:00
parent 837b302d0f
commit 3de17daa74
No known key found for this signature in database
GPG Key ID: B78B908F23430F80
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ class parser():
def __init__(self, grammar):
self.grammar = grammar
def parse(self, inp):
print("Parsing input " + inp)
self.tokens = lexer.lex(inp)
self.tokens = [t for t in self.tokens if not t.type == "whitespace_nfa"]
self.tokens_ptr = 0
@ -16,7 +17,7 @@ class parser():
def term(self, t_type, literal = False):
this_token = self.tokens[self.tokens_ptr]
self.tokens_ptr += 1
print("attempting to match '" + str(literal) + "' ("+t_type+") to " + this_token.matched_string + " at position " + str(self.tokens_ptr - 1))
#print("attempting to match '" + str(literal) + "' ("+t_type+") to " + this_token.matched_string + " at position " + str(self.tokens_ptr - 1))
if t_type != this_token.type:
return False
if not literal:
@ -40,6 +41,7 @@ class parser():
for f in grammar[nterm]:
self.tokens_ptr = save
if self.match_syms(f):
print("Matched term " + str([k[1] for k in f]))
return True
return False

View File

@ -4,3 +4,6 @@ COOL is the Classroom Object Oriented Language. I'm going to get at least partwa
This is what the lexical analyzer looks like now
![](http://i.imgur.com/ZzrVRWG.png)
This is what the parser looks like so far
![](http://i.imgur.com/vq3DkmY.png)