1
2
3
4
5
6 using System;
7 using System.Collections;
8
9 namespace System.Lex
10 {
11 public class TrivialLexer : System.Lex.Lexer
12 {
13 public TrivialLexer(const uchar* start_, const uchar* end_, const string& fileName_) : base(start_, end_, fileName_, string())
14 {
15 }
16 public override int NextState(int state, uchar c)
17 {
18 token.id = cast<int>(c);
19 token.match = lexeme;
20 if (c == '\n')
21 {
22 ++line;
23 }
24 return -1;
25 }
26 }
27
28 public string GetTrivialTokenInfo(int tokenId)
29 {
30 if (tokenId == System.Lex.END_TOKEN)
31 {
32 return "end of file";
33 }
34 return ToString(tokenId);
35 }
36 }