PerCederberg.Grammatica.Parser.RE
Class AlternativeElement
ICloneable
|
+--Element
|
+--AlternativeElement
in AlternativeElement.cs
- class AlternativeElement
- extends Element
A regular expression alternative element. This element matches
the longest alternative element.
Method Summary |
override object |
Clone()
Creates a copy of this element. |
override int |
Match( Matcher m, string str, int start, int skip )
Returns the length of a matching string starting at the
specified position. |
override void |
PrintTo( TextWriter output, string indent )
Prints this element to the specified output stream. |
AlternativeElement
public AlternativeElement( Element first, Element second );
- Creates a new alternative element.
- Parameters:
first
- the first alternative
second
- the second alternative
Clone
public override object Clone();
- Creates a copy of this element. The copy will be an
instance of the same class matching the same strings.
Copies of elements are necessary to allow elements to cache
intermediate results while matching strings without
interfering with other threads.
- Returns:
- a copy of this element
Match
public override int Match( Matcher m, string str, int start, int skip );
- Returns the length of a matching string starting at the
specified position. The number of matches to skip can also
be specified, but numbers higher than zero (0) cause a
failed match for any element that doesn't attempt to
combine other elements.
- Parameters:
m
- the matcher being used
str
- the string to match
start
- the starting position
skip
- the number of matches to skip
- Returns:
- the length of the longest matching string, or
-1 if no match was found
PrintTo
public override void PrintTo( TextWriter output, string indent );
- Prints this element to the specified output stream.
- Parameters:
output
- the output stream to use
indent
- the current indentation