diff --git a/parser.py b/parser.py index 651adf2..c03b8ae 100644 --- a/parser.py +++ b/parser.py @@ -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 diff --git a/readme.md b/readme.md index e7ec8cb..5df536d 100644 --- a/readme.md +++ b/readme.md @@ -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)