static void Main(string[] args) { String input = @"(Type = 'Subject' AND ()Anatomical Region = 'Kidney' AND Type = 'Raw Image' AND Type Contains 'Clinical Study Data'))"; ExpressionEvaluatorGrammar grammar = new ExpressionEvaluatorGrammar(); Parser compiler = new Parser(grammar); var program = compiler.Parse(input); if (program.HasErrors()) { Console.WriteLine(input); foreach (var err in program.ParserMessages) { Console.WriteLine(string.Format("Line {0} , Column {1}", err.Location.Line, err.Location.Column)); Console.WriteLine(err.Message); //print message } System.Console.ReadLine(); return; } var generator = (IScriptGenerator)program.Root.AstNode; var js = new StringBuilder(); generator.GenerateScript(js); System.Console.WriteLine(js.ToString()); System.Console.ReadLine(); }
public Form1() { InitializeComponent(); grammar = new ExpressionEvaluatorGrammar(); compiler = new Parser(grammar); }
static void Main(string[] args) { Console.Title = "Irony Console Sample"; Console.WriteLine("Irony Console Sample."); Console.WriteLine(""); Console.WriteLine("Select a grammar to load:"); Console.WriteLine(" 1. Expression Evaluator"); Console.WriteLine(" 2. mini-Python"); Console.WriteLine(" Or press any other key to exit."); Console.WriteLine(""); Console.Write("?"); var choice = Console.ReadLine(); Grammar grammar; switch (choice) { case "1": grammar = new ExpressionEvaluatorGrammar(); break; case "2": grammar = new MiniPython.MiniPythonGrammar(); break; default: return; } Console.Clear(); var commandLine = new CommandLine(grammar); commandLine.Run(); }
public void TestNewScanner() { var grammar = new ExpressionEvaluatorGrammar(); var language = new LanguageData(grammar); var parser = new Parser(language); var ctx = new ParsingContext(parser); PrefixBasedScanner scanner = new PrefixBasedScanner(language); var src = @" # this is comment ""0123"".Substring(1) + ""abcd"".Length + ""456""[1] # expected '12345' "; var srcSegm = new TextSegment(src); var segments = scanner.Scan(ctx, srcSegm).ToList(); foreach (var segm in segments) { Debug.WriteLine(" Segment: " + segm.GetType().Name + ", " + segm.ToString()); } }