定制 icecave/dialekt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

icecave/dialekt

最新稳定版本:0.1.0

Composer 安装命令:

composer require icecave/dialekt

包简介

A simple language for representing boolean expressions.

README 文档

README

This project has been deprecated by the authors. Use dialekt/dialekt instead.

Dialekt is a very simple language for representing boolean expressions of the form often used by search engines.

composer require icecave/dialekt 

Rationale and Concepts

Dialekt was devised for specifing filters for lists of objects based on sets of human-readable "tags" or "labels". This PHP package provides an expression parser which parses Dialekt expressions into an abstract syntax tree, a list parser which parses lists of tags into arrays, and an evaluator which checks if a given set of tags matches a particular expression.

Additionally, the nodes of the abstract syntax tree implement the visitor pattern, allowing the creation of new algorithms that traverse the syntax tree. This could be used, for example, to generate an SQL query that finds entities with tags that match the expression.

Syntax

Below is an example of a Dialekt expression showing the available language features. You can see how this expression is parsed using the online demo.

foo bar AND (baz OR qux) AND NOT "doom hammer"

In the above example, foo, bar, baz, qux and "doom hammer" are examples of tags. The tag is the most basic syntactic element of an expression. An expression is composed of one or more tags, and the logical operators AND, OR and NOT. The logical operators are case-insensitive.

Tags may be formed by any non-whitespace characters except the parentheses and asterisk characters. Tags may optionally be enclosed in double-quotes, as the doom hammer tag has been in the example above. Doing so allows the inclusion of parentheses and whitespace characters. Tags must also be enclosed in double-quotes if they are one of the reserved words AND, OR or NOT. Inside a quoted tag the backslash character provides escaping functionality similar to a double-quoted PHP string.

Implicit AND operator

When one tag is directly adjacent to another (as foo and bar are above) they are treated equivalent to an AND, thus the expression foo bar baz is equivalent to foo AND bar AND baz.

Grouping and operator precedence

Sub-expressions can be grouped using parenthesis to control evaluation order, as baz and qux have been in the example above.

When parenthesis are not present, the AND operator has higher precedence than OR such that foo OR bar AND baz is equivalent to foo OR (bar AND baz).

统计信息

  • 总下载量: 99.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固