示例#1
1
        public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) {
            if (severity == Severity.Warning && !ReportWarning(_context.Verbose, errorCode)) {
                return;
            }

            CountError(severity);

            string path;
            string codeLine;
            int line = span.Start.Line;
            if (sourceUnit != null) {
                path = sourceUnit.Path;
                codeLine = (line > 0) ? sourceUnit.GetCodeLine(line) : null;
            } else {
                path = null;
                codeLine = null;
            }

            if (severity == Severity.Error || severity == Severity.FatalError) {
                throw new SyntaxError(message, path, line, span.Start.Column, codeLine);
            } else {

                if (_WriteSite == null) {
                    Interlocked.CompareExchange(
                        ref _WriteSite,
                        CallSite<Func<CallSite, object, object, object>>.Create(RubyCallAction.Make(_context, "write", 1)),
                        null
                    );
                }

                message = RubyContext.FormatErrorMessage(message, "warning", path, line, span.Start.Column, null);

                _WriteSite.Target(_WriteSite, _context.StandardErrorOutput, MutableString.CreateMutable(message));
            }
        }
示例#2
0
文件: Lexer.cs 项目: dlurton/Happy
        internal Lexer(SourceUnit unit, HappyLanguageContext languageContext)
        {
            _reader = new InputReader(unit);
            _errorCollector = new ErrorCollector(languageContext.ErrorSink);
            PushState(LexerMode.LexingStatement);

            _keywords["if"] = HappyTokenKind.KeywordIf;
            _keywords["else"] = HappyTokenKind.KeywordElse;
            _keywords["while"] = HappyTokenKind.KeywordWhile;
            _keywords["for"] = HappyTokenKind.KeywordFor;
            _keywords["in"] = HappyTokenKind.KeywordIn;
            _keywords["between"] = HappyTokenKind.KeywordBetween;
            _keywords["where"] = HappyTokenKind.KeywordWhere;
            _keywords["lookup"] = HappyTokenKind.KeywordLookup;
            _keywords["default"] = HappyTokenKind.KeywordDefault;
            _keywords["true"] = HappyTokenKind.LiteralBool;
            _keywords["false"] = HappyTokenKind.LiteralBool;
            _keywords["return"] = HappyTokenKind.KeywordReturn;
            _keywords["def"] = HappyTokenKind.KeywordDef;
            _keywords["null"] = HappyTokenKind.LiteralNull;
            _keywords["load"] = HappyTokenKind.KeywordLoad;
            _keywords["use"] = HappyTokenKind.KeywordUse;
            _keywords["new"] = HappyTokenKind.KeywordNew;
            _keywords["function"] = HappyTokenKind.KeywordFunction;
            _keywords["break"] = HappyTokenKind.KeywordBreak;
            _keywords["continue"] = HappyTokenKind.KeywordContinue;
            _keywords["switch"] = HappyTokenKind.KeywordSwitch;
            _keywords["case"] = HappyTokenKind.KeywordCase;
        }
示例#3
0
 HappySourceLocation(SourceUnit unit, SourceSpan span)
 {
     //ContractUtils.RequiresNotNull(unit, "unit");
     ContractUtils.RequiresNotNull(span, "span");
     this.Unit = unit;
     this.Span = span;
 }
示例#4
0
        public LambdaFunctionExpr(SourceUnit/*!*/ sourceUnit,
            Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
            Scope scope, NamespaceDecl ns,
            bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalParam> useParams,
            List<Statement>/*!*/ body)
            : base(position)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                else
                    formalParams.InsertRange(0, useParams);
            }
            
            //this.ns = ns;
            this.signature = new Signature(aliasReturn, formalParams);
            this.useParams = useParams;
            //this.typeSignature = new TypeSignature(genericParams);
            //this.attributes = new CustomAttributes(attributes);
            this.body = body;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;

            //QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);
            //function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
            function = new PhpLambdaFunction(this.signature, sourceUnit, position);
            function.WriteUp(new TypeSignature(FormalTypeParam.EmptyList).ToPhpRoutineSignature(function));
        }
 /// <summary>
 /// Creates a wrapper around a function which represents entry into a chunk of code
 /// </summary>
 public ExecutionContextExpression(CodeContext context, Expression scopeVariable, SourceUnit source, Expression body)
 {
     _context = context;
     _body = body;
     _scope = scopeVariable;
     _source = source;
 }
示例#6
0
        public void GeneratorTest(SourceUnit sourceUnit, bool useLua52)
        {
            var options = new LuaCompilerOptions()
            {
                SkipFirstLine = true,
                UseLua52Features = useLua52,
            };

            var reader = TestUtils.OpenReaderOrIgnoreTest(sourceUnit.GetReader);

            TestUtils.AssertSyntaxError(() =>
            {
                var tokenizer = new Tokenizer(ErrorSink.Default, options);
                tokenizer.Initialize(null, reader, sourceUnit, SourceLocation.MinValue);
                var parser = new Parser(tokenizer, tokenizer.ErrorSink, options);
                var ast = parser.Parse();
                Assert.That(ast, Is.Not.Null);

                var codeContext = new CodeContext((LuaContext)sourceUnit.LanguageContext);

                var gen = new Generator(codeContext);
                var expr = gen.Compile(ast, sourceUnit);
                Assert.That(expr, Is.Not.Null);
            });
        }
示例#7
0
		public override void Initialize(object state, TextReader textreader, SourceUnit sourceUnit, SS.SourceLocation initialLocation)
		{
			tokenizer = new Tokenizer (textreader.ReadToEnd ().ToCharArray (), new IdentifierTable ());
			tokenizer.Position = ConvertToMJCSrcLocation(initialLocation);
			this.sourceUnit = sourceUnit;
			this.state = state;
		}
示例#8
0
        public OptimizedScriptCode(Scope optimizedScope, DlrMainCallTarget optimizedTarget, SourceUnit sourceUnit)
            : base(sourceUnit) {
            ContractUtils.RequiresNotNull(optimizedScope, "optimizedScope");

            _optimizedScope = optimizedScope;
            _optimizedTarget = optimizedTarget;
        }
示例#9
0
        internal SourceUnitReader(SourceUnit sourceUnit, TextReader textReader)
        {
            Assert.NotNull(sourceUnit, textReader);

            _textReader = textReader;
            _sourceUnit = sourceUnit;
        }
示例#10
0
        private SourceUnitTree Parse(SourceUnit sourceUnit, bool allowSingle, out bool isExpression)
        {
            isExpression = false;
            IronyParser parser = new IronyParser(allowSingle ? singleStatement : fullGrammar);
            parser.Context.Mode = ParseMode.CommandLine;

            scopes = new Stack<LexicalScopeBuilder>();
            EnterTopLevelScope();
            try
            {
                var parsedScript = parser.Parse(sourceUnit.GetCode());
                if (parsedScript.HasErrors())
                {
                    sourceUnit.CodeProperties = ScriptCodeParseResult.Invalid;
                    return null;
                }

                if (sourceUnit.Kind == SourceCodeKind.InteractiveCode && parser.Context.Status == ParserStatus.AcceptedPartial)
                {
                    sourceUnit.CodeProperties = ScriptCodeParseResult.IncompleteStatement;
                    return null;
                }

                sourceUnit.CodeProperties = ScriptCodeParseResult.Complete;
                return BuildSourceTree(parsedScript.Root, sourceUnit, allowSingle, out isExpression);
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                LeaveScope();
            }
        }
示例#11
0
        internal LightExpression<Func<TotemEngine, IDynamicMetaObjectProvider, object>> ParseExprToLambda(SourceUnit sourceUnit)
        {
            bool isExpression;
            var ast = new Parser().ParseExpression(sourceUnit, out isExpression);
            if (ast == null)
                return null;
            var scope = new AnalysisScope.TopLevel(
                this,
                Expression.Parameter(typeof(TotemEngine), "totemRuntime"),
                Expression.Parameter(typeof(IDynamicMetaObjectProvider), "global"));

            var ret = Expression.Variable(typeof(object), "#__returnVariable");
            List<Expression> body = new List<Expression>();
            var b = AstGenerator.Generate(ast, scope);
            body.Add(Expression.Assign(ret, Expression.Convert(b, typeof(object))));
            if (sourceUnit.Kind == SourceCodeKind.InteractiveCode)
            {
                if(isExpression) body.Add(Expression.Call(typeof(Console).GetMethod("WriteLine", new[] { typeof(object) }), ret));
                body.Add(Expression.Call(typeof(Console).GetMethod("WriteLine", Type.EmptyTypes)));
                body.Add(ret);
            }

            var moduleFun = Utils.LightLambda<Func<TotemEngine, IDynamicMetaObjectProvider, object>>(
                typeof(object),
                Expression.Block(new ParameterExpression[] { ret }, body),
                "_snippet_",
                new List<ParameterExpression>() { scope.RuntimeExpr, scope.GlobalExpr }
            );
            //var moduleFun = Expression.Lambda<Func<TotemEngine, IDynamicMetaObjectProvider, object>>(
            //    Expression.Block(new ParameterExpression[] { ret }, body),
            //    scope.RuntimeExpr,
            //    scope.ModuleExpr
            //);
            return moduleFun;
        }
示例#12
0
 internal RubyScriptCode(ScriptCodeFunc/*!*/ target, SourceUnit/*!*/ sourceUnit, TopScopeFactoryKind kind)
     : base(sourceUnit)
 {
     Assert.NotNull(target);
     _target = target;
     _kind = kind;
 }
示例#13
0
 public LuaScriptCode(CodeContext context, SourceUnit sourceUnit, Expression<Func<IDynamicMetaObjectProvider, dynamic>> chunk)
     : base(sourceUnit)
 {
     Contract.Requires(chunk != null);
     Context = context;
     _exprLambda = chunk;
 }
示例#14
0
        public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            try
            {
                switch (sourceUnit.Kind)
                {
                    case SourceCodeKind.SingleStatement:
                    case SourceCodeKind.Expression:
                    case SourceCodeKind.AutoDetect:
                    case SourceCodeKind.InteractiveCode:
                        return new TotemScriptCode(
                            engine, engine.ParseExprToLambda(sourceUnit),
                            sourceUnit);

                    //case SourceCodeKind.Statements:
                    //case SourceCodeKind.File:
                    //    return new TotemScriptCode(
                    //        engine, engine.ParseFileToLambda(sourceUnit.Path, sourceUnit.GetCode()),
                    //        sourceUnit);

                    default:
                        throw Assert.Unreachable;
                }
            }
            catch (Exception e)
            {
                // Real language implementation would have a specific type
                // of exception.  Also, they would pass errorSink down into
                // the parser and add messages while doing tighter error
                // recovery and continuing to parse.
                errorSink.Add(sourceUnit, e.Message, SourceSpan.None, 0,
                              Severity.FatalError);
                return null;
            }
        }
示例#15
0
 public RubyScriptCode(Expression<ScriptCodeFunc>/*!*/ code, SourceUnit/*!*/ sourceUnit, TopScopeFactoryKind kind)
     : base(sourceUnit)
 {
     Assert.NotNull(code);
     _code = code;
     _kind = kind;
 }
示例#16
0
		internal override Evaluation EvaluatePriorAnalysis(SourceUnit/*!*/ sourceUnit)
		{
			Evaluation left_eval = leftExpr.EvaluatePriorAnalysis(sourceUnit);
			Evaluation right_eval = leftExpr.EvaluatePriorAnalysis(sourceUnit);

			return Evaluation.ReadOnlyEvaluate(this, left_eval, right_eval);
		}
        public LambdaFunctionExpr(SourceUnit/*!*/ sourceUnit,
            Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
            Scope scope, NamespaceDecl ns,
            bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalParam> useParams,
            List<Statement>/*!*/ body)
            : base(span)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                else
                    formalParams.InsertRange(0, useParams);
            }
            
            //this.ns = ns;
            this.signature = new Signature(aliasReturn, formalParams);
            this.useParams = useParams;
            //this.typeSignature = new TypeSignature(genericParams);
            //this.attributes = new CustomAttributes(attributes);
            this.body = body;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
示例#18
0
        public HappyLambdaScriptCode Analyze(Module module, SourceUnit sourceUnit)
        {
            Dictionary<string, HappyNamespaceTracker> rootNamespaces = LoadAllAssemblies(module.LoadDirectives);

            AstVisitorBase[] visitors =
                {
                    new BinaryExpressionFixerVisitor(),
                    new BuildSymbolTablesVisitor(this, _errorCollector, rootNamespaces),
                    new ResolveSymbolsVisitor(_errorCollector),
                    new SemanticVisitor(_errorCollector)
                };

            foreach (var v in visitors)
                module.Accept(v);

            prepareAssemblyGenerator();

            module.Accept(this);

            Expression expression = _expressionStack.Pop();
            DebugAssert.IsZero(_expressionStack.Count, "AstAnalyzer didn't consume all expressions on the stack");

            var runtimeContextInitializer = (LambdaExpression)expression;
            return new HappyLambdaScriptCode(sourceUnit, compileDynamicAssembly(runtimeContextInitializer));
        }
示例#19
0
 public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) {
     if (severity == Severity.Warning) {
         PythonOps.SyntaxWarning(message, sourceUnit, span, errorCode);
     } else {
         throw PythonOps.SyntaxError(message, sourceUnit, span, errorCode);
     }
 }
示例#20
0
文件: Parser.cs 项目: dlurton/Happy
 public static Module ParseModule(SourceUnit sourceUnit, HappyLanguageContext languageContext)
 {
     Lexer lexer = new Lexer(sourceUnit, languageContext);
     Parser parser = new Parser(lexer, languageContext);
     Module retval = null;
     try
     {
         retval = parser.Parse();
     }
     catch(AbortParseException)
     {
         //Left blank intentionally because AbortParseExceptions should never
         //be allowed to bubble up to the caller.
     }
     catch(SyntaxErrorException)
     {
         //We actually want to allow this exception to propogate as-is back
         //to the caller.  This is needed because of the catch-all below
         throw;
     }
     catch(Exception e)
     {
         //All other exceptions are to be considered an internal error
         //We may not know the exact location of the error, but we'll just
         //take the next token out of the lexer to give *some* kind of
         //idea line might contain the error
         DebugAssert.IsNotNull(e);
         Token t = lexer.NextToken();
         throw new InternalSourceException(e, t.Location,
             "The parser threw an unhandled exception.  This is usually caused by a syntax error " +
             "in the script being parsed.  The error ocurred at or before the this locaiton.");
     }
     return retval;
 }
示例#21
0
文件: Program.cs 项目: TerabyteX/main
            public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity)
            {
                base.Add(sourceUnit, message, span, errorCode, severity);

                Console.Error.WriteLine("{0}({1}:{2}): {3}: RB{4}: {5}", sourceUnit.Name, span.Start.Line, span.Start.Column,
                    severity, errorCode, message);
            }
示例#22
0
 public LightScriptCode(LambdaExpression lambda, SourceUnit sourceUnit, bool optimized)
     : base(lambda, sourceUnit)
 {
     //var sw = System.Diagnostics.Stopwatch.StartNew();
     EnsureCompiled(optimized);
     //sw.Stop();
     //System.Console.WriteLine("{0} light compile", sw.Elapsed.TotalSeconds);
 }
示例#23
0
        internal static AST BuildAst(CodeContext context, SourceUnit sourceUnit, PythonCompilerOptions opts, string mode) {
            Parser parser = Parser.CreateParser(
                new CompilerContext(sourceUnit, opts, ThrowingErrorSink.Default),
                (PythonOptions)context.LanguageContext.Options);

            PythonAst ast = parser.ParseFile(true);
            return ConvertToAST(ast, mode);
        }
示例#24
0
		void CreateTokenizer(SourceUnit source)
		{
			PythonCompilerSink sink = new PythonCompilerSink();
			PythonCompilerOptions options = new PythonCompilerOptions();
			
			tokenizer = new Tokenizer(sink, options);
			tokenizer.Initialize(source);
		}
示例#25
0
        public LegacyScriptCode(LambdaExpression code, DlrMainCallTarget target, SourceUnit sourceUnit)
            : base(sourceUnit)
        {
            ContractUtils.RequiresNotNull(sourceUnit, "sourceUnit");

            _target = target;
            _code = code;
        }
示例#26
0
        public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
        {
            this.ErrorCount++;

            message = FormatMessage(source != null ? source.Path : "<none>", span.Start.Line, span.Start.Column, message);
            _languageContext.ErrorOutput.WriteLine(message);
            base.Add(source, message, span, errorCode, severity);
        }
        public MultiFileTokenizer(SourceUnit compilationUnit, Report report)
        {
            fileIndex = 0;
            this.compilationUnit = compilationUnit;
            this.report = report;

            Initialize();
        }
示例#28
0
        public static void SyntaxWarning(string message, SourceUnit sourceUnit, SourceSpan span, int errorCode)
        {
            throw new NotImplementedException();
            //TotemContext pc = (TotemContext)sourceUnit.LanguageContext;
            //CodeContext context = pc.SharedContext;

            //ShowWarning(context, PythonExceptions.SyntaxWarning, message, sourceUnit.Path, span.Start.Line);
        }
示例#29
0
        private Func<CodeContext/*!*/, FunctionCode/*!*/, object>/*!*/ _target, _tracingTarget; // lazily compiled targets

        public PythonScriptCode(CompilerContext/*!*/ context, Expression<Func<CodeContext/*!*/, FunctionCode/*!*/, object>>/*!*/ lambda, SourceUnit/*!*/ sourceUnit, Dictionary<int, bool> handlerLocations, Dictionary<int, Dictionary<int, bool>> loopAndFinallyLocations)
            : base(sourceUnit) {
            Assert.NotNull(lambda, context);

            _context = context;
            _lambda = lambda;
            _handlerLocations = handlerLocations;
            _loopAndFinallyLocations = loopAndFinallyLocations;
        }
示例#30
0
        public CompilerContext(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink, ParserSink parserSink)
        {
            Contract.RequiresNotNull(sourceUnit, "sourceUnit");

            _sourceUnit = sourceUnit;
            _options = options ?? sourceUnit.Engine.GetDefaultCompilerOptions();
            _errors = errorSink ?? sourceUnit.Engine.GetCompilerErrorSink();
            _parserSink = parserSink ?? ParserSink.Null;
        }
示例#31
0
文件: imp.cs 项目: rudimk/dlr-dotnet
        private static PythonModule /*!*/ LoadPythonSource(PythonContext /*!*/ context, string /*!*/ name, PythonFile /*!*/ file, string /*!*/ fileName)
        {
            SourceUnit sourceUnit = context.CreateSnippet(file.read(), String.IsNullOrEmpty(fileName) ? null : fileName, SourceCodeKind.File);

            return(context.CompileModule(fileName, name, sourceUnit, ModuleOptions.Initialize));
        }
 public InterpretedScriptCode(LambdaExpression code, SourceUnit sourceUnit)
     : base(code, sourceUnit)
 {
 }
示例#33
0
 public BasicNodesFactory(SourceUnit sourceUnit)
 {
     _sourceUnit = sourceUnit;
 }
示例#34
0
        public static MSA.Expression <T> /*!*/ Transform <T>(SourceUnitTree /*!*/ ast, SourceUnit /*!*/ sourceUnit,
                                                             RubyCompilerOptions /*!*/ options, int sourceId)
        {
            var siteNodes = new Dictionary <MSA.DynamicExpression, SourceSpan>();
            var context   = (RubyContext)sourceUnit.LanguageContext;

            context.CallSiteCreated = (expression, callSite) => siteNodes.Add(callSite, expression.Location);

            var generator = new AstGenerator(context, options, sourceUnit.Document, ast.Encoding, false);
            var lambda    = ast.Transform <T>(generator);

            return((MSA.Expression <T>) new CallSiteTraceInjector(siteNodes, sourceId).Visit(lambda));
        }
示例#35
0
 public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
 {
     // invariant language doesn't have a grammar:
     throw new NotSupportedException();
 }
示例#36
0
 public TraceAstGenerator(Dictionary <MSA.DynamicExpression, SourceSpan> /*!*/ sites,
                          RubyContext /*!*/ context, RubyCompilerOptions /*!*/ options, SourceUnit /*!*/ sourceUnit, Encoding /*!*/ encoding)
     : base((RubyBinder)context.Binder, options, sourceUnit, encoding, false,
            context.DomainManager.Configuration.DebugMode, false, false, false)
 {
     _sites = sites;
 }
示例#37
0
 public CompilerContext(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
     : this(sourceUnit, options, errorSink, ParserSink.Null)
 {
 }
示例#38
0
 public AstCounterFactory(SourceUnit sourceUnit) : base(sourceUnit)
 {
 }
示例#39
0
 public SymplCode(SymplContext symplContext,
                  Expression <Func <CodeContext, IDynamicMetaObjectProvider, Object> > lambda, SourceUnit sourceUnit) : base(
         sourceUnit)
 {
     this.lambda       = lambda;
     this.symplContext = symplContext;
 }
示例#40
0
文件: Literal.cs 项目: ikvm/Phalanger
 internal override Evaluation EvaluatePriorAnalysis(SourceUnit /*!*/ sourceUnit)
 {
     return(new Evaluation(this, Value));
 }
示例#41
0
        ExecInModule(string code, PythonModule module)
        {
            SourceUnit script = this.python.CreateSnippet(code, SourceCodeKind.Statements);

            script.Execute(new Scope(new DictionaryWrapper((IDictionary <object, object>)module.Get__dict__())));
        }
示例#42
0
        public static MSA.Expression <T> /*!*/ Transform <T>(SourceUnitTree /*!*/ ast, SourceUnit /*!*/ sourceUnit,
                                                             RubyCompilerOptions /*!*/ options, int sourceId)
        {
            var context   = (RubyContext)sourceUnit.LanguageContext;
            var siteNodes = new Dictionary <MSA.DynamicExpression, SourceSpan>();
            var generator = new TraceAstGenerator(siteNodes, context, options, sourceUnit, ast.Encoding);
            var lambda    = ast.Transform <T>(generator);

            return((MSA.Expression <T>) new CallSiteTraceInjector(siteNodes, sourceId).Visit(lambda));
        }
示例#43
0
 public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
 {
     span = Add(message, span, severity);
 }
示例#44
0
 /// <summary>
 /// Create naming context.
 /// </summary>
 /// <param name="ns">Current namespace declaration. In case it is <c>null</c>, context for global code is created.</param>
 /// <param name="unit">Global code used when <paramref name="ns"/> is <c>null</c>.</param>
 /// <returns>Naming context. Cannot be <c>null</c>.</returns>
 public static NamingContext GetNamingContext(NamespaceDecl ns, SourceUnit unit)
 {
     return((ns != null) ? ns.Naming : unit.Naming);
 }
示例#45
0
 public PythonSavableScriptCode(Expression <Func <CodeContext, FunctionCode, object> > code, SourceUnit sourceUnit, string[] names, string moduleName)
     : base(sourceUnit)
 {
     _code       = code;
     _names      = names;
     _moduleName = moduleName;
 }
示例#46
0
 /// <summary>
 /// Parses the source code within a specified compiler context.
 /// The source unit to parse is held on by the context.
 /// </summary>
 /// <returns><b>null</b> on failure.</returns>
 /// <remarks>Could also set the code properties and line/file mappings on the source unit.</remarks>
 public abstract ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink);
示例#47
0
        private PhpSyntaxTree(SourceUnit source)
        {
            Contract.ThrowIfNull(source);

            _source = source;
        }
示例#48
0
 public FunctionDefinition(string name, Parameter[] parameters, SourceUnit sourceUnit)
     : this(name, parameters, (Statement)null)
 {
 }
示例#49
0
 public FunctionDefinition(string name, Parameter[] parameters, Statement body, SourceUnit sourceUnit)
     : this(name, parameters, body)
 {
 }
示例#50
0
 public ResolvedFile(SourceUnit /*!*/ sourceUnit, string appendedExtension)
 {
     SourceUnit        = sourceUnit;
     Path              = sourceUnit.Path;
     AppendedExtension = appendedExtension;
 }
示例#51
0
 public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
 {
     CountError(severity);
     _errors.Add(String.Format("{0}: {1}", severity, message));
 }
示例#52
0
 public NodesFactory(SourceUnit sourceUnit) : base(sourceUnit)
 {
 }
示例#53
0
 internal TypeRefContext(SourceUnit sourceUnit, SourceTypeSymbol containingType)
 {
     _sourceUnit     = sourceUnit;
     _typeRefs       = new List <ITypeRef>();
     _containingType = containingType;
 }
示例#54
0
 private static PythonModule /*!*/ LoadFromSourceUnit(CodeContext /*!*/ context, SourceUnit /*!*/ sourceCode, string /*!*/ name, string /*!*/ path)
 {
     Assert.NotNull(sourceCode, name, path);
     return(PythonContext.GetContext(context).CompileModule(path, name, sourceCode, ModuleOptions.Initialize | ModuleOptions.Optimized));
 }
示例#55
0
 public override void Add(SourceUnit source, String message, SourceSpan span, Int32 errorCode, Severity severity)
 {
     Add(message, source.Path, source.GetCode(), source.GetCodeLine(span.Start.Line), span, errorCode, severity);
 }
示例#56
0
 internal override Evaluation EvaluatePriorAnalysis(SourceUnit /*!*/ sourceUnit)
 {
     return(expr.EvaluatePriorAnalysis(sourceUnit).ReadOnlyEvaluate(this));
 }
示例#57
0
 public abstract void Initialize(object state, TextReader sourceReader, SourceUnit sourceUnit, SourceLocation initialLocation);
示例#58
0
 public TabException(string message, SourceUnit sourceUnit, SourceSpan span, int errorCode, Severity severity)
     : base(message, sourceUnit, span, errorCode, severity)
 {
 }
示例#59
0
 public override ScriptCode CompileSourceCode(SourceUnit sourceUnit,
                                              CompilerOptions options, ErrorSink errorSink)
 {
     return(new HelloScriptCode(sourceUnit));
 }
示例#60
0
        public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            var sc = new QsScriptCode(sourceUnit);

            return(sc);
        }