예제 #1
0
        [Test] public void IncludeStructFile()
        {
            StructSourceContext context = new StructSourceContext();

            context.AddSourceText("a.strs", "include b.strs; struct A { enum8 [enum=E] q; }");
            context.AddSourceText("b.strs", "enum E { z, x, c }");
            StructParser parser = new StructParser();
            StructFile   file   = parser.LoadStructs("a.strs", context);

            Assert.IsNotNull(file);
            Assert.AreEqual(0, parser.Errors.Count);
            EnumDef e = file.GetEnumByName("E");

            Assert.AreEqual("c", e.ValueToString(2));
        }
예제 #2
0
        private void ParseStructures()
        {
            StructParser parser = new StructParser();

            try
            {
                StructSourceContext context = new StructSourceContext();
                context.BaseDirectory = Path.GetDirectoryName(_structFileName);
                context.AddSourceText(_structFileName, _structEditControl.Text);
                _structFile = parser.LoadStructs(_structFileName, context);
            }
            catch (ParseException ex)
            {
                MessageBox.Show(this, "Error in " + ex.Position + ": " + ex.Message);
                List <ParseException> list = new List <ParseException>();
                list.Add(ex);
                HighlightErrors(list.AsReadOnly());
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error loading structures: " + ex.Message);
            }
            HighlightErrors(parser.Errors);
            if (parser.Errors.Count > 0)
            {
                ParseException ex = parser.Errors[0];
                MessageBox.Show(this, "Error in " + ex.Position + ": " + ex.Message);
            }
        }
예제 #3
0
 public void IncludeStructFile()
 {
     StructSourceContext context = new StructSourceContext();
     context.AddSourceText("a.strs", "include b.strs; struct A { enum8 [enum=E] q; }");
     context.AddSourceText("b.strs", "enum E { z, x, c }");
     StructParser parser = new StructParser();
     StructFile file = parser.LoadStructs("a.strs", context);
     Assert.IsNotNull(file);
     Assert.AreEqual(0, parser.Errors.Count);
     EnumDef e = file.GetEnumByName("E");
     Assert.AreEqual("c", e.ValueToString(2));
 }