- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个符合 System for Cross-domain Identity Management: Protocol Filtering 的解析器规范我几乎可以用 Sprache 解析任何表达式,除了“pr”运算符。我不知道如何让它正常工作。
这里是主要的解析内容:
{
And = Operator("and", "And");
Or = Operator("or", "Or");
Le = Operator("le", "LessThanOrEqual");
Lt = Operator("lt", "LessThan");
Gt = Operator("gt", "GreaterThan");
Ge = Operator("ge", "GreaterThanOrEqual");
Eq = Operator("eq", "Equal");
Ne = Operator("ne", "NotEqual");
Co = Operator("co", "Contains");
Sw = Operator("sw", "StartsWith");
Ew = Operator("ew", "EndsWith");
Pr = Operator("pr", "Present");
...
Operand = (Parentheses
.XOr(Literal.Or(AttrPath.Token()))
.XOr(CaseInsensitiveString)).Token();
//compareOp = "eq" / "ne" / "co" /
// "sw" / "ew" /
// "gt" / "lt" /
// "ge" / "le"
CompareExpression = Parse.XChainOperator(Le.Or(Lt).XOr(Ge.Or(Gt)).XOr(Eq.Or(Ne)).XOr(Sw.Or(Ew)).XOr(Co).XOr(Pr), Operand, FilterExpression.Binary);
PresentsExpression = Parse.XChainRightOperator(Pr, Operand, FilterExpression.Binary).Or(CompareExpression);
// logExp = FILTER SP ("and" / "or") SP FILTER
AndExpression = Parse.XChainOperator(And, CompareExpression, FilterExpression.Binary);
// logExp = FILTER SP ("and" / "or") SP FILTER
OrExpression = Parse.XChainOperator(Or, AndExpression, FilterExpression.Binary);
Filter = OrExpression;
}
private static Parser<string> Operator(string op, string opName)
{
return Parse.String(op).Token().Return(opName);
}
这是我添加“pr”解析的地方:
Parse.XChainRightOperator(Pr, Operand, FilterExpression.Binary).Or(CompareExpression);
此过滤器失败:title pr and addresses[type eq\"work\"].streetAddress eq\"workStreet\"
这没关系:
addresses[type eq \"work\"].streetAddress eq \"workStreet\"
and (userType eq \"Employee\" or userType eq \"ParttimeEmployee\")
也许有人可以帮我解决这个问题。
编辑:也许我应该在某个时候使用 XChainRightOperator 链接运算符,因为 pr title 工作正常。但是链扩展是针对二元表达式的,我需要一元。
最佳答案
我找到了答案。这是正确的解析代码:
Operand = (Parentheses
.XOr(Literal.Or(AttrPath.Token()))
.XOr(CaseInsensitiveString)).Token();
// compareOp = "eq" / "ne" / "co" /
// "sw" / "ew" /
// "gt" / "lt" /
// "ge" / "le"
Comparison = Parse.XChainOperator(Le.Or(Lt).XOr(Ge.Or(Gt)).XOr(Eq.Or(Ne)).XOr(Sw.Or(Ew)).XOr(Co).XOr(Pr), Operand, FilterExpression.Binary);
// attrPath SP "pr"
Presence = Operand.SelectMany(operand => Pr, (operand, pr) => FilterExpression.Unary(pr, operand));
// attrExp = (attrPath SP "pr") /
// (attrPath SP compareOp SP compValue)
AttributeExpression = Presence.Or(Comparison);
// logExp = FILTER SP ("and" / "or") SP FILTER
LogicalExpression = Parse.XChainOperator(Or.Or(And), AttributeExpression, FilterExpression.Binary);
Filter = LogicalExpression;
技巧是先检查操作数,然后检查操作数,并在 AttributeExpression = Presence.Or(Comparison);
关于c# - “Sprache” 解析器 `Present` 语义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34009137/
let appDelegate = UIKit.UIApplication.shared.delegate! if let tabBarController = appDelegate
我的演示文稿终于成功了。我的第一个屏幕有一个主要的 activity,第二个屏幕有一个 Presentation。我的问题是,我无法更改演示 View 中的内容。 为什么我不能在第二个屏幕上显示演示文
这个问题在这里已经有了答案: ios, getting a pointer to a controller from a view (5 个答案) 关闭 4 年前。 我有一个 uiview 文件,我
我有一个表示小部件的 View 类和一个随附的演示者类。我还有一个 View 类,用于拥有小部件的窗口,以及窗口 View 的随附演示者。窗口操作小部件,所以我需要窗口展示器与小部件展示器进行通信。可
关闭相机后。它给了我这个警告:在演示过程中尝试继续演示! - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picke
由于这个错误,我无法切换到另一个 View Controller 。我想在成功扫描二维码后切换到另一个 View Controller 。 2015-01-27 17:59:16.093 *[5416
有时它会发生 - 从代码的不同地方 - 我们想要做 UIViewController.presentViewController(a, b, c),有时我们已经在呈现了,在这种情况下我们得到: 警告:
这是我的第一个 iOS 应用程序。 所以我有一个 UIVIewController 和一个 UITableView,其中我按顺序集成了一个 UISearchBar 和一个 UISearchContro
我的模式允许一个特定的元素是可选的,但是当我稍后在文件中遇到一个不同的也是可选的元素时,我需要前一个元素存在。我如何通过 XSD 确保这一点? 例子: true 应该是有效的,
我正在使用 xcode 4.5.2 并为相机按钮创建了自己的 OverlayViewController。 现在,当我的委托(delegate) Controller - TakePhotoViewC
如何在 MVP 中创建 View ? Presenter 是否总是创建它们(除了 subview 的 View 之外)?或者它是一个单独的第三方组件或应用程序或创建它们的东西? 我们还要补充一点,我可
当我调用viewController.presentViewController时,如果已经存在另一个 Controller ,则会出现以下警告。 Warning: Attempt to presen
我有一个关于 React Native 的模块,并在这个问题的标题中抛出错误。这是模块的代码,我不知道 swift 或 Objective-C,所以我需要你像“swift for idiots”一样解
我在 didSelectRowAtIndexPath 中选择一个 segue 时收到上面的警告。这发生在 iPad 上。 iPhone 给出了不同的警告,我会看看是否可以解决这个问题。 我在方法中确实
我的应用程序中有一个包含两个场景的 StoryBoard - 它使用自动转场(在 IB 中创建)。当在第一个 UIViewController 中单击按钮时,第二个 UIViewController
如何在成功验证登录后转到我的第二页? 我已经从登录页面 View Controller (不是登录按钮)拉出一个 segue 到下一页,并将该 segue 命名为“nextPage”。 (如果我从登录
我正在构建一个应用程序,最近发现了由传统转场引起的巨大内存泄漏。因此我了解了 unwind segue。如果我简单地使用,一切都很好: @IBAction func prepareForUnw
我不知道如何将按钮添加到 link_to_add_fields 中 在我制作的 Rails 应用程序中。 我尝试在各处添加 class: "btn btn-mini btn-info",但我一直收到
大家好,感谢阅读。我正在制作一个应用程序,您可以在其中拍照并从相机胶卷中检索照片并将其显示在 View 中。问题是,当我尝试使用调出相机胶卷的按钮时,出现如上标题中的错误“演示正在进行中”。 如果我注
我有一个模型,其中有两个字段在技术上可以为空。字段名称是 :is_activated 和 :activated_at。 :activated_at 仅在 :is_activated 设置为 true
我是一名优秀的程序员,十分优秀!