Exemplo n.º 1
0
 public void LineBreak()
 {
     StructLexer lexer = new StructLexer("struct BITMAPINFOHEADER {\n}\n");
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.String));
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.String));
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.OpenCurly));
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.CloseCurly));
     Assert.IsTrue(lexer.EndOfStream());
 }
Exemplo n.º 2
0
        [Test] public void LineBreak()
        {
            StructLexer lexer = new StructLexer("struct BITMAPINFOHEADER {\n}\n");

            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.String));
            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.String));
            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.OpenCurly));
            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.CloseCurly));
            Assert.IsTrue(lexer.EndOfStream());
        }
Exemplo n.º 3
0
        [Test] public void SimpleLexer()
        {
            StructLexer lexer = new StructLexer("struct BITMAPINFOHEADER { }");

            Assert.AreEqual(StructTokenType.String, lexer.PeekNextToken());
            Assert.AreEqual("struct", lexer.GetNextToken(StructTokenType.String));
            Assert.AreEqual(StructTokenType.String, lexer.PeekNextToken());
            Assert.AreEqual("BITMAPINFOHEADER", lexer.GetNextToken(StructTokenType.String));
            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.OpenCurly));
            Assert.IsTrue(lexer.CheckNextToken(StructTokenType.CloseCurly));
            Assert.IsTrue(lexer.EndOfStream());
        }
Exemplo n.º 4
0
 public void SimpleLexer()
 {
     StructLexer lexer = new StructLexer("struct BITMAPINFOHEADER { }");
     Assert.AreEqual(StructTokenType.String, lexer.PeekNextToken());
     Assert.AreEqual("struct", lexer.GetNextToken(StructTokenType.String));
     Assert.AreEqual(StructTokenType.String, lexer.PeekNextToken());
     Assert.AreEqual("BITMAPINFOHEADER", lexer.GetNextToken(StructTokenType.String));
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.OpenCurly));
     Assert.IsTrue(lexer.CheckNextToken(StructTokenType.CloseCurly));
     Assert.IsTrue(lexer.EndOfStream());
 }
Exemplo n.º 5
0
 private void LoadStructFile(string fileName, StructSourceContext context)
 {
     StructLexer lexer = new StructLexer(fileName, context.GetSourceText(fileName));
     while(!lexer.EndOfStream())
     {
         List<Attribute> attrs = new List<Attribute>();
         LoadAttributes(lexer, attrs);
         string token = lexer.GetNextToken(StructTokenType.String);
         if (token == "struct")
             LoadStruct(lexer, attrs);
         else if (token == "enum")
             LoadEnum(lexer, attrs);
         else if (token == "alias")
             LoadAlias(lexer, attrs);
         else if (token == "plugin")
             LoadPlugin(lexer);
         else if (token == "include")
         {
             string includeName = lexer.GetNextToken(StructTokenType.String);
             lexer.GetNextToken(StructTokenType.Semicolon);
             LoadStructFile(includeName, context);
         }
         else
             throw new Exception("Unexpected top-level item " + token);
     }
 }