Example #1
0
        public object RunLexer(string configuration)
        {
            var antlrInputStream       = new AntlrInputStream(configuration);
            var deviceSimulationLexer  = new DeviceSimulationLexer(antlrInputStream);
            var commonTokenStream      = new CommonTokenStream(deviceSimulationLexer);
            var deviceSimulationParser = new DeviceSimulationParser(commonTokenStream);

            var tree    = deviceSimulationParser.compileUnit();
            var visitor = new SimpleDeviceSimulationVisitor();

            return(visitor.Visit(tree));
        }
Example #2
0
        public IDictionary <string, object> RunLexer(string configuration)
        {
            ServiceLocator.BuildServiceProvider();

            var antlrInputStream       = new AntlrInputStream(configuration);
            var deviceSimulationLexer  = new DeviceSimulationLexer(antlrInputStream);
            var commonTokenStream      = new CommonTokenStream(deviceSimulationLexer);
            var deviceSimulationParser = new DeviceSimulationParser(commonTokenStream);

            deviceSimulationParser.AddParseListener(new DeviceListener());

            deviceSimulationParser.program();

            var stateService = ServiceLocator.GetRequiredService <IStateService>();

            return(stateService.ToDictionary());
        }