def isLeftLinear(Grammar):
    if OneVar_LHS(Grammar) == False:
        raise isNotRestricted(Grammar)
    for state in Grammar.dict_grammar:
        for rule in Grammar.dict_grammar[state]:
            if rule == '%':
                pass
            else:
                variable = containsStates(Grammar,rule)
                if variable == [] and len(rule)== num_terminal(Grammar,rule):
                    pass
                elif len(variable) > 1 or isState(Grammar,rule[0]) == False:
                    return [False,rule]
                
    return [True]       
Ejemplo n.º 2
0
def isLeftLinear(Grammar):
    if OneVar_LHS(Grammar) == False:
        raise isNotRestricted(Grammar)
    for state in Grammar.dict_grammar:
        for rule in Grammar.dict_grammar[state]:
            if rule == '%':
                pass
            else:
                variable = containsStates(Grammar,rule)
                if variable == [] and len(rule)== num_terminal(Grammar,rule):
                    pass
                elif len(variable) > 1 or isState(Grammar,rule[0]) == False:
                    return [False,rule]
                
    return [True]       
def isContextFree(Grammar):
    if OneVar_LHS == False:
        raise isNotRestricted(Grammar)
    else:
        return True
Ejemplo n.º 4
0
def isContextFree(Grammar):
    if OneVar_LHS == False:
        raise isNotRestricted(Grammar)
    else:
        return True