diff --git a/parse.py b/parse.py index 0f11950..0847b21 100644 --- a/parse.py +++ b/parse.py @@ -150,14 +150,14 @@ log.log(log.PARSER, log.DEBUG, "Parsed language version %s" % (version)) return version - def parse_value(self, type, value): + def parse_value(self, context, subject, type, value): + context = ParseContext(context, "parsing %s value" % (subject)) if type == "symbol": return Reference(value) elif type == "text": return Text(value) else: - log.log(log.PARSER, log.NORMAL, "Unexpected type %s" % (type)) - return None + raise ParseError(context, "Unexpected value type '%s'" % (type)) def parse_arguments(self, context, terminator): context = ParseContext(context, "parsing arguments until '%s'" % (terminator)) @@ -170,20 +170,14 @@ else: raise ParseError(context, "Unexpected keyword '%s' in arguments" % (token.value)) else: - arg = self.parse_value(token.type, token.value) - if not arg: - log.log(log.PARSER, log.NORMAL, "While parsing argument") - return None + arg = self.parse_value(context, "argument", token.type, token.value) log.log(log.PARSER, log.TRACE, "Parsed %s" % (arg)) args.append(arg) def parse_statement(self, context, terminator, type): context = ParseContext(context, "parsing %s statement" % (type)) token = self.next() - subject = self.parse_value(token.type, token.value) - if not subject: - log.log(log.PARSER, log.NORMAL, "While parsing subject") - return None + subject = self.parse_value(context, "subject", token.type, token.value) token = self.next() if token.type == "keyword": if token.value == terminator: