-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
32 lines (29 loc) · 1.23 KB
/
Program.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
using System;
using System.IO;
using MultiGrammar.Expression;
using MultiGrammar.Query;
using bsn.GoldParser.Grammar;
using bsn.GoldParser.Parser;
using bsn.GoldParser.Semantic;
namespace MultiGrammar {
internal class Program {
private static void Main(string[] args) {
SemanticTypeActions<QueryToken> queryActions = new SemanticTypeActions<QueryToken>(CompiledGrammar.Load(typeof(QueryToken), "Query.cgt"));
queryActions.Initialize(true);
SemanticTypeActions<ExpressionToken> expressionActions = new SemanticTypeActions<ExpressionToken>(CompiledGrammar.Load(typeof(ExpressionToken), "Expression.cgt"));
expressionActions.Initialize(true);
string input = "VIEW a WHERE x = 20 ORDER BY y";
using (StringReader reader = new StringReader(input)) {
QueryProcessor processor = new QueryProcessor(new QueryTokenizer(reader, queryActions, expressionActions));
ParseMessage message = processor.ParseAll();
Console.WriteLine("Parsing result: "+message);
if (message != ParseMessage.Accept) {
Console.WriteLine(input);
Console.Write(new string(' ', (int)((IToken)processor.CurrentToken).Position.Index));
Console.WriteLine('^');
}
}
Console.ReadKey(false);
}
}
}