Commit 2b725133 authored by BELCOUR Arnaud's avatar BELCOUR Arnaud

Add positional argument to grammar-boolean-rapsody.

parent d8e4cc26
......@@ -42,11 +42,13 @@ Idea is, mainly, that a syntree is simple to store (dict {node:successors}),
Note that there is no real error handling for parenthesis.
import argparse
import re
from enum import Enum
from collections import ChainMap, defaultdict
import sys
from collections import ChainMap, defaultdict
from enum import Enum
# Constants
ERROR_LIMIT = 10 # at most 10 errors before compilation abortion
SILENT_SYNTACTIC_ANALYSIS = True # continue compilation even if syntactic error
......@@ -333,7 +335,11 @@ def compile_input(string, combine_or:bool=False):
yield from eval_tree(syntree, combine_or=bool(combine_or))
if __name__ == '__main__':
string = sys.argv[1]
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
#string = "(b3670|b3671)&(b0077|b0078)"
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