コード例 #1
0
ファイル: Scanner.cs プロジェクト: pcluddite/tbasic
        public bool NextFunction(Executer exec, out Function func)
        {
            func = null;
            if (EndOfStream)
            {
                return(false);
            }
            int originalPos = position;

            if (char.IsLetter(_buffer[position]) || _buffer[position] == '_')
            {
                position = FindAcceptableFuncChars(_buffer, ++position);
                if (position < _buffer.Length)
                {
                    StringSegment name = _buffer.Subsegment(originalPos, position - originalPos);
                    SkipWhiteSpace();
                    if (Next("("))
                    {
                        IList <object> args;
                        position = GroupParser.ReadGroup(_buffer, position - 1, exec, out args) + 1;
                        func     = new Function(exec);
                        func.Parse(_buffer.Subsegment(originalPos, position - originalPos), name, args);
                        return(true);
                    }
                }
            }
            position = originalPos;
            return(false);
        }
コード例 #2
0
ファイル: Scanner.cs プロジェクト: pcluddite/tbasic
        public bool NextIndices(Executer exec, out int[] indices)
        {
            indices = null;
            int originalPos = position;

            if (!EndOfStream && _buffer[position] == '[')
            {
                IList <object> args;
                position = GroupParser.ReadGroup(_buffer, position, exec, out args) + 1;
                indices  = new int[args.Count];
                for (int i = 0; i < args.Count; ++i)
                {
                    int?index = args[i] as int?;
                    if (index == null)
                    {
                        throw ThrowHelper.InvalidTypeInExpression(args[i].GetType().Name, typeof(int).Name);
                    }
                    else
                    {
                        indices[i] = index.Value;
                    }
                }
                return(true);
            }
            position = originalPos;
            return(false);
        }
コード例 #3
0
ファイル: Scanner.cs プロジェクト: pcluddite/tbasic
        public bool NextString(out string parsed)
        {
            if (EndOfStream || (_buffer[position] != '\"' && _buffer[position] != '\''))
            {
                parsed = null;
                return(false);
            }
            int endPos = GroupParser.ReadString(_buffer, position, out parsed) + 1;

            position = endPos;
            return(true);
        }