示例#1
0
def create_symbols(lines):
    global symbols

    rules = make_rules(lines)

    for rule in rules:
        name = rule[1:-1]
        symbol = Symbol(name)
        symbols.append(symbol)

    for rule in rules:
        name = rule[1:-1]
        symbol = get_symbol(name)
        if "regex" in rules[rule]:
            symbol.regex = extract_regex(rules[rule])
            symbol.is_regex = True
        else:
            prods = make_prods(rules[rule])
            symbol.prods = prods