From 9268fcefc2fcf568893ccdd00ccb4c40a85f64ca Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 22 Apr 2017 01:18:08 +0300 Subject: [PATCH] Version 0.5: Use parsimonious instead of grako --- ChangeLog | 4 ++++ README | 2 +- TODO | 5 ++++- search-tags.py | 13 +++++-------- version | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 215055b..8387608 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 0.5 (2017-04-??) + + Use parsimonious instead of grako. + Version 0.4 (2016-07-11) Use grako instead of PLY to compile EBNF to Python. diff --git a/README b/README index b8b749c..e5cfe83 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ Search for tags in my blog. Author: Oleg Broytman -Copyright (C) 2014-2016 PhiloSoft Design. +Copyright (C) 2014-2017 PhiloSoft Design. License: GPL. diff --git a/TODO b/TODO index 0b14ced..c77d12f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,7 @@ -Use parsimonious or parsley instead of grako. +Use parsley instead of parsimonious. + + +Use lark instead of parsley. Sort posts by date or tags. diff --git a/search-tags.py b/search-tags.py index 33d141f..c091966 100755 --- a/search-tags.py +++ b/search-tags.py @@ -3,13 +3,13 @@ """Search tags CGI""" __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2014-2016 PhiloSoft Design" +__copyright__ = "Copyright (C) 2014-2017 PhiloSoft Design" __license__ = "GNU GPL" import cgi, sys -from grako.exceptions import FailedParse - +from parsimonious import ParseError from html.response import redirect, response +from parser import parser form = cgi.FieldStorage() if not form.has_key('q'): @@ -20,11 +20,8 @@ if not form.has_key('q'): else: q = form['q'].value try: - from parser.parser import TagsParser - from parser.build_ast import TagsSemantics - parser = TagsParser(parseinfo=False) - tree = parser.parse(q, semantics=TagsSemantics()) - except FailedParse: + tree = parser.compile(q) + except ParseError: status = "400 Bad request" title = "Error!" body = "Bad query syntax!" diff --git a/version b/version index bd73f47..2eb3c4f 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.4 +0.5 -- 2.39.2