Exemple #1
0
 static int Main(string[] args)
 {
     SourceUnit unit = new SourceCodeUnit(RB, File.ReadAllText(args[0]));
     LoggingErrorSink log = new LoggingErrorSink();
     new Parser().Parse(new CompilerContext(unit, new RubyCompilerOptions(), log));
     return log.ErrorCount + log.FatalErrorCount;
 }
Exemple #2
0
        static int Main(string[] args)
        {
            SourceUnit       unit = new SourceCodeUnit(RB, File.ReadAllText(args[0]));
            LoggingErrorSink log  = new LoggingErrorSink();

            new Parser().Parse(new CompilerContext(unit, new RubyCompilerOptions(), log));
            return(log.ErrorCount + log.FatalErrorCount);
        }
Exemple #3
0
		public TransientCompilationUnit(string/*!*/ sourceCode, PhpSourceFile/*!*/ sourceFile, Encoding/*!*/ encoding, NamingContext namingContext, int line, int column, bool client)
		{
			Debug.Assert(sourceCode != null && sourceFile != null && encoding != null);
			Debug.Assert(!client);
			this.sourceUnit = new SourceCodeUnit(this, sourceCode, sourceFile, encoding, line, column);
			this.sourceUnit.AddImportedNamespaces(namingContext);
		}
Exemple #4
0
		public TransientCompilationUnit(string/*!*/ sourceCode, PhpSourceFile/*!*/ sourceFile, Encoding/*!*/ encoding, NamingContext namingContext, int line, int column, bool client)
		{
			Debug.Assert(sourceCode != null && sourceFile != null && encoding != null);
			Debug.Assert(!client);
			this.sourceUnit = new SourceCodeUnit(this, sourceCode, sourceFile, encoding, line, column);
            this.sourceUnit.Naming = namingContext ?? new NamingContext(null, null);    // cant be null
		}
Exemple #5
0
        private static CSharpSyntaxTree CreateSyntaxTree(SourceCodeUnit sourceCodeUnit)
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(sourceCodeUnit.SourceCode, null, sourceCodeUnit.FileName) as CSharpSyntaxTree;

            return(syntaxTree);
        }
Exemple #6
0
        public bool TryExpression(string expression)
        {
            CompilerOptions copts = engine.GetDefaultCompilerOptions();
            ErrorSink sink = new ErrorSink();

            SourceCodeUnit scu = new SourceCodeUnit(engine, expression);
            CompilerContext cc = new CompilerContext(scu, copts, sink);
            engine.Compiler.ParseExpressionCode(cc);
            return !sink.AnyError;
        }