_Core/Lang/Plugins/Parser/LinqPlugin.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ComLib.Lang;
namespace ComLib.Lang.Extensions
{
/* *************************************************************************
<doc:example>
// Linq plugin is a Light-weight and partial version of Linq style queries and comprehensions
// NOTE: This has limited functionality as of this release.
var books = [
{ name: 'book 1', pages: 200, author: 'homey' },
{ name: 'book 2', pages: 120, author: 'kdog' },
{ name: 'book 3', pages: 140, author: 'homeslice' }
];
// Case 1: start with source <books> and system auto creates variable <book>
var favorites = books where book.pages < 150 and book.author == 'kdog';
// Case 2: using from <variable> in <source>
var favorities = from book in books where book.pages < 150 and book.author == 'kdog';
</doc:example>
***************************************************************************/
/// <summary>
/// Combinator for handling comparisons.
/// </summary>
public class LinqPlugin : ExprPlugin
{
private static string[] _tokens = new string[] { "$IdToken", "select", "from", "where" };
private static IDictionary<Token, bool> _terminators;
private string _variableName;
private Expr _source;
private Expr _filter;
static LinqPlugin()
{
_terminators = new Dictionary<Token, bool>();
_terminators[new IdToken("order")] = true;
_terminators[Tokens.Semicolon] = true;
_terminators[Tokens.NewLine] = true;
_terminators[Tokens.Comma] = true;
_terminators[Tokens.RightParenthesis] = true;
}
/// <summary>
/// Initialize
/// </summary>
public LinqPlugin()
{
_startTokens = _tokens;
_precedence = 1;
后面还有 175 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
