Commit eb64d615 authored by BELCOUR Arnaud's avatar BELCOUR Arnaud

Move from argparse to docopt for grammar-boolean-rapsody.

parent 74213111
@author: Lucas Bourneuf,
Aim of this script is to produce, for any pattern like:
......@@ -41,8 +42,17 @@ Idea is, mainly, that a syntree is simple to store (dict {node:successors}),
Note that there is no real error handling for parenthesis.
Produce list of elements from a pattern.
usage: --string=STRING
-h --help Show help.
-s --string=STRING the pattern to parse, must be a string like 'a&(b|c)&(d|e)'.
import argparse
import docopt
import re
import sys
......@@ -335,14 +345,12 @@ def compile_input(string, combine_or:bool=False):
yield from eval_tree(syntree, combine_or=bool(combine_or))
if __name__ == '__main__':
parser = argparse.ArgumentParser(usage="python STRING", description="Produce list of elements from a pattern.")
parser.add_argument("input_string", metavar = "input_string", help = "The pattern to parse, must be a string like 'a&(b|c)&(d|e)'.")
parser_args = parser.parse_args()
string = parser_args.input_string
args = docopt.docopt(__doc__)
input_string = args["--string"]
#string = "(b3670|b3671)&(b0077|b0078)"
#string = '(b10648&b1064&(b2675|b2676))'
print([_ for _ in compile_input(string)], end='')
print([_ for _ in compile_input(input_string)], end='')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment