Regular expressions into finite automata
It is a well-established fact that each regular expression can be transformed into a nondeterministic finite automaton (NFA) with or without ∈-transitions, and all authors seem to provide their own variant of the construction. Of these, Berry and Sethi [BS86] have shown that the construction of an ∈-free NFA due to Glushkov [Glu61] is a natural representation of the regular expression, because it can be described in terms of the Brzozowski derivatives [Brz64] of the expression. Moreover, the Glushkov construction also plays a significant role in the document processing area: The SGML standard [ISO86], now widely adopted by publishing houses and government agencies for the syntactic specification of textual markup systems, uses deterministic regular expressions, i.e. expressions whose Glushkov automaton is deterministic, as a description language for document types.
In this paper, we first show that the Glushkov automaton can be constructed in time quadratic in the size of the expression, and that this is worst case optimal. For deterministic expressions, our algorithm has even linear run time. This improves on the cubic time methods suggested in the literature [BEGO71,ASU86,BS86]. A major step of the algorithm consists in bringing the expression into what we call star normal form. This concept is also useful for characterizing the relationship between two types of unambiguity that have been studied in the literature. Namely, we show that, modulo a technical condition, an expression is strongly unambiguous [SS88] if and only it is weakly unambiguous [BEGO71] and in star normal form. This leads to our third result, a quadratic time decision algorithm for weak unambiguity, that improves on the biquadratic method introduced by Book et al. [BEGO71].
Unable to display preview. Download preview PDF.
- [ASU86]Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley Series in Computer Science, Addison-Wesley, Reading, Massachusetts, 1986.Google Scholar
- [BEGO71]Ronald Book, Shimon Even, Sheila Greibach, and Gene Ott. Ambiguity in graphs and expressions. IEEE Transactions on Computers, C-20(2):149–153, February 1971.Google Scholar
- [Brz64]Janusz A. Brzozowski. Derivatives of regular expressions. Journal of the ACM, 11(4):481–494, October 1964.Google Scholar
- [BS86]Gerard Berry and Ravi Sethi. From regular expressions to deterministic automata. Theoretical Computer Science, 48:117–126, 1986.Google Scholar
- [BW91]Anne Brüggemann-Klein and Derick Wood. Parser generators for document grammars. Submitted for publication, 1991.Google Scholar
- [Glu61]V.M. Glushkov. The abstract theory of automata. Russian Mathematical Surveys, 16:1–53, 1961.Google Scholar
- [Hen68]Frederick C. Hennie. Finite-State Models for Logical Machines. John Wiley, New York, 1968.Google Scholar
- [HU79]John E. Hopcroft and Jeffrey D. Ullman. Introduction to Automata Theory, Languages and Computation. Addison-Wesley Series in Computer Science, Addison-Wesley, Reading, Massachusetts, 1979.Google Scholar
- [ISO86]ISO 8879. Information processing — text and office systems — standard generalized markup language (SGML). October 1986. International Organization for Standardization.Google Scholar
- [SS88]Seppo Sippu and Eljas Soisalon-Soininen. Parsing Theory. Volume 1, Languages and Parsing, of EATCS Monographs on Theoretical Computer Science, Springer-Verlag, Berlin, 1988.Google Scholar
- [Woo87]Derick Wood. Theory of Computation. John Wiley, New York, 1987.Google Scholar