Exemplo n.º 1
0
        public CatalogEntry(string title, string subtitle, List <string> ids, string publisher, string pubDate = null, int?pages = null, string desc = null, string shelf = null, int?minAge = null, int?maxAge = null, GradeLevels minGrd = GradeLevels.NotSet, GradeLevels maxGrd = GradeLevels.NotSet, params string[] genres) : base(true)
        {
            Title    = title;
            Subtitle = subtitle;
            if (!ids.IsNullOrEmpty())
            {
                foreach (var i in ids)
                {
                    Identifiers.Add(new Identifier(this, i));
                }
            }

            Publisher     = publisher;
            PubDate       = pubDate;
            PageCount     = pages;
            Description   = !string.IsNullOrWhiteSpace(desc) ? desc.Trim() : null;
            MinAge        = minAge;
            MaxAge        = maxAge;
            MinGrade      = minGrd;
            MaxGrade      = maxGrd;
            ShelfLocation = !string.IsNullOrWhiteSpace(shelf) ? shelf : null;
            if (!genres.IsNullOrEmpty())
            {
                foreach (var g in genres)
                {
                    Genres.Add(new Genre(this, g));
                }
            }
        }
Exemplo n.º 2
0
 public StringArgument(string name, params string[] identifiers)
 {
     Name        = name;
     Identifiers = identifiers.ToList();
     Identifiers.Add(name);
     Value = string.Empty;
 }
Exemplo n.º 3
0
 private void ReturnIdOrTokenOrLabel(LexerState lexerState, Symbol symbol)
 {
     if (_tokens.Contains(CurrentToken.ToString()))
     {
         CurrentToken.TokenIndex = _tokens.IndexOf(CurrentToken.ToString()) + 1;
         Log(LogEventLevel.Information, "Found token {0}", false, CurrentToken);
         ReturnToken(CurrentToken, symbol);
     }
     else if (symbol.Class?.Class == Class.Colon || Parsed.Last().Substring == "goto")
     {
         //Label
         ReturnLabel(new StateMachine.Transition(lexerState, LexerState.LabelDefinition, symbol));
     }
     else
     {
         Log(LogEventLevel.Information, "Not found token - treat as ID: {0}", false, CurrentToken);
         var identifier =
             Identifiers.FirstOrDefault(x => x.Name == CurrentToken.ToString())?.Clone() as IdentifierToken;
         if (identifier == null)
         {
             identifier = new IdentifierToken(CurrentToken.ToString())
             {
                 TokenIndex = IdIndex
             };
             Identifiers.Add(identifier);
         }
         identifier.Line = Line;
         ReturnToken(identifier, symbol);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// If there is no defined SSA identifier for <paramref name="id"/>
        /// identifier, then create DefInstruction in the <paramref name="b"/>
        /// block. Return existing SSA identifier otherwise
        /// </summary>
        /// <param name="id"></param>
        /// <param name="b"></param>
        /// <returns>
        /// New or existing SSA identifier for <paramref name="id"/>
        /// </returns>
        public SsaIdentifier EnsureDefInstruction(Identifier id, Block b)
        {
            if (Identifiers.TryGetValue(id, out var sid))
            {
                return(sid);
            }
            sid = Identifiers.Add(id, null, null, false);
            var stm = new Statement(
                b.Address.ToLinear(),
                new DefInstruction(id),
                b);

            sid.DefStatement = stm;

            if (b == b.Procedure.EntryBlock)
            {
                int defPos = LastDefPosition(b.Statements) + 1;
                b.Statements.Insert(defPos, stm);
            }
            else
            {
                b.Statements.Add(stm);
            }
            return(sid);
        }
Exemplo n.º 5
0
        static AccordionItemIsSelectedDesignModeValueProvider()
        {
#if SILVERLIGHT
            _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.AccordionItem), "IsSelected");
#else
            _propertyIdentifier = new PropertyIdentifier(SSWC.AccordionItem.IsSelectedProperty);
#endif
            Identifiers.Add(typeof(SSWC.AccordionItem), _propertyIdentifier);
        }
Exemplo n.º 6
0
Arquivo: Scope.cs Projeto: mortend/uno
        string GetUnique(UXIL.Node n, string baseId, Node pathOrigin)
        {
            var id = baseId;

            if ((n.InstanceType == InstanceType.Local || n.InstanceType == InstanceType.None) && !DocumentScope.ContainsNode(n) && (pathOrigin != null))
            {
                var ps = pathOrigin.ParentScope;

                if (n == ps && ps is TemplateNode)
                {
                    return("__parentInstance");
                }

                var prefix = "__parent";

                while (ps != null)
                {
                    if (n == ps)
                    {
                        return(prefix);
                    }

                    if (ps.ContainsNode(n))
                    {
                        return(prefix + "." + id);
                    }

                    ps     = ps.ParentScope;
                    prefix = prefix + ".__parent";
                }

                throw new Exception(id + " cannot be accessed from this scope");
            }

            var c = 0;

            while (true)
            {
                if (!_identifiers.ContainsIdentifier(id) &&
                    !reservedWords.Contains(id) &&
                    (id != DocumentScope.GeneratedClassName.Surname))
                {
                    if (_identifiers.ContainsNode(n))
                    {
                        return(_identifiers.Get(n));
                    }

                    _identifiers.Add(n, id);

                    return(id);
                }

                c++;
                id = baseId + c;
            }
        }
Exemplo n.º 7
0
 // This function can load dishes from a text file.
 public Dish Load(StreamReader reader, String[] ids)
 {
     for (int i = 0; i < ids.Length; i++)
     {
         Identifiers.Add(ids[i]);
     }
     Name        = reader.ReadLine();
     Description = reader.ReadLine();
     Price       = reader.ReadSingle();
     return(this);
 }
Exemplo n.º 8
0
        public virtual CollectionDiff <AlbumIdentifier, AlbumIdentifier> SyncIdentifiers(string[] newIdentifiers)
        {
            Func <AlbumIdentifier, string, bool> equality = ((i1, i2) => i1.Value == i2);
            Func <string, AlbumIdentifier>       create   = (data => {
                var id = new AlbumIdentifier(this, data);
                Identifiers.Add(id);
                return(id);
            });

            var diff = CollectionHelper.Sync(Identifiers, newIdentifiers, equality, create);

            return(diff);
        }
Exemplo n.º 9
0
        public IdOptions Id <TOut>(Expression <Func <T, TOut> > expression, string columnName = null)
        {
            var property = GetProperty(expression, columnName);

            Identifiers.Add(property);
            var idOptions = new IdOptions(property);

            if (!typeof(TOut).GetTypeInfo().IsPrimitive)
            {
                idOptions.GeneratedBy.Assigned();
            }

            return(idOptions);
        }
Exemplo n.º 10
0
        private void AddIdentifier(string value)
        {
            if (Identifiers.Any(e => e.Name.Equals(value)))
            {
                return;
            }

            int index = Identifiers.Count + 1;

            Identifiers.Add(new Identifier
            {
                Index = index,
                Type  = Lexemes.Any() ? Lexemes.Last()?.Token ?? "" : "",
                Name  = value
            }
                            );
        }
Exemplo n.º 11
0
        void AddConstantOrIdentifier(string atomName)
        {
            if (Regex.IsMatch(atomName, IdentifierPattern))
            {
                Identifier identifier = new Identifier(-1, atomName);

                FIP.Add(identifier);
                Identifiers.Add(identifier);
            }
            else if (Regex.IsMatch(atomName, ConstantPattern))
            {
                Constant constant = new Constant(-1, atomName);

                FIP.Add(constant);
                Constants.Add(constant);
            }
        }
Exemplo n.º 12
0
        private void defineLexem()
        {
            bool f = false;

            switch (currentState)
            {
            case State.Identifier:
                f = searchInTable(Keywords);
                if (!f)
                {
                    f = searchInTable(Identifiers);
                    nextLexem.type = LexemType.Identifier;
                    nextLexem.code = lastId++;
                    Identifiers.Add(currentLexemString.ToString(), nextLexem.code);
                    nextLexem.type = LexemType.Identifier;
                }
                else
                {
                    nextLexem.type = LexemType.Keyword;
                }
                outputLexem();
                break;

            case State.Constant:
                f = searchInTable(Constants);
                if (!f)
                {
                    nextLexem.code = lastConst++;
                    Constants.Add(currentLexemString.ToString(), nextLexem.code);
                }
                nextLexem.type = LexemType.Constant;
                outputLexem();
                break;

            case State.Delimiter:
                f = searchInTable(Delimiters);
                nextLexem.type   = LexemType.Delimiter;
                nextLexem.line   = CurrentLine;
                nextLexem.column = CurrentColumn;
                outputLexem();
                break;

            case State.WhiteSpace:
                break;
            }
        }
Exemplo n.º 13
0
        private void IdentifierOut(StringBuilder sb)
        {
            var str = sb.ToString();

            //handle keyword
            if (Keywords.ContainsKey(str))
            {
                Output.Add(Keywords[str]);
            }
            else if (Identifiers.ContainsKey(str)) //handle existing user identifier
            {
                Output.Add(Identifiers[str]);
            }
            else //create new identifier
            {
                Identifiers.Add(str);
                Output.Add(Identifiers[str]);
            }
        }
Exemplo n.º 14
0
 static TSale()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
Exemplo n.º 15
0
 static TIten()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
 static ExpanderIsExpandedDesignModeValueProvider()
 {
     _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.Expander), "IsExpanded");
     Identifiers.Add(typeof(SSWC.Expander), _propertyIdentifier);
 }
Exemplo n.º 17
0
 public void AddIdentifier(ClientIdentifier personName)
 {
     personName.ClientId = Id;
     Identifiers.Add(personName);
 }
Exemplo n.º 18
0
 static TUser()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
Exemplo n.º 19
0
 static DatePickerIsDropDownOpenDesignModeValueProvider()
 {
     _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.DatePicker), "IsDropDownOpen");
     Identifiers.Add(typeof(SSWC.DatePicker), _propertyIdentifier);
 }
Exemplo n.º 20
0
 public ArgumentsListNode(ArgumentsListNode arguments, IdentifierNode identifier)
 {
     Identifiers.AddRange(arguments.Identifiers);
     Identifiers.Add(identifier);
 }
Exemplo n.º 21
0
 static TMovieCategory()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
Exemplo n.º 22
0
        public void AddLexemLog(Tuple <State, string> value)
        {
            int position = 0;

            switch (value.Item1)
            {
            case (State.Identifier):
            {
                position = Identifiers.IndexOf(value.Item2);
                if (position == -1)
                {
                    Identifiers.Add(value.Item2);
                    position = Identifiers.IndexOf(value.Item2);
                }
                break;
            }

            case (State.Keyword):
            {
                position = Keywords.IndexOf(value.Item2);
                if (position == -1)
                {
                    Keywords.Add(value.Item2);
                    position = Keywords.IndexOf(value.Item2);
                }
                break;
            }

            case (State.DecimalNumber):
            {
                position = DecimalNumbers.IndexOf(value.Item2);
                if (position == -1)
                {
                    DecimalNumbers.Add(value.Item2);
                    position = DecimalNumbers.IndexOf(value.Item2);
                }
                break;
            }

            case (State.Delimiter):
            {
                position = Delimiters.IndexOf(value.Item2);
                if (position == -1)
                {
                    Delimiters.Add(value.Item2);
                    position = Delimiters.IndexOf(value.Item2);
                }
                break;
            }

            case (State.DoubleDelimiter):
            {
                position = Delimiters.IndexOf(value.Item2);
                if (position == -1)
                {
                    Delimiters.Add(value.Item2);
                    position = Delimiters.IndexOf(value.Item2);
                }
                break;
            }

            case (State.String):
            {
                position = Strings.IndexOf(value.Item2);
                if (position == -1)
                {
                    Strings.Add(value.Item2);
                    position = Strings.IndexOf(value.Item2);
                }
                break;
            }

            default:
            {
                Console.WriteLine($"{value} Not found");
                break;
            }
            }
            var entry = new DecompositionTableEntry
            {
                Table    = value.Item1,
                Lexem    = value.Item2,
                Position = position
            };

            CommonSymbolTable.Add(entry);
        }
Exemplo n.º 23
0
 static TClient()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
Exemplo n.º 24
0
        private void Parse(string line)
        {
            /*
             * 0 : file name
             * 1 : code
             * 2 : parameters list divided by space
             * 3 : message
             */
            var blocks = line.Split('|');

            var code       = Convert.ToInt32(blocks[1]);
            var parameters = blocks[2].Split(' ');

            if (code > 0)
            {
                switch (code)
                {
                case 1:
                    var lineNumber = Convert.ToInt32(parameters[2]);

                    if (!Tokens.ContainsKey(lineNumber))
                    {
                        Tokens.Add(lineNumber, new List <string>());
                    }

                    Tokens[lineNumber].Add($"[{parameters[0]}:{parameters[1]} ({parameters[3]})]");
                    break;

                case 2:
                    Identifiers.Add(new KeyValuePair <int, string>(Convert.ToInt32(parameters[0]), parameters[1]));
                    break;

                case 3:
                    MessageBox.Show(blocks[3]);
                    break;
                }
            }
            if (code >= 0)
            {
                return;
            }

            code = Math.Abs(code);

            // error message
            switch (code)
            {
            case 3:
                Errors.Add(new Error
                {
                    FileName    = blocks[0],
                    Description = $"Symbol {parameters[0]} is not expected.",
                    Message     = blocks[3],
                    Code        = code,
                    Line        = Convert.ToInt32(parameters[1])
                });
                break;

            case 4:
                Errors.Add(new Error
                {
                    FileName    = blocks[0],
                    Description = $"Identifier type {parameters[0]} is not defined.",
                    Message     = blocks[3],
                    Code        = code
                });
                break;

            case 5:
                Errors.Add(new Error
                {
                    FileName    = blocks[0],
                    Description = $"Expected: {parameters[0]}, found: {parameters[1]}",
                    Message     = blocks[3],
                    Code        = code
                });
                break;

            default:
                Errors.Add(new Error {
                    FileName = blocks[0], Message = blocks[3]
                });
                break;
            }
        }
Exemplo n.º 25
0
        private void DefineLexem()
        {
            bool f = false;

            switch (currentState)
            {
            case State.Identificator:
                f = SearchInTable(Keywords);
                nextLexem.type = LexemType.Keyword;
                if (!f)
                {
                    f = SearchInTable(Identifiers);
                    nextLexem.type = LexemType.Identifier;
                }
                if (!f)
                {
                    nextLexem.code = lastId++;
                    Identifiers.Add(currentLexem.ToString(), nextLexem.code);
                    nextLexem.type = LexemType.Identifier;
                }
                OutputLexem();
                break;

            case State.Variable:
                f = SearchInTable(Constants);
                if (!f)
                {
                    nextLexem.code = lastConst++;
                    Constants.Add(currentLexem.ToString(), nextLexem.code);
                }
                nextLexem.type = LexemType.Variable;
                OutputLexem();
                break;

            case State.Separtor:
                SearchInTable(Separators);
                nextLexem.type   = LexemType.Separtor;
                nextLexem.line   = CurrentLine;
                nextLexem.column = CurrentColumn;
                OutputLexem();
                break;

            case State.WhiteSpace:
                break;

            case State.MultiSeparator:
                f = SearchInTable(MultiSeparators);
                if (f)
                {
                    nextLexem.type   = LexemType.MultiSymbolicSeparator;
                    nextLexem.line   = CurrentLine - currentLexem.Length;
                    nextLexem.column = CurrentColumn - currentLexem.Length + 1;
                    OutputLexem();
                }
                else
                {
                    int    i          = 1;
                    string separators = currentLexem.ToString();
                    foreach (var item in separators)
                    {
                        currentLexem.Clear();
                        currentLexem.Append(item);
                        nextLexem.line   = CurrentLine;
                        nextLexem.column = CurrentColumn - separators.Length + i;
                        i++;
                        if (SearchInTable(Separators))
                        {
                            nextLexem.type = LexemType.Separtor;
                            OutputLexem();
                        }
                        else
                        {
                            currentState = State.Separtor;
                            DefineError(item);
                        }
                    }
                }
                break;

            case State.LastA:
                nextLexem.type = LexemType.SpecialLexem;
                nextLexem.code = SL++;
                OutputLexem();
                break;
            }
        }
Exemplo n.º 26
0
 static TReservation()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }
Exemplo n.º 27
0
 public ArgumentsListNode(IdentifierNode identifier)
 {
     Identifiers.Add(identifier);
 }
Exemplo n.º 28
0
 public SwitchArgument(string name, params string[] identifiers)
 {
     Name        = name;
     Identifiers = identifiers.ToList();
     Identifiers.Add(name);
 }
Exemplo n.º 29
0
 static AccordionItemIsSelectedDesignModeValueProvider()
 {
     _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.AccordionItem), "IsSelected");
     Identifiers.Add(typeof(SSWC.AccordionItem), _propertyIdentifier);
 }
Exemplo n.º 30
0
 static TPreference()
 {
     Identifiers
     .Add(x => x.Id)
     ;
 }