def patterns(): """ Return a list of the patterns that appear n the match expressions's arms. """ return Self.arms.map(lambda x: x.pattern.as_entity) lkql_grammar = Grammar('main_rule') G = lkql_grammar # noinspection PyTypeChecker lkql_grammar.add_rules( main_rule=List(Or(G.decl, G.expr), list_cls=TopLevelList), query=Query("select", c(), G.pattern), pattern=Or(FilteredPattern(G.unfiltered_pattern_optional_chain, "when", G.expr), G.unfiltered_pattern_optional_chain), unfiltered_pattern_optional_chain=Or( ChainedNodePattern( G.unfiltered_pattern, List(Or( SelectorLink(G.selector_call, "is", G.unfiltered_pattern), FieldLink(".", G.identifier, "=", G.unfiltered_pattern), PropertyLink(".", G.fun_call, "is", G.unfiltered_pattern) )) ),
class Tuple(Expr): """ Tuple expression. """ exprs = Field(type=Expr.list) lkql_grammar = Grammar('main_rule') G = lkql_grammar # noinspection PyTypeChecker lkql_grammar.add_rules( main_rule=List(Or(G.decl, G.expr), list_cls=TopLevelList), query=Query(Opt("from", Or(G.expr, Unpack("*", G.expr))), "select", c(), G.pattern), pattern=Or( ChainedNodePattern( G.filtered_pattern, List( Or(SelectorLink(G.selector_call, "is", G.filtered_pattern), FieldLink(".", G.id, "is", G.filtered_pattern), PropertyLink(".", G.fun_call, "is", G.filtered_pattern)))), G.filtered_pattern), filtered_pattern=Or(FilteredPattern(G.binding_pattern, "when", G.expr), G.binding_pattern), binding_pattern=Or(BindingPattern(G.id, "@", G.value_pattern), G.value_pattern), value_pattern=Or( ExtendedNodePattern(
# noinspection PyTypeChecker lkql_grammar.add_rules( main_rule=List( Or(G.import_clause, G.decl, G.expr), list_cls=TopLevelList, empty_valid=True ), import_clause=Import("import", G.id), query=Query( Opt( "from", Or(G.expr, Unpack("*", G.expr)) ), "select", c(), Or( QueryKind.alt_first(L.Identifier(match_text="first")), QueryKind.alt_all(), ), G.pattern ), pattern=Or( OrPattern( G.chained_node_pattern, "or", G.pattern ), G.chained_node_pattern ), chained_node_pattern=Or(
Tuple expression. """ exprs = Field(type=Expr.list) lkql_grammar = Grammar('main_rule') G = lkql_grammar # noinspection PyTypeChecker lkql_grammar.add_rules( main_rule=List(Or(G.import_clause, G.decl, G.expr), list_cls=TopLevelList, empty_valid=True), import_clause=Import("import", G.id), query=Query( Opt("from", Or(G.expr, Unpack("*", G.expr))), "select", c(), Or( QueryKind.alt_first(L.Identifier(match_text="first")), QueryKind.alt_all(), ), G.pattern), pattern=Or(OrPattern(G.chained_node_pattern, "or", G.pattern), G.chained_node_pattern), chained_node_pattern=Or( ChainedNodePattern( G.filtered_pattern, List( Or(SelectorLink(G.selector_call, "is", G.filtered_pattern), FieldLink(".", G.id, "is", G.filtered_pattern), PropertyLink(".", G.fun_call, "is", G.filtered_pattern)))), G.filtered_pattern), filtered_pattern=Or(FilteredPattern(G.binding_pattern, "when", G.expr),