Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Parsing / Token.cs / 1305376 / Token.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a type to represent a parsed token. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Parsing { using System; using System.Diagnostics; ///Use this class to represent a lexical token. [DebuggerDisplay("{Id} @ {Position}: [{Text}]")] internal struct Token { ///Token representing gt keyword internal static readonly Token GreaterThan = new Token { Text = ExpressionConstants.KeywordGreaterThan, Id = TokenId.Identifier, Position = 0 }; ///Token representing eq keyword internal static readonly Token EqualsTo = new Token { Text = ExpressionConstants.KeywordEqual, Id = TokenId.Identifier, Position = 0 }; ///Token representing lt keyword internal static readonly Token LessThan = new Token { Text = ExpressionConstants.KeywordLessThan, Id = TokenId.Identifier, Position = 0 }; ///Kind of token. internal TokenId Id; ///Token text. internal string Text; ///Position of token. internal int Position; ///Checks whether this token is a comparison operator. internal bool IsComparisonOperator { get { if (this.Id != TokenId.Identifier) { return false; } return this.Text == ExpressionConstants.KeywordEqual || this.Text == ExpressionConstants.KeywordNotEqual || this.Text == ExpressionConstants.KeywordLessThan || this.Text == ExpressionConstants.KeywordGreaterThan || this.Text == ExpressionConstants.KeywordLessThanOrEqual || this.Text == ExpressionConstants.KeywordGreaterThanOrEqual; } } ///Checks whether this token is an equality operator. internal bool IsEqualityOperator { get { return this.Id == TokenId.Identifier && (this.Text == ExpressionConstants.KeywordEqual || this.Text == ExpressionConstants.KeywordNotEqual); } } ///Checks whether this token is a valid token for a key value. internal bool IsKeyValueToken { get { return this.Id == TokenId.BinaryLiteral || this.Id == TokenId.BooleanLiteral || this.Id == TokenId.DateTimeLiteral || this.Id == TokenId.GuidLiteral || this.Id == TokenId.StringLiteral || ExpressionLexer.IsNumeric(this.Id); } } ///Provides a string representation of this token. ///String representation of this token. public override string ToString() { return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} @ {1}: [{2}]", this.Id, this.Position, this.Text); } ///Gets the current identifier text. ///The current identifier text. internal string GetIdentifier() { if (this.Id != TokenId.Identifier) { throw DataServiceException.CreateSyntaxError(Strings.RequestQueryParser_IdentifierExpected(this.Position)); } return this.Text; } ///Checks that this token has the specified identifier. /// Identifier to check. ///true if this is an identifier with the specified text. internal bool IdentifierIs(string id) { return this.Id == TokenId.Identifier && this.Text == id; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a type to represent a parsed token. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Parsing { using System; using System.Diagnostics; ///Use this class to represent a lexical token. [DebuggerDisplay("{Id} @ {Position}: [{Text}]")] internal struct Token { ///Token representing gt keyword internal static readonly Token GreaterThan = new Token { Text = ExpressionConstants.KeywordGreaterThan, Id = TokenId.Identifier, Position = 0 }; ///Token representing eq keyword internal static readonly Token EqualsTo = new Token { Text = ExpressionConstants.KeywordEqual, Id = TokenId.Identifier, Position = 0 }; ///Token representing lt keyword internal static readonly Token LessThan = new Token { Text = ExpressionConstants.KeywordLessThan, Id = TokenId.Identifier, Position = 0 }; ///Kind of token. internal TokenId Id; ///Token text. internal string Text; ///Position of token. internal int Position; ///Checks whether this token is a comparison operator. internal bool IsComparisonOperator { get { if (this.Id != TokenId.Identifier) { return false; } return this.Text == ExpressionConstants.KeywordEqual || this.Text == ExpressionConstants.KeywordNotEqual || this.Text == ExpressionConstants.KeywordLessThan || this.Text == ExpressionConstants.KeywordGreaterThan || this.Text == ExpressionConstants.KeywordLessThanOrEqual || this.Text == ExpressionConstants.KeywordGreaterThanOrEqual; } } ///Checks whether this token is an equality operator. internal bool IsEqualityOperator { get { return this.Id == TokenId.Identifier && (this.Text == ExpressionConstants.KeywordEqual || this.Text == ExpressionConstants.KeywordNotEqual); } } ///Checks whether this token is a valid token for a key value. internal bool IsKeyValueToken { get { return this.Id == TokenId.BinaryLiteral || this.Id == TokenId.BooleanLiteral || this.Id == TokenId.DateTimeLiteral || this.Id == TokenId.GuidLiteral || this.Id == TokenId.StringLiteral || ExpressionLexer.IsNumeric(this.Id); } } ///Provides a string representation of this token. ///String representation of this token. public override string ToString() { return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} @ {1}: [{2}]", this.Id, this.Position, this.Text); } ///Gets the current identifier text. ///The current identifier text. internal string GetIdentifier() { if (this.Id != TokenId.Identifier) { throw DataServiceException.CreateSyntaxError(Strings.RequestQueryParser_IdentifierExpected(this.Position)); } return this.Text; } ///Checks that this token has the specified identifier. /// Identifier to check. ///true if this is an identifier with the specified text. internal bool IdentifierIs(string id) { return this.Id == TokenId.Identifier && this.Text == id; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebZone.cs
- ConstructorNeedsTagAttribute.cs
- Polyline.cs
- EdmComplexPropertyAttribute.cs
- EntityModelBuildProvider.cs
- Comparer.cs
- BasicBrowserDialog.cs
- TraversalRequest.cs
- IPHostEntry.cs
- TemplateParser.cs
- translator.cs
- DrawingImage.cs
- ThreadStateException.cs
- TreeViewItemAutomationPeer.cs
- RegexStringValidatorAttribute.cs
- ISAPIApplicationHost.cs
- UseAttributeSetsAction.cs
- EntityDataSourceUtil.cs
- ServiceHttpModule.cs
- NativeObjectSecurity.cs
- SystemNetHelpers.cs
- SettingsPropertyCollection.cs
- DisplayInformation.cs
- UserPreferenceChangedEventArgs.cs
- SystemMulticastIPAddressInformation.cs
- JumpPath.cs
- TextAnchor.cs
- QuaternionAnimationUsingKeyFrames.cs
- ServiceHostFactory.cs
- ClientRoleProvider.cs
- HtmlImage.cs
- UserControl.cs
- WSSecurityPolicy12.cs
- UserMapPath.cs
- PropertyPath.cs
- ConfigXmlSignificantWhitespace.cs
- ChangesetResponse.cs
- Timeline.cs
- TiffBitmapEncoder.cs
- FlowLayout.cs
- StringDictionaryWithComparer.cs
- ProvideValueServiceProvider.cs
- LinearGradientBrush.cs
- DiscoveryDocumentReference.cs
- TargetParameterCountException.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- FixedPageProcessor.cs
- TextBoxBase.cs
- XamlToRtfWriter.cs
- RegularExpressionValidator.cs
- ItemCollectionEditor.cs
- Int64KeyFrameCollection.cs
- DrawingBrush.cs
- ColorConvertedBitmapExtension.cs
- ToolStripContainer.cs
- GeometryHitTestParameters.cs
- MemberAccessException.cs
- PersonalizationStateInfo.cs
- _BaseOverlappedAsyncResult.cs
- SettingsBase.cs
- PropertyValueUIItem.cs
- NamedPermissionSet.cs
- ActiveXMessageFormatter.cs
- ToolstripProfessionalRenderer.cs
- TextStore.cs
- VarRefManager.cs
- EntityCommandDefinition.cs
- GridViewCellAutomationPeer.cs
- HostingEnvironmentException.cs
- ServicePoint.cs
- Rfc4050KeyFormatter.cs
- SyntaxCheck.cs
- XamlPoint3DCollectionSerializer.cs
- MemberAssignmentAnalysis.cs
- XmlSchemaSimpleContent.cs
- RegularExpressionValidator.cs
- SqlGenerator.cs
- DataGridColumnFloatingHeader.cs
- FileChangesMonitor.cs
- CompositionAdorner.cs
- TextBox.cs
- KeyFrames.cs
- HttpConfigurationContext.cs
- OuterGlowBitmapEffect.cs
- EntitySet.cs
- _RequestCacheProtocol.cs
- OLEDB_Enum.cs
- EditingCoordinator.cs
- XMLSchema.cs
- CompoundFileIOPermission.cs
- PanelStyle.cs
- EventProvider.cs
- CultureTableRecord.cs
- EntityContainerEmitter.cs
- XamlParser.cs
- FusionWrap.cs
- OrCondition.cs
- DataObject.cs
- MembershipUser.cs
- EntityContainerEntitySetDefiningQuery.cs