Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataWeb / Server / System / Data / Services / Parsing / Token.cs / 1 / 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
{
/// 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
{
/// 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
- CollectionViewGroupRoot.cs
- ToolBarOverflowPanel.cs
- OdbcDataReader.cs
- CodeCommentStatement.cs
- ResourceManagerWrapper.cs
- Utilities.cs
- RootBrowserWindow.cs
- ExclusiveHandle.cs
- ProfilePropertySettingsCollection.cs
- ClipboardData.cs
- BrowserDefinitionCollection.cs
- SqlCharStream.cs
- WebPartEditorCancelVerb.cs
- DataObjectAttribute.cs
- DataServiceStreamProviderWrapper.cs
- DocumentEventArgs.cs
- SR.Designer.cs
- CommandID.cs
- ApplicationId.cs
- SqlExpressionNullability.cs
- EntryIndex.cs
- DesignerAttribute.cs
- EmptyEnumerable.cs
- ForceCopyBuildProvider.cs
- NamespaceInfo.cs
- DataGridViewAdvancedBorderStyle.cs
- SocketElement.cs
- ProcessHost.cs
- PropertyGrid.cs
- SimpleTypeResolver.cs
- DataGridLinkButton.cs
- DrawListViewSubItemEventArgs.cs
- HashCodeCombiner.cs
- ListBoxItem.cs
- ProcessHostConfigUtils.cs
- StringUtil.cs
- NetTcpBinding.cs
- CodeDirectiveCollection.cs
- SerializerDescriptor.cs
- InstanceDataCollectionCollection.cs
- PrivilegeNotHeldException.cs
- LassoHelper.cs
- AsymmetricSecurityProtocolFactory.cs
- UpdateTracker.cs
- DataKeyCollection.cs
- Endpoint.cs
- StringUtil.cs
- CurrentChangedEventManager.cs
- SelectedCellsCollection.cs
- SortDescription.cs
- AutomationEventArgs.cs
- Vector3DAnimationUsingKeyFrames.cs
- ZipFileInfo.cs
- CallSiteOps.cs
- X509SubjectKeyIdentifierClause.cs
- Receive.cs
- ToolStripItemImageRenderEventArgs.cs
- CallSite.cs
- WindowsTokenRoleProvider.cs
- ResXResourceSet.cs
- SpeechDetectedEventArgs.cs
- Sequence.cs
- EventKeyword.cs
- HttpModuleActionCollection.cs
- WebConfigurationFileMap.cs
- TextRenderer.cs
- PropertyEntry.cs
- DataGridViewComboBoxColumn.cs
- XmlValidatingReaderImpl.cs
- ResourceCollectionInfo.cs
- TextEditorCopyPaste.cs
- HostingEnvironmentException.cs
- PartialTrustHelpers.cs
- XPathConvert.cs
- TreeNodeBinding.cs
- XmlCDATASection.cs
- RubberbandSelector.cs
- MediaTimeline.cs
- RtfFormatStack.cs
- Trustee.cs
- SrgsNameValueTag.cs
- CompilerErrorCollection.cs
- Span.cs
- XomlSerializationHelpers.cs
- QueryStringParameter.cs
- HttpApplicationFactory.cs
- DataGridViewMethods.cs
- DataError.cs
- TextFormatterHost.cs
- WorkflowPersistenceService.cs
- cookiecontainer.cs
- StringFormat.cs
- QueueTransferProtocol.cs
- SudsParser.cs
- SymmetricCryptoHandle.cs
- PeerContact.cs
- IntranetCredentialPolicy.cs
- RowUpdatedEventArgs.cs
- ExpressionBuilderCollection.cs
- WSUtilitySpecificationVersion.cs