예제 #1
0
 /// <summary>
 /// Creates a new instance of <see cref="Lexer"/>.
 /// </summary>
 public Lexer(
     Lexicon lexicon,
     IdentifierChecker identifier_checker,
     LiteralSniffer literal_sniffer,
     short[] illegal_duplicates)
 {
     this.Lexicon       = lexicon;
     this.IsIdentifier  = identifier_checker;
     this.SniffLiterals = literal_sniffer;
     this.Tokens        = new List <Token>();
 }
예제 #2
0
 /// <summary>
 /// Creates a new instance of <see cref="Lexer"/>.
 /// </summary>
 public Lexer(
     Lexicon lexicon,
     IdentifierChecker identifier_checker,
     LiteralSniffer literal_sniffer,
     string source,
     short[] illegal_duplicates)
     : this(
         lexicon,
         identifier_checker,
         literal_sniffer,
         illegal_duplicates)
 {
     this.Tokenize(source);
 }
        public void Has_Duplicate_Identifiers_Test()
        {
            IdentifierChecker identifier = new IdentifierChecker(manager);

            Assert.IsTrue(manager.GetNotifications().Count == 0);

            List <FormObject> formObjects = new List <FormObject>();

            formObjects.Add(CreateQuestion("id1", "label1", null));
            formObjects.Add(CreateQuestion("id1", "label2", null));

            INotificationManager notificationManager = identifier.AnalyzeAndReport(new Form(formObjects, position));

            Assert.IsTrue(notificationManager.GetNotifications().Count == 1);
        }
        public void Has_Undefined_Identifiers_Test()
        {
            IdentifierChecker identifier = new IdentifierChecker(manager);

            Assert.IsTrue(manager.GetNotifications().Count == 0);

            Id id = new Id("id3", position);

            id.SetType(new Types.BoolType());

            Expression computed = new And(
                new Bool(true, position),
                id,
                position);

            List <FormObject> formObjects = new List <FormObject>();

            formObjects.Add(CreateQuestion("id1", "label1", computed));

            INotificationManager notificationManager = identifier.AnalyzeAndReport(new Form(formObjects, position));

            Assert.IsTrue(notificationManager.GetNotifications().Count == 1);
        }