Scala 包 scala.util.automata 的用途是什么?

发布于 2024-10-20 12:30:41 字数 570 浏览 0 评论 0 原文

我很久以前就看到了 scala.util.automata 包,最近在阅读一些 ScalaDoc

有人在任何地方见过这个包的使用情况吗?其用途是什么?

我想知道这些类是否与解析器组合器有某种联系,或者它们是否独立使用?

这些类的名称如下

class BaseBerrySethi
class DetWordAutom[T <: AnyRef]
trait Inclusion[A <: AnyRef]
class NondetWordAutom[T <: AnyRef]
class SubsetConstruction[T <: AnyRef]
class WordBerrySethi extends BaseBerrySethi 

,但描述不是很有帮助。

看起来它们将随 Scala 2.9 一起发布。

I saw the scala.util.automata package quite some time ago and just fell over it recently when reading a bit of ScalaDoc.

Does anyone have seen this package in usage anywhere yet and for which purpose?

I wonder if those classes have some connection to the parser combinators or if they are used standalone?

The classes have names like

class BaseBerrySethi
class DetWordAutom[T <: AnyRef]
trait Inclusion[A <: AnyRef]
class NondetWordAutom[T <: AnyRef]
class SubsetConstruction[T <: AnyRef]
class WordBerrySethi extends BaseBerrySethi 

and a not very helpful description.

It seems like they will be shipped with Scala 2.9.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十秒萌定你 2024-10-27 12:30:41

它是正则表达式到有限自动机转换的实现。 http://www2.in.tum.de/hp/file?fid=571 [PDF] 创建 NDFA 的一种方法示例可以在 http://www.scala-lang.org/api/current/scala/util/regexp/WordExp.html,尽管它没有显示如何使用生成的自动机。看起来自动机将通过重复调用“next”来使用,以 BitSet 的形式线程化状态集,并每次使用 containsFinal 检查自动机是否已达到最终状态。我没有看到初始状态应该表示为什么,但初始状态很可能是一个空的 BitSet。

It's the implementation of a regular expression to a finite automaton conversion. http://www2.in.tum.de/hp/file?fid=571 [PDF] An example of one way to create an NDFA can be found at http://www.scala-lang.org/api/current/scala/util/regexp/WordExp.html, although that doesn't show how to use the resulting automaton. It appears the automaton would be used by calling "next" repeatedly, threading the state set in the form of a BitSet through and checking each time with containsFinal to see if the automaton had reached a final state. What I don't see is what the initial states should be represented as, but it would seem likely that the initial state would be an empty BitSet.

扎心 2024-10-27 12:30:41

这是我开始学习 Scala 时首先想到的事情之一。也发现了一些bug。它并不是特别有用,甚至有一些关于弃用它的讨论。

它确实实现了一个相当灵活的算法来将正则表达式一直转换为 DFA,但 DFA 本身并不是特别灵活,iirc。

It was one of the first things I came upon when I started learning Scala. Found some bugs in it, too. It isn't particularly useful, and there was even some discussion about deprecating it.

It does implement a fairly flexible algorithm to convert regular expressions all the way to DFAs, but the DFA itself isn't particularly flexible, iirc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文