Newer
Older
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.IO;
using SimpleScanner;
using ScannerHelper;
using System.Collections.Generic;
namespace GeneratedLexer
{
public class LexerAddon
{
public Scanner myScanner;
private byte[] inputText = new byte[255];
public int idCount = 0;
public int minIdLength = Int32.MaxValue;
public double avgIdLength = 0;
public int maxIdLength = 0;
public int sumInt = 0;
public double sumDouble = 0.0;
public List<string> idsInComment = new List<string>();
public LexerAddon(string programText)
{
using (StreamWriter writer = new StreamWriter(new MemoryStream(inputText)))
{
writer.Write(programText);
writer.Flush();
}
MemoryStream inputStream = new MemoryStream(inputText);
myScanner = new Scanner(inputStream);
}
public void Lex()
{
// 3.14 ( 3,14 Culture)
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
int tok = 0;
do {
tok = myScanner.yylex();
if (tok == (int)Tok.EOF)
{
break;
}
} while (true);
}
}
}