summaryrefslogtreecommitdiff
path: root/examples/simpleSQL.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simpleSQL.py')
-rw-r--r--examples/simpleSQL.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/simpleSQL.py b/examples/simpleSQL.py
index 5c93191..39b8b4b 100644
--- a/examples/simpleSQL.py
+++ b/examples/simpleSQL.py
@@ -35,24 +35,24 @@ NOT_NULL = NOT + NULL
ident = Word(alphas, alphanums + "_$").setName("identifier")
columnName = delimitedList(ident, ".", combine=True).setName("column name")
columnName.addParseAction(ppc.upcaseTokens)
-columnNameList = Group(delimitedList(columnName))
+columnNameList = Group(delimitedList(columnName).setName("column_list"))
tableName = delimitedList(ident, ".", combine=True).setName("table name")
tableName.addParseAction(ppc.upcaseTokens)
-tableNameList = Group(delimitedList(tableName))
+tableNameList = Group(delimitedList(tableName).setName("table_list"))
-binop = oneOf("= != < > >= <= eq ne lt le gt ge", caseless=True)
-realNum = ppc.real()
+binop = oneOf("= != < > >= <= eq ne lt le gt ge", caseless=True).setName("binop")
+realNum = ppc.real().setName("real number")
intNum = ppc.signed_integer()
columnRval = (
realNum | intNum | quotedString | columnName
-) # need to add support for alg expressions
+).setName("column_rvalue") # need to add support for alg expressions
whereCondition = Group(
(columnName + binop + columnRval)
- | (columnName + IN + Group("(" + delimitedList(columnRval) + ")"))
+ | (columnName + IN + Group("(" + delimitedList(columnRval).setName("in_values_list") + ")"))
| (columnName + IN + Group("(" + selectStmt + ")"))
| (columnName + IS + (NULL | NOT_NULL))
-)
+).setName("where_condition")
whereExpression = infixNotation(
whereCondition,
@@ -61,7 +61,7 @@ whereExpression = infixNotation(
(AND, 2, opAssoc.LEFT),
(OR, 2, opAssoc.LEFT),
],
-)
+).setName("where_expression")
# define the grammar
selectStmt <<= (
@@ -70,7 +70,7 @@ selectStmt <<= (
+ FROM
+ tableNameList("tables")
+ Optional(Group(WHERE + whereExpression), "")("where")
-)
+).setName("select_statement")
simpleSQL = selectStmt