我似乎完全无法理解为什么无法解析。以下是我的简单语法(只是试图理解简约,因此语法可能没有意义)。
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")
ASELECT 10
解析但由于某种原因,aSELECT A
无法解析。我的理解要么存在,object_name
要么alias
应该存在。我究竟做错了什么?提前致谢。