public void Parser_Lexicon_QualifiedIdentifier() { const string s1 = "a.b.c"; var parser = new ApteridParser { SourceFile = new MemorySourceFile(s1) }; var m1 = parser.GetMatch(s1, parser.QualifiedIdentifier); Assert.IsTrue(m1.Success); Assert.IsInstanceOfType(m1.Result, typeof(Syntax.QualifiedIdentifier)); var r1 = m1.Result as Syntax.QualifiedIdentifier; Assert.AreEqual(5, r1.Children.Length); Assert.IsInstanceOfType(r1.Children[0], typeof(Syntax.Identifier)); Assert.IsInstanceOfType(r1.Children[1], typeof(Syntax.Punct)); Assert.IsInstanceOfType(r1.Children[2], typeof(Syntax.Identifier)); Assert.IsInstanceOfType(r1.Children[3], typeof(Syntax.Punct)); Assert.IsInstanceOfType(r1.Children[4], typeof(Syntax.Identifier)); Assert.AreEqual(2, r1.Qualifiers.Count()); Assert.AreEqual("a", r1.Qualifiers.ElementAt(0).Text); Assert.AreEqual("b", r1.Qualifiers.ElementAt(1).Text); }
public void Parser_Module_SimpleModule() { var s = @" module Qualified.One = f1 = 123 f2 = 314 /* comment */ module Qualified.Two = // comment f3 = 3345 f4 = -12345 "; var sa = s.Select(c => c).ToArray(); var m = parser.GetMatch(s, parser.ApteridSource); Assert.IsTrue(m.Success); }
public void Parser_Lexicon_QualifiedIdentifier() { const string s1 = "a.b.c"; var parser = new ApteridParser { SourceFile = new MemorySourceFile(s1) }; var m1 = parser.GetMatch(s1, parser.QualifiedIdentifier); Assert.IsTrue(m1.Success); Assert.IsInstanceOfType(m1.Result, typeof(Syntax.QualifiedIdentifier)); var r1 = m1.Result as Syntax.QualifiedIdentifier; Assert.AreEqual(5, r1.Children.Length); Assert.IsInstanceOfType(r1.Children[0], typeof(Syntax.Identifier)); Assert.IsInstanceOfType(r1.Children[1], typeof(Syntax.Punct)); Assert.IsInstanceOfType(r1.Children[2], typeof(Syntax.Identifier)); Assert.IsInstanceOfType(r1.Children[3], typeof(Syntax.Punct)); Assert.IsInstanceOfType(r1.Children[4], typeof(Syntax.Identifier)); Assert.AreEqual(2, r1.Qualifiers.Count()); Assert.AreEqual("a", r1.Qualifiers.ElementAt(0).Text); Assert.AreEqual("b", r1.Qualifiers.ElementAt(1).Text); }
public void Parser_Lexicon_IntegerLiteral() { const string s1 = "123"; var m1 = parser.GetMatch(s1, parser.DecimalInteger); Assert.IsTrue(m1.Success); Assert.AreEqual(123, (int)((Syntax.Literal <BigInteger>)m1.Result).Value); const string s2 = "-34_56"; var m2 = parser.GetMatch(s2, parser.DecimalInteger); Assert.IsTrue(m2.Success); Assert.AreEqual(-3456, (int)((Syntax.Literal <BigInteger>)m2.Result).Value); }