From 8f0ae9731d40ff106e230e174f79eb2b9e3e81b6 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 7 Nov 2011 12:00:38 -0500 Subject: [PATCH] Wildcard, plus parsing of it. --- pymbolic/parser.py | 5 ++++- pymbolic/primitives.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pymbolic/parser.py b/pymbolic/parser.py index 9a067df..bfc4f55 100644 --- a/pymbolic/parser.py +++ b/pymbolic/parser.py @@ -66,7 +66,10 @@ def parse(expr_str): def parse_expression(pstate, min_precedence=0): pstate.expect_not_end() - if pstate.is_next(_minus): + if pstate.is_next(_times): + pstate.advance() + left_exp = primitives.Wildcard() + elif pstate.is_next(_minus): pstate.advance() left_exp = -parse_expression(pstate, _PREC_UNARY_MINUS) elif pstate.is_next(_openpar): diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index 825ebd1..a04a0c5 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -259,6 +259,17 @@ class Variable(Leaf): +class Wildcard(Leaf): + def is_equal(self, other): + return (other.__class__ == self.__class__ + and self.name == other.name) + + def get_hash(self): + return hash((self.__class__, self.name)) + + mapper_method = intern("map_wildcard") + + class FunctionSymbol(AlgebraicLeaf): """Represents the name of a function. -- GitLab