示例#1
0
 public static IProjectReader ToReader(this InputKind kind)
 {
     return(kind switch
     {
         InputKind.Directory => new DirectoryFileReader(),
         InputKind.Csproj => new CSProjectReader(),
         InputKind.Sln => new SolutionReader(),
         InputKind.CSharpFile => new CSharpFileReader(),
         _ => throw new System.ArgumentException($"Undefined inputKind [{kind}]"),
     });
示例#2
0
        public static IProjectReader ToReader(this InputKind kind)
        {
            switch (kind)
            {
            case InputKind.Directory: return(new DirectoryFileReader());

            case InputKind.Csproj: return(new CSProjectReader());

            case InputKind.Sln: return(new SolutionReader());

            default: throw new System.ArgumentException($"Undefined inputKind [kind]");
            }
        }
示例#3
0
        public override IDictionary <string, object> Serialize()
        {
            var props = base.Serialize();

            props[nameof(DimensionData.Channels)] = DimensionData.Channels;
            props[nameof(DimensionData.Height)]   = DimensionData.Height;
            props[nameof(DimensionData.Width)]    = DimensionData.Width;
            props[nameof(InputKind)]           = InputKind.ToString();
            props[nameof(Parameter.BatchSize)] = Parameter.BatchSize;
            props[nameof(Parameter.CropSize)]  = Parameter.CropSize;
            props[nameof(Parameter.Mirror)]    = Parameter.Mirror;
            return(props);
        }
示例#4
0
        internal static Currency Min(Currency currency, Currency rhs, InputKind kind = InputKind.Auto)
        {
            if (currency is null)
            {
                throw new ArgumentNullException(nameof(currency));
            }

            if (rhs is null)
            {
                throw new ArgumentNullException(nameof(rhs));
            }

            return(new Currency(Math.Min(currency.Value, rhs.Value), kind));
        }
示例#5
0
        /// <summary>
        /// Выполняет основную работу программы.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="inputKind"></param>
        private static void Start(string[] args, InputKind inputKind)
        {
            Text text;
            Text output;

            //Чекаем способ ввода, получчаем текст в зависисости от результата проверки
            if (inputKind == InputKind.Console)
            {
                Console.WriteLine("Введите текст:");
                string userinput = Console.ReadLine();
                text = new Text(userinput);
            }
            else
            {
                string input = File.ReadAllText(args[args.Length - 1]);
                text = new Text(input);
            }
            //Исходящий текст.
            output = new Text(text);
            //Выполняем просьбы пользователя исходя из параметров

            if (args.Contains("-l"))
            {
                PrintLengthInfos(text);
            }


            if (args.Contains("-s"))
            {
                output.DeleteDupSpaces();
            }

            if (args.Contains("-c"))
            {
                output.OnlyRealWords();
            }

            if (args.Contains("-p"))
            {
                PrintStatistics(text, output);
            }
            //Если пользователь не просил новый файл то его делать не будет
            if (!args.Contains("-q"))
            {
                var sw = File.CreateText("text.txt");
                sw.Write(output.Content);
                sw.Close();
            }
        }
示例#6
0
        /// <summary>
        /// Gets the unknown input kind. Must be overridden in sub-classes.
        /// </summary>
        /// <returns>The input kind.</returns>
        public virtual InputKind GetKind()
        {
            string[] pathComponents =
                Util.SubstringAfter(this.Path, "/data/inputs/", null).Split('/');
            string kindPath;

            if (pathComponents[0].Equals("tcp"))
            {
                kindPath = "tcp/" + pathComponents[1];
            }
            else
            {
                kindPath = pathComponents[0];
            }

            return(InputKind.Create(kindPath));
        }
示例#7
0
        public void SetDefaultSettings()
        {
            size = TC_Settings.instance.global.defaultTerrainSize;

            if (transform.parent.GetSiblingIndex() == 0)
            {
                inputKind  = InputKind.Shape;
                inputShape = InputShape.Circle;
                wrapMode   = ImageWrapMode.Clamp;
            }
            else if (outputId == TC.heightOutput)
            {
                inputKind = InputKind.File;
                inputFile = InputFile.RawImage;
                wrapMode  = ImageWrapMode.Clamp;
            }
        }
示例#8
0
    private void UpdateInput()
    {
        var  input          = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        bool wasJumpPressed = Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical");

        if (!wasJumpPressed)
        {
            if (!wasJumpPressedDuringJump)
            {
                currentInput = InputKind.None;
            }
            return;
        }

        if (input.x > 0.01f)
        {
            currentInput = InputKind.JumpRight;
        }
        else if (input.x < -0.01f)
        {
            currentInput = InputKind.JumpLeft;
        }
        else if (input.y > 0.01f)
        {
            currentInput = InputKind.JumpForward;
        }

        /// If the Jump button was pressed
        /// right before the previous jump ends
        /// then the character should make another jump after the current one ends.
        if (isJumping)
        {
            float timeNow         = Time.unscaledTime;
            float nextLandingTime = previousJumpStartTime + jumpDuration;
            if (timeNow >= nextLandingTime - doubleJumpTime && timeNow <= nextLandingTime)
            {
                wasJumpPressedDuringJump = true;
            }
        }
    }
        //
        // Parses the string @input and returns a CSharpParser if succeeful.
        //
        // if @silent is set to true then no errors are
        // reported to the user.  This is used to do various calls to the
        // parser and check if the expression is parsable.
        //
        // @partial_input: if @silent is true, then it returns whether the
        // parsed expression was partial, and more data is needed
        //
        static CSharpParser ParseString(ParseMode mode, string input, out bool partial_input)
        {
            partial_input = false;
            Reset();
            queued_fields.Clear();
            Tokenizer.LocatedToken.Initialize();

            Stream s = new MemoryStream(Encoding.Default.GetBytes(input));
            SeekableStreamReader seekable = new SeekableStreamReader(s, Encoding.Default);

            InputKind kind = ToplevelOrStatement(seekable);

            if (kind == InputKind.Error)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    ctx.Report.Error(-25, "Detection Parsing Error");
                }
                partial_input = false;
                return(null);
            }

            if (kind == InputKind.EOF)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true");
                }
                partial_input = true;
                return(null);
            }
            seekable.Position = 0;

            CSharpParser parser = new CSharpParser(seekable, Location.SourceFiles [0], RootContext.ToplevelTypes);

            if (kind == InputKind.StatementOrExpression)
            {
                parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter;
                RootContext.StatementMode = true;
            }
            else
            {
                //
                // Do not activate EvalCompilationUnitParserCharacter until
                // I have figured out all the limitations to invoke methods
                // in the generated classes.  See repl.txt
                //
                parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
                //parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
                RootContext.StatementMode = false;
            }

            if (mode == ParseMode.GetCompletions)
            {
                parser.Lexer.CompleteOnEOF = true;
            }

            ReportPrinter old_printer = null;

            if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions) && CSharpParser.yacc_verbose_flag == 0)
            {
                old_printer = SetPrinter(new StreamReportPrinter(TextWriter.Null));
            }

            try
            {
                parser.parse();
            }
            finally
            {
                if (ctx.Report.Errors != 0)
                {
                    if (mode != ParseMode.ReportErrors && parser.UnexpectedEOF)
                    {
                        partial_input = true;
                    }

                    parser.undo.ExecuteUndo();
                    parser = null;
                }

                if (old_printer != null)
                {
                    SetPrinter(old_printer);
                }
            }
            return(parser);
        }
示例#10
0
文件: datetime.cs 项目: kashano/main
 internal static void ValidateInput(InputKind kind, int value) {
     switch (kind) {
         case InputKind.Year:
             if (value > DateTime.MaxValue.Year || value < DateTime.MinValue.Year) {
                 throw PythonOps.ValueError("year is out of range");
             }
             break;
         case InputKind.Month:
             if (value > 12 || value < 1) {
                 throw PythonOps.ValueError("month must be in 1..12");
             }
             break;
         case InputKind.Day:
             // TODO: changing upper bound
             if (value > 31 || value < 1) {
                 throw PythonOps.ValueError("day is out of range for month");
             }
             break;
         case InputKind.Hour:
             if (value > 23 || value < 0) {
                 throw PythonOps.ValueError("hour must be in 0..23");
             }
             break;
         case InputKind.Minute:
             if (value > 59 || value < 0) {
                 throw PythonOps.ValueError("minute must be in 0..59");
             }
             break;
         case InputKind.Second:
             if (value > 59 || value < 0) {
                 throw PythonOps.ValueError("second must be in 0..59");
             }
             break;
         case InputKind.Microsecond:
             if (value > 999999 || value < 0) {
                 throw PythonOps.ValueError("microsecond must be in 0..999999");
             }
             break;
     }
 }
示例#11
0
        //
        // Parses the string @input and returns a CSharpParser if succeeful.
        //
        // if @silent is set to true then no errors are
        // reported to the user.  This is used to do various calls to the
        // parser and check if the expression is parsable.
        //
        // @partial_input: if @silent is true, then it returns whether the
        // parsed expression was partial, and more data is needed
        //
        CSharpParser ParseString(ParseMode mode, string input, out bool partial_input)
        {
            partial_input = false;
            Reset();

            var enc = ctx.Settings.Encoding;
            var s   = new MemoryStream(enc.GetBytes(input));
            SeekableStreamReader seekable = new SeekableStreamReader(s, enc);

            InputKind kind = ToplevelOrStatement(seekable);

            if (kind == InputKind.Error)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    ctx.Report.Error(-25, "Detection Parsing Error");
                }
                partial_input = false;
                return(null);
            }

            if (kind == InputKind.EOF)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true");
                }
                partial_input = true;
                return(null);
            }
            seekable.Position = 0;

            source_file.DeclarationFound = false;
            CSharpParser parser = new CSharpParser(seekable, source_file, new ParserSession());

            if (kind == InputKind.StatementOrExpression)
            {
                parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter;
                parser.Lexer.parsing_block++;
                ctx.Settings.StatementMode = true;
            }
            else
            {
                parser.Lexer.putback_char  = Tokenizer.EvalCompilationUnitParserCharacter;
                ctx.Settings.StatementMode = false;
            }

            if (mode == ParseMode.GetCompletions)
            {
                parser.Lexer.CompleteOnEOF = true;
            }

            ReportPrinter old_printer = null;

            if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions))
            {
                old_printer = ctx.Report.SetPrinter(new StreamReportPrinter(TextWriter.Null));
            }

            try {
                parser.parse();
            } finally {
                if (ctx.Report.Errors != 0)
                {
                    if (mode != ParseMode.ReportErrors && parser.UnexpectedEOF)
                    {
                        partial_input = true;
                    }

                    if (parser.undo != null)
                    {
                        parser.undo.ExecuteUndo();
                    }

                    parser = null;
                }

                if (old_printer != null)
                {
                    ctx.Report.SetPrinter(old_printer);
                }
            }
            return(parser);
        }
示例#12
0
 private ImmutableArray <Project> LoadProject(InputKind inputKind)
 {
     return(inputKind.ToReader().ReadAllSourceCodeFiles(TargetFileOrDirectory, StyleCopJsonFilePath));
 }
示例#13
0
        //
        // Parses the string @input and returns a CSharpParser if succeeful.
        //
        // if @silent is set to true then no errors are
        // reported to the user.  This is used to do various calls to the
        // parser and check if the expression is parsable.
        //
        // @partial_input: if @silent is true, then it returns whether the
        // parsed expression was partial, and more data is needed
        //
        static CSharpParser ParseString(bool silent, string input, out bool partial_input)
        {
            partial_input = false;
            Reset();
            queued_fields.Clear();

            Stream s = new MemoryStream(Encoding.Default.GetBytes(input));
            SeekableStreamReader seekable = new SeekableStreamReader(s, Encoding.Default);

            InputKind kind = ToplevelOrStatement(seekable);

            if (kind == InputKind.Error)
            {
                if (!silent)
                {
                    Report.Error(-25, "Detection Parsing Error");
                }
                partial_input = false;
                return(null);
            }

            if (kind == InputKind.EOF)
            {
                if (silent == false)
                {
                    Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true");
                }
                partial_input = true;
                return(null);
            }
            seekable.Position = 0;

            CSharpParser parser = new CSharpParser(seekable, (CompilationUnit)Location.SourceFiles [0]);

            parser.ErrorOutput = Report.Stderr;

            if (kind == InputKind.StatementOrExpression)
            {
                parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter;
                RootContext.StatementMode = true;
            }
            else
            {
                //
                // Do not activate EvalCompilationUnitParserCharacter until
                // I have figured out all the limitations to invoke methods
                // in the generated classes.  See repl.txt
                //
                parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
                //parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
                RootContext.StatementMode = false;
            }

            if (silent)
            {
                Report.DisableReporting();
            }
            try {
                parser.parse();
            } finally {
                if (Report.Errors != 0)
                {
                    if (silent && parser.UnexpectedEOF)
                    {
                        partial_input = true;
                    }

                    parser.undo.ExecuteUndo();
                    parser = null;
                }

                if (silent)
                {
                    Report.EnableReporting();
                }
            }
            return(parser);
        }
示例#14
0
        /// <summary>
        /// Touch all the properties of all any input
        /// </summary>
        /// <param name="input">The Input</param>
        private void TouchSpecificInput(Input input)
        {
            InputKind      inputKind      = input.GetKind();
            TcpConnections tcpConnections = null;
            UdpConnections udpConnections = null;

            string[] dummyStrings;
            string   dummyString;
            bool     dummyBoolean;
            DateTime dummyDate;
            int      dummyInt;

            if (inputKind.Equals(InputKind.Monitor))
            {
                MonitorInput monitorInput = (MonitorInput)input;
                dummyString  = monitorInput.Blacklist;
                dummyString  = monitorInput.CrcSalt;
                dummyInt     = monitorInput.FileCount;
                dummyBoolean = monitorInput.FollowTail;
                dummyString  = monitorInput.Host;
                dummyString  = monitorInput.HostRegex;
                dummyString  = monitorInput.IgnoreOlderThan;
                dummyString  = monitorInput.Index;
                dummyString  = monitorInput.Queue;
                dummyBoolean = monitorInput.IsRecursive;
                dummyString  = monitorInput.Source;
                dummyString  = monitorInput.SourceType;
                dummyInt     = monitorInput.TimeBeforeClose;
                dummyString  = monitorInput.Whitelist;
            }
            else if (inputKind.Equals(InputKind.Script))
            {
                ScriptInput scriptInput = (ScriptInput)input;
                dummyDate   = scriptInput.EndTime;
                dummyString = scriptInput.Group;
                dummyString = scriptInput.Host;
                dummyString = scriptInput.Index;
                dummyString = scriptInput.Interval;
                dummyDate   = scriptInput.StartTime;
            }
            else if (inputKind.Equals(InputKind.Tcp))
            {
                TcpInput tcpInput = (TcpInput)input;
                dummyString    = tcpInput.ConnectionHost;
                dummyString    = tcpInput.Group;
                dummyString    = tcpInput.Host;
                dummyString    = tcpInput.Index;
                dummyString    = tcpInput.Queue;
                dummyString    = tcpInput.RestrictToHost;
                dummyString    = tcpInput.Source;
                dummyString    = tcpInput.SourceType;
                dummyBoolean   = tcpInput.SSL;
                tcpConnections = tcpInput.Connections();
                dummyString    = tcpConnections.Connection;
                dummyString    = tcpConnections.Servername;
            }
            else if (inputKind.Equals(InputKind.TcpSplunk))
            {
                TcpSplunkInput tcpSplunkInput = (TcpSplunkInput)input;
                dummyString    = tcpSplunkInput.ConnectionHost;
                dummyString    = tcpSplunkInput.Group;
                dummyString    = tcpSplunkInput.Host;
                dummyString    = tcpSplunkInput.Index;
                dummyString    = tcpSplunkInput.Queue;
                dummyString    = tcpSplunkInput.Source;
                dummyString    = tcpSplunkInput.SourceType;
                dummyBoolean   = tcpSplunkInput.SSL;
                tcpConnections = tcpSplunkInput.Connections();
                dummyString    = tcpConnections.Connection;
                dummyString    = tcpConnections.Servername;
            }
            else if (inputKind.Equals(InputKind.Udp))
            {
                UdpInput udpInput = (UdpInput)input;
                dummyString    = udpInput.ConnectionHost;
                dummyString    = udpInput.Group;
                dummyString    = udpInput.Host;
                dummyString    = udpInput.Index;
                dummyString    = udpInput.Queue;
                dummyString    = udpInput.Source;
                dummyString    = udpInput.SourceType;
                dummyBoolean   = udpInput.NoAppendingTimeStamp;
                dummyBoolean   = udpInput.NoPriorityStripping;
                udpConnections = udpInput.Connections();
                dummyString    = udpConnections.Group;
            }
            else if (inputKind.Equals(InputKind.WindowsActiveDirectory))
            {
                WindowsActiveDirectoryInput windowsActiveDirectoryInput = (WindowsActiveDirectoryInput)input;
                dummyString  = windowsActiveDirectoryInput.Index;
                dummyBoolean = windowsActiveDirectoryInput.MonitorSubtree;
                dummyString  = windowsActiveDirectoryInput.StartingNode;
                dummyString  = windowsActiveDirectoryInput.TargetDc;
            }
            else if (inputKind.Equals(InputKind.WindowsEventLog))
            {
                WindowsEventLogInput windowsEventLogInput = (WindowsEventLogInput)input;
                dummyString  = windowsEventLogInput.Hosts;
                dummyString  = windowsEventLogInput.Index;
                dummyString  = windowsEventLogInput.LocalName;
                dummyStrings = windowsEventLogInput.Logs;
                dummyString  = windowsEventLogInput.LookupHost;
            }
            else if (inputKind.Equals(InputKind.WindowsPerfmon))
            {
                WindowsPerfmonInput windowsPerfmonInput = (WindowsPerfmonInput)input;
                dummyStrings = windowsPerfmonInput.Counters;
                dummyString  = windowsPerfmonInput.Index;
                dummyStrings = windowsPerfmonInput.Instances;
                dummyInt     = windowsPerfmonInput.Interval;
                dummyString  = windowsPerfmonInput.Object;
            }
            else if (inputKind.Equals(InputKind.WindowsRegistry))
            {
                WindowsRegistryInput windowsRegistryInput = (WindowsRegistryInput)input;
                dummyBoolean = windowsRegistryInput.Baseline;
                dummyString  = windowsRegistryInput.Hive;
                dummyString  = windowsRegistryInput.Index;
                dummyBoolean = windowsRegistryInput.MonitorSubnodes;
                dummyString  = windowsRegistryInput.Proc;
                dummyStrings = windowsRegistryInput.Type;
            }
            else if (inputKind.Equals(InputKind.WindowsWmi))
            {
                WindowsWmiInput windowsWmiInput = (WindowsWmiInput)input;
                dummyString  = windowsWmiInput.Classes;
                dummyStrings = windowsWmiInput.Fields;
                dummyString  = windowsWmiInput.Index;
                dummyStrings = windowsWmiInput.Instances;
                dummyInt     = windowsWmiInput.Interval;
                dummyString  = windowsWmiInput.LocalName;
                dummyString  = windowsWmiInput.LookupHost;
                dummyString  = windowsWmiInput.Servers;
                dummyString  = windowsWmiInput.Wql;
            }
            else
            {
                Assert.Fail();
            }
        }
示例#15
0
        static public void ClickMenuInput(object obj)
        {
            int    instanceID;
            string command = TD.ObjectToCommandAndInstanceID(obj, out instanceID);

            TC_Node node = EditorUtility.InstanceIDToObject(instanceID) as TC_Node;

            if (node != null)
            {
                int    index     = command.IndexOf("/");
                string inputKind = command.Substring(0, index);
                string input     = command.Substring(index + 1);
                bool   changed   = false;

                InputKind oldInputKind = node.inputKind;
                node.inputKind = (InputKind)Enum.Parse(typeof(InputKind), inputKind);

                if (node.inputKind != oldInputKind)
                {
                    changed = true;
                }

                if (inputKind == "Terrain")
                {
                    InputTerrain oldInputTerrain = node.inputTerrain;
                    node.inputTerrain = (InputTerrain)Enum.Parse(typeof(InputTerrain), input);
                    if (node.inputTerrain != oldInputTerrain)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Noise")
                {
                    InputNoise oldInputNoise = node.inputNoise;
                    node.inputNoise = (InputNoise)Enum.Parse(typeof(InputNoise), input);
                    if (node.inputNoise != oldInputNoise)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Shape")
                {
                    InputShape oldInputShape = node.inputShape;
                    node.inputShape = (InputShape)Enum.Parse(typeof(InputShape), input);
                    if (node.inputShape != oldInputShape)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "File")
                {
                    InputFile oldInputFile = node.inputFile;
                    node.inputFile = (InputFile)Enum.Parse(typeof(InputFile), input);
                    if (node.inputFile != oldInputFile)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Current")
                {
                    InputCurrent oldInputCurrent = node.inputCurrent;
                    node.inputCurrent = (InputCurrent)Enum.Parse(typeof(InputCurrent), input);
                    if (node.inputCurrent != oldInputCurrent)
                    {
                        changed = true;
                    }
                }

                if (changed)
                {
                    node.Init();
                    EditorUtility.SetDirty(node);
                    TC.RefreshOutputReferences(node.outputId, true);
                }
            }
        }
示例#16
0
 public Currency(double value = 0, InputKind kind = InputKind.Auto)
 {
     Value = value;
     Kind  = kind;
 }
示例#17
0
 public Currency(Currency interest, InputKind kind) : this(interest.Value, kind)
 {
 }
示例#18
0
        //
        // Parses the string @input and returns a CSharpParser if succeeful.
        //
        // if @silent is set to true then no errors are
        // reported to the user.  This is used to do various calls to the
        // parser and check if the expression is parsable.
        //
        // @partial_input: if @silent is true, then it returns whether the
        // parsed expression was partial, and more data is needed
        //
        CSharpParser ParseString(ParseMode mode, string input, out bool partial_input)
        {
            partial_input = false;
            Reset();
            Tokenizer.LocatedToken.Initialize();

            Stream s = new MemoryStream(Encoding.UTF8.GetBytes(input));
            SeekableStreamReader seekable = new SeekableStreamReader(s, Encoding.UTF8);

            InputKind kind = ToplevelOrStatement(seekable);

            if (kind == InputKind.Error)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    ctx.Report.Error(-25, "Detection Parsing Error");
                }
                partial_input = false;
                return(null);
            }

            if (kind == InputKind.EOF)
            {
                if (mode == ParseMode.ReportErrors)
                {
                    Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true");
                }
                partial_input = true;
                return(null);
            }
            seekable.Position = 0;

            if (ns == null)
            {
                ns = new NamespaceEntry(module, null, Location.SourceFiles[0], null);
            }

            ns.DeclarationFound = false;
            CSharpParser parser = new CSharpParser(seekable, Location.SourceFiles [0], module, ns);

            if (kind == InputKind.StatementOrExpression)
            {
                parser.Lexer.putback_char  = Tokenizer.EvalStatementParserCharacter;
                ctx.Settings.StatementMode = true;
            }
            else
            {
                parser.Lexer.putback_char  = Tokenizer.EvalCompilationUnitParserCharacter;
                ctx.Settings.StatementMode = false;
            }

            if (mode == ParseMode.GetCompletions)
            {
                parser.Lexer.CompleteOnEOF = true;
            }

            ReportPrinter old_printer = null;

            if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions) && CSharpParser.yacc_verbose_flag == 0)
            {
                old_printer = ctx.Report.SetPrinter(new StreamReportPrinter(TextWriter.Null));
            }

            try {
                parser.parse();
            } finally {
                if (ctx.Report.Errors != 0)
                {
                    if (mode != ParseMode.ReportErrors && parser.UnexpectedEOF)
                    {
                        partial_input = true;
                    }

                    if (parser.undo != null)
                    {
                        parser.undo.ExecuteUndo();
                    }

                    parser = null;
                }

                if (old_printer != null)
                {
                    ctx.Report.SetPrinter(old_printer);
                }
            }
            return(parser);
        }
示例#19
0
 void OnEnable()
 {
     currentInput             = InputKind.None;
     wasJumpPressedDuringJump = false;
 }
示例#20
0
        public static string GetInputTypeName(Generator gen, ITypeRequestSource source, TypeReference t, InputKind kind)
        {
            switch (kind)
            {
            case InputKind.Default: return(GetTypeName(gen, source, t, TypeUsage.In));

            case InputKind.Raw: return(GetTypeName(gen, source, t, TypeUsage.Raw));

            case InputKind.Slice: return($"&[{ GetTypeName(gen, source, t, TypeUsage.In) }]");

            case InputKind.MutSlice:
                Assert(t.IsValueType);
                return($"&mut [{ GetTypeName(gen, source, t, TypeUsage.In) }]");

            case InputKind.VecBuffer: return($"&mut Vec<{ GetTypeName(gen, source, t, TypeUsage.OutNonNull) }>");

            default: throw new InvalidOperationException();
            }
        }