1 // =================================
 2 // Copyright (c) 2024 Seppo Laakko
 3 // Distributed under the MIT license
 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 stateuchar 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 }