Exemplo n.º 1
0
 public FSM(LaconfigLexer lex)
 {
     lexer  = lex;
     source = lexer.Source;
     tokens = lexer.m_Tokens;
     srcRef = lexer.SourceCodeReference;
 }
Exemplo n.º 2
0
        public void ePrematureEOF_Thrown()
        {
          var src = @"";

          var lxr = new LL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Exemplo n.º 3
0
        public void String_Escapes2()
        {
            var src = @"{'str\'ing'}";

            var lxr = new LL(new StringSource(src));

            Aver.AreEqual(@"str'ing", lxr.ElementAt(2).Text);
        }
Exemplo n.º 4
0
        public void eUnterminatedString2()
        {
            var src = @"a: ""aaaa";

            var lxr = new LL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Exemplo n.º 5
0
        public void String_Escapes1()
        {
            var src = @"{""str\""ing""}";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(@"str""ing", lxr.ElementAt(2).Text);
        }
Exemplo n.º 6
0
        public void String_Escapes2_2()
        {
            var src = @"a{ n = 'string\''}";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(@"string'", lxr.ElementAt(5).Text);
        }
Exemplo n.º 7
0
        public void String_Escapes3()
        {
            var src = @"{'str\n\rring'}";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual("str\n\rring", lxr.ElementAt(2).Text);
        }
Exemplo n.º 8
0
        public void String_Escapes5_Unicode()
        {
            var src = @"{""str\u8978ring""}";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Exemplo n.º 9
0
        public void ePrematureEOF_Thrown()
        {
            var src = @"";

            var lxr = new LL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Exemplo n.º 10
0
        public void String_Escapes4_Unicode()
        {
            var src = @"{'str\u8978ring'}";

            var lxr = new LL(new StringSource(src));

            Aver.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Exemplo n.º 11
0
        public void BOF_EOF()
        {
          var src = @"a";

          var lxr = new LL(new StringSource(src));

          var expected = new LaconfigTokenType[]{LaconfigTokenType.tBOF, LaconfigTokenType.tIdentifier, LaconfigTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Exemplo n.º 12
0
        public void String2()
        {
            var src = @"{""string""}";

            var lxr = new LL(new StringSource(src));

            var expected = new LaconfigTokenType[] { LaconfigTokenType.tBOF, LaconfigTokenType.tBraceOpen, LaconfigTokenType.tStringLiteral, LaconfigTokenType.tBraceClose, LaconfigTokenType.tEOF };

            Assert.IsTrue(lxr.Select(t => t.Type).SequenceEqual(expected));
        }
Exemplo n.º 13
0
        public void BOF_EOF()
        {
            var src = @"a";

            var lxr = new LL(new StringSource(src));

            var expected = new LaconfigTokenType[] { LaconfigTokenType.tBOF, LaconfigTokenType.tIdentifier, LaconfigTokenType.tEOF };

            Assert.IsTrue(lxr.Select(t => t.Type).SequenceEqual(expected));
        }
Exemplo n.º 14
0
        public void eUnterminatedString4_Verbatim()
        {
            var src = @"a: $'aa
          
          aa";

            var lxr = new LL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Exemplo n.º 15
0
        public void eUnterminatedComment1()
        {
            var src = @"a: /*aa
          
          aa";

            var lxr = new LL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Exemplo n.º 16
0
        public void Comments8()
        {
            var src = @"{
          /* //comment text " + "\r\n" + @" */
          }
          ";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(" //comment text \r\n ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 17
0
        public void Comments9()
        {
            var src = @"{
          /* //comment text " + "\n\r" + @" */
          }
          ";

            var lxr = new LL(new StringSource(src));

            Aver.AreEqual(" //comment text \n\r ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 18
0
        public void Comments4()
        {
            var src = @"{
           //comment text
          }
          ";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual("comment text", lxr.ElementAt(2).Text);
        }
Exemplo n.º 19
0
        public void Comments10()
        {
            var src = @"{       
          |* /* //comment text " + "\n\r" + @" */ *|
          }
          ";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(" /* //comment text \n\r */ ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 20
0
        public void ePrematureEOF_CouldLogButThrown()
        {
          var src = @"";

          var msgs = new MessageList();

          var lxr = new LL(new StringSource(src), msgs, throwErrors: true);
          lxr.AnalyzeAll();

          Assert.IsNotNull(msgs.FirstOrDefault(m => m.Type == MessageType.Error && m.Code == (int)LaconfigMsgCode.ePrematureEOF));
        }
Exemplo n.º 21
0
        public void Comments13withStrings()
        {
            var src = @"{       
          |*'aaaa /* //comment""text " + "\n\r" + @" */ *|
          }
          ";
            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(LaconfigTokenType.tComment, lxr.ElementAt(2).Type);
            Assert.AreEqual("'aaaa /* //comment\"text \n\r */ ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 22
0
        public void ePrematureEOF_CouldLogButThrown()
        {
            var src = @"";

            var msgs = new MessageList();

            var lxr = new LL(new StringSource(src), msgs, throwErrors: true);

            lxr.AnalyzeAll();

            Assert.IsNotNull(msgs.FirstOrDefault(m => m.Type == MessageType.Error && m.Code == (int)LaconfigMsgCode.ePrematureEOF));
        }
Exemplo n.º 23
0
        public void ePrematureEOF_Logged()
        {
            var src = @"";

            var msgs = new MessageList();

            var lxr = new LL(new StringSource(src), msgs);

            lxr.AnalyzeAll();

            Aver.IsNotNull(msgs.FirstOrDefault(m => m.Type == MessageType.Error && m.Code == (int)LaconfigMsgCode.ePrematureEOF));
        }
Exemplo n.º 24
0
        public void Comments11withStrings()
        {
            var src = @"{       
          $'|* /* //comment text " + "\n\r" + @" */ *|'
          }
          ";

            var lxr = new LL(new StringSource(src));

            Assert.AreEqual(LaconfigTokenType.tStringLiteral, lxr.ElementAt(2).Type);
            Assert.AreEqual("|* /* //comment text \n\r */ *|", lxr.ElementAt(2).Text);
        }
Exemplo n.º 25
0
        public void Comments12withStrings()
        {
            //string is opened but line break
            var src = @"{       
          '|* /* //comment text " + "\n\r" + @" */ *|'
          }
          ";

            var lxr = new LL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Exemplo n.º 26
0
        public void Comments2()
        {
            var src = @"{
           /*'string'}*/
          }
          ";

            var lxr = new LL(new StringSource(src));

            var expected = new LaconfigTokenType[] { LaconfigTokenType.tBOF, LaconfigTokenType.tBraceOpen, LaconfigTokenType.tComment, LaconfigTokenType.tBraceClose, LaconfigTokenType.tEOF };

            Assert.IsTrue(lxr.Select(t => t.Type).SequenceEqual(expected));
        }
Exemplo n.º 27
0
        public void TokenClassifications()
        {
            var src = @"a 'string' = 12 {} //comment";

            var tokens = new LL(new StringSource(src)).Tokens;

            Assert.IsTrue(tokens[0].IsBOF);
            Assert.IsTrue(tokens[0].IsNonLanguage);
            Assert.IsFalse(tokens[0].IsPrimary);
            Assert.AreEqual(TokenKind.BOF, tokens[0].Kind);

            Assert.AreEqual(LaconfigTokenType.tIdentifier, tokens[1].Type);
            Assert.IsFalse(tokens[1].IsNonLanguage);
            Assert.IsTrue(tokens[1].IsPrimary);
            Assert.AreEqual(TokenKind.Identifier, tokens[1].Kind);

            Assert.AreEqual(LaconfigTokenType.tStringLiteral, tokens[2].Type);
            Assert.IsFalse(tokens[2].IsNonLanguage);
            Assert.IsTrue(tokens[2].IsPrimary);
            Assert.IsTrue(tokens[2].IsTextualLiteral);
            Assert.AreEqual(TokenKind.Literal, tokens[2].Kind);

            Assert.AreEqual(LaconfigTokenType.tEQ, tokens[3].Type);
            Assert.IsFalse(tokens[3].IsNonLanguage);
            Assert.IsTrue(tokens[3].IsPrimary);
            Assert.IsTrue(tokens[3].IsOperator);
            Assert.AreEqual(TokenKind.Operator, tokens[3].Kind);


            Assert.AreEqual(LaconfigTokenType.tIdentifier, tokens[4].Type);
            Assert.IsFalse(tokens[4].IsNonLanguage);
            Assert.IsTrue(tokens[4].IsPrimary);
            Assert.AreEqual(TokenKind.Identifier, tokens[4].Kind);

            Assert.AreEqual(LaconfigTokenType.tBraceOpen, tokens[5].Type);
            Assert.IsFalse(tokens[5].IsNonLanguage);
            Assert.IsTrue(tokens[5].IsPrimary);
            Assert.AreEqual(TokenKind.Symbol, tokens[5].Kind);

            Assert.AreEqual(LaconfigTokenType.tBraceClose, tokens[6].Type);
            Assert.IsFalse(tokens[6].IsNonLanguage);
            Assert.IsTrue(tokens[6].IsPrimary);
            Assert.AreEqual(TokenKind.Symbol, tokens[6].Kind);

            Assert.AreEqual(LaconfigTokenType.tComment, tokens[7].Type);
            Assert.IsFalse(tokens[7].IsNonLanguage);
            Assert.IsFalse(tokens[7].IsPrimary);
            Assert.IsTrue(tokens[7].IsComment);
            Assert.AreEqual(TokenKind.Comment, tokens[7].Kind);
        }
Exemplo n.º 28
0
        public void Comments11withStrings()
        {
          var src = @"{       
          $'|* /* //comment text "+"\n\r"+@" */ *|'
          }
          ";

          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(LaconfigTokenType.tStringLiteral, lxr.ElementAt(2).Type);
          Assert.AreEqual("|* /* //comment text \n\r */ *|", lxr.ElementAt(2).Text);
        }
Exemplo n.º 29
0
        public void Comments10()
        {
          var src = @"{       
          |* /* //comment text "+"\n\r"+@" */ *|
          }
          ";

          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(" /* //comment text \n\r */ ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 30
0
        public void Comments13withStrings()
        {
          var src = @"{       
          |*'aaaa /* //comment""text "+"\n\r"+@" */ *|
          }
          ";
          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(LaconfigTokenType.tComment, lxr.ElementAt(2).Type);
          Assert.AreEqual("'aaaa /* //comment\"text \n\r */ ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 31
0
        public void Comments12withStrings()
        {
          //string is opened but line break
          var src = @"{       
          '|* /* //comment text "+"\n\r"+@" */ *|'
          }
          ";

          var lxr = new LL(new StringSource(src));

          lxr.AnalyzeAll();
        }
Exemplo n.º 32
0
        public void String2()
        {
          var src = @"{""string""}";

          var lxr = new LL(new StringSource(src));

          var expected = new LaconfigTokenType[]{LaconfigTokenType.tBOF, LaconfigTokenType.tBraceOpen, LaconfigTokenType.tStringLiteral, LaconfigTokenType.tBraceClose, LaconfigTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Exemplo n.º 33
0
        public void eUnterminatedComment1()
        {
          var src = @"a: /*aa
          
          aa";

          var lxr = new LL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Exemplo n.º 34
0
        public void eUnterminatedString4_Verbatim()
        {
          var src = @"a: $'aa
          
          aa";

          var lxr = new LL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Exemplo n.º 35
0
 public LaconfigToken(LaconfigLexer lexer, LaconfigTokenType type, SourcePosition startPos, SourcePosition endPos, string text, object value = null) :
     base(lexer, startPos, endPos, text, value)
 {
     Type = type;
 }
Exemplo n.º 36
0
        public void String_Escapes2_2()
        {
          var src = @"a{ n = 'string\''}";
                                               
          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(@"string'", lxr.ElementAt(5).Text);
        }
Exemplo n.º 37
0
        public void String_Escapes1()
        {
          var src = @"{""str\""ing""}";
                                              
          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(@"str""ing", lxr.ElementAt(2).Text);
        }
Exemplo n.º 38
0
        public void String_Escapes3()
        {
          var src = @"{'str\n\rring'}";
                                               
          var lxr = new LL(new StringSource(src));

          Assert.AreEqual("str\n\rring", lxr.ElementAt(2).Text);
        }
Exemplo n.º 39
0
        public void String_Escapes5_Unicode()
        {
          var src = @"{""str\u8978ring""}";
                                               
          var lxr = new LL(new StringSource(src));

          Assert.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Exemplo n.º 40
0
        public void TokenClassifications()
        {
          var src = @"a 'string' = 12 {} //comment";

          var tokens = new LL(new StringSource(src)).Tokens;

          Assert.IsTrue( tokens[0].IsBOF);
          Assert.IsTrue( tokens[0].IsNonLanguage);
          Assert.IsFalse( tokens[0].IsPrimary);
          Assert.AreEqual(TokenKind.BOF, tokens[0].Kind);

          Assert.AreEqual( LaconfigTokenType.tIdentifier, tokens[1].Type);
          Assert.IsFalse( tokens[1].IsNonLanguage);
          Assert.IsTrue( tokens[1].IsPrimary);
          Assert.AreEqual(TokenKind.Identifier, tokens[1].Kind);

          Assert.AreEqual( LaconfigTokenType.tStringLiteral, tokens[2].Type);
          Assert.IsFalse( tokens[2].IsNonLanguage);
          Assert.IsTrue( tokens[2].IsPrimary);
          Assert.IsTrue( tokens[2].IsTextualLiteral);
          Assert.AreEqual(TokenKind.Literal, tokens[2].Kind);

          Assert.AreEqual( LaconfigTokenType.tEQ, tokens[3].Type);
          Assert.IsFalse( tokens[3].IsNonLanguage);
          Assert.IsTrue( tokens[3].IsPrimary);
          Assert.IsTrue( tokens[3].IsOperator);
          Assert.AreEqual(TokenKind.Operator, tokens[3].Kind);


          Assert.AreEqual( LaconfigTokenType.tIdentifier, tokens[4].Type);
          Assert.IsFalse( tokens[4].IsNonLanguage);
          Assert.IsTrue( tokens[4].IsPrimary);
          Assert.AreEqual(TokenKind.Identifier, tokens[4].Kind);

          Assert.AreEqual( LaconfigTokenType.tBraceOpen, tokens[5].Type);
          Assert.IsFalse( tokens[5].IsNonLanguage);
          Assert.IsTrue( tokens[5].IsPrimary);
          Assert.AreEqual(TokenKind.Symbol, tokens[5].Kind);

          Assert.AreEqual( LaconfigTokenType.tBraceClose, tokens[6].Type);
          Assert.IsFalse( tokens[6].IsNonLanguage);
          Assert.IsTrue( tokens[6].IsPrimary);
          Assert.AreEqual(TokenKind.Symbol, tokens[6].Kind);

          Assert.AreEqual( LaconfigTokenType.tComment, tokens[7].Type);
          Assert.IsFalse( tokens[7].IsNonLanguage);
          Assert.IsFalse( tokens[7].IsPrimary);
          Assert.IsTrue( tokens[7].IsComment);
          Assert.AreEqual(TokenKind.Comment, tokens[7].Kind);

        }
Exemplo n.º 41
0
        public void Comments8()
        {
          var src = @"{
          /* //comment text "+"\r\n"+@" */
          }
          ";

          var lxr = new LL(new StringSource(src));

          Assert.AreEqual(" //comment text \r\n ", lxr.ElementAt(2).Text);
        }
Exemplo n.º 42
0
        public void eUnterminatedString2()
        {
          var src = @"a: ""aaaa";

          var lxr = new LL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Exemplo n.º 43
0
        public void Comments3()
        {
          var src = @"{/*
                     
          'string //'}//inner
          */
          }
          ";

          var lxr = new LL(new StringSource(src));

          var expected = new LaconfigTokenType[]{LaconfigTokenType.tBOF, LaconfigTokenType.tBraceOpen, LaconfigTokenType.tComment, LaconfigTokenType.tBraceClose, LaconfigTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Exemplo n.º 44
0
        public void Comments4()
        {
          var src = @"{
           //comment text
          }
          ";

          var lxr = new LL(new StringSource(src));

          Assert.AreEqual("comment text", lxr.ElementAt(2).Text);
        }