github.com/aretext/aretext@v1.3.0/input/engine/expression.go (about)

     1  package engine
     2  
     3  // Event is an input event.
     4  // This usually represents a keypress, but the compiled state machine doesn't assume
     5  // that the events have any particular meaning.
     6  type Event int64
     7  
     8  // CaptureId is an identifier for a subsequence of events.
     9  type CaptureId uint64
    10  
    11  // Expr is a regular expression that matches input events.
    12  type Expr interface{}
    13  
    14  // EventExpr matches a single input event.
    15  type EventExpr struct {
    16  	Event Event
    17  }
    18  
    19  // EventRangeExpr matches any event in the range [start, end].
    20  // The range boundaries are inclusive.
    21  type EventRangeExpr struct {
    22  	StartEvent Event
    23  	EndEvent   Event
    24  }
    25  
    26  // ConcatExpr matches a sequence of expressions.
    27  type ConcatExpr struct {
    28  	Children []Expr
    29  }
    30  
    31  // AltExpr matches any of a set of expressions.
    32  type AltExpr struct {
    33  	Children []Expr
    34  }
    35  
    36  // OptionExpr matches a child expression or an empty input sequence.
    37  type OptionExpr struct {
    38  	Child Expr
    39  }
    40  
    41  // StarExpr matches zero or more repetitions of a child expression.
    42  type StarExpr struct {
    43  	Child Expr
    44  }
    45  
    46  // CaptureExpr includes the matched child expression in a capture with the specified ID.
    47  // Captures must NOT be nested.
    48  type CaptureExpr struct {
    49  	CaptureId CaptureId
    50  	Child     Expr
    51  }