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)); } } }
public StringArgument(string name, params string[] identifiers) { Name = name; Identifiers = identifiers.ToList(); Identifiers.Add(name); Value = string.Empty; }
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); } }
/// <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); }
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); }
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; } }
// 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); }
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); }
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); }
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 } ); }
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); } }
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; } }
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]); } }
static TSale() { Identifiers .Add(x => x.Id) ; }
static TIten() { Identifiers .Add(x => x.Id) ; }
static ExpanderIsExpandedDesignModeValueProvider() { _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.Expander), "IsExpanded"); Identifiers.Add(typeof(SSWC.Expander), _propertyIdentifier); }
public void AddIdentifier(ClientIdentifier personName) { personName.ClientId = Id; Identifiers.Add(personName); }
static TUser() { Identifiers .Add(x => x.Id) ; }
static DatePickerIsDropDownOpenDesignModeValueProvider() { _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.DatePicker), "IsDropDownOpen"); Identifiers.Add(typeof(SSWC.DatePicker), _propertyIdentifier); }
public ArgumentsListNode(ArgumentsListNode arguments, IdentifierNode identifier) { Identifiers.AddRange(arguments.Identifiers); Identifiers.Add(identifier); }
static TMovieCategory() { Identifiers .Add(x => x.Id) ; }
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); }
static TClient() { Identifiers .Add(x => x.Id) ; }
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; } }
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; } }
static TReservation() { Identifiers .Add(x => x.Id) ; }
public ArgumentsListNode(IdentifierNode identifier) { Identifiers.Add(identifier); }
public SwitchArgument(string name, params string[] identifiers) { Name = name; Identifiers = identifiers.ToList(); Identifiers.Add(name); }
static AccordionItemIsSelectedDesignModeValueProvider() { _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.AccordionItem), "IsSelected"); Identifiers.Add(typeof(SSWC.AccordionItem), _propertyIdentifier); }
static TPreference() { Identifiers .Add(x => x.Id) ; }