public SprocketScript(string source, string descriptiveName, string scriptIdentificationString)
		{
			this.source = source;
			this.identifier = new ExecutionState.ScriptRecursionIdentifier(descriptiveName, scriptIdentificationString);

			TokenList tokens;
			try
			{
				tokens = Tokeniser.Extract(source);
			}
			catch (TokeniserException ex)
			{
				Token falseToken = new Token(source.Substring(ex.Position, 1), TokenType.FreeText, ex.Position);
				Token token = new Token(GetErrorHTML(ex.Message, falseToken, null), TokenType.FreeText, 0);
				tokens = new TokenList(new List<Token>(new Token[] { token }));
				instruction = new ShowInstruction();
				instruction.Build(tokens);
				hasError = true;
				exception = ex;
				return;
			}

			try
			{
				instruction = TokenParser.BuildInstruction(tokens);
			}
			catch (TokenParserException ex)
			{
				Token token = new Token(GetErrorHTML(ex.Message, ex.Token, null), TokenType.FreeText, 0);
				tokens = new TokenList(new List<Token>(new Token[] { token }));
				instruction = new ShowInstruction();
				instruction.Build(tokens);
				hasError = true;
			}
		}
예제 #2
0
        public SprocketScript(string source, string descriptiveName, string scriptIdentificationString)
        {
            this.source     = source;
            this.identifier = new ExecutionState.ScriptRecursionIdentifier(descriptiveName, scriptIdentificationString);

            TokenList tokens;

            try
            {
                tokens = Tokeniser.Extract(source);
            }
            catch (TokeniserException ex)
            {
                Token falseToken = new Token(source.Substring(ex.Position, 1), TokenType.FreeText, ex.Position);
                Token token      = new Token(GetErrorHTML(ex.Message, falseToken, null), TokenType.FreeText, 0);
                tokens      = new TokenList(new List <Token>(new Token[] { token }));
                instruction = new ShowInstruction();
                instruction.Build(tokens);
                hasError  = true;
                exception = ex;
                return;
            }

            try
            {
                instruction = TokenParser.BuildInstruction(tokens);
            }
            catch (TokenParserException ex)
            {
                Token token = new Token(GetErrorHTML(ex.Message, ex.Token, null), TokenType.FreeText, 0);
                tokens      = new TokenList(new List <Token>(new Token[] { token }));
                instruction = new ShowInstruction();
                instruction.Build(tokens);
                hasError = true;
            }
        }