Pattern Matching

Patterns can match against streams of any objects. There are many primitive pattern expressions that can be combined together to form more complex patterns.


Name Syntax
And x y z
Or x | y | z
Character 'x'
String "xyz"
Number 7 or 7.11 or 0xFF
Range "a".."z" or 0..100
Bool true or false
Array [ x y z ]
Object x { y = z }
Any any
Default default
Fail fail
Reference x or self.x or super.x
Variable x:X
Production x -> y
  • The any keyword matches exactly one of anything in the stream, if the stream is empty it returns fail.
  • The default pattern always matches, even if the stream is empty, and consumes nothing from the stream. It is especially useful for the last pattern in an Or clause.

Last edited Nov 24, 2012 at 5:10 PM by justinc, version 1


No comments yet.