示例#1
0
        internal static ParseException forInvalidEnd(ParseStringRunner parseStrignRunner)
        {
            StringPointer sp          = parseStrignRunner.getStringPointer();
            string        fullMessage = "Unexpected end of input - " + sp.getLineAndColumnForException() + ", near: " + sp.getSubStringForException(16) + getExceptionMessageTail(parseStrignRunner);

            return(new ParseException(fullMessage));
        }
示例#2
0
        internal static ParseException forCharactersAfterEnd(ParseStringRunner parseStrignRunner)
        {
            StringPointer sp          = parseStrignRunner.getStringPointer();
            string        fullMessage = "Unexpected non-white character after end of object - " + sp.getLineAndColumnForException() + ", near: " + sp.getSubStringForException(32) + getExceptionMessageTail(parseStrignRunner);

            return(new ParseException(fullMessage));
        }
示例#3
0
        internal static ParseException forInvalidCharacter(String message, ParseStringRunner parseStrignRunner)
        {
            StringPointer sp          = parseStrignRunner.getStringPointer();
            string        fullMessage = message + " - " + sp.getLineAndColumnForException() + ", near: " + sp.getSubStringForException(32) + getExceptionMessageTail(parseStrignRunner);

            return(new ParseException(fullMessage));
        }
示例#4
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     if (str.Value().Length > 0)
     {
         yield return(new AtomicMatch(this, str, 1));
     }
 }
示例#5
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var match in _content.HeadMatches(str, context))
     {
         yield return(new CompositeMatch(this, str, match));
     }
 }
示例#6
0
        internal static JBoolean zParse(ParseStringRunner parseStringRunner, bool expectingTrue)
        {
            StringPointer sp = parseStringRunner.getStringPointer();

            if (expectingTrue)
            {
                if (sp.isNextChars(TRUE.Substring(1)))
                {
                    return(new JBoolean(true));
                }
                else
                {
                    throw ParseException.forInvalidCharacter("Invalid string when expecting '" + TRUE + "'", parseStringRunner);
                }
            }
            else
            {
                if (sp.isNextChars(FALSE.Substring(1)))
                {
                    return(new JBoolean(false));
                }
                else
                {
                    throw ParseException.forInvalidCharacter("Invalid string when expecting '" + FALSE + "'", parseStringRunner);
                }
            }
        }
示例#7
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     if (str.Pointer == str.RawStr.Length)
     {
         yield return(new PositionMatch(this, str));
     }
 }
示例#8
0
 public AtomicMatch(Regex regex, StringPointer str, int length) : base(regex, str)
 {
     if (str.Length < length)
     {
         throw new Exception("すすめすぎ");
     }
     _length = length;
 }
示例#9
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var match in _arg.SimpleMatchings(str, context))
     {
         yield break;
     }
     yield return(new PositionMatch(this, str));
 }
示例#10
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     //NamedはMatchTreeに影響しない
     if (!context.NamedRegexes.ContainsKey(_label))
     {
         context.NamedRegexes.Add(_label, this);
     }
     return(_content.HeadMatches(str, context));
 }
示例#11
0
 internal ParseStringRunner(string sourceString, ParseStringSettings settings)
 {
     if (settings == null)
     {
         settings = new ParseStringSettings();
     }
     this.settings = settings;
     stringPointer = new StringPointer(sourceString, settings.ParseStartIndex, this);
 }
示例#12
0
        public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
        {
            var matches = _content.HeadMatches(str, context).ToList();

            for (int i = 0; i < matches.Count; i++)
            {
                yield return(matches[matches.Count - 1 - i]);
            }
        }
示例#13
0
        public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
        {
            var match = _target.HeadMatch(str, context);

            if (match != null)
            {
                yield return(new CompositeMatch(this, str, match));
            }
            yield return(new PositionMatch(this, str));
        }
示例#14
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var targetMatch in _target.SimpleMatchings(str, context))
     {
         var nextPos        = str.SubString(targetMatch.Length);
         var conditionMatch = _condition.SimpleMatchings(nextPos, context).FirstOrDefault();
         if (conditionMatch == null)
         {
             yield return(new CompositeMatch(this, str, targetMatch));
         }
     }
 }
示例#15
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var targetMatch in _target.SimpleMatchings(str, context))
     {
         var nextPos        = str.RawStr.Substring(0, str.Pointer);                                     //ここより前の文字列
         var conditionMatch = _condition.TailMatches((StringPointer)nextPos, context).FirstOrDefault(); //条件の直前へのマッチ
         if (conditionMatch != null)
         {
             yield return(new CompositeMatch(this, str, targetMatch));
         }
     }
 }
示例#16
0
        public sealed override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
        {
            if (str.Length == 0)
            {
                yield break;
            }
            var sub = str.Value()[0];

            if (CheckChar(sub))
            {
                yield return(new AtomicMatch(this, str, 1));
            }
        }
示例#17
0
        internal static JNull zParse(ParseStringRunner parseStringRunner)
        {
            StringPointer sp = parseStringRunner.getStringPointer();

            if (sp.isNextChars(NULL.Substring(1)))
            {
                return(new JNull());
            }
            else
            {
                throw ParseException.forInvalidCharacter("Invalid string when expecting '" + NULL + "'", parseStringRunner);
            }
        }
示例#18
0
	private void refreshInformation()
	{
		//lambda functions WOO!
		new Thread(() =>
		{
			StringPointer busyLock = new StringPointer("refreshInformation");
			business.Add(busyLock);
			version = (execute("git", "version")).Trim();

			string name = System.IO.Directory.GetCurrentDirectory();
			name = name.Substring(name.LastIndexOf("" + System.IO.Path.DirectorySeparatorChar) + 1);
			name = Regex.Replace(name, "-", m => " ");
			name = name.Trim();
			this._name = name;

			execute("git", "fetch"); // and pray
					string branchesCommand = execute("git", "branch -a");
			string[] branches = branchesCommand.Split('\n');
			for (int i = 0; i < branches.Length; i++)
			{
				branches[i] = branches[i].Trim();
				if (branches[i].StartsWith("*"))
				{
					branches[i] = branches[i].Substring(1).Trim();
					this.currentBranch = branches[i];
				}
				branches[i] = branches[i].Trim();
				if (branches[i].Contains("/"))
				{
					string b = branches[i];
					string r = b.Substring(8);
					r = r.Substring(0, r.IndexOf('/'));
					b = b.Substring(b.LastIndexOf('/') + 1);
							//dialogue(r);
							branches[i] = b;
							//dialogue(branches[i]);
						}
			}
			this.branches = branches;

			mainThreadInvokeQueue += new Invoke(() =>
					{
					business.Remove(busyLock);
					Repaint();
				});
		}).Start();

	}
示例#19
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var selfMatch in _target.HeadMatches(str, context))
     {
         var next = str.SubString(selfMatch.Length);
         foreach (var nextMatch in SimpleMatchings(next, context))
         {
             var list = new List <RegexMatch>();
             list.Add(selfMatch);
             var composite = (CompositeMatch)nextMatch;
             list.AddRange(composite.Matches);
             yield return(new CompositeMatch(this, str, list.ToArray()));
         }
         yield return(new CompositeMatch(this, str, selfMatch));
     }
 }
示例#20
0
        protected override void OnGameHook()
        {
            mono.Run(() => {
                MonoNestedPointerFactory ptrFactory = new MonoNestedPointerFactory(this, mono);

                var game  = ptrFactory.Make <IntPtr>("Game", "ins_", out IntPtr gameClass);
                globalVar = ptrFactory.Make <IntPtr>(game, mono.GetFieldOffset(gameClass, "<GlobalVar>k__BackingField"));
                status    = ptrFactory.Make <int>(game, mono.GetFieldOffset(gameClass, "<status>k__BackingField"));

                playMgr               = ptrFactory.Make <IntPtr>("PlayMgr", "ins", out IntPtr playMgrClass);
                uiLock                = ptrFactory.Make <int>(playMgr, mono.GetFieldOffset(playMgrClass, "<ui>k__BackingField"), 0x174);
                playerTile            = ptrFactory.MakeString(playMgr, mono.GetFieldOffset(playMgrClass, "<player>k__BackingField"), 0x38, 0x20, 0x10, 0x100, 0x14);
                playerTile.StringType = EStringType.UTF16Sized;

                Logger.Log(ptrFactory.ToString());
            });
        }
示例#21
0
	private void refreshHistory()
	{
		new Thread(() =>
		{
			StringPointer busyLock = new StringPointer("refreshHistory");
			business.Add(busyLock);
			int commitCount = Math.Min(Int32.Parse(execute("git", "rev-list --count HEAD").Trim()), maxCommits);
			string[] syncedCommits = execute("git", "log @{u} -n " + commitCount + " --pretty=format:\"%h;%an;%ar;%s\"").Trim().Split('\n');
			string[] localCommits = execute("git", "log @{u}..HEAD -n " + commitCount + " --pretty=format:\"%h;%an;%ar;%s\"").Trim().Split('\n');

			history = new Commit[commitCount];

			if (localCommits.Length == 1 && localCommits[0] == "")
				localCommits = new string[] { };

			for (int i = 0; i < localCommits.Length; i++)
			{
				Commit commit;
						//				log(localCommits[i]);
						string[] parts = localCommits[i].Split(';');
				commit.local = true;
				commit.hash = parts[0];
				commit.author = parts[1];
				commit.date = parts[2];
				commit.subject = parts[3];
				history[i] = commit;
			}
			for (int i = 0; i < syncedCommits.Length; i++)
			{
				Commit commit;
						//				log(syncedCommits[i]);
						string[] parts = syncedCommits[i].Split(';');
				commit.local = false;
				commit.hash = parts[0];
				commit.author = parts[1];
				commit.date = parts[2];
				commit.subject = parts[3];
				history[i + localCommits.Length] = commit;
			}
			mainThreadInvokeQueue += new Invoke(() =>
					{
					business.Remove(busyLock);
					Repaint();
				});
		}).Start();
	}
示例#22
0
        internal static JNumber zParse(ParseStringRunner parseStringRunner, char firstChr)
        {
            StringPointer sp = parseStringRunner.getStringPointer();

            int  start = sp.getCurrentIndex() - 1;        // -1 since first character is already read
            bool valid = parseCheck(sp, firstChr);

            if (!valid)
            {
                throw ParseException.forInvalidCharacter("Invalid number value \"" + sp.getSubStringStartingFrom(start) + "\"", parseStringRunner);
            }
            else
            {
                sp.stepBack();
                string validNumber = sp.getSubStringStartingFrom(start);
                return(new JNumber(validNumber, parseStringRunner));
            }
        }
示例#23
0
        public ArrayMatch(StringPointer str, params RegexMatch[] contents) : base(new Empty(), str)
        {
            //ArrayMatchは展開する
            var list = new List <RegexMatch>();

            foreach (var child in contents)
            {
                var array = child as ArrayMatch;
                if (array == null)
                {
                    list.Add(child);
                }
                else
                {
                    list.AddRange(array.Contents);
                }
            }
            Contents = list.ToArray();
        }
示例#24
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            StringPointer str = (StringPointer)value;

            if (str.Length <= 5)
            {
                return(str);
            }
            else if (str.Length <= 16)
            {
                int sep = (str.Length + 1) / 2;
                return(string.Format("{0}\n{1}", str.Substring(0, sep), str.Substring(sep)));
            }
            else
            {
                int sep = (str.Length + 2) / 3;
                return(string.Format("{0}\n{1}\n{2}", str.Substring(0, sep), str.Substring(sep, sep), str.Substring(2 * sep)));
            }
        }
示例#25
0
        internal static JString zParse(ParseStringRunner parseStringRunner, bool expectStartOfString)
        {
            StringPointer sp = parseStringRunner.getStringPointer();

            if (expectStartOfString)
            {
                char chr;
                if (!sp.tryGetNextNonWhiteChar(out chr))
                {
                    throw ParseException.forInvalidStart("Parameter string didn't contain any non-white characters", parseStringRunner);
                }
                if (chr != '"')
                {
                    throw ParseException.forInvalidStart("Invalid character '" + chr + "' when expecting start of string '\"'", parseStringRunner);
                }
            }

            return(new JString(decode(parseStringRunner)));
        }
示例#26
0
        public CompositeMatch(Regex regex, StringPointer str, params RegexMatch[] children) : base(regex, str)
        {
            //ArrayMatchは展開する
            var list = new List <RegexMatch>();

            foreach (var child in children)
            {
                var array = child as ArrayMatch;
                if (array == null)
                {
                    list.Add(child);
                }
                else
                {
                    list.AddRange(array.Contents);
                }
            }
            Matches = list.ToArray();
        }
示例#27
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            StringPointer str = (StringPointer)value;

            if (str.Length <= 6)
            {
                return(48.0);
            }
            else if (str.Length <= 12)
            {
                return(40.0);
            }
            else if (str.Length <= 20)
            {
                return(32.0);
            }
            else
            {
                return(24.0);
            }
        }
示例#28
0
        private IEnumerable <RegexMatch> Sm(StringPointer str, MatingContext context, int minCount, int maxCount)
        {
            if (maxCount == 0)
            {
                yield return(new PositionMatch(this, str));

                yield break;
            }
            foreach (var selfMatch in _target.HeadMatches(str, context))
            {
                var next = str.SubString(selfMatch.Length);
                foreach (var targetMatch in Sm(next, context, minCount - 1, maxCount - 1))
                {
                    var composite = targetMatch as CompositeMatch;
                    var list      = new List <RegexMatch>();
                    list.Add(selfMatch);
                    if (composite != null)
                    {
                        list.AddRange(composite.Matches);
                    }
                    else
                    {
                        break;
                    }
                    yield return(new CompositeMatch(this, str, list.ToArray()));
                }
                if (minCount <= 1)
                {
                    yield return(new CompositeMatch(this, str, selfMatch));
                }
            }
            if (minCount <= 0)
            {
                yield return(new PositionMatch(this, str));
            }
        }
示例#29
0
	private void checkout(string branch)
	{
		dialogue(branch);
		new Thread(() =>
		{
			StringPointer busyLock = new StringPointer("checkout");
			business.Add(busyLock);
			ExecuteResponse checkoutResponse = executeWithCode("git", "checkout " + branch);
			if (checkoutResponse.exitCode == 0)
			{
				refreshInformation();
			}
			else
			{
				dialogue("Could not checkout", checkoutResponse.message);

			}
			mainThreadInvokeQueue += new Invoke(() =>
					{
					business.Remove(busyLock);
					Repaint();
				});
		}).Start();
	}
示例#30
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)//TODO:fix
 {
     foreach (var selfMatch in _target.HeadMatches(str, context))
     {
         var next = str.SubString(selfMatch.Length);
         foreach (var targetMatch in SimpleMatchings(next, context))
         {
             var composite = targetMatch as CompositeMatch;
             var list      = new List <RegexMatch>();
             list.Add(selfMatch);
             if (composite != null)
             {
                 list.AddRange(composite.Matches);
             }
             else
             {
                 break;
             }
             yield return(new CompositeMatch(this, str, list.ToArray()));
         }
         yield return(new CompositeMatch(this, str, selfMatch));
     }
     yield return(new PositionMatch(this, str));
 }
示例#31
0
 public StringPointer(StringPointer p)
 {
     Index = p.Index;
     _data = p._data;
 }
示例#32
0
        public StringPointer Increment(int i, bool withUpdate = true)
        {
            if (withUpdate)
            {
                Index += i;
                if (Index > _data.Length)
                    Index = _data.Length;

                return this;
            }

            var sp = new StringPointer(this);
            return sp.Increment(i);
        }