public int Add(CharacterSetBuild Item) { CharacterSet item = Item; Item = (CharacterSetBuild)item; return(base.Add(item)); }
public void RpcAddCharacters(CharacterSet characterSet) { if (!isLocalPlayer) { return; } if (netId.Value == 1) { SetCharacters(characterSet.characters, characterSet.characters2, characterSet.characters3, characterSet.characters4); SetCharacterNames(2, 3, 4); } else if (netId.Value == 2) { SetCharacters(characterSet.characters2, characterSet.characters, characterSet.characters3, characterSet.characters4); SetCharacterNames(1, 3, 4); } else if (netId.Value == 3) { SetCharacters(characterSet.characters3, characterSet.characters, characterSet.characters2, characterSet.characters4); SetCharacterNames(1, 2, 4); } else if (netId.Value == 4) { SetCharacters(characterSet.characters4, characterSet.characters, characterSet.characters2, characterSet.characters3); SetCharacterNames(1, 2, 3); } var cover = GameObject.Find("Cover"); if (cover) { Destroy(cover); } }
public void TestEncodingOverride(string content, CharacterSet overrideCharacterSet) { Splitter splitter = new Splitter(); var result = splitter.Split(content, overrideCharacterSet); Assert.Equal(overrideCharacterSet, result.CharacterSet); }
public void TestEncodingRecognition(string content, CharacterSet expectedCharacterSet) { Splitter splitter = new Splitter(); var result = splitter.Split(content); Assert.Equal(expectedCharacterSet, result.CharacterSet); }
public RegexRecognizerPattern(System.Text.RegularExpressions.Regex rx, CharacterSet first, int priority) { _Regex = rx; _First = first; _Priority = priority; }
public void ChangeCharacterSet(CharacterSet characters) { this.characters = characters; RemoveChildren(); CreateButtons(); PlaceButtons(); }
private static char Character(CharacterSet characterSet) { string characters = ""; if (characterSet.HasFlag(CharacterSet.Alphabetic)) { characters += Alphabet; } if (characterSet.HasFlag(CharacterSet.Numeric)) { characters += Numeric; } if (characterSet.HasFlag(CharacterSet.ExtraCharacters)) { characters += ExtraCharacters; } if (characters.Length == 0) { throw new ArgumentOutOfRangeException("characterSet"); } return(characters[Random.Next(0, characters.Length)]); }
private IConverter CreateKanjiConverter(CharacterSet characterSet) { if (characterSet.Equals(CharacterSet.ASCII)) { return(new CompoundConverter(CreateKanjiConverter(CharacterSet.HIRAGANA), CreateHiraganaConverter(CharacterSet.ASCII))); } else if (characterSet.Equals(CharacterSet.KANJI)) { return(new DelegateConverter(kanjiConverterImpl.ToKanji)); } else if (characterSet.Equals(CharacterSet.HIRAGANA)) { return(new DelegateConverter(kanjiConverterImpl.ToHiragana)); } else if (characterSet.Equals(CharacterSet.KATAKANA)) { return(new CompoundConverter(CreateKanjiConverter(CharacterSet.HIRAGANA), CreateHiraganaConverter(CharacterSet.KATAKANA))); } else if (characterSet.Equals(CharacterSet.HALFKANA)) { return(new CompoundConverter(CreateKanjiConverter(CharacterSet.HIRAGANA), CreateHiraganaConverter(CharacterSet.HALFKANA))); } else { return(null); } }
// Event triggered when DataGridView cell value has been changed and committed. private void dgvCharacterSets_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (this.UserEditing) { // Add or remove allowed character set as specified by the end-user. if (this.dgvCharacterSets.Columns[e.ColumnIndex].Name == COLUMN_NAME_ALLOWED) { if ((bool)this.dgvCharacterSets.CurrentRow.Cells[e.ColumnIndex].Value == true) { CharacterSet charSet = this.dgvCharacterSets.CurrentRow.DataBoundItem as CharacterSet; this.PasswordGen.Policy.CharacterSetAdd(charSet); this.dgvCharacterSets.CurrentRow.Cells[COLUMN_NAME_MINIMUM_NUMBER_OF_CHARACTERS].ReadOnly = false; } else { string key = this.dgvCharacterSets.CurrentRow.Cells[COLUMN_NAME_KEY].Value.ToString(); this.PasswordGen.Policy.CharacterSetRemove(key); this.dgvCharacterSets.CurrentRow.Cells[COLUMN_NAME_MINIMUM_NUMBER_OF_CHARACTERS].ReadOnly = true; } this.AtLeastOneCharacterSetAllowed(); } // Update password minimum length based on minumum number of symbols in allowed character sets. if (this.dgvCharacterSets.Columns[e.ColumnIndex].Name == COLUMN_NAME_MINIMUM_NUMBER_OF_CHARACTERS) { string key = this.dgvCharacterSets.CurrentRow.Cells[COLUMN_NAME_KEY].Value.ToString(); Int32 symbolCount = (Int32)this.dgvCharacterSets.CurrentRow.Cells[COLUMN_NAME_MINIMUM_NUMBER_OF_CHARACTERS].Value; this.PasswordGen.Policy.CharacterSetMinimumCharacters(key, symbolCount); this.udnPasswordLengthMinimum.Minimum = this.CalculateMinimumPasswordLength(); } this.GenerateNewPassword(); } }
public void Visit(CharacterSet expression, Nonterminal context) { foreach (var character in expression.Characters) { Add(context, expression, character); } }
public void CaseClosure() { int num5 = base.Edges().Count() - 1; for (int i = 0; i <= num5; i++) { NumberSet setB = new NumberSet(new int[0]); CharacterSet characters = base.Edges()[i].Characters; int num6 = characters.Count() - 1; for (int j = 0; j <= num6; j++) { int charCode = characters[j]; int num3 = UnicodeTable.ToLowerCase(charCode); if (charCode != num3) { setB.Add(new int[] { num3 }); } num3 = UnicodeTable.ToUpperCase(charCode); if (charCode != num3) { setB.Add(new int[] { num3 }); } } characters.UnionWith(setB); characters = null; } }
public override int GetHashCode() { unchecked { int result = (m_ObjPropertyCollection != null ? m_ObjPropertyCollection.GetHashCode() : 0); result = (result * 397) ^ (CharacterSet != null ? CharacterSet.GetHashCode() : 0); result = (result * 397) ^ (ContentEncoding != null ? ContentEncoding.GetHashCode() : 0); result = (result * 397) ^ (ContentType != null ? ContentType.GetHashCode() : 0); result = (result * 397) ^ (Headers != null ? Headers.GetHashCode() : 0); result = (result * 397) ^ IsFromCache.GetHashCode(); result = (result * 397) ^ IsMutuallyAuthenticated.GetHashCode(); result = (result * 397) ^ LastModified.GetHashCode(); result = (result * 397) ^ (Method != null ? Method.GetHashCode() : 0); result = (result * 397) ^ (OriginalReferrerUrl != null ? OriginalReferrerUrl.GetHashCode() : 0); result = (result * 397) ^ (OriginalUrl != null ? OriginalUrl.GetHashCode() : 0); result = (result * 397) ^ (ProtocolVersion != null ? ProtocolVersion.GetHashCode() : 0); result = (result * 397) ^ (Referrer != null ? Referrer.GetHashCode() : 0); result = (result * 397) ^ (ResponseUri != null ? ResponseUri.GetHashCode() : 0); result = (result * 397) ^ (Server != null ? Server.GetHashCode() : 0); result = (result * 397) ^ StatusCode.GetHashCode(); result = (result * 397) ^ (StatusDescription != null ? StatusDescription.GetHashCode() : 0); result = (result * 397) ^ (Step != null ? Step.GetHashCode() : 0); result = (result * 397) ^ (Text != null ? Text.GetHashCode() : 0); result = (result * 397) ^ (Title != null ? Title.GetHashCode() : 0); result = (result * 397) ^ DownloadTime.GetHashCode(); return(result); } }
private Recognizer CreateHeadingNumberRecognizer(System.Globalization.CultureInfo culture, int priority) { try { // TODO use culture's digits but don't use Regex \d placeholder as it's not culture sensitive // TODO set context (word boundaries) // TODO make IP address an alphanumeric token with placeable features? // TODO treat all alphanumeric tokens as placeables? string pattern = "[0-9]+(\\.([0-9]{1,3}))+"; CharacterSet first = new CharacterSet(); first.Add('0', '9'); RegexRecognizer recog = new RegexRecognizer(TokenType.OtherTextPlaceable, priority, "GENHNUMPLC", "GENERIC_HEADINGNUMBER_RECOGNIZER", true); recog.Add(pattern, first); // TODO is this culture-dependent? recog.OnlyIfFollowedByNonwordCharacter = true; return(recog); } catch // (System.Exception e) { return(null); } }
public virtual ZplRenderer CreateZplRenderer([NotNull] ZplTransformer zplTransformer, CharacterSet characterSet = CharacterSet.Utf8) { if (zplTransformer == null) { throw new ArgumentNullException(nameof(zplTransformer)); } var svgUnitReader = this.CreateSvgUnitReader(); var zplCommands = this.CreateZplCommands(); var zplRenderer = this.CreateZplRenderer(zplCommands, characterSet); var svgLineTranslator = this.CreateSvgLineTranslator(zplTransformer, zplCommands); var svgRectangleTranslator = this.CreateSvgRectangleTranslator(zplTransformer, zplCommands, svgUnitReader); var svgTextTranslator = this.CreateSvgTextTranslator(zplTransformer, zplCommands); var svgTextSpanTranslator = this.CreateSvgTextSpanTranslator(zplTransformer, zplCommands); var svgPathTranslator = this.CreateSvgPathTranslator(zplTransformer, zplCommands); var svgImageTranslator = this.CreateSvgImageTranslator(zplTransformer, zplCommands); zplRenderer.RegisterTranslator(svgLineTranslator); zplRenderer.RegisterTranslator(svgRectangleTranslator); zplRenderer.RegisterTranslator(svgTextTranslator); zplRenderer.RegisterTranslator(svgTextSpanTranslator); zplRenderer.RegisterTranslator(svgPathTranslator); zplRenderer.RegisterTranslator(svgImageTranslator); return(zplRenderer); }
public virtual void Visit(CharacterSet expression, T context) { foreach (var c in expression.Characters) { c.Accept(this, context); } }
private string FormatMenuText(string s) { if (s == null) { return(" "); } s = CharacterSet.DBCToSBC(s); switch (s.Length) { case 0: return(" "); case 1: return(" " + s); case 2: return(" " + s); case 3: return(" " + s); default: return(s); } }
public static int GetBytesPerCharacter(CharacterSet characterSet) { // not an exhaustive mapping, but should cover commonly-used character sets switch (characterSet) { case CharacterSet.Utf16Binary: case CharacterSet.Utf16GeneralCaseInsensitive: case CharacterSet.Utf16UnicodeCaseInsensitive: case CharacterSet.Utf16leBinary: return 2; case CharacterSet.Utf8Binary: case CharacterSet.Utf8GeneralCaseInsensitive: case CharacterSet.Utf8UnicodeCaseInsensitive: return 3; case CharacterSet.Utf8Mb4Binary: case CharacterSet.Utf8Mb4GeneralCaseInsensitive: case CharacterSet.Utf8Mb4UnicodeCaseInsensitive: case CharacterSet.Utf32Binary: case CharacterSet.Utf32GeneralCaseInsensitive: case CharacterSet.Utf32UnicodeCaseInsensitive: return 4; default: return 1; } }
public void CanParseThis1() { var x = new CharacterSet("a-fG-L", false); AssertIdentifier(x.Characters, "a-fG-L"); Assert.Equal(x.ExpandedCharacters, "abcdefGHIJKL"); }
public static int GetBytesPerCharacter(CharacterSet characterSet) { // not an exhaustive mapping, but should cover commonly-used character sets switch (characterSet) { case CharacterSet.Utf16Binary: case CharacterSet.Utf16GeneralCaseInsensitive: case CharacterSet.Utf16UnicodeCaseInsensitive: case CharacterSet.Utf16leBinary: return(2); case CharacterSet.Utf8Binary: case CharacterSet.Utf8GeneralCaseInsensitive: case CharacterSet.Utf8UnicodeCaseInsensitive: return(3); case CharacterSet.Utf8Mb4Binary: case CharacterSet.Utf8Mb4GeneralCaseInsensitive: case CharacterSet.Utf8Mb4UnicodeCaseInsensitive: case CharacterSet.Utf8Mb4Unicode520CaseInsensitive: case CharacterSet.Utf8Mb4Uca900AccentInsensitiveCaseInsensitive: case CharacterSet.Utf8Mb4Uca900AccentSensitiveCaseSensitive: case CharacterSet.Utf32Binary: case CharacterSet.Utf32GeneralCaseInsensitive: case CharacterSet.Utf32UnicodeCaseInsensitive: case CharacterSet.Utf32Unicode520CaseInsensitive: return(4); default: return(1); } }
private RegexRecognizer CreateUriRecognizer(System.Globalization.CultureInfo actualCulture, int priority) { // TODO this shouldn't be a recognizer but rather a simple classifier after the // default fallback recognizer (for performance reasons) // TODO set context restrictions of the recognizer RegexRecognizer recog = new RegexRecognizer(TokenType.Uri, priority, "URI", "DEFAULT_URI_REGOCNIZER"); CharacterSet first = new CharacterSet(); // http, https, mailto, ftp, file first.Add('h'); first.Add('H'); first.Add('m'); first.Add('M'); first.Add('f'); first.Add('F'); recog.Add("(mailto:|((https|http|ftp|file)://))[\\p{L}\\p{N}\\p{Pc}\\p{Pd}\\p{Po}\\p{S}-['\"<>]]*[\\p{L}\\p{N}\\p{Pc}\\p{Pd}\\p{S}/]", first, true); // not sure about this one: recog.OnlyIfFollowedByNonwordCharacter = Core.CultureInfoExtensions.UseBlankAsWordSeparator(actualCulture); return(recog); }
// Note: we allow identifiers that start with a number, // but not if they *only* comprise numbers protected string Identifier() { if (_identifierCharSet == null) { _identifierCharSet = new CharacterSet (); _identifierCharSet.AddRange ('A', 'Z'); _identifierCharSet.AddRange ('a', 'z'); _identifierCharSet.AddRange ('0', '9'); _identifierCharSet.Add ('_'); } // Parse remaining characters (if any) var name = ParseCharactersFromCharSet (_identifierCharSet); if (name == null) return null; // Reject if it's just a number bool isNumberCharsOnly = true; foreach (var c in name) { if ( !(c >= '0' && c <= '9') ) { isNumberCharsOnly = false; break; } } if (isNumberCharsOnly) { return null; } return name; }
public MySQLCompiledQueryCacheKey( RelationalCompiledQueryCacheKey relationalCompiledQueryCacheKey, CharacterSet charSet) { _relationalCompiledQueryCacheKey = relationalCompiledQueryCacheKey; _charSet = charSet; }
public ScionWindow() { InitializeComponent(); sets = new CharacterSet(); // TEST CODE sets = Structural.TestCharSet(); Combat r = new Combat(sets); // Rectangle r = new Rectangle(); r.Height = 300; r.Width = 300; //r.Fill = new SolidColorBrush() { Color = Colors.Red }; Object.Children.Add(r); Grid.SetColumn(r, 1); //CombatWindow = new Combat(sets); //CombatWindow.Height = 300; //CombatWindow.Width = 300; //Object.Children.Add(CombatWindow); //Grid.SetColumn(CombatWindow, 1); //CombatWindow.Visibility = Visibility.Visible; int x = 1; }
protected override string GetEncodedData() { StringBuilder tempBuilder = new StringBuilder(); CharacterSet nowCharacterSet = Code128.GetCharacterSet(this._rawData, 0); int checkNum;//校验字符 switch (nowCharacterSet) { case CharacterSet.A: tempBuilder.Append(Code128.BSList[Code128.StartA]); //加上起始符StartA checkNum = Code128.StartA; break; case CharacterSet.B: tempBuilder.Append(Code128.BSList[Code128.StartB]); //加上起始符StartB checkNum = Code128.StartB; break; default: tempBuilder.Append(Code128.BSList[Code128.StartC]); //加上起始符StartC checkNum = Code128.StartC; break; } int nowWeight = 1, nowIndex = 0; this.GetEncodedData(tempBuilder, nowCharacterSet, ref nowIndex, ref nowWeight, ref checkNum); checkNum %= 103; tempBuilder.Append(Code128.BSList[checkNum]); //加上校验符 tempBuilder.Append(Code128.BSList[Code128.Stop]); //加上结束符 return(tempBuilder.ToString()); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public MySQLOptionsExtension WithCharSet(CharacterSet charSet) { var clone = (MySQLOptionsExtension)Clone(); clone._charset = charSet; return(clone); }
private ColumnDefinitionPayload(string name, CharacterSet characterSet, int columnLength, ColumnType columnType, ColumnFlags columnFlags) { Name = name; CharacterSet = characterSet; ColumnLength = columnLength; ColumnType = columnType; ColumnFlags = columnFlags; }
private ColumnDefinitionPayload(string name, CharacterSet characterSet, int columnLength, ColumnType columnType, ColumnFlags columnFlags) { Name = name; CharacterSet = characterSet; ColumnLength = columnLength; ColumnType = columnType; ColumnFlags = columnFlags; }
public SplitResult Split(string content, CharacterSet overrideCharacterSet = CharacterSet.Unknown) { var charSet = GetCharset(content, overrideCharacterSet); ISplitMessage messageSplitter = CreateMessageSplitter(charSet); var result = messageSplitter.Split(content); return(result); }
public CalculatorViewModel(CharacterSet characterSet) { _script = _output = string.Empty; CharacterSet = characterSet; _flatCharacterList = characterSet.Groups.SelectMany(g => g.Characters); ExecuteCommand = new DelegateCommand <object>(_ => Execute()); Languages = Enum.GetValues(typeof(Language)).OfType <Language>(); }
public DefaultChineseFallbackRecognizer(Core.Tokenization.TokenType t, int priority, System.Globalization.CultureInfo culture, Core.Resources.IResourceDataAccessor dataAccessor) : base(t, priority, culture, dataAccessor, false) { int i = 0; _IsFallbackRecognizer = true; _DefaultPunctCharset = CharacterSetParser.Parse(_DEFAULT_PUNC_CS, ref i); }
public static char[] Get(Region region, bool tallCharacters) { return(region == Region.Jap ? CharacterSet.GetJapaneseSet() : !tallCharacters? CharacterSet.GetEnglishSet() : CharacterSet.GetLargeEnglishSet()); }
private void LoadEGT(BinaryReader reader) { using (EGTReader egtReader = new EGTReader(reader)) { while (egtReader.GetNextRecord()) { switch (egtReader.ReadRecordType()) { case EGTRecord.Property: GrammarProperties.SetProperty(egtReader.ReadGrammarProperty()); break; case EGTRecord.TableCounts: GrammarTables = egtReader.ReadGrammarTables(); break; case EGTRecord.InitialStates: //DFA, LALR ushort dfaState = egtReader.ReadUInt16(); ushort lalrState = egtReader.ReadUInt16(); Debug.Assert(dfaState == 0, "The initial DFA State is not 0!"); Debug.Assert(lalrState == 0, "The initial LALR State is not 0!"); break; case EGTRecord.Symbol: Symbol sym = egtReader.ReadSymbol(); GrammarTables.Symbols[sym.TableIndex] = sym; break; case EGTRecord.Group: Group group = egtReader.ReadGroup(); GrammarTables.Groups[group.TableIndex] = group; break; case EGTRecord.CharRanges: CharacterSet charSet = egtReader.ReadCharacterSet(); GrammarTables.CharacterSets[charSet.Index] = charSet; break; case EGTRecord.Production: Production prod = egtReader.ReadProduction(); GrammarTables.Productions[prod.TableIndex] = prod; break; case EGTRecord.DFAState: FAState faState = egtReader.ReadFAState(); GrammarTables.FAStates[faState.TableIndex] = faState; break; case EGTRecord.LRState: LRActionList actionList = egtReader.ReadLRActionList(); GrammarTables.LRActionLists[actionList.Index] = actionList; break; } } } }
public void WhenSmsMessageIsSerializedThenTheCharacterSetIsSerialisedAsExpected(CharacterSet characterSet, string expectedXml) { var message = new SmsMessage {CharacterSet = characterSet}; var serialiser = new XmlSerialiser(); var serialisedMessage = serialiser.Serialise(message); Assert.That(serialisedMessage, Is.EqualTo(expectedXml)); }
private ColumnDefinitionPayload(ResizableArraySegment <byte> originalData, CharacterSet characterSet, uint columnLength, ColumnType columnType, ColumnFlags columnFlags, byte decimals) { OriginalData = originalData; CharacterSet = characterSet; ColumnLength = columnLength; ColumnType = columnType; ColumnFlags = columnFlags; Decimals = decimals; }
/// <summary> /// 判断指定字符是否仅属于指定字符集 /// </summary> /// <param name="characterSet"></param> /// <param name="c"></param> /// <returns></returns> internal static bool CharOnlyBelongsTo(CharacterSet characterSet, char c) { switch (characterSet) { case CharacterSet.A: return (byte)c < 32; case CharacterSet.B: return (byte)c > 95 && (byte)c < 128; default: throw new NotImplementedException(); } }
public CharacterSet() { _include = ""; _exclude = this; _isSingleCharacter = false; }
public CharacterSet(string/*!*/ include, CharacterSet/*!*/ exclude) : this(false, include, exclude) { }
/// <summary> /// Create a new TypeSpecification object. /// </summary> /// <param name="typeName">Initial value of TypeName.</param> /// <param name="collation">Initial value of Collation.</param> /// <param name="characterSet">Initial value of CharacterSet.</param> /// <param name="isMultiSet">Initial value of IsMultiSet.</param> public static TypeSpecification CreateTypeSpecification(string typeName, Collation collation, CharacterSet characterSet, bool isMultiSet) { TypeSpecification typeSpecification = new TypeSpecification(); typeSpecification.TypeName = typeName; typeSpecification.Collation = global::System.Data.Objects.DataClasses.StructuralObject.VerifyComplexObjectIsNotNull(collation, "Collation"); typeSpecification.CharacterSet = global::System.Data.Objects.DataClasses.StructuralObject.VerifyComplexObjectIsNotNull(characterSet, "CharacterSet"); typeSpecification.IsMultiSet = isMultiSet; return typeSpecification; }
/// <summary> /// 获取指定字符串应该采用的起始符对应的符号字符值 /// </summary> /// <param name="data"></param> /// <returns></returns> internal static byte GetStartIndex(string data, out CharacterSet startCharacterSet) { startCharacterSet = GetCharacterSet(data, 0); switch (startCharacterSet) { case CharacterSet.A: return StartA; case CharacterSet.B: return StartB; default: return StartC; } }
/// <summary> /// Adds the specified character set to the list of allowed character sets. /// </summary> public void CharacterSetAdd(CharacterSet allowedCharacterSet) { if (allowedCharacterSet == null) { throw new ArgumentNullException("allowedCharacterSet", String.Format(CultureInfo.InvariantCulture, "Character set must not be null")); } else if (m_AllowedCharacterSets.ContainsKey(allowedCharacterSet.Key)) { throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified character set already exists"), "allowedCharacterSet"); } else { m_AllowedCharacterSets.Add(allowedCharacterSet.Key, allowedCharacterSet); m_AllowedSymbols = this.FindAllowedSymbols(); } }
// Content text is an unusual parse rule compared with most since it's // less about saying "this is is the small selection of stuff that we parse" // and more "we parse ANYTHING except this small selection of stuff". protected string ContentTextNoEscape() { // Eat through text, pausing at the following characters, and // attempt to parse the nonTextRule. // "-": possible start of divert or start of gather // "<": possible start of glue if (_nonTextPauseCharacters == null) { _nonTextPauseCharacters = new CharacterSet ("-<"); } // If we hit any of these characters, we stop *immediately* without bothering to even check the nonTextRule // "{" for start of logic // "|" for mid logic branch if (_nonTextEndCharacters == null) { _nonTextEndCharacters = new CharacterSet ("{}|\n\r\\#"); _notTextEndCharactersChoice = new CharacterSet (_nonTextEndCharacters); _notTextEndCharactersChoice.AddCharacters ("[]"); _notTextEndCharactersString = new CharacterSet (_nonTextEndCharacters); _notTextEndCharactersString.AddCharacters ("\""); } // When the ParseUntil pauses, check these rules in case they evaluate successfully ParseRule nonTextRule = () => OneOf (ParseDivertArrow, ParseThreadArrow, EndOfLine, Glue); CharacterSet endChars = null; if (parsingStringExpression) { endChars = _notTextEndCharactersString; } else if (_parsingChoice) { endChars = _notTextEndCharactersChoice; } else { endChars = _nonTextEndCharacters; } string pureTextContent = ParseUntil (nonTextRule, _nonTextPauseCharacters, endChars); if (pureTextContent != null ) { return pureTextContent; } else { return null; } }
internal CharacterSet ReadCharacterSet() { ushort index = ReadUInt16(); //'Unicode Plane'?; skip ReadUInt16(); ushort rangeCount = ReadUInt16(); //Reserved; skip ReadEntry(); CharacterSet charSet = new CharacterSet(index, rangeCount); while (!IsRecordComplete()) { charSet.Add(ReadCharacterRange()); } return charSet; }
internal CharacterSet/*!*/ Union(CharacterSet/*!*/ set) { if (IsEmpty) { return set; } else if (set.IsEmpty) { return this; } if (_negated) { if (set._negated) { // ^A or ^B == ^(A and B) return Complement().Intersect(set.Complement()).Complement(); } else { // ^A or B == ^(A \ B) return Complement().Subtract(set).Complement(); } } else if (set._negated) { // A or ^B == ^(B \ A) return set.Complement().Subtract(this).Complement(); } // (a \ B) or (c \ D) == (a or c) \ ((D \ a) or (B \ c) or (B and D)) // // Proof: // (a \ B) or (c \ D) == // (a and ^B) or (c and ^D) == // (a or c) and (a or ^D) and (^B or c) and (^B or ^D) == // (a or c) \ (^(a or ^D) or ^(^B or c) or ^(^B or ^D)) == // (a or c) \ ((D \ a) or (B \ c) or (B and D)) QED return new CharacterSet(_include + set._include, set._exclude.Subtract(GetIncludedSet()). Union(this._exclude.Subtract(set.GetIncludedSet())). Union(this._exclude.Intersect(set._exclude)) ); }
/// <summary> /// 当编码转换时,获取相应的切换符对应的符号字符值 /// </summary> /// <param name="newCharacterSet"></param> /// <returns></returns> internal static byte GetCodeXIndex(CharacterSet newCharacterSet) { switch (newCharacterSet) { case CharacterSet.A: return CODEA_BC; case CharacterSet.B: return CODEB_AC; default: return CODEC_AB; } }
internal EGT(BinaryReader Reader) { EGTReader EGT = new EGTReader(Reader); EGTRecord RecType = default(EGTRecord); try { while (!EGT.EndOfFile()) { EGT.GetNextRecord(); RecType = (EGTRecord)EGT.RetrieveByte(); switch (RecType) { case EGTRecord.Property: { //Index, Name, Value int Index = 0; string Name = null; Index = EGT.RetrieveInt16(); Name = EGT.RetrieveString(); //Just discard m_Grammar.SetValue(Index, EGT.RetrieveString()); } break; case EGTRecord.TableCounts: //Symbol, CharacterSet, Rule, DFA, LALR m_SymbolTable = new SymbolList(EGT.RetrieveInt16()); m_CharSetTable = new CharacterSetList(EGT.RetrieveInt16()); m_ProductionTable = new ProductionList(EGT.RetrieveInt16()); m_DFA = new FAStateList(EGT.RetrieveInt16()); m_LRStates = new LRStateList(EGT.RetrieveInt16()); m_GroupTable = new GroupList(EGT.RetrieveInt16()); break; case EGTRecord.InitialStates: //DFA, LALR m_DFA.InitialState = EGT.RetrieveInt16(); m_LRStates.InitialState = EGT.RetrieveInt16(); break; case EGTRecord.Symbol: { //#, Name, Kind short Index = 0; string Name = null; SymbolType Type = default(SymbolType); Index = EGT.RetrieveInt16(); Name = EGT.RetrieveString(); Type = (SymbolType)EGT.RetrieveInt16(); m_SymbolTable[Index] = new Symbol(Name, Type, Index); } break; case EGTRecord.Group: //#, Name, Container#, Start#, End#, Tokenized, Open Ended, Reserved, Count, (Nested Group #...) { Group G = new Group(); G.TableIndex = EGT.RetrieveInt16(); //# G.Name = EGT.RetrieveString(); G.Container = m_SymbolTable[EGT.RetrieveInt16()]; G.Start = m_SymbolTable[EGT.RetrieveInt16()]; G.End = m_SymbolTable[EGT.RetrieveInt16()]; G.Advance = (Group.AdvanceMode)EGT.RetrieveInt16(); G.Ending = (Group.EndingMode)EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved int Count = EGT.RetrieveInt16(); for (int n = 1; n <= Count; n++) { G.Nesting.Add(EGT.RetrieveInt16()); } //=== Link back m_GroupStart.Add(G.Start, G); m_GroupTable[G.TableIndex] = G; } break; case EGTRecord.CharRanges: //#, Total Sets, RESERVED, (Start#, End# ...) { int Index = 0; int Total = 0; Index = EGT.RetrieveInt16(); EGT.RetrieveInt16(); //Codepage Total = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_CharSetTable[Index] = new CharacterSet(); while (!(EGT.RecordComplete())) { m_CharSetTable[Index].Add(new CharacterRange(EGT.RetrieveUInt16(), EGT.RetrieveUInt16())); } } break; case EGTRecord.Production: //#, ID#, Reserved, (Symbol#, ...) { short Index = 0; int HeadIndex = 0; int SymIndex = 0; Index = EGT.RetrieveInt16(); HeadIndex = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved List<Symbol> symbols = new List<Symbol>(); while (!(EGT.RecordComplete())) { SymIndex = EGT.RetrieveInt16(); //m_ProductionTable[Index].Handle().Add(m_SymbolTable[SymIndex]); symbols.Add(m_SymbolTable[SymIndex]); } SymbolList symbolList = new SymbolList(symbols); m_ProductionTable[Index] = new Production(m_SymbolTable[HeadIndex], Index, symbolList); } break; case EGTRecord.DFAState: //#, Accept?, Accept#, Reserved (CharSet#, Target#, Reserved)... { int Index = 0; bool Accept = false; int AcceptIndex = 0; int SetIndex = 0; short Target = 0; Index = EGT.RetrieveInt16(); Accept = EGT.RetrieveBoolean(); AcceptIndex = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved if (Accept) { m_DFA[Index] = new FAState(m_SymbolTable[AcceptIndex]); } else { m_DFA[Index] = new FAState(); } //(Edge chars, Target#, Reserved)... while (!(EGT.RecordComplete())) { SetIndex = EGT.RetrieveInt16(); //Char table index Target = EGT.RetrieveInt16(); //Target EGT.RetrieveEntry(); //Reserved m_DFA[Index].Edges.Add(new FAEdge(m_CharSetTable[SetIndex], Target)); } } break; case EGTRecord.LRState: //#, Reserved (Symbol#, Action, Target#, Reserved)... { int Index = 0; int SymIndex = 0; LRActionType Action = 0; short Target = 0; Index = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_LRStates[Index] = new LRState(); //(Symbol#, Action, Target#, Reserved)... while (!EGT.RecordComplete()) { SymIndex = EGT.RetrieveInt16(); Action = (LRActionType)EGT.RetrieveInt16(); Target = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_LRStates[Index].Add(new LRAction(m_SymbolTable[SymIndex], Action, Target)); } } break; default: //RecordIDComment throw new ParserException("File Error. A record of type '" + (char)RecType + "' was read. This is not a valid code."); } } } catch (Exception ex) { throw new ParserException(ex.Message, ex, "LoadTables"); } }
/// <summary> /// 获取原始数据对应的编码后数据(不包括起始符、特殊符(EAN128时)、检验符、终止符) /// </summary> /// <param name="rawData">编码对应的原始数据</param> /// <param name="tempBuilder">编码数据容器</param> /// <param name="nowCharacterSet">当前字符集</param> /// <param name="i">字符串索引</param> /// <param name="nowWeight">当前权值</param> /// <param name="checkNum">当前检验值总和</param> internal static void GetEncodedData(string rawData, StringBuilder tempBuilder, ref CharacterSet nowCharacterSet, ref int i, ref int nowWeight, ref int checkNum) { //因为可能存在字符集C,所以i与nowWeight可能存在不一致关系,所以要分别定义 byte sIndex; switch (nowCharacterSet) { case CharacterSet.A: case CharacterSet.B: for (; i < rawData.Length; i++) { if (char.IsDigit(rawData[i])) { //数字 int digitLength = GetDigitLength(rawData, i); if (digitLength >= 4) { //转入CodeC if (digitLength % 2 != 0) {//奇数位数字,在第一个数字之后插入CodeC字符 sIndex = GetSIndex(nowCharacterSet, (rawData[i])); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); i++; } nowCharacterSet = CharacterSet.C; sIndex = GetCodeXIndex(nowCharacterSet);//插入CodeC切换字符 EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); GetEncodedData(rawData, tempBuilder, ref nowCharacterSet, ref i, ref nowWeight, ref checkNum); return; } else { //如果小于4位数字,则直接内部循环结束 for (int j = 0; j < digitLength; j++) { sIndex = GetSIndex(nowCharacterSet, (rawData[i])); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); i++; } i--;//因为上面循环结束后继续外部循环会导致i多加了1,所以要减去1 continue; } } else if (CharNotBelongsTo(nowCharacterSet, rawData[i])) {//当前字符不属于目前的字符集 byte tempByte = GetProprietaryChar(rawData, i + 1);//获取当前字符后第一个属于A,或B的字符集 CharacterSet tempCharacterSet = GetShiftCharacterSet(nowCharacterSet); if (tempByte != byte.MaxValue && CharOnlyBelongsTo(nowCharacterSet, (char)tempByte)) { //加入转换符 sIndex = SHIFT_AB; EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); sIndex = GetSIndex(tempCharacterSet, rawData[i]); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); continue; } else { //加入切换符 nowCharacterSet = tempCharacterSet; sIndex = GetCodeXIndex(nowCharacterSet); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); GetEncodedData(rawData, tempBuilder, ref nowCharacterSet, ref i, ref nowWeight, ref checkNum); return; } } else { sIndex = GetSIndex(nowCharacterSet, rawData[i]); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); } } break; default: for (; i < rawData.Length; i += 2) { if (i != rawData.Length - 1 && char.IsDigit(rawData, i) && char.IsDigit(rawData, i + 1)) { sIndex = byte.Parse(rawData.Substring(i, 2)); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); } else { nowCharacterSet = GetCharacterSet(rawData, i); //插入转换字符 sIndex = GetCodeXIndex(nowCharacterSet); EncodingCommon(tempBuilder, sIndex, ref nowWeight, ref checkNum); GetEncodedData(rawData, tempBuilder, ref nowCharacterSet, ref i, ref nowWeight, ref checkNum); return; } } break; } }
/// <summary> /// 获取转换后的字符集 /// </summary> /// <param name="characterSet"></param> /// <returns></returns> internal static CharacterSet GetShiftCharacterSet(CharacterSet characterSet) { switch (characterSet) { case CharacterSet.A: return CharacterSet.B; case CharacterSet.B: return CharacterSet.A; default: throw new NotImplementedException(); } }
internal static byte GetSIndex(CharacterSet characterSet, char c) { switch (characterSet) { case CharacterSet.A: return GetSIndexFromA(c); case CharacterSet.B: return GetSIndexFromB(c); default: throw new NotImplementedException(); } }
public CharacterSet(bool negate, string/*!*/ include, CharacterSet/*!*/ exclude) { Assert.NotNull(include, exclude); _negated = negate; _include = include; _exclude = exclude; }
private void ResetCharacterSet() { CharacterSet = getDefaultCharacterSet(); }
internal CharacterSet/*!*/ Subtract(CharacterSet/*!*/ set) { if (IsEmpty || set.IsEmpty) { return this; } if (_negated) { if (set._negated) { // (^A) \ (^B) = ^A and B = B \ A return set.Complement().Subtract(Complement()); } else { // (^A) \ B == ^(A or B) return Complement().Union(set).Complement(); } } else if (set._negated) { // A \ ^(B) == A and B return Intersect(set.Complement()); } // (a \ B) \ C == a \ (B or C) return new CharacterSet(_include, _exclude.Union(set)); }
internal VcProjectConfiguration(XmlElement elem, VcProject parentProject, DirectoryInfo outputDir) : base(elem, parentProject, outputDir) { // determine relative output directory (outdir) XmlAttribute outputDirAttribute = elem.Attributes["OutputDirectory"]; if (outputDirAttribute != null) { _rawRelativeOutputDir = outputDirAttribute.Value; } // get intermediate directory and expand macros XmlAttribute intermidiateDirAttribute = elem.Attributes["IntermediateDirectory"]; if (intermidiateDirAttribute != null) { _rawIntermediateDir = intermidiateDirAttribute.Value; } // get referencespath directory and expand macros XmlAttribute referencesPathAttribute = elem.Attributes["ReferencesPath"]; if (referencesPathAttribute != null) { _rawReferencesPath = StringUtils.ConvertEmptyToNull(referencesPathAttribute.Value); } string managedExtentions = GetXmlAttributeValue(elem, "ManagedExtensions"); if (managedExtentions != null) { switch(managedExtentions.ToLower()) { case "false": case "0": _managedExtensions = false; break; case "true": case "1": _managedExtensions = true; break; default: throw new BuildException(String.Format("ManagedExtensions '{0}' is not supported yet.",managedExtentions)); } } // get configuration type string type = GetXmlAttributeValue(elem, "ConfigurationType"); if (type != null) { _type = (ConfigurationType) Enum.ToObject(typeof(ConfigurationType), int.Parse(type, CultureInfo.InvariantCulture)); } string wholeProgramOptimization = GetXmlAttributeValue(elem, "WholeProgramOptimization"); if (wholeProgramOptimization != null) { _wholeProgramOptimization = string.Compare(wholeProgramOptimization.Trim(), "true", true, CultureInfo.InvariantCulture) == 0; } string characterSet = GetXmlAttributeValue(elem, "CharacterSet"); if (characterSet != null) { _characterSet = (CharacterSet) Enum.ToObject(typeof(CharacterSet), int.Parse(characterSet, CultureInfo.InvariantCulture)); } // get MFC settings string useOfMFC = GetXmlAttributeValue(elem, "UseOfMFC"); if (useOfMFC != null) { _useOfMFC = (UseOfMFC) Enum.ToObject(typeof(UseOfMFC), int.Parse(useOfMFC, CultureInfo.InvariantCulture)); } // get ATL settings string useOfATL = GetXmlAttributeValue(elem, "UseOfATL"); if (useOfATL != null) { _useOfATL = (UseOfATL) Enum.ToObject(typeof(UseOfATL), int.Parse(useOfATL, CultureInfo.InvariantCulture)); } _linkerConfiguration = new LinkerConfig(this); }
internal CharacterSet/*!*/ Intersect(CharacterSet/*!*/ set) { if (IsEmpty || set.IsEmpty) { return Empty; } if (_negated) { if (set._negated) { // ^A and ^B == ^(A or B) return Complement().Union(set.Complement()).Complement(); } else { // ^A and B = B \ A return set.Subtract(Complement()); } } else if (set._negated) { // A and ^B = A \ B return Subtract(set.Complement()); } // (a \ B) and (c \ D) == a \ ^(c \ (B or D)) // // Proof: // (a \ B) and (c \ D) == // (a and ^B) and (c and ^D) == // a \ ^(c and ^B and ^D) == // a \ ^(c \ (B or D)) QED return new CharacterSet(_include, new CharacterSet(true, set._include, _exclude.Union(set._exclude))); }
public FAEdge(CharacterSet charSet, int target) { this.Characters = charSet; this.Target = target; }
public static string String(CharacterSet characterSet, int minLength, int maxLength) { return String(characterSet, Int(minLength, maxLength)); }
public Font(Device device, int height, int width, FontWeight weight, int mipLevels, bool italic, CharacterSet characterSet, Precision outputPrecision, FontQuality quality, PitchAndFamily pitchAndFamily, string faceName) : base(device, height, width, weight, mipLevels, italic, characterSet, outputPrecision, quality, pitchAndFamily, faceName) { }
public static string String(CharacterSet characterSet) { return String(characterSet, Int(1000)); }
// // union ::= union term // | term // // term ::= escape // | group // | posix_character_class // | character '-' character // | character // // posix_character_class ::= '[' negation_opt ':' posix_character_class_name ':' ']' // private CharacterSet ParseCharacterGroupUnion() { CharacterSet result = CharacterSet.Empty; // \u{1 2 3} produces multiple characters, the first and the last might be range bounds: IEnumerator<int> codepoints = null; while (true) { bool mayStartRange; var set = ParseCharacter(ref codepoints, out mayStartRange); if (set == null) { break; } if (codepoints == null && Read('-')) { // [a-] // [a-&&b] bool mayEndRange; var rangeEnd = ParseCharacter(ref codepoints, out mayEndRange); if (rangeEnd == null) { result = result.Union(set).Union(new CharacterSet(@"\-", true)); break; } // [a-b]-z // \p{L}-z if (!mayStartRange || !set.IsSingleCharacter) { throw MakeError("char-class value at start of range"); } // a-[a-z] // a-\p{L} if (!mayEndRange || !rangeEnd.IsSingleCharacter) { throw MakeError("char-class value at end of range"); } set = new CharacterSet(set.Include + "-" + rangeEnd.Include); } result = result.Union(set); } return result; }
partial void OnCharacterSetChanging(CharacterSet value);
/// <summary>Create a font object</summary> public Font CreateFont(Device device, int height, int width, FontWeight weight, int mip, bool italic, CharacterSet charSet, Precision outputPrecision, FontQuality quality, PitchAndFamily pandf, string fontName) { // Create the font description FontDescription desc = new FontDescription(); desc.Height = height; desc.Width = width; desc.Weight = weight; desc.MipLevels = mip; desc.IsItalic = italic; desc.CharSet = charSet; desc.OutputPrecision = outputPrecision; desc.Quality = quality; desc.PitchAndFamily = pandf; desc.FaceName = fontName; // return the font return CreateFont(device, desc); }