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); }
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; }
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); }
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; }
public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName) { mangledName = structName.Name + "::" + memberName.Name; return(script.FindTokenWithName(mangledName)); }
public ScriptReader(TokenizedScript source) { _source = source; _tokenStream = source.TokenStream; }
public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName) { mangledName = structName.Name + "::" + memberName.Name; return script.FindTokenWithName(mangledName); }