public void ReadToEndFromStringTextContentProvider()
		{
			string text = "abc";
			StringTextContentProvider provider = new StringTextContentProvider(text);
			using (SourceCodeReader reader = provider.GetReader()) {
				Assert.AreEqual("abc", reader.ReadToEnd());
			}
		}
		public IPyCompiler.Tokenizer CreateTokenizer(string text)
		{
			ScriptEngine engine = Python.CreateEngine();
			PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext;
			
			StringTextContentProvider textProvider = new StringTextContentProvider(text);
			SourceUnit source = context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement);

			PythonCompilerSink sink = new PythonCompilerSink();
			IPyCompiler.PythonCompilerOptions options = new IPyCompiler.PythonCompilerOptions();

			tokenizer = new IPyCompiler.Tokenizer(sink, options);
			tokenizer.Initialize(source);
			return tokenizer;
		}
		public FromImportStatement ParseStatement(string text)
		{
			ScriptEngine engine = Python.CreateEngine();
			PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext;
			
			StringTextContentProvider textProvider = new StringTextContentProvider(text);
			SourceUnit source = context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement);

			PythonCompilerSink sink = new PythonCompilerSink();
			CompilerContext compilerContext = new CompilerContext(source, new PythonCompilerOptions(), sink);

			PythonOptions options = new PythonOptions();
			using (Parser parser = Parser.CreateParser(compilerContext, options)) {
				return parser.ParseSingleStatement().Body as FromImportStatement;
			}
		}
Пример #4
0
		SourceUnit CreateSourceUnit(PythonContext context, string expression)
		{
			StringTextContentProvider textProvider = new StringTextContentProvider(expression);
			return context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement);
		}
Пример #5
0
        SourceUnit CreateSourceUnit(PythonContext context, string expression)
        {
            StringTextContentProvider textProvider = new StringTextContentProvider(expression);

            return(context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement));
        }
		public void StringTextContentProviderIsMicrosoftScriptingTextContentProvider()
		{
			StringTextContentProvider provider = new StringTextContentProvider(String.Empty);
			Assert.IsNotNull(provider as TextContentProvider);
		}