-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInputEndToken.cs
40 lines (31 loc) · 1.03 KB
/
InputEndToken.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace regexer {
/** The InputEndToken makes sure that the match ends and the end of the
* input string.
*
* For example, the input "aaaa" when matched by the pattern "a$" produces
* only one match, the last "a", whereas the pattern "a" matches all the "a"s;
* the pattern "a$a" does not match at all.
*
* \todo add support for single line/multiline regexes
*/
class InputEndToken : Token {
/* Creates a new InputStartToken
*/
public InputEndToken( )
: base( TokenType.InputEnd, "$" ) { }
public override bool Matches( string input, ref int cursor ) {
return cursor == input.Length;
}
public override bool CanBacktrack( string input, ref int cursor ) {
return false;
}
protected override string printContent( ) {
return string.Empty;
}
}
}