I seem to be completely stuck with understanding why this is failing to parse. Following is my simple grammar (just playing around trying to understand parsimonious and hence the grammar may not make sense).
from parsimonious.grammar import Grammar
from parsimonious.nodes import NodeVisitor
sql_grammar = Grammar(
"""
select_statement = "SELECT" ("ALL" / "DISTINCT")? object_alias_section
object_alias_section = object_name / alias
object_name = ~"[ 0-9]*"
alias = ~"[ A-Z]*"
"""
)
data = """SELECT A"""
tree = sql_grammar.parse(data)
print("tree:", tree, "\n")
A SELECT 10
parses but for some reason, a SELECT A
fails to parse. My understanding is either of object_name
or alias
should be present. What am i doing wrong? Thanks in advance.