How to use the edgedb.lang.caosql.parser.caosql.Nonterm function in edgedb

To help you get started, we’ve selected a few edgedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
class TransformedLinkedSetExpr(Nonterm):
    def reduce_QualifiedLinkedSetExpr_OptSortClause_OptSelectLimit(
                                                self, *kids):
        self.val = kids[0].val
        self.val.orderby = kids[1].val
        self.val.offset = kids[2].val[0]
        self.val.limit = kids[2].val[1]


class ParenthesizedTransformedLinkedSetExpr(Nonterm):
    def reduce_LPAREN_TransformedLinkedSetExpr_RPAREN(self, *kids):
        self.val = kids[1].val


class OptPointerRecursionSpec(Nonterm):
    def reduce_STAR(self, *kids):
        self.val = qlast.ConstantNode(value=0)

    def reduce_STAR_NumberConstant(self, *kids):
        self.val = kids[1].val

    def reduce_empty(self, *kids):
        self.val = None


class PointerGlob(Nonterm):
    def reduce_STAR(self, *kids):
        flt = qlast.PointerGlobFilter(property='loading', value='eager')
        self.val = qlast.PointerGlobNode(filters=[flt], type='link')

    def reduce_STAR_LPAREN_PointerGlobFilterList_RPAREN(self, *kids):
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_SimpleSelect_OptSelectLimit(self, *kids):
        qry = kids[0].val
        qry.offset = kids[1].val[0]
        qry.limit = kids[1].val[1]
        self.val = qry

    def reduce_SelectClause_SortClause_OptSelectLimit(self, *kids):
        qry = kids[0].val
        qry.orderby = kids[1].val
        qry.offset = kids[2].val[0]
        qry.limit = kids[2].val[1]

        self.val = qry


class WithClause(Nonterm):
    def reduce_WITH_CgeList(self, *kids):
        self.val = kids[1].val


class CgeList(Nonterm):
    def reduce_Cge(self, *kids):
        self.val = [kids[0].val]

    def reduce_CgeList_COMMA_Cge(self, *kids):
        self.val = kids[0].val + [kids[2].val]


class Cge(Nonterm):
    def reduce_AnchorName_AS_LPAREN_SelectStmt_RPAREN(self, *kids):
        self.val = qlast.CGENode(expr=kids[3].val, alias=kids[0].val)
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
self.val = qlast.SelectPathSpecNode(
            expr=qlast.LinkExprNode(expr=kids[0].val),
            where=kids[1].val
        )


class TransformedLinkedSetExpr(Nonterm):
    def reduce_QualifiedLinkedSetExpr_OptSortClause_OptSelectLimit(
                                                self, *kids):
        self.val = kids[0].val
        self.val.orderby = kids[1].val
        self.val.offset = kids[2].val[0]
        self.val.limit = kids[2].val[1]


class ParenthesizedTransformedLinkedSetExpr(Nonterm):
    def reduce_LPAREN_TransformedLinkedSetExpr_RPAREN(self, *kids):
        self.val = kids[1].val


class OptPointerRecursionSpec(Nonterm):
    def reduce_STAR(self, *kids):
        self.val = qlast.ConstantNode(value=0)

    def reduce_STAR_NumberConstant(self, *kids):
        self.val = kids[1].val

    def reduce_empty(self, *kids):
        self.val = None


class PointerGlob(Nonterm):
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_LPAREN_AnyFqNodeName_RPAREN(self, *kids):
        self.val = kids[1].val

    def reduce_empty(self, *kids):
        self.val = None


class LinkDirection(Nonterm):
    def reduce_LANGBRACKET(self, *kids):
        self.val = caos_types.InboundDirection

    def reduce_RANGBRACKET(self, *kids):
        self.val = caos_types.OutboundDirection


class FuncApplication(Nonterm):
    def reduce_CAST_LPAREN_Expr_AS_TypeName_RPAREN(self, *kids):
        self.val = qlast.TypeCastNode(expr=kids[2].val, type=kids[4].val)

    def reduce_FqFuncName_LPAREN_FuncArgList_OptSortClause_RPAREN(self, *kids):
        self.val = qlast.FunctionCallNode(func=kids[0].val, args=kids[2].val,
                                          agg_sort=kids[3].val)

    def reduce_IDENT_LPAREN_FuncArgList_OptSortClause_RPAREN(self, *kids):
        func_name = kids[0].val
        args = kids[2].val

        if func_name == 'type':
            if len(args) != 1:
                msg = 'type() takes exactly one argument, {} given' \
                            .format(len(args))
                raise CaosQLSyntaxError(msg)
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_FuncArgList_COMMA_FuncArgExpr(self, *kids):
        self.val = kids[0].val + [kids[2].val]

    def reduce_empty(self, *kids):
        self.val = []


class AnyFqLinkPropName(Nonterm):
    def reduce_AnyFqNodeName(self, *kids):
        self.val = qlast.LinkNode(name=kids[0].val.name,
                                  namespace=kids[0].val.module,
                                  direction=caos_types.OutboundDirection,
                                  type='property')


class AnchorName(Nonterm):
    def reduce_LabelExpr(self, *kids):
        self.val = kids[0].val


class FqNodeName(Nonterm):
    def reduce_FqName(self, *kids):
        self.val = qlast.PrototypeRefNode(module='.'.join(kids[0].val[:-1]),
                                          name=kids[0].val[-1])


class AnyFqNodeName(Nonterm):
    # Fully-qualified node name permitting reserved keywords
    def reduce_AnyFqName(self, *kids):
        self.val = qlast.PrototypeRefNode(module='.'.join(kids[0].val[:-1]),
                                          name=kids[0].val[-1])
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_IDENT(self, *kids):
        self.val = kids[0].val

    def reduce_UnreservedKeyword(self, *kids):
        self.val = kids[0].val


class AnyLabelExpr(Nonterm):
    def reduce_LabelExpr(self, *kids):
        self.val = kids[0].val

    def reduce_ReservedKeyword(self, *kids):
        self.val = kids[0].val


class TypeName(Nonterm):
    def reduce_ArgName(self, *kids):
        self.val = kids[0].val

    def reduce_ArgName_LBRACKET_RBRACKET(self, *kids):
        self.val = (list, kids[0].val)


class ArgName(Nonterm):
    def reduce_SimpleArgName(self, *kids):
        self.val = kids[0].val

    def reduce_LBRACKET_AnyFqName_RBRACKET(self, *kids):
        self.val = '.'.join(kids[1].val)


class SimpleArgName(Nonterm):
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_PointerGlob(self, *kids):
        self.val = kids[0].val

    def reduce_AT_AnyFqLinkPropName(self, *kids):
        self.val = qlast.SelectPathSpecNode(
            expr=qlast.LinkExprNode(expr=kids[1].val)
        )

    def reduce_PointerSpecSetExpr_OptPointerRecursionSpec_OptSelectPathSpec(
                                                    self, *kids):
        self.val = kids[0].val
        self.val.recurse = kids[1].val
        self.val.pathspec = kids[2].val


class PointerSpecSetExpr(Nonterm):
    def reduce_ParenthesizedTransformedLinkedSetExpr(self, *kids):
        self.val = kids[0].val

    def reduce_SimpleFqLinkExpr(self, *kids):
        self.val = qlast.SelectPathSpecNode(
            expr=qlast.LinkExprNode(expr=kids[0].val)
        )

    def reduce_TYPEINDIRECTION_PathStepList(self, *kids):
        self.val = qlast.SelectTypeRefNode(
            attrs=kids[1].val
        )


class QualifiedLinkedSetExpr(Nonterm):
    def reduce_SimpleFqLinkExpr(self, *kids):
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_ExprList_COMMA_Expr(self, *kids):
        self.val = kids[0].val + [kids[2].val]


class InExpr(Nonterm):
    def reduce_LPAREN_ExprList_RPAREN(self, *kids):
        self.val = qlast.SequenceNode(elements=kids[1].val)

    def reduce_Path(self, *kids):
        self.val = kids[0].val

    def reduce_ArgConstant(self, *kids):
        self.val = kids[0].val


class IsExpr(Nonterm):
    def reduce_LPAREN_FqNodeNameList_RPAREN(self, *kids):
        self.val = qlast.SequenceNode(elements=kids[1].val)

    def reduce_FqNodeName(self, *kids):
        self.val = kids[0].val

    def reduce_ArgConstant(self, *kids):
        self.val = kids[0].val


class Constant(Nonterm):
    # BaseConstant
    # | BaseNumberConstant
    # | BaseStringConstant
    # | BaseBooleanConstant
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
self.val = [kids[0].val]

    def reduce_FqNodeNameList_COMMA_FqNodeName(self, *kids):
        self.val = kids[0].val + [kids[2].val]


class NodeName(Nonterm):
    def reduce_LabelExpr(self, *kids):
        self.val = qlast.PrototypeRefNode(name=kids[0].val)

    def reduce_LBRACKET_AnyFqName_RBRACKET(self, *kids):
        self.val = qlast.PrototypeRefNode(module='.'.join(kids[1].val[:-1]),
                                          name=kids[1].val[-1])


class FqName(Nonterm):
    def reduce_LabelExpr(self, *kids):
        self.val = [kids[0].val]

    def reduce_FqName_DOT_LabelExpr(self, *kids):
        self.val = kids[0].val + [kids[2].val]


class AnyFqName(Nonterm):
    def reduce_AnyLabelExpr(self, *kids):
        self.val = [kids[0].val]

    def reduce_AnyFqName_DOT_AnyLabelExpr(self, *kids):
        self.val = kids[0].val + [kids[2].val]


class FqFuncName(Nonterm):
github edgedb / edgedb / edgedb / lang / caosql / parser / caosql.py View on Github external
def reduce_PARTITION_BY_ExprList(self, *kids):
        self.val = kids[2].val

    def reduce_empty(self, *kids):
        self.val = None


class FuncArgExpr(Nonterm):
    def reduce_Expr(self, *kids):
        self.val = kids[0].val

    def reduce_ParamName_COLONEQUALS_Expr(self, *kids):
        self.val = qlast.NamedArgNode(name=kids[0].val, arg=kids[2].val)


class FuncArgList(Nonterm):
    def reduce_FuncArgExpr(self, *kids):
        self.val = [kids[0].val]

    def reduce_FuncArgList_COMMA_FuncArgExpr(self, *kids):
        self.val = kids[0].val + [kids[2].val]

    def reduce_empty(self, *kids):
        self.val = []


class AnyFqLinkPropName(Nonterm):
    def reduce_AnyFqNodeName(self, *kids):
        self.val = qlast.LinkNode(name=kids[0].val.name,
                                  namespace=kids[0].val.module,
                                  direction=caos_types.OutboundDirection,
                                  type='property')