Abstract
We propose a practical technique to compile pattern-matching for prioritised overlapping patterns in equational languages into a minimal, deterministic, left-to-right, matching automaton. First, we present a method for constructing a tree matching automaton for such patterns. This allows pattern-matching to be performed without any backtracking. Space requirements are reduced by using a directed acyclic graph (dag) automaton that shares all the isomorphic subautomata which are duplicated in the tree automaton. We design an efficient method to identify such subautomata and avoid duplicating their construction while generating the dag automaton. We conclude with some easily computed bounds on the size of the automata, thereby improving on previously known equivalent bounds for the tree automaton.
Author sponsored by the British Council and the Algerian Ministry for High Education.
Preview
Unable to display preview. Download preview PDF.
References
Aho, A.V., Sethi, R. and Ulmann, J.D., Compilers: Principles, Techniques and Tools, Addison-Wesley Publishing Company, 1986.
Gräf, A., “Left-to-Right Pattern-Matching”, in Proc. Rewriting Techniques and Applications, Lecture Notes in Computer Science, Vol. 488, pp. 323–334, Springer Verlag, 1991.
Hoffman, C.M. and O'Donnell, M.J., “Pattern-Matching in Trees”, Journal of the ACM, Vol 29, pp. 68–95, January 1982.
Hoffman, C.M., O'Donnell, M.J. and Strandh, R. “Programming with Equations”, Software, Practice and Experience, Vol. 15, No. 12, pp. 1185–1204, December 1985.
Johnson, S. C., Yacc — Yet Another Compiler Compiler, Computing Science Technical Report 32, AT&T Laboratories, Murray Hill, N. J., 1975.
Kennaway, J. R., “The Specificity Rule for Lazy Pattern Matching in Ambiguous Term Rewriting Systems”, Proc. 3rd European Symposium on Programming, Lecture Notes in Computer Science, Vol. 432, pp. 256–270, Springer-Verlag,1990.
Knuth, D.E., Morris, J. and Pratt, V., “Fast Pattern-Matching in Strings”, SIAM Journal on Computing, Vol. 6, No. 2, pp. 323–350, 1977.
Nedjah, N., Pattern-Matching Automata for Efficient Evaluation in Equational Programming, Ph.D. Thesis, UMIST, Manchester, UK, 1997.
Nedjah, N., Walter, C.D. and Eldridge, S.E., Efficient Automaton-Driven Pattern-Matching for Equational Programs, Technical Report, Computation Dept., UMIST, Manchester, UK, 1996.
O'Donnell, M.J., Equational Logic as a Programming Language, The MIT Press, 1985.
Sekar, R.C., Ramesh, R. and Ramakrishnan, I.V., “Adaptive Pattern Matching”, SIAM Journal on Computing, Vol. 24, No. 5, pp. 1207–1234, December 1995.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1997 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Nedjah, N., Walter, C.D., Eldridge, S.E. (1997). Optimal left-to-right pattern-matching automata. In: Hanus, M., Heering, J., Meinke, K. (eds) Algebraic and Logic Programming. ALP HOA 1997 1997. Lecture Notes in Computer Science, vol 1298. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0027016
Download citation
DOI: https://doi.org/10.1007/BFb0027016
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-63459-1
Online ISBN: 978-3-540-69555-4
eBook Packages: Springer Book Archive