Class ErlPatternMatcher
Pattern matcher that implements a container of patterns to be matched against a given Erlang term. On successful match, the corresponding func registered with that pattern gets invoked
Inheritance
Implements
Inherited Members
Namespace: NFX.Erlang
Assembly: NFX.Erlang.dll
Syntax
public class ErlPatternMatcher : IEnumerable<ErlPatternMatcher.Pattern>, IEnumerable
Properties
PatternsToString
Declaration
public string PatternsToString { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
Add(IErlObject, PatternMatchFunc)
Add a matching pattern to the collection
Declaration
public int Add(IErlObject pattern, PatternMatchFunc func)
Parameters
Type | Name | Description |
---|---|---|
IErlObject | pattern | Erlang term to be used as a match pattern |
PatternMatchFunc | func | Function to invoke on successful match |
Returns
Type | Description |
---|---|
System.Int32 | ID of the newly added pattern |
Add(String, PatternMatchFunc)
Add a matching pattern to the collection
Declaration
public int Add(string pattern, PatternMatchFunc func)
Parameters
Type | Name | Description |
---|---|---|
System.String | pattern | Pattern to compile |
PatternMatchFunc | func | Function to invoke on successful match |
Returns
Type | Description |
---|---|
System.Int32 | ID of the newly added pattern |
Add<TContext>(TContext, IErlObject, PatternMatchFunc<TContext>)
Add a matching pattern to the collection
Declaration
public int Add<TContext>(TContext context, IErlObject pattern, PatternMatchFunc<TContext> func)
Parameters
Type | Name | Description |
---|---|---|
TContext | context | Context passed to func |
IErlObject | pattern | Compiled pattern containing variables to match |
PatternMatchFunc<TContext> | func | Function to invoke on successful match |
Returns
Type | Description |
---|---|
System.Int32 | ID of the newly added pattern |
Type Parameters
Name | Description |
---|---|
TContext | Type of context passed to func |
Add<TContext>(TContext, String, PatternMatchFunc<TContext>)
Add a matching pattern to the collection
Declaration
public int Add<TContext>(TContext context, string pattern, PatternMatchFunc<TContext> func)
Parameters
Type | Name | Description |
---|---|---|
TContext | context | Context passed to func |
System.String | pattern | Pattern to compile |
PatternMatchFunc<TContext> | func | Function to invoke on successful match |
Returns
Type | Description |
---|---|
System.Int32 | ID of the newly added pattern |
Type Parameters
Name | Description |
---|---|
TContext | Type of context passed to func |
Clear()
Clear the collection of patterns
Declaration
public void Clear()
Match(ref IErlObject, Object[])
Match a term against the patterns in the collection. The first successful match will result in invocation of the func associated with the pattern, and storing func result in the term
Declaration
public int Match(ref IErlObject term, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
IErlObject | term | Term to match against patterns |
System.Object[] | args | Arguments to be passed to an func on successful pattern match |
Returns
Type | Description |
---|---|
System.Int32 | ID of the pattern that matched, or -1 if there were no matches |
Remove(Int32)
Remove pattern from collection given its ID
Declaration
public void Remove(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Explicit Interface Implementations
IEnumerable<ErlPatternMatcher.Pattern>.GetEnumerator()
Declaration
IEnumerator<ErlPatternMatcher.Pattern> IEnumerable<ErlPatternMatcher.Pattern>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ErlPatternMatcher.Pattern> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |