Пример #1
0
        //=========================================================================================
        public void AddTokenDeclaration(string name, string declaration)
        {
            var oScanner = new SA.CodeView.Parsing.TokenDefParsing.Scanner(declaration, string.Empty);
            var oParser  = new SA.CodeView.Parsing.TokenDefParsing.Parser(oScanner);

            int iStartStatesCount = this.States.Count;

            oParser.Spec = this;
            oParser.Parse();

            ///Для всех состояний, у которых не определено ни одного перехода, определяем его на EndState.
            for (int iState = iStartStatesCount; iState < this.States.Count; iState++)
            {
                var oState = this.States[iState];
                if (oState.ElseState == null)
                {
                    if (oState.Entries.Count == 0)
                    {
                        oState.SetDefaultLink(this.EndState);
                    }
                    //else
                    //    oState.SetDefaultLink(this.FailState);
                }
                oState.ResultTokenName = name;
            }

            if (oParser.Errors.Count != 0)
            {
                throw new ArgumentException(oParser.Errors[0].Msg);
            }
        }
		//=========================================================================================
		public void AddTokenDeclaration(string name, string declaration)
		{
			var oScanner = new SA.CodeView.Parsing.TokenDefParsing.Scanner(declaration, string.Empty);
			var oParser = new SA.CodeView.Parsing.TokenDefParsing.Parser(oScanner);

			int iStartStatesCount = this.States.Count;

			oParser.Spec = this;
			oParser.Parse();

			///Для всех состояний, у которых не определено ни одного перехода, определяем его на EndState.
			for (int iState = iStartStatesCount; iState < this.States.Count; iState++)
			{
				var oState = this.States[iState];
				if (oState.ElseState == null)
				{
					if (oState.Entries.Count == 0)
						oState.SetDefaultLink(this.EndState);
					//else
					//    oState.SetDefaultLink(this.FailState);
				}
				oState.ResultTokenName = name;
			}

			if (oParser.Errors.Count != 0)
				throw new ArgumentException(oParser.Errors[0].Msg);
		}