예제 #1
0
파일: Parser.cs 프로젝트: ngbrown/Mcs3Rob
        public RobFile Read(string path)
        {
            using (var file = File.OpenRead(path))
            {
                var parser = new Mcs3RobParser();
                parser.Error += (sender, args) => Error?.Invoke(sender, args);
                parser.Parse(file);

                if (parser.AstFile == null)
                {
                    return(null);
                }

                try
                {
                    var astFile       = parser.AstFile;
                    var robFileHeader = ReadRobFileHeader(astFile.FileHeader);

                    return(new RobFile()
                    {
                        FileHeader = robFileHeader,
                        DeviceParams = ReadRobDeviceParams(astFile, robFileHeader.ControlUnitType),
                        Constants = ReadRobConstants(astFile),
                        Variables = ReadRobVariables(astFile),
                        CharacteristicMaps = ReadCharacteristicMaps(astFile),
                        RomTexts = ReadRomTexts(astFile),
                    });
                }
                catch (Exception e)
                {
                    this.OnError(new ErrorEventArgs(new ErrorContext(5, e)));
                    return(null);
                }
            }
        }
예제 #2
0
파일: Parser.cs 프로젝트: ngbrown/Mcs3Rob
        public string ParseAst(string path)
        {
            using (var file = File.OpenRead(path))
            {
                var parser = new Mcs3RobParser();
                parser.Error += (sender, args) => Error?.Invoke(sender, args);
                parser.Parse(file);

                return(parser.AstFile?.ToString());
            }
        }