private static Statement TimestampParse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^TIME\s+{Formats.RegisterEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new TimeStamp(FormatterUtil.GetRegEx(m.Groups[1].Value))); } return(null); }
public Statement Parse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{Formats.RegisterEx}\s*\{_meta.Operator}\s*{(_meta.OnlyInstant ? Formats.Instant : Formats.ValueEx)}$", RegexOptions.IgnoreCase); if (m.Success) { return(Activator.CreateInstance(_meta.StatementType, FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value)) as Statement); } return(null); }
public Statement Parse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{_meta.KeyWord}\s+{Formats.Register}$", RegexOptions.IgnoreCase); if (m.Success) { return(Activator.CreateInstance(_meta.StatementType, FormatterUtil.GetRegEx(m.Groups[1].Value, _lhs)) as Statement); } return(null); }
private static Statement MovParse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{Formats.RegisterEx}\s*=\s*{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new Mov(FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value))); } return(null); }
private static Statement PrintParse(ParserArgument args) { if (args.Text.Equals("print", StringComparison.OrdinalIgnoreCase)) { return(new Print(Array.Empty <Content>(), false)); } var m = Regex.Match(args.Text, @"^print\s+(.*)$", RegexOptions.IgnoreCase); if (m.Success) { var strs = m.Groups[1].Value.Split('&'); var contents = new List <Content>(); var cancellinebreak = false; for (int i = 0; i < strs.Length; i++) { var s = strs[i].Trim(); if (i == strs.Length - 1 && s == "\\") { contents.Add(new TextContent("", "\\")); cancellinebreak = true; continue; } if (s.Length == 0 && strs.Length > 1) { contents.Add(new TextContent(" ", "")); continue; } m = Regex.Match(s, Formats.RegisterEx_F); if (m.Success) { contents.Add(new RegContent(FormatterUtil.GetRegEx(s))); continue; } m = Regex.Match(s, Formats.Constant_F); if (m.Success) { var v = args.Formatter.GetConstant(s); contents.Add(new TextContent(v.Val.ToString(), s)); continue; } contents.Add(new TextContent(s)); } return(new Print(contents.ToArray(), cancellinebreak)); } return(null); }
Statement?IStatementParser.Parse(ParserArgument args) { if (args.Text.Equals("for", StringComparison.OrdinalIgnoreCase)) { return(new For_Infinite()); } var m = Regex.Match(args.Text, $@"^for\s+{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new For_Static(args.Formatter.GetValueEx(m.Groups[1].Value))); } m = Regex.Match(args.Text, $@"^for\s+{Formats.RegisterEx}\s*=\s*{Formats.ValueEx}\s*to\s*{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new For_Full(FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value), args.Formatter.GetValueEx(m.Groups[3].Value))); } // next return(NextParse(args)); }