object JPatterns
Java support for pattern matching terms and types using the java-patterns library.
E.g., the following Java code will assign the name of the constant/free variable/schematic variable term to name:
import de.unruh.javapatterns.Capture; import static de.unruh.javapatterns.Pattern.capture; import static de.unruh.javapatterns.Patterns.Any; import static de.unruh.javapatterns.Match.match; import static de.unruh.isabelle.java.JPatterns.*; Capture<String> x = capture("x"); String name = match(term, Const(x,Any), () -> x, Free(x,Any), () -> x, Var(x,Any,Any), () -> x);
See de.unruh.javapatterns.Match for general instructions how to do pattern matching using the java-patterns library.
Patterns for terms are Const, App, Free, Var, Abs, Bound. Patterns for types are Type, TFree, TVar.
- Source
- JPatterns.scala
- Alphabetic
- By Inheritance
- JPatterns
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
Abs(name: Pattern[_ >: String], typ: Pattern[_ >: Typ], body: Pattern[_ >: Term]): Pattern[Term]
Pattern matching a lambda abstraction (Abs)
a. -
def
App(fun: Pattern[_ >: Term], arg: Pattern[_ >: Term]): Pattern[Term]
Pattern matching a function application term (App)
a. -
def
Bound(index: Int): Pattern[Term]
Short for
Bound(Is(index)).Short for
Bound(Is(index)). That is, matches a constant with indexindex.- Annotations
- @NotNull()
-
def
Bound(index: Pattern[_ >: Int]): Pattern[Term]
Pattern matching a bound (de Bruijn) variable (Bound)
v. -
def
Const(name: String, typ: Pattern[_ >: Typ]): Pattern[Term]
Short for
Const(Is(name),typ).Short for
Const(Is(name),typ). That is, matches a constant with namename.- Annotations
- @NotNull()
-
def
Const(name: Pattern[_ >: String], typ: Pattern[_ >: Typ]): Pattern[Term]
Pattern matching a constant (Const)
c. -
def
Free(name: String, typ: Pattern[_ >: Typ]): Pattern[Term]
Short for
Free(Is(name),typ).Short for
Free(Is(name),typ). That is, matches a free variable with namename.- Annotations
- @NotNull()
-
def
Free(name: Pattern[_ >: String], typ: Pattern[_ >: Typ]): Pattern[Term]
Pattern matching a free variable (Free)
v. -
def
TFree(name: String, sort: Pattern[_ >: Array[String]]): Pattern[Typ]
Short for
TFree(Is(name),sort).Short for
TFree(Is(name),sort). That is, matches a free type variable with namename.- Annotations
- @NotNull()
-
def
TFree(name: Pattern[_ >: String], sort: Pattern[_ >: Array[String]]): Pattern[Typ]
Pattern matching a free type variable (TFree)
v. -
def
TVar(name: String, index: Int, sort: Pattern[_ >: Array[String]]): Pattern[Typ]
Short for
Var(Is(name),Is(index),typ).Short for
Var(Is(name),Is(index),typ). That is, matches a schematic variable with namenameand indexindex.- Annotations
- @NotNull()
-
def
TVar(name: Pattern[_ >: String], index: Pattern[_ >: Int], sort: Pattern[_ >: Array[String]]): Pattern[Typ]
Pattern matching a schematic type variable (TVar)
v. -
def
Type(name: Pattern[_ >: String], args: Pattern[_ >: Array[Typ]]): Pattern[Typ]
Pattern matching a type constructor (Type)
t. -
def
Type(name: String, args: Pattern[_ >: Typ]*): Pattern[Typ]
Short for
Type(Is(name),args).Short for
Type(Is(name),args). That is, matches a type with type constructornameand exactlyargs.lengthtype arguments.- Annotations
- @NotNull() @varargs()
-
def
Type(name: Pattern[_ >: String], args: Pattern[_ >: Typ]*): Pattern[Typ]
Pattern matching a type constructor (Type)
t.Pattern matching a type constructor (Type)
t. Subpatternnamewill be applied tot.name, and the n subpatternsargswill be applied to the n type argumentst.pure.Type.args. (Iftdoes not have n type arguments, the pattern does not match.)- Annotations
- @NotNull() @varargs()
-
def
Var(name: String, index: Int, typ: Pattern[_ >: Typ]): Pattern[Term]
Short for
Var(Is(name),Is(index),typ).Short for
Var(Is(name),Is(index),typ). That is, matches a schematic variable with namenameand indexindex.- Annotations
- @NotNull()
-
def
Var(name: Pattern[_ >: String], index: Pattern[_ >: Int], typ: Pattern[_ >: Typ]): Pattern[Term]
Pattern matching a schematic variable (Var)
v. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )