csharp/Actipro/WPF-Controls/Samples/SampleBrowser/ProductSamples/SyntaxEditorSamples/QuickStart/GettingStarted03c/SimpleLexer.cs

SimpleLexer.cs
using System;
using System.Collections.Generic;
using ActiproSoftware.Text;
using ActiproSoftware.Text.Lexing;
using ActiproSoftware.Text.Lexing.Implementation;
using ActiproSoftware.Text.RegularExpressions;
using ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.GettingStarted03b;

namespace ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.GettingStarted03c {

	/// 
	/// Represents a programmatic mergable Simple lexer (lexical astyzer) implementation.
	/// 
	public clast SimpleLexer : MergableLexerBase {

		private bool caseSensitive;
		private LexicalStateCollection lexicalStates;

		private static Dictionary keywords = new Dictionary();

		/////////////////////////////////////////////////////////////////////////////////////////////////////
		// OBJECT
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// 
		/// Initializes a new instance of the SimpleLexer clast.
		/// 
		/// Whether the language is case sensitive.
		public SimpleLexer(bool caseSensitive) {
			// This is added for demo purposes... normally a language knows whether it is case sensitive or not
			this.caseSensitive = caseSensitive;

			// Create ID providers
			this.LexicalStateIdProviderCore = new SimpleLexicalStateId();
			this.TokenIdProviderCore = new SimpleTokenId();

			// Initialize keywords
			if (keywords.Count == 0) {
				for (int tokenId = this.TokenIdProviderCore.MinId; tokenId = SimpleTokenId.Function) && (tokenId = '0') && (ch