Automation/Utilities/Interpreter.cs
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
namespace ComLib.Automation
{
/// <summary>
/// Very, Very light version of Javascript - JSLite. Non-Lexical parser.
/// Features include:
/// 1. var declarations
/// 2. if conditions
/// 3. while loops
/// 4. for loops
/// 5. func calls
/// </summary>
public class Interpreter
{
private const string RegexCommentSingleLine = @"\s*\\\\\s{1}\*";
private const string RegexVariable = @"\s*var\s*(?<name>[\w]+)\s*=\s*(?<value>.+)$";
private const string RegexForLoop = @"\s*for\s*\(\s*var\s+(?<name>\w+)\s*=\s*(?<start>[^;]+);\s*(?<checkname>\w+)\s*(?<checkop>[^\s]+)\s*(?<checkvalue>[^;]+);\s*(?<incrementname>\w+)\s*(?<incrementvalue>[^\)]+)\)\{?";
private const string RegexFuncCall = @"\s*(?<funcname>[\$_\w\.]+)\(";
private Scope _scope;
//private Func<JsLiteArgs,bool> _visitor;
/// <summary>
/// Initialize interpreter with scope.
/// </summary>
/// <param name="scope">Scope of the script.</param>
public Interpreter(Scope scope)
{
_scope = scope;
}
/// <summary>
/// Whether or not the line supplied is a for loop.
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public bool IsForLoop(string line)
{
var match = Regex.Match(line, RegexForLoop);
if (!match.Success) return false;
// Check the checkop
var checkOp = match.Groups["checkop"].Value;
if (checkOp != "<" && checkOp != "<=" && checkOp != ">" && checkOp != ">=")
return false;
return true;
}
/// <summary>
后面还有 371 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
