예제 #1
0
        public CompileResults CompileScript(string script)
        {
            ITokenizer tokenizer = CompilerFactory.CreateTokenizer();

            _tokenizedScript = tokenizer.TokenizeScript(script);
            _source          = new ScriptReader(_tokenizedScript);
            _output          = new CompiledScript();

            while (true)
            {
                Token thisToken = _source.ReadNextToken();

                if (thisToken is EndOfStreamToken)
                {
                    break;
                }

                try
                {
                    ProcessTokenAtTopLevel(thisToken);
                }
                catch (CompilerMessage error)
                {
                    RecordError(error.Code, error.Message);
                    break;
                }
            }

            return(_results);
        }
예제 #2
0
		public CompileResults CompileScript(string script)
		{
			ITokenizer tokenizer = CompilerFactory.CreateTokenizer();
            _tokenizedScript = tokenizer.TokenizeScript(script);
			_source = new ScriptReader(_tokenizedScript);
			_output = new CompiledScript();

			while (true)
			{
				Token thisToken = _source.ReadNextToken();

				if (thisToken is EndOfStreamToken)
				{
					break;
				}

				try
				{
					ProcessTokenAtTopLevel(thisToken);
				}
				catch (CompilerMessage error)
				{
					RecordError(error.Code, error.Message);
                    break;
				}
			}

			return _results;
		}
예제 #3
0
        public TokenizedScript TokenizeScript(string scriptToProcess)
        {
            TokenizedScript output = new TokenizedScript();

            int        lineNumber = 1;
            FastString script     = new FastString(scriptToProcess);

            while (script.Length > 0)
            {
                SkipWhitespace(ref script);

                if (script.Length == 0)
                {
                    break;
                }
                else if ((script[0] == '\r') || (script[0] == '\n'))
                {
                    output.WriteNewLineNumber(lineNumber);
                    lineNumber++;

                    if ((script.Length > 1) && (script[0] == '\r') && (script[1] == '\n'))
                    {
                        script = script.Substring(2);
                    }
                    else
                    {
                        script = script.Substring(1);
                    }
                }
                else
                {
                    int symbolStart = 0;
                    int i           = 1;
                    while (IsPartOfSameSymbol(script, symbolStart, i))
                    {
                        i++;
                    }

                    string thisSymbol = script.Substring(symbolStart, i);
                    output.WriteToken(thisSymbol);
                    if (thisSymbol.StartsWith(Constants.NEW_SCRIPT_MARKER))
                    {
                        lineNumber = 1;
                    }
                    if (i < script.Length)
                    {
                        script = script.Substring(i);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            output.WriteEndOfStream();
            return(output);
        }
예제 #4
0
        public TokenizedScript TokenizeScript(string scriptToProcess)
        {
            TokenizedScript output = new TokenizedScript();

            int lineNumber = 1;
            FastString script = new FastString(scriptToProcess);
            while (script.Length > 0)
            {
                SkipWhitespace(ref script);

                if (script.Length == 0)
                {
                    break;
                }
                else if ((script[0] == '\r') || (script[0] == '\n'))
                {
                    output.WriteNewLineNumber(lineNumber);
                    lineNumber++;

                    if ((script.Length > 1) && (script[0] == '\r') && (script[1] == '\n'))
                    {
                        script = script.Substring(2);
                    }
                    else
                    {
                        script = script.Substring(1);
                    }
                }
                else
                {
                    int symbolStart = 0;
                    int i = 1;
                    while (IsPartOfSameSymbol(script, symbolStart, i))
                    {
                        i++;
                    }

                    string thisSymbol = script.Substring(symbolStart, i);
                    output.WriteToken(thisSymbol);
                    if (thisSymbol.StartsWith(Constants.NEW_SCRIPT_MARKER))
                    {
                        lineNumber = 1;
                    }
                    if (i < script.Length)
                    {
                        script = script.Substring(i);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            output.WriteEndOfStream();
            return output;
        }
예제 #5
0
 public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName)
 {
     mangledName = structName.Name + "::" + memberName.Name;
     return(script.FindTokenWithName(mangledName));
 }
예제 #6
0
 public ScriptReader(TokenizedScript source)
 {
     _source      = source;
     _tokenStream = source.TokenStream;
 }
예제 #7
0
 public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName)
 {
     mangledName = structName.Name + "::" + memberName.Name;
     return script.FindTokenWithName(mangledName);
 }
예제 #8
0
 public ScriptReader(TokenizedScript source)
 {
     _source = source;
     _tokenStream = source.TokenStream;
 }